Merge pull request #2701 from mlorb/ml-sci-4793

Add empty states to inventories datatable and fix filtering bug [SCI-4793]
This commit is contained in:
mlorb 2020-07-09 11:49:16 +02:00 committed by GitHub
commit 73e2654d78
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 25 additions and 28 deletions

View file

@ -48,6 +48,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: !$('.repositories-index').data('readonly'),

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

@ -61,7 +61,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

@ -1080,6 +1080,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:
@ -1134,6 +1138,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'
@ -2309,7 +2317,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."

View file

@ -17,12 +17,6 @@ RSpec::Matchers.define :be_valid_default_repository_table_state do |nr_of_cols|
'start' => 0,
'length' => cols_length, # 8 default columns + parameter
'order' => [[2, 'asc']],
'search' => {
'search' => '',
'smart' => true,
'regex' => false,
'caseInsensitive' => true
},
'assigned' => 'assigned',
'ColReorder' => cols_array
)

View file

@ -9,7 +9,7 @@ RSpec::Matchers.define :be_valid_repository_table_state do
expect(state).to be_an_instance_of Hash
expect(state).to include(
'time', 'order', 'start', 'length', 'search', 'columns', 'ColReorder'
'time', 'order', 'start', 'length', 'columns', 'ColReorder'
)
expect(state['time']).to be_an_instance_of Integer
@ -55,15 +55,6 @@ RSpec::Matchers.define :be_valid_repository_table_state do
# Check that the ordering column exists in columns
expect(col_indexes).to include(state['order'][0][0])
expect(state['search']).to be_an_instance_of Hash
expect(state['search']).to include(
'regex', 'smart', 'search', 'caseInsensitive'
)
expect(state['search']['regex']).to eq(true).or eq(false)
expect(state['search']['smart']).to eq(true).or eq(false)
expect(state['search']['caseInsensitive']).to eq(true).or eq(false)
expect(state['search']['search']).to be_an_instance_of String
expect(state['ColReorder']).to be_an_instance_of Array
expect(state['ColReorder'].length).to eq cols_length