mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-10-03 02:14:29 +08:00
Fix inventory table custom error messages [SCI-6532] (#3855)
This commit is contained in:
parent
fa6f883fc7
commit
0ce6f43cbf
3 changed files with 18 additions and 12 deletions
|
@ -24,8 +24,6 @@ var RepositoryDatatable = (function(global) {
|
|||
// Tells whether we're currently viewing or editing table
|
||||
var currentMode = 'viewMode';
|
||||
|
||||
// var selectedRecord;
|
||||
|
||||
// Extend datatables API with searchable options
|
||||
// (http://stackoverflow.com/questions/39912395/datatables-dynamically-set-columns-searchable)
|
||||
$.fn.dataTable.Api.register('isColumnSearchable()', function(colSelector) {
|
||||
|
@ -419,13 +417,7 @@ var RepositoryDatatable = (function(global) {
|
|||
return JSON.stringify(d);
|
||||
},
|
||||
global: false,
|
||||
type: 'POST',
|
||||
error: function(e) {
|
||||
$('#filtersDropdownButton').removeClass('active-filters');
|
||||
$('#saveRepositoryFilters').addClass('hidden');
|
||||
$('.repository-table-error').addClass('active').html(e.responseJSON.error);
|
||||
animateSpinner(null, false);
|
||||
}
|
||||
type: 'POST'
|
||||
},
|
||||
columnDefs: [{
|
||||
// Checkbox column needs special handling
|
||||
|
@ -613,6 +605,20 @@ var RepositoryDatatable = (function(global) {
|
|||
$(this).parent().find('.repository-row-selector').trigger('click');
|
||||
});
|
||||
|
||||
// Handling of special errors
|
||||
$(TABLE_ID).on('xhr.dt', function(e, settings, json) {
|
||||
if (json.custom_error) {
|
||||
json.data = [];
|
||||
json.recordsFiltered = 0;
|
||||
json.recordsTotal = 0;
|
||||
TABLE.one('draw', function() {
|
||||
$('#filtersDropdownButton').removeClass('active-filters');
|
||||
$('#saveRepositoryFilters').addClass('hidden');
|
||||
$('.repository-table-error').addClass('active').text(json.custom_error);
|
||||
});
|
||||
}
|
||||
})
|
||||
|
||||
initRowSelection();
|
||||
bindExportActions();
|
||||
$(window).resize(() => {
|
||||
|
|
|
@ -32,9 +32,9 @@ class RepositoryRowsController < ApplicationController
|
|||
|
||||
@repository_rows = @repository_rows.where(archived: params[:archived]) unless @repository.archived?
|
||||
rescue RepositoryFilters::ColumnNotFoundException
|
||||
render json: { error: I18n.t('repositories.show.repository_filter.errors.column_not_found') }, status: :not_found
|
||||
render json: { custom_error: I18n.t('repositories.show.repository_filter.errors.column_not_found') }
|
||||
rescue RepositoryFilters::ValueNotFoundException
|
||||
render json: { error: I18n.t('repositories.show.repository_filter.errors.value_not_found') }, status: :not_found
|
||||
render json: { custom_error: I18n.t('repositories.show.repository_filter.errors.value_not_found') }
|
||||
end
|
||||
|
||||
def create
|
||||
|
|
|
@ -1398,7 +1398,7 @@ en:
|
|||
filter_inventory_items: "Filter items"
|
||||
no_items: "No items here"
|
||||
|
||||
no_items_matched: "No items matched your search request"
|
||||
no_items_matched: "No items here"
|
||||
no_archived_items: "No archived items here"
|
||||
no_archived_items_matched: "No archived items matched your search request"
|
||||
error_searching: "Error searching, please try again"
|
||||
|
|
Loading…
Add table
Reference in a new issue