diff --git a/CI/e2e/frontend.config.e2e.json b/CI/e2e/frontend.config.e2e.json index 462b82d983..79008598c9 100644 --- a/CI/e2e/frontend.config.e2e.json +++ b/CI/e2e/frontend.config.e2e.json @@ -3,7 +3,7 @@ "nonAuthenticatedUser": "DATASETS", "authenticatedUser": "PROPOSALS" }, - "checkBoxFilterClickTrigger": false, + "autoApplyFilters": false, "accessTokenPrefix": "Bearer ", "addDatasetEnabled": false, "allowConfigOverrides": true, diff --git a/cypress/e2e/datasets/datasets-general.cy.js b/cypress/e2e/datasets/datasets-general.cy.js index 0d4b5635d2..31c4b66e56 100644 --- a/cypress/e2e/datasets/datasets-general.cy.js +++ b/cypress/e2e/datasets/datasets-general.cy.js @@ -777,4 +777,80 @@ describe("Datasets general", () => { cy.get('[data-cy="remove-condition-button"]').click(); }); }); + + describe("Auto apply filters", () => { + beforeEach(() => { + cy.clearLocalStorage(); + cy.createDataset({ keywords: ["test auto apply"] }); + cy.createDataset({ keywords: ["another keyword"] }); + }); + + it("should apply checkbox filters when user clicks", () => { + cy.readFile("CI/e2e/frontend.config.e2e.json").then((baseConfig) => { + const testConfig = { + ...baseConfig, + autoApplyFilters: true, + defaultDatasetsListSettings: { + ...baseConfig.defaultDatasetsListSettings, + filters: [ + { + key: "keywords", + label: "Keyword", + type: "checkbox", + description: "Filter by keywords in the dataset", + enabled: true, + }, + ], + }, + }; + + cy.intercept("GET", "**/admin/config", testConfig).as("getConfig"); + }); + + cy.visit("/datasets"); + cy.wait("@getConfig", { timeout: 20000 }); + cy.finishedLoading(); + + cy.get(".checkbox-list mat-checkbox") + .contains(/test auto apply/i) + .click({ force: true }); + }); + + it("should apply typed filters when user presses Enter", () => { + cy.readFile("CI/e2e/frontend.config.e2e.json").then((baseConfig) => { + const testConfig = { + ...baseConfig, + autoApplyFilters: true, + defaultDatasetsListSettings: { + ...baseConfig.defaultDatasetsListSettings, + filters: [ + { + key: "keywords", + label: "Keyword", + type: "multiSelect", + description: "Filter by keywords in the dataset", + enabled: true, + }, + ], + }, + }; + + cy.intercept("GET", "**/admin/config", testConfig).as("getConfig"); + }); + + cy.visit("/datasets"); + cy.wait("@getConfig", { timeout: 20000 }); + cy.finishedLoading(); + + cy.get("mat-form-field#keywords input.item-input") + .click() + .type("test auto apply"); + cy.get("mat-option") + .contains(/test auto apply/i) + .click(); + cy.get("mat-form-field#keywords input.item-input") + .click() + .type("{enter}"); + }); + }); }); diff --git a/src/app/admin/schema/frontend.config.jsonforms.json b/src/app/admin/schema/frontend.config.jsonforms.json index d02e5e19c4..15891fc577 100644 --- a/src/app/admin/schema/frontend.config.jsonforms.json +++ b/src/app/admin/schema/frontend.config.jsonforms.json @@ -18,7 +18,6 @@ }, "skipSciCatLoginPageEnabled": { "type": "boolean" }, "allowConfigOverrides": { "type": "boolean" }, - "checkBoxFilterClickTrigger": { "type": "boolean" }, "dateFormat": { "type": "string" }, "accessTokenPrefix": { "type": "string" }, "addDatasetEnabled": { "type": "boolean" }, @@ -56,6 +55,7 @@ "logbookEnabled": { "type": "boolean" }, "loginFormEnabled": { "type": "boolean" }, "metadataPreviewEnabled": { "type": "boolean" }, + "autoApplyFilters": { "type": "boolean" }, "metadataStructure": { "type": "string" }, "multipleDownloadAction": { "type": "string" }, "multipleDownloadEnabled": { "type": "boolean" }, @@ -437,10 +437,6 @@ { "type": "Control", "scope": "#/properties/siteSciCatLogo" }, { "type": "Control", "scope": "#/properties/statusBannerMessage" }, { "type": "Control", "scope": "#/properties/statusBannerCode" }, - { - "type": "Control", - "scope": "#/properties/checkBoxFilterClickTrigger" - }, { "type": "Control", "scope": "#/properties/addDatasetEnabled" }, { "type": "Control", @@ -467,7 +463,8 @@ { "type": "Control", "scope": "#/properties/jsonMetadataEnabled" }, { "type": "Control", "scope": "#/properties/logbookEnabled" }, { "type": "Control", "scope": "#/properties/loginFormEnabled" }, - { "type": "Control", "scope": "#/properties/metadataPreviewEnabled" } + { "type": "Control", "scope": "#/properties/metadataPreviewEnabled" }, + { "type": "Control", "scope": "#/properties/autoApplyFilters" } ] }, { diff --git a/src/app/app-config.service.ts b/src/app/app-config.service.ts index e669d360f7..ad2655cee3 100644 --- a/src/app/app-config.service.ts +++ b/src/app/app-config.service.ts @@ -164,12 +164,12 @@ export interface AppConfigInterface { siteHeaderLogoUrl?: string; mainMenu?: MainMenuConfiguration; supportEmail?: string; - checkBoxFilterClickTrigger?: boolean; hideEmptyMetadataTable?: boolean; ingestorComponent?: IngestorComponentConfig; defaultTab?: DefaultTab; statusBannerMessage?: string; statusBannerCode?: "INFO" | "WARN"; + autoApplyFilters?: boolean; } function isMainPageConfiguration(obj: any): obj is MainPageConfiguration { diff --git a/src/app/datasets/datasets-filter/datasets-filter.component.html b/src/app/datasets/datasets-filter/datasets-filter.component.html index e919e6791f..f7568c2c35 100644 --- a/src/app/datasets/datasets-filter/datasets-filter.component.html +++ b/src/app/datasets/datasets-filter/datasets-filter.component.html @@ -51,6 +51,7 @@ (numericRangeChange)="numericRangeChange(filter.key, $event)" [filterValue]="activeFilters[filter.key]" [collapsible]="filter.type === 'checkbox'" + (applyEnterKey)="applyFilters()" > diff --git a/src/app/datasets/datasets-filter/datasets-filter.component.ts b/src/app/datasets/datasets-filter/datasets-filter.component.ts index 334dbfdead..5cb315bc96 100644 --- a/src/app/datasets/datasets-filter/datasets-filter.component.ts +++ b/src/app/datasets/datasets-filter/datasets-filter.component.ts @@ -298,7 +298,7 @@ export class DatasetsFilterComponent implements OnInit, OnDestroy { // This applies to both multiselect type and checkBoxFilter // skip PID text input to avoid triggering on keystrokes // Array check can be removed when we remove text input filter type - if (Array.isArray(value) && this.appConfig.checkBoxFilterClickTrigger) { + if (Array.isArray(value) && this.appConfig.autoApplyFilters) { this.applyFilters(); } } diff --git a/src/app/files/files-dashboard/files-dashboard.component.html b/src/app/files/files-dashboard/files-dashboard.component.html index ff827a6658..6738ab4bd0 100644 --- a/src/app/files/files-dashboard/files-dashboard.component.html +++ b/src/app/files/files-dashboard/files-dashboard.component.html @@ -8,7 +8,7 @@ [pagination]="pagination" [rowSelectionMode]="rowSelectionMode" [globalTextSearch]="globalTextSearch" - globalTextSearchPlaceholder="Global text search" + globalTextSearchPlaceholder="Filename, Size..." (paginationChange)="onPaginationChange($event)" (globalTextSearchChange)="onGlobalTextSearchChange($event)" (onRowEvent)="onRowClick($event)" diff --git a/src/app/instruments/instruments-dashboard/instruments-dashboard.component.spec.ts b/src/app/instruments/instruments-dashboard/instruments-dashboard.component.spec.ts index df5c266502..2112475049 100644 --- a/src/app/instruments/instruments-dashboard/instruments-dashboard.component.spec.ts +++ b/src/app/instruments/instruments-dashboard/instruments-dashboard.component.spec.ts @@ -16,6 +16,7 @@ import { import { TablePagination } from "shared/modules/dynamic-material-table/models/table-pagination.model"; import { BrowserAnimationsModule } from "@angular/platform-browser/animations"; import { TranslateService } from "@ngx-translate/core"; +import { AppConfigService } from "app-config.service"; describe("InstrumentsDashboardComponent", () => { let component: InstrumentsDashboardComponent; @@ -49,6 +50,7 @@ describe("InstrumentsDashboardComponent", () => { ], }), { provide: TranslateService, useValue: { instant: (k: string) => k } }, + { provide: AppConfigService, useValue: { getConfig: () => ({}) } }, ], }); TestBed.overrideComponent(InstrumentsDashboardComponent, { diff --git a/src/app/proposals/proposal-filters/side-bar-filter/proposal-side-filter.component.html b/src/app/proposals/proposal-filters/side-bar-filter/proposal-side-filter.component.html index 43ac47fbb5..e4d87fbc43 100644 --- a/src/app/proposals/proposal-filters/side-bar-filter/proposal-side-filter.component.html +++ b/src/app/proposals/proposal-filters/side-bar-filter/proposal-side-filter.component.html @@ -26,6 +26,7 @@ (dateRangeChange)="setDateFilter(filter.key, $event)" [filterValue]="activeFilters[filter.key]" [collapsible]="filter.type === 'checkbox'" + (applyEnterKey)="applyFilters()" >