diff --git a/app/javascript/vue/repositories/table.vue b/app/javascript/vue/repositories/table.vue index ebafb90a4..8b986cad9 100644 --- a/app/javascript/vue/repositories/table.vue +++ b/app/javascript/vue/repositories/table.vue @@ -130,7 +130,8 @@ export default { }, { field: 'nr_of_rows', - headerName: this.i18n.t('libraries.index.table.number_of_items') + headerName: this.i18n.t('libraries.index.table.number_of_items'), + sortable: true }, { field: 'shared_label', diff --git a/app/javascript/vue/shared/datatable/table.vue b/app/javascript/vue/shared/datatable/table.vue index 91280518a..8a4f1ccb5 100644 --- a/app/javascript/vue/shared/datatable/table.vue +++ b/app/javascript/vue/shared/datatable/table.vue @@ -50,6 +50,8 @@ @columnResized="saveTableState" @columnMoved="saveTableState" @bodyScroll="handleScroll" + @columnPinned="handlePin" + @columnVisible="handleVisibility" @rowSelected="setSelectedRows" @cellClicked="clickCell" :CheckboxSelectionCallback="withCheckboxes" @@ -300,6 +302,18 @@ export default { this.loadData(); } }, + handlePin(event) { + if (event.pinned === 'right') { + this.columnApi.setColumnPinned(event.column.colId, null); + } + this.saveTableState(); + }, + handleVisibility(event) { + if (!event.visible && event.source !== 'api') { + this.columnApi.setColumnVisible(event.column.colId, true); + } + this.saveTableState(); + }, fetchAndApplyTableState() { axios .get(this.userSettingsUrl, { @@ -327,6 +341,8 @@ export default { state: this.tableState.columnsState, applyOrder: true }); + } else { + this.saveTableState(); } setTimeout(() => { this.initializing = false; @@ -484,19 +500,15 @@ export default { }, hideColumn(column) { this.columnApi.setColumnVisible(column.field, false); - this.saveTableState(); }, showColumn(column) { this.columnApi.setColumnVisible(column.field, true); - this.saveTableState(); }, pinColumn(column) { this.columnApi.setColumnPinned(column.field, 'left'); - this.saveTableState(); }, unPinColumn(column) { this.columnApi.setColumnPinned(column.field, null); - this.saveTableState(); }, reorderColumns(columns) { this.columnApi.moveColumns(columns, 1); diff --git a/app/javascript/vue/shared/filters/filter_dropdown.vue b/app/javascript/vue/shared/filters/filter_dropdown.vue index 5a54a6fc4..ce164db57 100644 --- a/app/javascript/vue/shared/filters/filter_dropdown.vue +++ b/app/javascript/vue/shared/filters/filter_dropdown.vue @@ -19,7 +19,7 @@ -
+
-
+
{{ i18n.t('filters_modal.clear_btn') }}
diff --git a/app/serializers/lists/repository_serializer.rb b/app/serializers/lists/repository_serializer.rb index 8f0d0bea4..8425d8e23 100644 --- a/app/serializers/lists/repository_serializer.rb +++ b/app/serializers/lists/repository_serializer.rb @@ -10,7 +10,7 @@ module Lists :urls, :shared_read, :shared_write, :shareable_write def nr_of_rows - object.repository_rows.count + object[:row_count] end def shared diff --git a/app/services/lists/repositories_service.rb b/app/services/lists/repositories_service.rb index 57bb91c60..6c08d256b 100644 --- a/app/services/lists/repositories_service.rb +++ b/app/services/lists/repositories_service.rb @@ -13,12 +13,14 @@ module Lists 'LEFT OUTER JOIN users AS archivers ' \ 'ON repositories.archived_by_id = archivers.id' ) - .includes(:repository_rows) + .joins(:repository_rows) .joins(:team) - .select('repositories.* AS repositories') - .select('teams.name AS team_name') - .select('creators.full_name AS created_by_user') - .select('archivers.full_name AS archived_by_user') + .select('repositories.*') + .select('MAX(teams.name) AS team_name') + .select('COUNT(repository_rows.*) AS row_count') + .select('MAX(creators.full_name) AS created_by_user') + .select('MAX(archivers.full_name) AS archived_by_user') + .group('repositories.id') view_mode = @params[:view_mode] || 'active' @@ -47,7 +49,8 @@ module Lists created_by: 'creators.full_name', created_at: 'repositories.created_at', archived_on: 'repositories.archived_on', - archived_by: 'archivers.full_name' + archived_by: 'archivers.full_name', + nr_of_rows: 'row_count' } end end