mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-10-10 05:46:47 +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
|
// Tells whether we're currently viewing or editing table
|
||||||
var currentMode = 'viewMode';
|
var currentMode = 'viewMode';
|
||||||
|
|
||||||
// var selectedRecord;
|
|
||||||
|
|
||||||
// Extend datatables API with searchable options
|
// Extend datatables API with searchable options
|
||||||
// (http://stackoverflow.com/questions/39912395/datatables-dynamically-set-columns-searchable)
|
// (http://stackoverflow.com/questions/39912395/datatables-dynamically-set-columns-searchable)
|
||||||
$.fn.dataTable.Api.register('isColumnSearchable()', function(colSelector) {
|
$.fn.dataTable.Api.register('isColumnSearchable()', function(colSelector) {
|
||||||
|
@ -419,13 +417,7 @@ var RepositoryDatatable = (function(global) {
|
||||||
return JSON.stringify(d);
|
return JSON.stringify(d);
|
||||||
},
|
},
|
||||||
global: false,
|
global: false,
|
||||||
type: 'POST',
|
type: 'POST'
|
||||||
error: function(e) {
|
|
||||||
$('#filtersDropdownButton').removeClass('active-filters');
|
|
||||||
$('#saveRepositoryFilters').addClass('hidden');
|
|
||||||
$('.repository-table-error').addClass('active').html(e.responseJSON.error);
|
|
||||||
animateSpinner(null, false);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
columnDefs: [{
|
columnDefs: [{
|
||||||
// Checkbox column needs special handling
|
// Checkbox column needs special handling
|
||||||
|
@ -613,6 +605,20 @@ var RepositoryDatatable = (function(global) {
|
||||||
$(this).parent().find('.repository-row-selector').trigger('click');
|
$(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();
|
initRowSelection();
|
||||||
bindExportActions();
|
bindExportActions();
|
||||||
$(window).resize(() => {
|
$(window).resize(() => {
|
||||||
|
|
|
@ -32,9 +32,9 @@ class RepositoryRowsController < ApplicationController
|
||||||
|
|
||||||
@repository_rows = @repository_rows.where(archived: params[:archived]) unless @repository.archived?
|
@repository_rows = @repository_rows.where(archived: params[:archived]) unless @repository.archived?
|
||||||
rescue RepositoryFilters::ColumnNotFoundException
|
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
|
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
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
|
|
|
@ -1398,7 +1398,7 @@ en:
|
||||||
filter_inventory_items: "Filter items"
|
filter_inventory_items: "Filter items"
|
||||||
no_items: "No items here"
|
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: "No archived items here"
|
||||||
no_archived_items_matched: "No archived items matched your search request"
|
no_archived_items_matched: "No archived items matched your search request"
|
||||||
error_searching: "Error searching, please try again"
|
error_searching: "Error searching, please try again"
|
||||||
|
|
Loading…
Add table
Reference in a new issue