Skip to content

Commit

Permalink
feat(document): advanced search
Browse files Browse the repository at this point in the history
If there is only one value in the search type menu, it is disabled.

* Adds the new options hideLabelSelectOption on the schema.
* Fixes templateOptions to avoid overwriting default values.

Co-Authored-by: Bertrand Zuchuat <[email protected]>
  • Loading branch information
Garfield-fr committed Jan 29, 2024
1 parent 6d2704d commit dfd4cae
Showing 1 changed file with 13 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* RERO ILS UI
* Copyright (C) 2019-2023 RERO
* Copyright (C) 2021-2023 UCLouvain
* Copyright (C) 2019-2024 RERO
* Copyright (C) 2021-2024 UCLouvain
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
Expand Down Expand Up @@ -159,11 +159,8 @@ export class DocumentAdvancedSearchFormComponent implements OnInit {
*/
private initField(field: any, fieldParentKey: string, subject: BehaviorSubject<any>): void {
if (Object.keys(this.fieldDataConfig).some(key => key === fieldParentKey)) {
field.templateOptions = {
options: subject.asObservable(),
minItemsToDisplaySearch: 10,
sort: false,
};
field.templateOptions.options = subject.asObservable();
field.templateOptions.sort = false;
field.type = 'select';
subject.next(this.fieldDataConfig[fieldParentKey]);
} else {
Expand All @@ -179,10 +176,9 @@ export class DocumentAdvancedSearchFormComponent implements OnInit {
*/
private initFieldSearchType(field: any, fieldParentKey: string, subject: BehaviorSubject<any>): void {
if (Object.keys(this.fieldsSearchTypeConfig).some(key => key === fieldParentKey)) {
field.templateOptions = {
options: subject.asObservable(),
sort: false,
};
field.templateOptions.options = subject.asObservable();
field.templateOptions.sort = false;
field.templateOptions.readonly = this.fieldsSearchTypeConfig[fieldParentKey].length < 2;
subject.next(this.fieldsSearchTypeConfig[fieldParentKey]);
const fieldSearchTypeValue = this.fieldsSearchTypeConfig[fieldParentKey][0].value;
if (
Expand Down Expand Up @@ -223,7 +219,9 @@ export class DocumentAdvancedSearchFormComponent implements OnInit {
templateOptions: {
sort: false,
hideLabel: true,
hideLabelSelectOption: true,
required: true,
minItemsToDisplaySearch: 999,
options: this.advancedSearchService.getFieldsConfig(),
},
},
Expand All @@ -233,6 +231,7 @@ export class DocumentAdvancedSearchFormComponent implements OnInit {
key: 'searchType',
defaultValue: false,
templateOptions: {
hideLabelSelectOption: true,
options: []
},
hooks: {
Expand Down Expand Up @@ -286,7 +285,9 @@ export class DocumentAdvancedSearchFormComponent implements OnInit {
templateOptions: {
sort: false,
hideLabel: true,
hideLabelSelectOption: true,
required: true,
minItemsToDisplaySearch: 999,
options: this.advancedSearchService.getFieldsConfig(),
},
},
Expand All @@ -296,6 +297,7 @@ export class DocumentAdvancedSearchFormComponent implements OnInit {
key: 'searchType',
defaultValue: false,
templateOptions: {
hideLabelSelectOption: true,
options: []
},
hooks: {
Expand Down

0 comments on commit dfd4cae

Please sign in to comment.