Add empty states to inventories datatable and fix filtering bug

This commit is contained in:
Mojca Lorber 2020-07-02 15:51:07 +02:00
parent 6726a19cbe
commit db8c7cd97c
5 changed files with 24 additions and 12 deletions

View file

@ -45,6 +45,10 @@
sScrollXInner: '100%',
order: [[1, 'asc']],
destroy: true,
language: {
emptyTable: archived ? I18n.t('repositories.index.no_archived_inventories') : I18n.t('repositories.index.no_inventories'),
zeroRecords: archived ? I18n.t('repositories.index.no_archived_inventories_matched') : I18n.t('repositories.index.no_inventories_matched')
},
columnDefs: [{
targets: 0,
visible: true,

View file

@ -494,8 +494,9 @@ var RepositoryDatatable = (function(global) {
return data;
}
}],
oLanguage: {
sSearch: I18n.t('general.filter_dots')
language: {
emptyTable: I18n.t('repositories.show.no_items'),
zeroRecords: I18n.t('repositories.show.no_items_matched')
},
rowCallback: function(row, data) {
$(row).attr('data-editable', data.recordEditable);
@ -539,6 +540,9 @@ var RepositoryDatatable = (function(global) {
checkArchivedColumnsState();
},
preDrawCallback: function() {
var archived = $('.repository-show').hasClass('archived');
TABLE.context[0].oLanguage.sEmptyTable = archived ? I18n.t('repositories.show.no_archived_items') : I18n.t('repositories.show.no_items');
TABLE.context[0].oLanguage.sZeroRecords = archived ? I18n.t('repositories.show.no_archived_items_matched') : I18n.t('repositories.show.no_items_matched');
animateSpinner(this);
$('.record-info-link').off('click');
},
@ -553,6 +557,7 @@ var RepositoryDatatable = (function(global) {
var archived = $('.repository-show').hasClass('archived');
if (json.state.columns[6]) json.state.columns[6].visible = archived;
if (json.state.columns[7]) json.state.columns[7].visible = archived;
delete json.state.search
callback(json.state);
}
});

View file

@ -62,7 +62,11 @@ class RepositoryDatatableService
end
def fetch_rows(search_value)
repository_rows = @repository.repository_rows
repository_rows = if @repository.archived?
@repository.repository_rows
else
@repository.repository_rows.where(archived: @params[:archived] || false)
end
@all_count =
if @my_module && @params[:assigned] == 'assigned'

View file

@ -942,10 +942,6 @@ class Constants
'start' => 0,
'length' => 8,
'order' => [[2, 'asc']], # Default sorting by 'ID' column
'search' => { 'search' => '',
'smart' => true,
'regex' => false,
'caseInsensitive' => true },
'columns' => [],
'assigned' => 'assigned',
'ColReorder' => [*0..7]
@ -968,10 +964,6 @@ class Constants
'start' => 0,
'length' => 5,
'order' => [[1, 'asc']], # Default sorting by 'ID' column
'search' => { 'search' => '',
'smart' => true,
'regex' => false,
'caseInsensitive' => true },
'columns' => [],
'assigned' => 'assigned',
'ColReorder' => [*0..4]

View file

@ -1078,6 +1078,10 @@ en:
view_only_permission_label: "You have veiw-only permission"
show_per_page: "Show %{number} per page"
filter_inventory: "Filter inventory item"
no_inventories: "No inventories here"
no_inventories_matched: "No inventories matched your search request"
no_archived_inventories: "No archived inventories here"
no_archived_inventories_matched: "No archived inventories matched your search request"
snapshot_provisioning_in_progress: 'Editing is disabled while a snapshot is being created. This will only take a moment.'
options_dropdown:
@ -1130,6 +1134,10 @@ en:
active: "These are individually archived items from the %{repository_name} inventory. The inventory itself is active."
archived_on: "Inventory archived on"
archived_by: "by"
no_items: "No items here"
no_items_matched: "No items matched your search request"
no_archived_items: "No archived items here"
no_archived_items_matched: "No archived items matched your search request"
table:
id: 'ID'
@ -2304,7 +2312,6 @@ en:
no_name: "(no name)"
error: "An error has occurred, please try again later."
filter: "Filter:"
filter_dots: "Filter..."
no_teams:
title: "Your dashboard is empty!"
text: "It seems you're not a member of any team."