mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-10-23 04:08:14 +08:00
Move redirect to controller
This commit is contained in:
parent
d9b691103c
commit
aa88b6bdb4
5 changed files with 13 additions and 21 deletions
|
@ -245,12 +245,7 @@ function applyTaskStatusChangeCallBack() {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: list.data('link-url'),
|
url: list.data('link-url'),
|
||||||
type: 'PATCH',
|
type: 'PATCH',
|
||||||
dataType: 'json',
|
|
||||||
data: { my_module: { status_id: item.data('state-id') } },
|
data: { my_module: { status_id: item.data('state-id') } },
|
||||||
success: function(data) {
|
|
||||||
container.html(data.content);
|
|
||||||
location.reload();
|
|
||||||
},
|
|
||||||
error: function(e) {
|
error: function(e) {
|
||||||
animateSpinner(null, false);
|
animateSpinner(null, false);
|
||||||
if (e.status === 403) {
|
if (e.status === 403) {
|
||||||
|
@ -301,9 +296,9 @@ function initTagsSelector() {
|
||||||
if (lastTagId > 0) {
|
if (lastTagId > 0) {
|
||||||
newTag = { my_module_tag: { tag_id: lastTagId } };
|
newTag = { my_module_tag: { tag_id: lastTagId } };
|
||||||
$.post(selectElement.data('update-module-tags-url'), newTag)
|
$.post(selectElement.data('update-module-tags-url'), newTag)
|
||||||
.fail(function(r) {
|
.fail(function(response) {
|
||||||
dropdownSelector.removeValue(myModuleTagsSelector, lastTagId, '', true);
|
dropdownSelector.removeValue(myModuleTagsSelector, lastTagId, '', true);
|
||||||
if (r.status === 403) {
|
if (response.status === 403) {
|
||||||
HelperModule.flashAlertMsg(I18n.t('general.no_permissions'), 'danger');
|
HelperModule.flashAlertMsg(I18n.t('general.no_permissions'), 'danger');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -361,11 +361,11 @@ function loadFromRepository() {
|
||||||
// Simply reload page
|
// Simply reload page
|
||||||
location.reload();
|
location.reload();
|
||||||
},
|
},
|
||||||
error: function(ev) {
|
error: function(response) {
|
||||||
if (ev.status === 403) {
|
if (response.status === 403) {
|
||||||
HelperModule.flashAlertMsg(I18n.t('general.no_permissions'), 'danger');
|
HelperModule.flashAlertMsg(I18n.t('general.no_permissions'), 'danger');
|
||||||
} else {
|
} else {
|
||||||
alert(ev.responseJSON.message);
|
alert(response.responseJSON.message);
|
||||||
}
|
}
|
||||||
|
|
||||||
modal.modal('hide');
|
modal.modal('hide');
|
||||||
|
|
|
@ -635,11 +635,11 @@ var MyModuleRepositories = (function() {
|
||||||
updateFullViewRowsCount(data.rows_count);
|
updateFullViewRowsCount(data.rows_count);
|
||||||
renderFullViewAssignButtons();
|
renderFullViewAssignButtons();
|
||||||
},
|
},
|
||||||
error: function(data) {
|
error: function(response) {
|
||||||
if (data.status === 403) {
|
if (response.status === 403) {
|
||||||
HelperModule.flashAlertMsg(I18n.t('general.no_permissions'), 'danger');
|
HelperModule.flashAlertMsg(I18n.t('general.no_permissions'), 'danger');
|
||||||
} else {
|
} else {
|
||||||
HelperModule.flashAlertMsg(data.responseJSON.flash, 'danger');
|
HelperModule.flashAlertMsg(response.responseJSON.flash, 'danger');
|
||||||
}
|
}
|
||||||
UPDATE_REPOSITORY_MODAL.modal('hide');
|
UPDATE_REPOSITORY_MODAL.modal('hide');
|
||||||
SELECTED_ROWS = {};
|
SELECTED_ROWS = {};
|
||||||
|
|
|
@ -160,8 +160,8 @@
|
||||||
TinyMCE.init('#step_description_textarea');
|
TinyMCE.init('#step_description_textarea');
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.on("ajax:error", function(e, xhr) {
|
.on("ajax:error", function(e, response) {
|
||||||
if (xhr.status === 403) {
|
if (response.status === 403) {
|
||||||
HelperModule.flashAlertMsg(I18n.t('general.no_permissions'), 'danger');
|
HelperModule.flashAlertMsg(I18n.t('general.no_permissions'), 'danger');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -530,8 +530,8 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
},
|
},
|
||||||
error: function(request) {
|
error: function(response) {
|
||||||
if (request.status === 403) {
|
if (response.status === 403) {
|
||||||
HelperModule.flashAlertMsg(I18n.t('general.no_permissions'), 'danger');
|
HelperModule.flashAlertMsg(I18n.t('general.no_permissions'), 'danger');
|
||||||
animateSpinner(null, false);
|
animateSpinner(null, false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -269,10 +269,7 @@ class MyModulesController < ApplicationController
|
||||||
log_activity(:change_status_on_task_flow, @my_module, my_module_status_old: old_status_id,
|
log_activity(:change_status_on_task_flow, @my_module, my_module_status_old: old_status_id,
|
||||||
my_module_status_new: @my_module.my_module_status.id)
|
my_module_status_new: @my_module.my_module_status.id)
|
||||||
|
|
||||||
render json: { content: render_to_string(
|
return redirect_to protocols_my_module_path(@my_module)
|
||||||
partial: 'my_modules/status_flow/task_flow_button.html.erb',
|
|
||||||
locals: { my_module: @my_module }
|
|
||||||
) }, status: :ok
|
|
||||||
else
|
else
|
||||||
render json: { errors: @my_module.errors.messages.values.flatten.join('\n') }, status: :unprocessable_entity
|
render json: { errors: @my_module.errors.messages.values.flatten.join('\n') }, status: :unprocessable_entity
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue