Refactor RfC creation to prevent users from navigating
This commit is contained in:
@ -507,7 +507,7 @@ var CodeOceanEditor = {
|
|||||||
new bootstrap.Modal($('#comment-modal')).show();
|
new bootstrap.Modal($('#comment-modal')).show();
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#askForCommentsButton').on('click', this.requestComments.bind(this));
|
$('#askForCommentsButton').one('click', this.requestComments.bind(this));
|
||||||
$('#closeAskForCommentsButton').on('click', function () {
|
$('#closeAskForCommentsButton').on('click', function () {
|
||||||
bootstrap.Modal.getInstance($('#comment-modal')).hide();
|
bootstrap.Modal.getInstance($('#comment-modal')).hide();
|
||||||
});
|
});
|
||||||
|
@ -111,6 +111,8 @@ CodeOceanEditorRequestForComments = {
|
|||||||
requestComments: function () {
|
requestComments: function () {
|
||||||
const cause = $('#requestComments');
|
const cause = $('#requestComments');
|
||||||
this.startSentryTransaction(cause);
|
this.startSentryTransaction(cause);
|
||||||
|
$('#question').prop("disabled", true);
|
||||||
|
$('#closeAskForCommentsButton').addClass('d-none');
|
||||||
|
|
||||||
var user_id = $('#editor').data('user-id');
|
var user_id = $('#editor').data('user-id');
|
||||||
var exercise_id = $('#editor').data('exercise-id');
|
var exercise_id = $('#editor').data('exercise-id');
|
||||||
@ -118,6 +120,7 @@ CodeOceanEditorRequestForComments = {
|
|||||||
var question = $('#question').val();
|
var question = $('#question').val();
|
||||||
|
|
||||||
var createRequestForComments = function (submission) {
|
var createRequestForComments = function (submission) {
|
||||||
|
this.showSpinner($('#askForCommentsButton'));
|
||||||
$.ajax({
|
$.ajax({
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: Routes.request_for_comments_path(),
|
url: Routes.request_for_comments_path(),
|
||||||
@ -129,18 +132,21 @@ CodeOceanEditorRequestForComments = {
|
|||||||
question: question
|
question: question
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}).done(function () {
|
}).done(function() {
|
||||||
this.hideSpinner();
|
|
||||||
$.flash.success({text: $('#askForCommentsButton').data('message-success')});
|
|
||||||
// trigger a run
|
// trigger a run
|
||||||
this.runSubmission.call(this, submission);
|
this.runSubmission.call(this, submission);
|
||||||
}.bind(this)).fail(this.ajaxError.bind(this));
|
$.flash.success({text: $('#askForCommentsButton').data('message-success')});
|
||||||
|
}.bind(this)).fail(this.ajaxError.bind(this))
|
||||||
|
.always(function () {
|
||||||
|
bootstrap.Modal.getInstance($('#comment-modal')).hide();
|
||||||
|
this.hideSpinner();
|
||||||
|
$('#question').prop("disabled", false).val('');
|
||||||
|
$('#closeAskForCommentsButton').removeClass('d-none');
|
||||||
|
$('#askForCommentsButton').one('click', this.requestComments.bind(this));
|
||||||
|
}.bind(this));
|
||||||
};
|
};
|
||||||
|
|
||||||
this.createSubmission(cause, null, createRequestForComments.bind(this));
|
this.createSubmission(cause, null, createRequestForComments.bind(this));
|
||||||
|
|
||||||
bootstrap.Modal.getInstance($('#comment-modal')).hide();
|
|
||||||
$('#question').val('');
|
|
||||||
// we disabled the button to prevent that the user spams RFCs, but decided against this now.
|
// we disabled the button to prevent that the user spams RFCs, but decided against this now.
|
||||||
//var button = $('#requestComments');
|
//var button = $('#requestComments');
|
||||||
//button.prop('disabled', true);
|
//button.prop('disabled', true);
|
||||||
|
@ -7,5 +7,7 @@ p = ''
|
|||||||
/ data-cause='requestComments' is not used here right now, we pass the button #requestComments (not askForCommentsButton) as initiator of the action.
|
/ data-cause='requestComments' is not used here right now, we pass the button #requestComments (not askForCommentsButton) as initiator of the action.
|
||||||
/ But if we use this button, it will work since the correct cause is supplied
|
/ But if we use this button, it will work since the correct cause is supplied
|
||||||
.d-grid.gap-2
|
.d-grid.gap-2
|
||||||
button#askForCommentsButton.btn.btn-primary(type='button' data-cause='requestComments' data-message-success=t('exercises.editor.request_for_comments_sent')) =t('exercises.implement.comment.request')
|
button#askForCommentsButton.btn.btn-primary(type='button' data-cause='requestComments' data-message-success=t('exercises.editor.request_for_comments_sent'))
|
||||||
|
i.fa-solid.fa-circle-notch.fa-spin.d-none
|
||||||
|
=t('exercises.implement.comment.request')
|
||||||
button#closeAskForCommentsButton.btn.btn-warning(type='button') =t('activerecord.attributes.request_for_comments.close')
|
button#closeAskForCommentsButton.btn.btn-warning(type='button') =t('activerecord.attributes.request_for_comments.close')
|
||||||
|
Reference in New Issue
Block a user