From f8455a57cc5e8875df4c6b73a342b562a1c3030a Mon Sep 17 00:00:00 2001 From: "swapnil.verma" Date: Fri, 9 Jun 2023 16:45:47 +0530 Subject: [PATCH 01/54] [ACS-4985] Added SearchFilterTabbedComponent and SearchDateRangeAdvancedComponent. Added config for using the new components --- .../search-date-range-advanced.component.html | 40 +++ .../search-date-range-advanced.component.scss | 25 ++ ...arch-date-range-advanced.component.spec.ts | 23 ++ .../search-date-range-advanced.component.ts | 238 ++++++++++++++++++ .../search-widget-chip.component.ts | 4 +- .../search-filter-tabbed.component.spec.ts | 23 ++ 6 files changed, 351 insertions(+), 2 deletions(-) create mode 100644 lib/content-services/src/lib/search/components/search-date-range-advanced/search-date-range-advanced.component.html create mode 100644 lib/content-services/src/lib/search/components/search-date-range-advanced/search-date-range-advanced.component.scss create mode 100644 lib/content-services/src/lib/search/components/search-date-range-advanced/search-date-range-advanced.component.spec.ts create mode 100644 lib/content-services/src/lib/search/components/search-date-range-advanced/search-date-range-advanced.component.ts create mode 100644 lib/content-services/src/lib/search/components/search-filter-tabbed/search-filter-tabbed.component.spec.ts diff --git a/lib/content-services/src/lib/search/components/search-date-range-advanced/search-date-range-advanced.component.html b/lib/content-services/src/lib/search/components/search-date-range-advanced/search-date-range-advanced.component.html new file mode 100644 index 00000000000..45cf7039a4a --- /dev/null +++ b/lib/content-services/src/lib/search/components/search-date-range-advanced/search-date-range-advanced.component.html @@ -0,0 +1,40 @@ + + + + {{ 'SEARCH.DATE_RANGE_ADVANCED.OPTIONS.ANYTIME' | translate }} + + + + {{ 'SEARCH.DATE_RANGE_ADVANCED.OPTIONS.IN_LAST' | translate }} + + + + + + {{ 'SEARCH.DATE_RANGE_ADVANCED.IN_LAST_LABELS.DAYS' | translate }} + {{ 'SEARCH.DATE_RANGE_ADVANCED.IN_LAST_LABELS.WEEKS' | translate }} + {{ 'SEARCH.DATE_RANGE_ADVANCED.IN_LAST_LABELS.MONTHS' | translate }} + + + + + {{ 'SEARCH.DATE_RANGE_ADVANCED.OPTIONS.BETWEEN' | translate }} + + + + + + + + + + + +
+ + +
diff --git a/lib/content-services/src/lib/search/components/search-date-range-advanced/search-date-range-advanced.component.scss b/lib/content-services/src/lib/search/components/search-date-range-advanced/search-date-range-advanced.component.scss new file mode 100644 index 00000000000..28166f5b1e0 --- /dev/null +++ b/lib/content-services/src/lib/search/components/search-date-range-advanced/search-date-range-advanced.component.scss @@ -0,0 +1,25 @@ +.adf-search-date-range-advanced { + .mat-radio-group { + display: flex; + flex-direction: column; + } + + .mat-radio-button { + margin: 5px; + } + + .adf-search-date-range-horizontal-container { + display: flex; + flex-direction: row; + align-items: center; + + .adf-search-date-range-input-field { + width: 75px; + } + + .adf-search-date-range-form-field { + padding-left: 10px; + flex: 1; + } + } +} diff --git a/lib/content-services/src/lib/search/components/search-date-range-advanced/search-date-range-advanced.component.spec.ts b/lib/content-services/src/lib/search/components/search-date-range-advanced/search-date-range-advanced.component.spec.ts new file mode 100644 index 00000000000..c1e851f9eb5 --- /dev/null +++ b/lib/content-services/src/lib/search/components/search-date-range-advanced/search-date-range-advanced.component.spec.ts @@ -0,0 +1,23 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { SearchDateRangeAdvancedComponent } from './search-date-range-advanced.component'; + +describe('SearchDateRangeAdvancedComponent', () => { + let component: SearchDateRangeAdvancedComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [ SearchDateRangeAdvancedComponent ] + }) + .compileComponents(); + + fixture = TestBed.createComponent(SearchDateRangeAdvancedComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/lib/content-services/src/lib/search/components/search-date-range-advanced/search-date-range-advanced.component.ts b/lib/content-services/src/lib/search/components/search-date-range-advanced/search-date-range-advanced.component.ts new file mode 100644 index 00000000000..6fa9ba1f211 --- /dev/null +++ b/lib/content-services/src/lib/search/components/search-date-range-advanced/search-date-range-advanced.component.ts @@ -0,0 +1,238 @@ +import { Component, OnDestroy, OnInit, ViewEncapsulation } from '@angular/core'; +import { + SearchQueryBuilderService, + SearchWidget, + SearchWidgetSettings +} from '@alfresco/adf-content-services'; +import { DateAdapter, MAT_DATE_FORMATS, MAT_DATE_LOCALE } from '@angular/material/core'; +import { Moment } from 'moment'; +import { Subject } from 'rxjs'; +import { TranslateService } from '@ngx-translate/core'; +import { + MOMENT_DATE_FORMATS, + MomentDateAdapter, + UserPreferencesService, + UserPreferenceValues +} from '@alfresco/adf-core'; +import { takeUntil } from 'rxjs/operators'; + +declare let moment: any; + +enum DateRangeType { + ANY = 'ANY', + IN_LAST = 'IN_LAST', + BETWEEN = 'BETWEEN', +} + +enum InLastDateType { + DAYS = 'DAYS', + WEEKS = 'WEEKS', + MONTHS = 'MONTHS' +} + +interface SearchDateRangeAdvanced { + dateRangeType: DateRangeType; + + [indexer: string]: any; +} + +const DEFAULT_FORMAT_DATE: string = 'DD/MM/YYYY'; + +@Component({ + selector: 'adf-search-date-range-advanced', + templateUrl: './search-date-range-advanced.component.html', + styleUrls: ['./search-date-range-advanced.component.scss'], + providers: [ + {provide: DateAdapter, useClass: MomentDateAdapter, deps: [MAT_DATE_LOCALE]}, + {provide: MAT_DATE_FORMATS, useValue: MOMENT_DATE_FORMATS} + ], + encapsulation: ViewEncapsulation.None, + host: {class: 'adf-search-date-range-advanced'} +}) +export class SearchDateRangeAdvancedComponent implements SearchWidget, OnInit, OnDestroy { + displayValue$: Subject = new Subject(); + isActive: boolean; + + id: string; + settings?: SearchWidgetSettings; + context?: SearchQueryBuilderService; + startValue: SearchDateRangeAdvanced; + maxDate: any; + dateRangeTypeValue: DateRangeType = DateRangeType.ANY; + inLastValue: string; + inLastValueType: InLastDateType = InLastDateType.DAYS; + betweenStartDate: any; + betweenEndDate: any; + + DateRangeType = DateRangeType; + InLastDateType = InLastDateType; + + private enableChangeUpdate: boolean; + private datePickerFormat: string; + private disableUpdateOnSubmit = false; + + private onDestroy$ = new Subject(); + + constructor(private dateAdapter: DateAdapter, + private translate: TranslateService, + private userPreferencesService: UserPreferencesService) { + } + + ngOnInit(): void { + this.datePickerFormat = this.settings?.dateFormat ? this.settings.dateFormat : DEFAULT_FORMAT_DATE; + this.disableUpdateOnSubmit = this.settings?.disableUpdateOnSubmit; + if (this.settings && this.settings.maxDate) { + if (this.settings.maxDate === 'today') { + this.maxDate = this.dateAdapter.today().endOf('day'); + } else { + this.maxDate = moment(this.settings.maxDate).endOf('day'); + } + } + this.enableChangeUpdate = this.settings?.allowUpdateOnChange ?? true; + + this.userPreferencesService + .select(UserPreferenceValues.Locale) + .pipe(takeUntil(this.onDestroy$)) + .subscribe(locale => this.setLocale(locale)); + + if (this.startValue) { + this.setValue(this.startValue); + } + } + + ngOnDestroy(): void { + this.onDestroy$.next(); + this.onDestroy$.complete(); + } + + setLocale(locale) { + this.dateAdapter.setLocale(locale); + moment.locale(locale); + } + + getCurrentValue(): SearchDateRangeAdvanced { + let currentValue = {}; + switch (this.dateRangeTypeValue) { + case DateRangeType.IN_LAST: + currentValue = { + inLastValue: this.inLastValue, + inLastValueType: this.inLastValueType + }; + break; + case DateRangeType.BETWEEN: + currentValue = { + betweenStartDate: this.betweenStartDate, + betweenEndDate: this.betweenEndDate + }; + break; + } + return { + dateRangeType: this.dateRangeTypeValue, + ...currentValue + }; + } + + hasValidValue(): boolean { + let isValid = false; + switch (this.dateRangeTypeValue) { + case DateRangeType.ANY: + isValid = true; + break; + case DateRangeType.IN_LAST: + if (this.inLastValue) { + isValid = true; + } + break; + case DateRangeType.BETWEEN: + if (this.betweenStartDate && this.betweenEndDate) { + isValid = true; + } + break; + default: + isValid = false; + } + return isValid; + } + + reset(): void { + this.isActive = false; + + this.dateRangeTypeValue = DateRangeType.ANY; + this.inLastValue = ''; + this.inLastValueType = InLastDateType.DAYS; + this.betweenStartDate = ''; + this.betweenEndDate = ''; + + if (this.id && this.context) { + this.context.queryFragments[this.id] = ''; + if (this.enableChangeUpdate) { + this.updateQuery(); + } + } + + } + + setValue(value: SearchDateRangeAdvanced) { + this.dateRangeTypeValue = value.dateRangeType ? value.dateRangeType : DateRangeType.ANY; + switch (this.dateRangeTypeValue) { + case DateRangeType.IN_LAST: + this.inLastValue = value.inLastValue; + this.inLastValueType = value.inLastValueType; + break; + case DateRangeType.BETWEEN: + this.betweenStartDate = value.betweenStartDate; + this.betweenEndDate = value.betweeenEndDate; + break; + } + } + + submitValues(): void { + let query = ''; + this.isActive = true; + switch (this.dateRangeTypeValue) { + case DateRangeType.IN_LAST: + if (this.hasValidValue()) { + query = `${this.settings.field}:[NOW/DAY-${this.inLastValue}${this.inLastValueType} TO NOW/DAY+1DAY]`; + } + break; + case DateRangeType.BETWEEN: + if (this.hasValidValue()) { + const start = moment(this.betweenStartDate).startOf('day').format(); + const end = moment(this.betweenEndDate).endOf('day').format(); + query = `${this.settings.field}:['${start}' TO '${end}']`; + } + } + this.context.queryFragments[this.id] = query; + this.updateDisplayValue(); + if (!this.disableUpdateOnSubmit) { + this.updateQuery(); + } + } + + updateDisplayValue(): void { + let displayLabel = ''; + switch (this.dateRangeTypeValue) { + case DateRangeType.IN_LAST: + if (this.hasValidValue()) { + displayLabel = `${this.translate.instant('SEARCH.DATE_RANGE_ADVANCED.OPTIONS.IN_LAST')} ${this.inLastValue} ${this.translate.instant(`SEARCH.DATE_RANGE_ADVANCED.IN_LAST_LABELS.${this.inLastValueType}`)}`; + } + break; + case DateRangeType.BETWEEN: + if (this.hasValidValue()) { + const start = moment(this.betweenStartDate).startOf('day').format(this.datePickerFormat); + const end = moment(this.betweenEndDate).endOf('day').format(this.datePickerFormat); + displayLabel = `${start} - ${end}`; + } + break; + } + this.displayValue$.next(displayLabel); + } + + private updateQuery() { + if (this.id && this.context) { + this.context.update(); + } + } +} + +//TODO: Format dates for Between date range type diff --git a/lib/content-services/src/lib/search/components/search-filter-chips/search-widget-chip/search-widget-chip.component.ts b/lib/content-services/src/lib/search/components/search-filter-chips/search-widget-chip/search-widget-chip.component.ts index 4ff847a7531..3845ac94949 100644 --- a/lib/content-services/src/lib/search/components/search-filter-chips/search-widget-chip/search-widget-chip.component.ts +++ b/lib/content-services/src/lib/search/components/search-filter-chips/search-widget-chip/search-widget-chip.component.ts @@ -16,10 +16,10 @@ */ import { Component, ElementRef, Input, ViewChild, ViewEncapsulation } from '@angular/core'; -import { SearchCategory } from '../../../models/search-category.interface'; +import { SearchCategory } from '@alfresco/adf-content-services'; import { ConfigurableFocusTrap, ConfigurableFocusTrapFactory } from '@angular/cdk/a11y'; import { MatMenuTrigger } from '@angular/material/menu'; -import { SearchWidgetContainerComponent } from '../../search-widget-container/search-widget-container.component'; +import { SearchWidgetContainerComponent } from '@alfresco/adf-content-services'; @Component({ selector: 'adf-search-widget-chip', diff --git a/lib/content-services/src/lib/search/components/search-filter-tabbed/search-filter-tabbed.component.spec.ts b/lib/content-services/src/lib/search/components/search-filter-tabbed/search-filter-tabbed.component.spec.ts new file mode 100644 index 00000000000..6ebb93db08e --- /dev/null +++ b/lib/content-services/src/lib/search/components/search-filter-tabbed/search-filter-tabbed.component.spec.ts @@ -0,0 +1,23 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { SearchFilterTabbedComponent } from './search-filter-tabbed.component'; + +describe('SearchFilterTabbedComponent', () => { + let component: SearchFilterTabbedComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [ SearchFilterTabbedComponent ] + }) + .compileComponents(); + + fixture = TestBed.createComponent(SearchFilterTabbedComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); From df1801dd44e3468b89813cab3ff79f48db5f074e Mon Sep 17 00:00:00 2001 From: "swapnil.verma" Date: Mon, 12 Jun 2023 12:57:38 +0530 Subject: [PATCH 02/54] [ACS-4985] Using widget-composite component now correctly updates the search query on submit. Added optional property to disable update on submit button click for widget-composite. --- .../search-date-range-advanced.component.ts | 4 +-- .../search-widget-container.component.ts | 4 +++ .../search/models/search-widget.interface.ts | 1 + .../services/base-query-builder.service.ts | 25 +++++++++++++++---- 4 files changed, 27 insertions(+), 7 deletions(-) diff --git a/lib/content-services/src/lib/search/components/search-date-range-advanced/search-date-range-advanced.component.ts b/lib/content-services/src/lib/search/components/search-date-range-advanced/search-date-range-advanced.component.ts index 6fa9ba1f211..f43d08b9706 100644 --- a/lib/content-services/src/lib/search/components/search-date-range-advanced/search-date-range-advanced.component.ts +++ b/lib/content-services/src/lib/search/components/search-date-range-advanced/search-date-range-advanced.component.ts @@ -57,6 +57,7 @@ export class SearchDateRangeAdvancedComponent implements SearchWidget, OnInit, O settings?: SearchWidgetSettings; context?: SearchQueryBuilderService; startValue: SearchDateRangeAdvanced; + disableUpdateOnSubmit: boolean; maxDate: any; dateRangeTypeValue: DateRangeType = DateRangeType.ANY; inLastValue: string; @@ -69,7 +70,6 @@ export class SearchDateRangeAdvancedComponent implements SearchWidget, OnInit, O private enableChangeUpdate: boolean; private datePickerFormat: string; - private disableUpdateOnSubmit = false; private onDestroy$ = new Subject(); @@ -234,5 +234,5 @@ export class SearchDateRangeAdvancedComponent implements SearchWidget, OnInit, O } } } - //TODO: Format dates for Between date range type + diff --git a/lib/content-services/src/lib/search/components/search-widget-container/search-widget-container.component.ts b/lib/content-services/src/lib/search/components/search-widget-container/search-widget-container.component.ts index 1455e456d2c..1e08a9423ac 100644 --- a/lib/content-services/src/lib/search/components/search-widget-container/search-widget-container.component.ts +++ b/lib/content-services/src/lib/search/components/search-widget-container/search-widget-container.component.ts @@ -57,6 +57,9 @@ export class SearchWidgetContainerComponent implements OnInit, OnDestroy, OnChan @Input() value: any; + @Input() + disableUpdateOnSubmit = false; + componentRef: ComponentRef; constructor( @@ -89,6 +92,7 @@ export class SearchWidgetContainerComponent implements OnInit, OnDestroy, OnChan ref.instance.id = this.id; ref.instance.settings = {...this.settings}; ref.instance.context = this.queryBuilder; + ref.instance.disableUpdateOnSubmit = this.disableUpdateOnSubmit; if (this.value) { ref.instance.isActive = true; ref.instance.startValue = this.value; diff --git a/lib/content-services/src/lib/search/models/search-widget.interface.ts b/lib/content-services/src/lib/search/models/search-widget.interface.ts index b7dcbf58b00..233899de9dd 100644 --- a/lib/content-services/src/lib/search/models/search-widget.interface.ts +++ b/lib/content-services/src/lib/search/models/search-widget.interface.ts @@ -25,6 +25,7 @@ export interface SearchWidget { settings?: SearchWidgetSettings; context?: SearchQueryBuilderService; isActive?: boolean; + disableUpdateOnSubmit?: boolean; startValue: any; /* stream emit value on changes */ displayValue$: Subject; diff --git a/lib/content-services/src/lib/search/services/base-query-builder.service.ts b/lib/content-services/src/lib/search/services/base-query-builder.service.ts index c0446f98a08..6979f3b118d 100644 --- a/lib/content-services/src/lib/search/services/base-query-builder.service.ts +++ b/lib/content-services/src/lib/search/services/base-query-builder.service.ts @@ -487,12 +487,27 @@ export abstract class BaseQueryBuilderService { let query = ''; this.categories.forEach((facet) => { - const customQuery = this.queryFragments[facet.id]; - if (customQuery) { - if (query.length > 0) { - query += ' AND '; + let customQuery: string; + + if (facet.component.selector === 'widget-composite') { + const widgetTabs: any[] = facet.component.settings.tabs; + widgetTabs.forEach(tab => { + customQuery = this.queryFragments[tab.id]; + if (customQuery) { + if (query.length > 0) { + query += ' AND '; + } + query += `(${customQuery})`; + } + }); + } else { + customQuery = this.queryFragments[facet.id]; + if (customQuery) { + if (query.length > 0) { + query += ' AND '; + } + query += `(${customQuery})`; } - query += `(${customQuery})`; } }); From 0bb2e00956f0afa9aac4f6fbee5cb3cff099d517 Mon Sep 17 00:00:00 2001 From: "swapnil.verma" Date: Tue, 13 Jun 2023 11:30:01 +0530 Subject: [PATCH 03/54] [ACS-4985] Added compatibility of all search filters/facets with SearchFilterTabbedComponent --- .../search-check-list/search-check-list.component.ts | 5 ++++- .../search-date-range/search-date-range.component.ts | 5 ++++- .../search-datetime-range/search-datetime-range.component.ts | 5 ++++- .../search-number-range/search-number-range.component.ts | 5 ++++- .../search/components/search-radio/search-radio.component.ts | 5 ++++- .../components/search-slider/search-slider.component.ts | 5 ++++- .../search/components/search-text/search-text.component.ts | 5 ++++- 7 files changed, 28 insertions(+), 7 deletions(-) diff --git a/lib/content-services/src/lib/search/components/search-check-list/search-check-list.component.ts b/lib/content-services/src/lib/search/components/search-check-list/search-check-list.component.ts index 7a4516e5209..d0cd7fa8fe1 100644 --- a/lib/content-services/src/lib/search/components/search-check-list/search-check-list.component.ts +++ b/lib/content-services/src/lib/search/components/search-check-list/search-check-list.component.ts @@ -48,6 +48,7 @@ export class SearchCheckListComponent implements SearchWidget, OnInit { pageSize = 5; isActive = false; enableChangeUpdate = true; + disableUpdateOnSubmit: boolean; displayValue$: Subject = new Subject(); constructor(private translationService: TranslationService) { @@ -142,7 +143,9 @@ export class SearchCheckListComponent implements SearchWidget, OnInit { if (this.id && this.context) { this.context.queryFragments[this.id] = query; this.updateDisplayValue(); - this.context.update(); + if(!this.disableUpdateOnSubmit) { + this.context.update(); + } } } } diff --git a/lib/content-services/src/lib/search/components/search-date-range/search-date-range.component.ts b/lib/content-services/src/lib/search/components/search-date-range/search-date-range.component.ts index 86ce7d7adb2..c454b69e334 100644 --- a/lib/content-services/src/lib/search/components/search-date-range/search-date-range.component.ts +++ b/lib/content-services/src/lib/search/components/search-date-range/search-date-range.component.ts @@ -70,6 +70,7 @@ export class SearchDateRangeComponent implements SearchWidget, OnInit, OnDestroy isActive = false; startValue: any; enableChangeUpdate: boolean; + disableUpdateOnSubmit: boolean; displayValue$: Subject = new Subject(); private onDestroy$ = new Subject(); @@ -151,7 +152,9 @@ export class SearchDateRangeComponent implements SearchWidget, OnInit, OnDestroy this.context.queryFragments[this.id] = `${this.settings.field}:['${start}' TO '${end}']`; this.updateDisplayValue(); - this.context.update(); + if(!this.disableUpdateOnSubmit) { + this.context.update(); + } } } diff --git a/lib/content-services/src/lib/search/components/search-datetime-range/search-datetime-range.component.ts b/lib/content-services/src/lib/search/components/search-datetime-range/search-datetime-range.component.ts index 11e32d6c360..268f5443f56 100644 --- a/lib/content-services/src/lib/search/components/search-datetime-range/search-datetime-range.component.ts +++ b/lib/content-services/src/lib/search/components/search-datetime-range/search-datetime-range.component.ts @@ -65,6 +65,7 @@ export class SearchDatetimeRangeComponent implements SearchWidget, OnInit, OnDes isActive = false; startValue: any; enableChangeUpdate: boolean; + disableUpdateOnSubmit: boolean; displayValue$: Subject = new Subject(); private onDestroy$ = new Subject(); @@ -138,7 +139,9 @@ export class SearchDatetimeRangeComponent implements SearchWidget, OnInit, OnDes this.context.queryFragments[this.id] = `${this.settings.field}:['${start}' TO '${end}']`; this.updateDisplayValue(); - this.context.update(); + if(!this.disableUpdateOnSubmit) { + this.context.update(); + } } } diff --git a/lib/content-services/src/lib/search/components/search-number-range/search-number-range.component.ts b/lib/content-services/src/lib/search/components/search-number-range/search-number-range.component.ts index 6a842b875b4..cd792f96275 100644 --- a/lib/content-services/src/lib/search/components/search-number-range/search-number-range.component.ts +++ b/lib/content-services/src/lib/search/components/search-number-range/search-number-range.component.ts @@ -41,6 +41,7 @@ export class SearchNumberRangeComponent implements SearchWidget, OnInit { id: string; settings?: SearchWidgetSettings; context?: SearchQueryBuilderService; + disableUpdateOnSubmit: boolean; field: string; format = '[{FROM} TO {TO}]'; @@ -98,7 +99,9 @@ export class SearchNumberRangeComponent implements SearchWidget, OnInit { const value = this.formatString(this.format, map); this.context.queryFragments[this.id] = `${this.field}:${value}`; - this.context.update(); + if (!this.disableUpdateOnSubmit) { + this.context.update(); + } } } diff --git a/lib/content-services/src/lib/search/components/search-radio/search-radio.component.ts b/lib/content-services/src/lib/search/components/search-radio/search-radio.component.ts index 2c33ce85801..3a27a068b4e 100644 --- a/lib/content-services/src/lib/search/components/search-radio/search-radio.component.ts +++ b/lib/content-services/src/lib/search/components/search-radio/search-radio.component.ts @@ -50,6 +50,7 @@ export class SearchRadioComponent implements SearchWidget, OnInit { isActive = false; startValue: any; enableChangeUpdate: boolean; + disableUpdateOnSubmit: boolean; displayValue$: Subject = new Subject(); constructor() { @@ -97,7 +98,9 @@ export class SearchRadioComponent implements SearchWidget, OnInit { submitValues() { this.setValue(this.value); this.updateDisplayValue(); - this.context.update(); + if(!this.disableUpdateOnSubmit) { + this.context.update(); + } } hasValidValue() { diff --git a/lib/content-services/src/lib/search/components/search-slider/search-slider.component.ts b/lib/content-services/src/lib/search/components/search-slider/search-slider.component.ts index 52c5c8121ad..9aca24539b4 100644 --- a/lib/content-services/src/lib/search/components/search-slider/search-slider.component.ts +++ b/lib/content-services/src/lib/search/components/search-slider/search-slider.component.ts @@ -41,6 +41,7 @@ export class SearchSliderComponent implements SearchWidget, OnInit { max: number; thumbLabel = false; enableChangeUpdate: boolean; + disableUpdateOnSubmit: boolean; displayValue$: Subject = new Subject(); /** The numeric value represented by the slider. */ @@ -90,7 +91,9 @@ export class SearchSliderComponent implements SearchWidget, OnInit { } submitValues() { - this.updateQuery(this.value); + if(!this.disableUpdateOnSubmit) { + this.updateQuery(this.value); + } } hasValidValue() { diff --git a/lib/content-services/src/lib/search/components/search-text/search-text.component.ts b/lib/content-services/src/lib/search/components/search-text/search-text.component.ts index c257c26debe..ac9fef40a09 100644 --- a/lib/content-services/src/lib/search/components/search-text/search-text.component.ts +++ b/lib/content-services/src/lib/search/components/search-text/search-text.component.ts @@ -40,6 +40,7 @@ export class SearchTextComponent implements SearchWidget, OnInit { startValue: string; isActive = false; enableChangeUpdate = true; + disableUpdateOnSubmit: boolean; displayValue$: Subject = new Subject(); ngOnInit() { @@ -91,7 +92,9 @@ export class SearchTextComponent implements SearchWidget, OnInit { } submitValues() { - this.updateQuery(this.value); + if(!this.disableUpdateOnSubmit) { + this.updateQuery(this.value); + } } hasValidValue() { From 839a7184a3ba7eead3507c0540e60ca41f3cb2a6 Mon Sep 17 00:00:00 2001 From: "swapnil.verma" Date: Tue, 13 Jun 2023 12:47:27 +0530 Subject: [PATCH 04/54] [ACS-4985] Updated UI for search filters. Minor fixes --- .../search-date-range-advanced.component.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/content-services/src/lib/search/components/search-date-range-advanced/search-date-range-advanced.component.ts b/lib/content-services/src/lib/search/components/search-date-range-advanced/search-date-range-advanced.component.ts index f43d08b9706..98fd2e90312 100644 --- a/lib/content-services/src/lib/search/components/search-date-range-advanced/search-date-range-advanced.component.ts +++ b/lib/content-services/src/lib/search/components/search-date-range-advanced/search-date-range-advanced.component.ts @@ -80,7 +80,6 @@ export class SearchDateRangeAdvancedComponent implements SearchWidget, OnInit, O ngOnInit(): void { this.datePickerFormat = this.settings?.dateFormat ? this.settings.dateFormat : DEFAULT_FORMAT_DATE; - this.disableUpdateOnSubmit = this.settings?.disableUpdateOnSubmit; if (this.settings && this.settings.maxDate) { if (this.settings.maxDate === 'today') { this.maxDate = this.dateAdapter.today().endOf('day'); From c54b4e1de057fca2c763462d4af9f5b14c3e1365 Mon Sep 17 00:00:00 2001 From: "swapnil.verma" Date: Tue, 13 Jun 2023 16:14:56 +0530 Subject: [PATCH 05/54] [ACS-4985] Added test cases for SearchFilterTabbedComponent --- .../search-filter-tabbed.component.html | 9 ++ .../search-filter-tabbed.component.spec.ts | 140 ++++++++++++++++-- 2 files changed, 134 insertions(+), 15 deletions(-) diff --git a/lib/content-services/src/lib/search/components/search-filter-tabbed/search-filter-tabbed.component.html b/lib/content-services/src/lib/search/components/search-filter-tabbed/search-filter-tabbed.component.html index 558c13b1eeb..1040a4bb695 100644 --- a/lib/content-services/src/lib/search/components/search-filter-tabbed/search-filter-tabbed.component.html +++ b/lib/content-services/src/lib/search/components/search-filter-tabbed/search-filter-tabbed.component.html @@ -3,3 +3,12 @@ + +
+ + +
diff --git a/lib/content-services/src/lib/search/components/search-filter-tabbed/search-filter-tabbed.component.spec.ts b/lib/content-services/src/lib/search/components/search-filter-tabbed/search-filter-tabbed.component.spec.ts index 6ebb93db08e..02f632b8b4e 100644 --- a/lib/content-services/src/lib/search/components/search-filter-tabbed/search-filter-tabbed.component.spec.ts +++ b/lib/content-services/src/lib/search/components/search-filter-tabbed/search-filter-tabbed.component.spec.ts @@ -1,23 +1,133 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { SearchFilterTabbedComponent } from './search-filter-tabbed.component'; +import { By } from '@angular/platform-browser'; +import { ContentTestingModule } from '../../../testing/content.testing.module'; +import { TranslateModule } from '@ngx-translate/core'; -describe('SearchFilterTabbedComponent', () => { - let component: SearchFilterTabbedComponent; - let fixture: ComponentFixture; +xdescribe('SearchFilterTabbedComponent', () => { + let component: SearchFilterTabbedComponent; + let fixture: ComponentFixture; - beforeEach(async () => { - await TestBed.configureTestingModule({ - declarations: [ SearchFilterTabbedComponent ] - }) - .compileComponents(); + beforeEach(async () => { + TestBed.configureTestingModule({ + declarations: [SearchFilterTabbedComponent], + imports: [ + TranslateModule.forRoot(), + ContentTestingModule + ] + }); - fixture = TestBed.createComponent(SearchFilterTabbedComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); + fixture = TestBed.createComponent(SearchFilterTabbedComponent); + component = fixture.componentInstance; + component.id = 'tabbed'; + component.context = { + queryFragments: { + field1: '', + field2: '' + }, + update: () => { + } + } as any; + component.settings = { + field: undefined, + hideDefaultAction: true, + displayLabelSeparator: ';', + tabs: [ + { + id: 'widget1', + tabDisplayLabel: 'Widget1', + component: { + settings: { + field: 'field1' + } + } + }, + { + id: 'widget2', + tabDisplayLabel: 'Widget2', + component: { + settings: { + field: 'field2' + } + } + } + ] + }; + fixture.detectChanges(); + }); - it('should create', () => { - expect(component).toBeTruthy(); - }); + function getButtonByDataAutomationId(buttonDataAutomtaionId: string) { + return fixture.debugElement.query(By.css(`[data-automation-id="${buttonDataAutomtaionId}"]`)).nativeElement; + } + + it('should update displayLabel when inner widgets display label is updated', async () => { + spyOn(component.displayValue$, 'next'); + fixture.detectChanges(); + component.widgetContainerComponentList.get(0).componentRef.instance.displayValue$.next('test-label-1'); + fixture.detectChanges(); + await fixture.whenStable(); + expect(component.displayValue$.next).toHaveBeenCalledWith('Widget1 test-label-1'); + + component.widgetContainerComponentList.get(1).componentRef.instance.displayValue$.next('test-label-2'); + fixture.detectChanges(); + await fixture.whenStable(); + expect(component.displayValue$.next).toHaveBeenCalledWith('Widget1 test-label-1; Widget2 test-label-2'); + }); + + it('should call submitValues for inner widgets and update context when apply button is clicked', () => { + component.widgetContainerComponentList.forEach(widget => { + spyOn(widget, 'applyInnerWidget'); + }); + spyOn(component.context, 'update'); + const resetButton = getButtonByDataAutomationId('tab-apply-btn'); + resetButton.dispatchEvent(new Event('click')); + fixture.detectChanges(); + component.widgetContainerComponentList.forEach(widget => { + expect(widget.applyInnerWidget).toHaveBeenCalled(); + }); + expect(component.context.update).toHaveBeenCalled(); + }); + + it('should reset inner widgets when clear button is clicked', () => { + component.widgetContainerComponentList.forEach(widget => { + spyOn(widget, 'resetInnerWidget'); + }); + const resetButton = getButtonByDataAutomationId('tab-clear-btn'); + resetButton.dispatchEvent(new Event('click')); + fixture.detectChanges(); + component.widgetContainerComponentList.forEach(widget => { + expect(widget.resetInnerWidget).toHaveBeenCalled(); + }); + }); + + it('should have valid value when inner widgets have valid values', () => { + component.widgetContainerComponentList.forEach(widget => { + spyOn(widget, 'hasValueSelected').and.returnValue(true); + }); + expect(component.hasValidValue()).toBe(true); + }); + + it('should set values on init for inner widgets if initial value is provided', () => { + component.widgetContainerComponentList.forEach(widget => { + spyOn(widget, 'setValue'); + }); + const valueForWidget1 = { + testStringValue: 'test value', + testNumberValue: 28 + } + const valueForWidget2 = { + testBooleanValue: false, + testStringValue: 'test value' + } + component.startValue = { + widget1: valueForWidget1, + widget2: valueForWidget2 + } + component.ngOnInit(); + component.widgetContainerComponentList.forEach(widget => { + const value = component.startValue[widget.id]; + expect(widget.setValue).toHaveBeenCalledWith(value); + }); + }); }); From 9a37bd239dd61a6c4e015ccb0b46fc8cf29d46fa Mon Sep 17 00:00:00 2001 From: "swapnil.verma" Date: Tue, 13 Jun 2023 17:40:12 +0530 Subject: [PATCH 06/54] [ACS-4985] Added data-automation-id to search-date-range-advanced.component.html --- .../search-date-range-advanced.component.html | 28 +++++++++++-------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/lib/content-services/src/lib/search/components/search-date-range-advanced/search-date-range-advanced.component.html b/lib/content-services/src/lib/search/components/search-date-range-advanced/search-date-range-advanced.component.html index 45cf7039a4a..55c3abb993c 100644 --- a/lib/content-services/src/lib/search/components/search-date-range-advanced/search-date-range-advanced.component.html +++ b/lib/content-services/src/lib/search/components/search-date-range-advanced/search-date-range-advanced.component.html @@ -1,30 +1,36 @@ - + {{ 'SEARCH.DATE_RANGE_ADVANCED.OPTIONS.ANYTIME' | translate }} - {{ 'SEARCH.DATE_RANGE_ADVANCED.OPTIONS.IN_LAST' | translate }} + + {{ 'SEARCH.DATE_RANGE_ADVANCED.OPTIONS.IN_LAST' | translate }} + - + - - {{ 'SEARCH.DATE_RANGE_ADVANCED.IN_LAST_LABELS.DAYS' | translate }} - {{ 'SEARCH.DATE_RANGE_ADVANCED.IN_LAST_LABELS.WEEKS' | translate }} - {{ 'SEARCH.DATE_RANGE_ADVANCED.IN_LAST_LABELS.MONTHS' | translate }} + + {{ 'SEARCH.DATE_RANGE_ADVANCED.IN_LAST_LABELS.DAYS' | translate }} + {{ 'SEARCH.DATE_RANGE_ADVANCED.IN_LAST_LABELS.WEEKS' | translate }} + {{ 'SEARCH.DATE_RANGE_ADVANCED.IN_LAST_LABELS.MONTHS' | translate }} - {{ 'SEARCH.DATE_RANGE_ADVANCED.OPTIONS.BETWEEN' | translate }} + + {{ 'SEARCH.DATE_RANGE_ADVANCED.OPTIONS.BETWEEN' | translate }} + - - + + - + From 164a5a5e4aa3e22c947e72cc6aab7640e81dec08 Mon Sep 17 00:00:00 2001 From: "swapnil.verma" Date: Tue, 13 Jun 2023 17:41:10 +0530 Subject: [PATCH 07/54] [ACS-4985] Added test cases for SearchFilterTabbedComponent. Added test case placeholders for SearchDateRangeAdvancedComponent --- ...arch-date-range-advanced.component.spec.ts | 66 ++++++++++++++----- .../search-filter-tabbed.component.spec.ts | 6 +- 2 files changed, 52 insertions(+), 20 deletions(-) diff --git a/lib/content-services/src/lib/search/components/search-date-range-advanced/search-date-range-advanced.component.spec.ts b/lib/content-services/src/lib/search/components/search-date-range-advanced/search-date-range-advanced.component.spec.ts index c1e851f9eb5..ff9e78012d8 100644 --- a/lib/content-services/src/lib/search/components/search-date-range-advanced/search-date-range-advanced.component.spec.ts +++ b/lib/content-services/src/lib/search/components/search-date-range-advanced/search-date-range-advanced.component.spec.ts @@ -3,21 +3,53 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { SearchDateRangeAdvancedComponent } from './search-date-range-advanced.component'; describe('SearchDateRangeAdvancedComponent', () => { - let component: SearchDateRangeAdvancedComponent; - let fixture: ComponentFixture; - - beforeEach(async () => { - await TestBed.configureTestingModule({ - declarations: [ SearchDateRangeAdvancedComponent ] - }) - .compileComponents(); - - fixture = TestBed.createComponent(SearchDateRangeAdvancedComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); + let component: SearchDateRangeAdvancedComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [SearchDateRangeAdvancedComponent] + }) + .compileComponents(); + + fixture = TestBed.createComponent(SearchDateRangeAdvancedComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should not set any date filter in context when Anytime option is selected', () => { + + }); + + it('should set proper date filter in context when In the last option is selected', () => { + + }); + + it('should not set any date filter in context when In the last option is selected, but no value is provided', () => { + + }); + + it('should set proper date filter in context when Between option is selected', () => { + + }); + + it('should not set any date filter in context when Between option is selected, but no value is provided in the dates', () => { + + }); + + it('should clear context when widget is reset', () => { + + }); + + it('should update display label with proper text when In the last/Between option is selected and values are properly set', () => { + + }); + + it('should set values if initial value is provided', () => { + + }); + + it('should not allow selecting a date after the current date when Between option is selected', () => { + + }); }); diff --git a/lib/content-services/src/lib/search/components/search-filter-tabbed/search-filter-tabbed.component.spec.ts b/lib/content-services/src/lib/search/components/search-filter-tabbed/search-filter-tabbed.component.spec.ts index 02f632b8b4e..5b724c0089e 100644 --- a/lib/content-services/src/lib/search/components/search-filter-tabbed/search-filter-tabbed.component.spec.ts +++ b/lib/content-services/src/lib/search/components/search-filter-tabbed/search-filter-tabbed.component.spec.ts @@ -5,7 +5,7 @@ import { By } from '@angular/platform-browser'; import { ContentTestingModule } from '../../../testing/content.testing.module'; import { TranslateModule } from '@ngx-translate/core'; -xdescribe('SearchFilterTabbedComponent', () => { +describe('SearchFilterTabbedComponent', () => { let component: SearchFilterTabbedComponent; let fixture: ComponentFixture; @@ -57,8 +57,8 @@ xdescribe('SearchFilterTabbedComponent', () => { fixture.detectChanges(); }); - function getButtonByDataAutomationId(buttonDataAutomtaionId: string) { - return fixture.debugElement.query(By.css(`[data-automation-id="${buttonDataAutomtaionId}"]`)).nativeElement; + function getButtonByDataAutomationId(buttonDataAutomationId: string) { + return fixture.debugElement.query(By.css(`[data-automation-id="${buttonDataAutomationId}"]`)).nativeElement; } it('should update displayLabel when inner widgets display label is updated', async () => { From ccb4b4c52df18ce011a99d5710a972975bf8eb80 Mon Sep 17 00:00:00 2001 From: "swapnil.verma" Date: Wed, 14 Jun 2023 12:40:18 +0530 Subject: [PATCH 08/54] [ACS-4985] Updated Labels for 'In last' date range option --- .../search-date-range-advanced.component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/content-services/src/lib/search/components/search-date-range-advanced/search-date-range-advanced.component.ts b/lib/content-services/src/lib/search/components/search-date-range-advanced/search-date-range-advanced.component.ts index 98fd2e90312..16e974c3f3e 100644 --- a/lib/content-services/src/lib/search/components/search-date-range-advanced/search-date-range-advanced.component.ts +++ b/lib/content-services/src/lib/search/components/search-date-range-advanced/search-date-range-advanced.component.ts @@ -213,7 +213,7 @@ export class SearchDateRangeAdvancedComponent implements SearchWidget, OnInit, O switch (this.dateRangeTypeValue) { case DateRangeType.IN_LAST: if (this.hasValidValue()) { - displayLabel = `${this.translate.instant('SEARCH.DATE_RANGE_ADVANCED.OPTIONS.IN_LAST')} ${this.inLastValue} ${this.translate.instant(`SEARCH.DATE_RANGE_ADVANCED.IN_LAST_LABELS.${this.inLastValueType}`)}`; + displayLabel = this.translate.instant(`SEARCH.DATE_RANGE_ADVANCED.IN_LAST_DISPLAY_LABELS.${this.inLastValueType}`, { value: this.inLastValue }); } break; case DateRangeType.BETWEEN: From 9b38a8b48b98068422fad04909a325fd65d1a468 Mon Sep 17 00:00:00 2001 From: "swapnil.verma" Date: Wed, 14 Jun 2023 12:41:23 +0530 Subject: [PATCH 09/54] [ACS-4985] Added test cases for SearchDateRangeAdvancedComponent. Minor update to test cases for SearchFilterTabbedComponent --- ...arch-date-range-advanced.component.spec.ts | 177 ++++++++++++++++-- .../search-filter-tabbed.component.spec.ts | 4 +- 2 files changed, 166 insertions(+), 15 deletions(-) diff --git a/lib/content-services/src/lib/search/components/search-date-range-advanced/search-date-range-advanced.component.spec.ts b/lib/content-services/src/lib/search/components/search-date-range-advanced/search-date-range-advanced.component.spec.ts index ff9e78012d8..ab2f384c2ae 100644 --- a/lib/content-services/src/lib/search/components/search-date-range-advanced/search-date-range-advanced.component.spec.ts +++ b/lib/content-services/src/lib/search/components/search-date-range-advanced/search-date-range-advanced.component.spec.ts @@ -1,6 +1,7 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { SearchDateRangeAdvancedComponent } from './search-date-range-advanced.component'; +import { By } from '@angular/platform-browser'; describe('SearchDateRangeAdvancedComponent', () => { let component: SearchDateRangeAdvancedComponent; @@ -9,44 +10,196 @@ describe('SearchDateRangeAdvancedComponent', () => { beforeEach(async () => { await TestBed.configureTestingModule({ declarations: [SearchDateRangeAdvancedComponent] - }) - .compileComponents(); + }).compileComponents(); fixture = TestBed.createComponent(SearchDateRangeAdvancedComponent); component = fixture.componentInstance; + component.id = 'date-range-advanced'; + component.context = { + queryFragments: { + date: '' + }, + update: jasmine.createSpy() + } as any; + fixture.detectChanges(); }); - it('should not set any date filter in context when Anytime option is selected', () => { + const getElementByDataAutomationId = (dataAutomationId) => { + return fixture.debugElement.query(By.css(`[data-automation-id="${dataAutomationId}"]`)).nativeElement; + } - }); + const clickElementByAutomationId = async (elementDataAutomationId) => { + const el = getElementByDataAutomationId(elementDataAutomationId); + el.dispatchEvent(new Event('click')); + await fixture.whenStable(); + fixture.detectChanges(); + } - it('should set proper date filter in context when In the last option is selected', () => { + const enterValueInInputField = async (inputElementId: string, value: string) => { + const inputField = getElementByDataAutomationId(inputElementId); + inputField.value = value; + inputField.dispatchEvent(new Event('input')); + await fixture.whenStable(); + fixture.detectChanges(); + } - }); + const selectDropdownOption = (itemId: string) => { + const matSelect = fixture.debugElement.query(By.css('[data-automation-id="date-range-advanced-in-last-dropdown"]')).nativeElement; + matSelect.click(); + fixture.detectChanges(); + const matOption = fixture.debugElement.query(By.css(`[data-automation-id="${itemId}"]`)).nativeElement; + matOption.click(); + fixture.detectChanges(); + }; - it('should not set any date filter in context when In the last option is selected, but no value is provided', () => { + it('should not set any date filter in context when Anytime option is selected', async () => { + await clickElementByAutomationId('date-range-advanced-anytime'); + await clickElementByAutomationId('date-range-advanced-apply-btn'); + expect(component.context.queryFragments[component.id]).toBe(''); + expect(component.context.update).toHaveBeenCalled(); + }); + it('should set proper date filter in context when In the last option is selected', async () => { + await clickElementByAutomationId('date-range-advanced-in-last'); + await enterValueInInputField('date-range-advanced-in-last-input', '5'); + await selectDropdownOption('date-range-advanced-in-last-option-days') + await clickElementByAutomationId('date-range-advanced-apply-btn'); + fixture.detectChanges(); + let query = '[NOW/DAY-5DAYS TO NOW/DAY+1DAY]'; + expect(component.context.queryFragments[component.id]).toBe(query); + expect(component.context.update).toHaveBeenCalled(); + + await clickElementByAutomationId('date-range-advanced-in-last'); + await enterValueInInputField('date-range-advanced-in-last-input', '3'); + await selectDropdownOption('date-range-advanced-in-last-option-weeks'); + await clickElementByAutomationId('date-range-advanced-apply-btn'); + fixture.detectChanges(); + query = '[NOW/DAY-3WEEKS TO NOW/DAY+1DAY]'; + expect(component.context.queryFragments[component.id]).toBe(query); + expect(component.context.update).toHaveBeenCalled(); + + await clickElementByAutomationId('date-range-advanced-in-last'); + await enterValueInInputField('date-range-advanced-in-last-input', '6'); + await selectDropdownOption('date-range-advanced-in-last-option-months'); + await clickElementByAutomationId('date-range-advanced-apply-btn'); + fixture.detectChanges(); + query = '[NOW/DAY-6MONTHS TO NOW/DAY+1DAY]'; + expect(component.context.queryFragments[component.id]).toBe(query); + expect(component.context.update).toHaveBeenCalled(); }); - it('should set proper date filter in context when Between option is selected', () => { + it('should not set any date filter in context when In the last or Between option is selected, but no value is provided', async () => { + await clickElementByAutomationId('date-range-advanced-in-last'); + await selectDropdownOption('date-range-advanced-in-last-option-weeks') + await clickElementByAutomationId('date-range-advanced-apply-btn'); + fixture.detectChanges(); + expect(component.context.queryFragments[component.id]).toBe(''); + expect(component.context.update).toHaveBeenCalled(); + + await clickElementByAutomationId('date-range-advanced-between'); + await clickElementByAutomationId('date-range-advanced-apply-btn'); + fixture.detectChanges(); + expect(component.context.queryFragments[component.id]).toBe(''); + expect(component.context.update).toHaveBeenCalled(); + }); + it('should set proper date filter in context when Between option is selected', async () => { + // TODO might need to get updated with date-fns + await clickElementByAutomationId('date-range-advanced-between'); + await enterValueInInputField('date-range-advanced-between-start-input', '05/06/2023'); + await enterValueInInputField('date-range-advanced-between-end-input', '10/06/2023'); + await clickElementByAutomationId('date-range-advanced-apply-btn'); + fixture.detectChanges(); + let query = '[NOW/DAY-5DAYS TO NOW/DAY+1DAY]'; + expect(component.context.queryFragments[component.id]).toBe(query); + expect(component.context.update).toHaveBeenCalled(); }); - it('should not set any date filter in context when Between option is selected, but no value is provided in the dates', () => { + it('should clear context when widget is reset', async () => { + component.context.queryFragments[component.id] = '[NOW/DAY-5DAYS TO NOW/DAY+1DAY]'; + await clickElementByAutomationId('date-range-advanced-clear-btn'); + expect(component.context.queryFragments[component.id]).toBe(''); + expect(component.context.update).toHaveBeenCalled(); + }); + it('should update display label with proper text when In the last/Between option is selected and values are properly set', async () => { + spyOn(component.displayValue$, 'next'); + + await clickElementByAutomationId('date-range-advanced-in-last'); + await enterValueInInputField('date-range-advanced-in-last-input', '5'); + await selectDropdownOption('date-range-advanced-in-last-option-days') + await clickElementByAutomationId('date-range-advanced-apply-btn'); + expect(component.displayValue$.next).toHaveBeenCalledWith('In the last 5 days'); + + await enterValueInInputField('date-range-advanced-in-last-input', '3'); + await selectDropdownOption('date-range-advanced-in-last-option-weeks') + await clickElementByAutomationId('date-range-advanced-apply-btn'); + expect(component.displayValue$.next).toHaveBeenCalledWith('In the last 3 weeks'); + + await enterValueInInputField('date-range-advanced-in-last-input', '7'); + await selectDropdownOption('date-range-advanced-in-last-option-months') + await clickElementByAutomationId('date-range-advanced-apply-btn'); + expect(component.displayValue$.next).toHaveBeenCalledWith('In the last 7 months'); + + //TODO: Might need to be updated with date-fns + await clickElementByAutomationId('date-range-advanced-between'); + await enterValueInInputField('date-range-advanced-between-start-input', '05/06/2023'); + await enterValueInInputField('date-range-advanced-between-end-input', '10/06/2023'); + await clickElementByAutomationId('date-range-advanced-apply-btn'); + expect(component.displayValue$.next).toHaveBeenCalledWith('Between 05-Jun-2023 - 10-Jun-2023'); }); - it('should clear context when widget is reset', () => { + it('should not update display label if anytime option is selected', async() => { + spyOn(component.displayValue$, 'next'); + await clickElementByAutomationId('date-range-advanced-anytime'); + await clickElementByAutomationId('date-range-advanced-apply-btn'); + fixture.detectChanges(); + expect(component.displayValue$.next).toHaveBeenCalledWith(''); }); - it('should update display label with proper text when In the last/Between option is selected and values are properly set', () => { + it('should not update display label if no valid value was provided', async () => { + spyOn(component.displayValue$, 'next'); + + await clickElementByAutomationId('date-range-advanced-in-last'); + await selectDropdownOption('date-range-advanced-in-last-option-weeks') + await clickElementByAutomationId('date-range-advanced-apply-btn'); + fixture.detectChanges(); + expect(component.displayValue$.next).toHaveBeenCalledWith(''); + await clickElementByAutomationId('date-range-advanced-between'); + await clickElementByAutomationId('date-range-advanced-apply-btn'); + fixture.detectChanges(); + expect(component.displayValue$.next).toHaveBeenCalledWith(''); }); it('should set values if initial value is provided', () => { - + let value: any = { + dateRangeType: component.DateRangeType.ANY + } + component.startValue = value; + component.ngOnInit(); + expect(component.getCurrentValue()).toBe(value); + + value = { + dateRangeType: component.DateRangeType.IN_LAST, + inLastValue: 5, + inLastValueType: component.InLastDateType.WEEKS + } + component.startValue = value; + component.ngOnInit(); + expect(component.getCurrentValue()).toBe(value); + + //TODO: Might need to be changed after date-fns + value = { + dateRangeType: component.DateRangeType.BETWEEN, + betweenStartDate: '05/06/2023', + betweenEndDate: '10/06/2023' + } + component.startValue = value; + component.ngOnInit(); + expect(component.getCurrentValue()).toBe(value); }); it('should not allow selecting a date after the current date when Between option is selected', () => { diff --git a/lib/content-services/src/lib/search/components/search-filter-tabbed/search-filter-tabbed.component.spec.ts b/lib/content-services/src/lib/search/components/search-filter-tabbed/search-filter-tabbed.component.spec.ts index 5b724c0089e..c46c71efc23 100644 --- a/lib/content-services/src/lib/search/components/search-filter-tabbed/search-filter-tabbed.component.spec.ts +++ b/lib/content-services/src/lib/search/components/search-filter-tabbed/search-filter-tabbed.component.spec.ts @@ -26,8 +26,7 @@ describe('SearchFilterTabbedComponent', () => { field1: '', field2: '' }, - update: () => { - } + update: jasmine.createSpy() } as any; component.settings = { field: undefined, @@ -79,7 +78,6 @@ describe('SearchFilterTabbedComponent', () => { component.widgetContainerComponentList.forEach(widget => { spyOn(widget, 'applyInnerWidget'); }); - spyOn(component.context, 'update'); const resetButton = getButtonByDataAutomationId('tab-apply-btn'); resetButton.dispatchEvent(new Event('click')); fixture.detectChanges(); From 2ae8b4b510e10e7b06c9193a394aaa5d78c71054 Mon Sep 17 00:00:00 2001 From: "swapnil.verma" Date: Wed, 14 Jun 2023 12:48:56 +0530 Subject: [PATCH 10/54] [ACS-4985] Resolved minor issue where the reset method would still trigger multiple api calls when used with the TabbedComponent --- .../search-check-list/search-check-list.component.ts | 4 +++- .../search-date-range-advanced.component.ts | 4 +--- .../search-date-range/search-date-range.component.ts | 4 +++- .../search-datetime-range.component.ts | 4 +++- .../search-number-range/search-number-range.component.ts | 6 ++++-- .../components/search-radio/search-radio.component.ts | 4 +++- .../components/search-slider/search-slider.component.ts | 4 +++- .../search/components/search-text/search-text.component.ts | 4 +++- 8 files changed, 23 insertions(+), 11 deletions(-) diff --git a/lib/content-services/src/lib/search/components/search-check-list/search-check-list.component.ts b/lib/content-services/src/lib/search/components/search-check-list/search-check-list.component.ts index d0cd7fa8fe1..989e272b88c 100644 --- a/lib/content-services/src/lib/search/components/search-check-list/search-check-list.component.ts +++ b/lib/content-services/src/lib/search/components/search-check-list/search-check-list.component.ts @@ -95,7 +95,9 @@ export class SearchCheckListComponent implements SearchWidget, OnInit { this.clearOptions(); if (this.id && this.context) { this.updateDisplayValue(); - this.context.update(); + if (!this.disableUpdateOnSubmit) { + this.context.update(); + } } } diff --git a/lib/content-services/src/lib/search/components/search-date-range-advanced/search-date-range-advanced.component.ts b/lib/content-services/src/lib/search/components/search-date-range-advanced/search-date-range-advanced.component.ts index 16e974c3f3e..bc175d06306 100644 --- a/lib/content-services/src/lib/search/components/search-date-range-advanced/search-date-range-advanced.component.ts +++ b/lib/content-services/src/lib/search/components/search-date-range-advanced/search-date-range-advanced.component.ts @@ -68,7 +68,6 @@ export class SearchDateRangeAdvancedComponent implements SearchWidget, OnInit, O DateRangeType = DateRangeType; InLastDateType = InLastDateType; - private enableChangeUpdate: boolean; private datePickerFormat: string; private onDestroy$ = new Subject(); @@ -87,7 +86,6 @@ export class SearchDateRangeAdvancedComponent implements SearchWidget, OnInit, O this.maxDate = moment(this.settings.maxDate).endOf('day'); } } - this.enableChangeUpdate = this.settings?.allowUpdateOnChange ?? true; this.userPreferencesService .select(UserPreferenceValues.Locale) @@ -164,7 +162,7 @@ export class SearchDateRangeAdvancedComponent implements SearchWidget, OnInit, O if (this.id && this.context) { this.context.queryFragments[this.id] = ''; - if (this.enableChangeUpdate) { + if (!this.disableUpdateOnSubmit) { this.updateQuery(); } } diff --git a/lib/content-services/src/lib/search/components/search-date-range/search-date-range.component.ts b/lib/content-services/src/lib/search/components/search-date-range/search-date-range.component.ts index c454b69e334..be6e56008af 100644 --- a/lib/content-services/src/lib/search/components/search-date-range/search-date-range.component.ts +++ b/lib/content-services/src/lib/search/components/search-date-range/search-date-range.component.ts @@ -217,7 +217,9 @@ export class SearchDateRangeComponent implements SearchWidget, OnInit, OnDestroy private updateQuery() { if (this.id && this.context) { this.updateDisplayValue(); - this.context.update(); + if (!this.disableUpdateOnSubmit) { + this.context.update(); + } } } diff --git a/lib/content-services/src/lib/search/components/search-datetime-range/search-datetime-range.component.ts b/lib/content-services/src/lib/search/components/search-datetime-range/search-datetime-range.component.ts index 268f5443f56..1fd12ce2319 100644 --- a/lib/content-services/src/lib/search/components/search-datetime-range/search-datetime-range.component.ts +++ b/lib/content-services/src/lib/search/components/search-datetime-range/search-datetime-range.component.ts @@ -205,7 +205,9 @@ export class SearchDatetimeRangeComponent implements SearchWidget, OnInit, OnDes private updateQuery() { if (this.id && this.context) { this.updateDisplayValue(); - this.context.update(); + if (!this.disableUpdateOnSubmit) { + this.context.update(); + } } } diff --git a/lib/content-services/src/lib/search/components/search-number-range/search-number-range.component.ts b/lib/content-services/src/lib/search/components/search-number-range/search-number-range.component.ts index cd792f96275..c371d0531fa 100644 --- a/lib/content-services/src/lib/search/components/search-number-range/search-number-range.component.ts +++ b/lib/content-services/src/lib/search/components/search-number-range/search-number-range.component.ts @@ -161,8 +161,10 @@ export class SearchNumberRangeComponent implements SearchWidget, OnInit { reset() { this.clear(); - if (this.id && this.context) { - this.context.update(); + if (!this.disableUpdateOnSubmit) { + if (this.id && this.context) { + this.context.update(); + } } } } diff --git a/lib/content-services/src/lib/search/components/search-radio/search-radio.component.ts b/lib/content-services/src/lib/search/components/search-radio/search-radio.component.ts index 3a27a068b4e..ff8c10c184d 100644 --- a/lib/content-services/src/lib/search/components/search-radio/search-radio.component.ts +++ b/lib/content-services/src/lib/search/components/search-radio/search-radio.component.ts @@ -147,7 +147,9 @@ export class SearchRadioComponent implements SearchWidget, OnInit { if (initialValue !== null) { this.setValue(initialValue); this.updateDisplayValue(); - this.context.update(); + if (!this.disableUpdateOnSubmit) { + this.context.update(); + } } } } diff --git a/lib/content-services/src/lib/search/components/search-slider/search-slider.component.ts b/lib/content-services/src/lib/search/components/search-slider/search-slider.component.ts index 9aca24539b4..756998a3c6d 100644 --- a/lib/content-services/src/lib/search/components/search-slider/search-slider.component.ts +++ b/lib/content-services/src/lib/search/components/search-slider/search-slider.component.ts @@ -117,7 +117,9 @@ export class SearchSliderComponent implements SearchWidget, OnInit { } else { this.context.queryFragments[this.id] = `${this.settings.field}:[0 TO ${value}]`; } - this.context.update(); + if (!this.disableUpdateOnSubmit) { + this.context.update(); + } } } diff --git a/lib/content-services/src/lib/search/components/search-text/search-text.component.ts b/lib/content-services/src/lib/search/components/search-text/search-text.component.ts index ac9fef40a09..18843597750 100644 --- a/lib/content-services/src/lib/search/components/search-text/search-text.component.ts +++ b/lib/content-services/src/lib/search/components/search-text/search-text.component.ts @@ -87,7 +87,9 @@ export class SearchTextComponent implements SearchWidget, OnInit { this.displayValue$.next(value); if (this.context && this.settings && this.settings.field) { this.context.queryFragments[this.id] = value ? `${this.settings.field}:'${this.getSearchPrefix()}${value}${this.getSearchSuffix()}'` : ''; - this.context.update(); + if (!this.disableUpdateOnSubmit) { + this.context.update(); + } } } From 20f38a0d46fcceffc6d616e1abc559b912ed7471 Mon Sep 17 00:00:00 2001 From: "swapnil.verma" Date: Wed, 14 Jun 2023 15:34:06 +0530 Subject: [PATCH 11/54] [ACS-4985] Added exports for SearchDateRangeAdvanced and SearchFilterTabbed components to public-api.ts. Updated imports in both components --- .../search-date-range-advanced.component.ts | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/lib/content-services/src/lib/search/components/search-date-range-advanced/search-date-range-advanced.component.ts b/lib/content-services/src/lib/search/components/search-date-range-advanced/search-date-range-advanced.component.ts index bc175d06306..60f7e504cd9 100644 --- a/lib/content-services/src/lib/search/components/search-date-range-advanced/search-date-range-advanced.component.ts +++ b/lib/content-services/src/lib/search/components/search-date-range-advanced/search-date-range-advanced.component.ts @@ -1,16 +1,13 @@ import { Component, OnDestroy, OnInit, ViewEncapsulation } from '@angular/core'; -import { - SearchQueryBuilderService, - SearchWidget, - SearchWidgetSettings -} from '@alfresco/adf-content-services'; +import { SearchWidget } from '../../models/search-widget.interface'; +import { SearchWidgetSettings } from '../../models/search-widget-settings.interface'; +import { SearchQueryBuilderService } from '../../services/search-query-builder.service'; import { DateAdapter, MAT_DATE_FORMATS, MAT_DATE_LOCALE } from '@angular/material/core'; import { Moment } from 'moment'; import { Subject } from 'rxjs'; -import { TranslateService } from '@ngx-translate/core'; import { MOMENT_DATE_FORMATS, - MomentDateAdapter, + MomentDateAdapter, TranslationService, UserPreferencesService, UserPreferenceValues } from '@alfresco/adf-core'; @@ -73,7 +70,7 @@ export class SearchDateRangeAdvancedComponent implements SearchWidget, OnInit, O private onDestroy$ = new Subject(); constructor(private dateAdapter: DateAdapter, - private translate: TranslateService, + private translate: TranslationService, private userPreferencesService: UserPreferencesService) { } From c8e4e179b3faa2f6fbef38ae63b7fdd1a7324f78 Mon Sep 17 00:00:00 2001 From: "swapnil.verma" Date: Wed, 14 Jun 2023 15:37:47 +0530 Subject: [PATCH 12/54] [ACS-4985] Updated imports in test cases --- .../search-date-range-advanced.component.spec.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/content-services/src/lib/search/components/search-date-range-advanced/search-date-range-advanced.component.spec.ts b/lib/content-services/src/lib/search/components/search-date-range-advanced/search-date-range-advanced.component.spec.ts index ab2f384c2ae..083ffceb14e 100644 --- a/lib/content-services/src/lib/search/components/search-date-range-advanced/search-date-range-advanced.component.spec.ts +++ b/lib/content-services/src/lib/search/components/search-date-range-advanced/search-date-range-advanced.component.spec.ts @@ -2,6 +2,8 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { SearchDateRangeAdvancedComponent } from './search-date-range-advanced.component'; import { By } from '@angular/platform-browser'; +import { TranslateModule } from '@ngx-translate/core'; +import { ContentTestingModule } from '../../../testing/content.testing.module'; describe('SearchDateRangeAdvancedComponent', () => { let component: SearchDateRangeAdvancedComponent; @@ -9,7 +11,11 @@ describe('SearchDateRangeAdvancedComponent', () => { beforeEach(async () => { await TestBed.configureTestingModule({ - declarations: [SearchDateRangeAdvancedComponent] + declarations: [SearchDateRangeAdvancedComponent], + imports: [ + TranslateModule.forRoot(), + ContentTestingModule + ] }).compileComponents(); fixture = TestBed.createComponent(SearchDateRangeAdvancedComponent); @@ -203,6 +209,6 @@ describe('SearchDateRangeAdvancedComponent', () => { }); it('should not allow selecting a date after the current date when Between option is selected', () => { - + //TODO: Will need to be updated after date-fns }); }); From 520c6e588f041146babee42e0ca392f1c0952321 Mon Sep 17 00:00:00 2001 From: "swapnil.verma" Date: Wed, 14 Jun 2023 17:00:59 +0530 Subject: [PATCH 13/54] [ACS-4985] Migrated SearchDateRangeAdvancedComponent from moment.js to date-fns --- .../search-date-range-advanced.component.ts | 65 ++++++------------- 1 file changed, 19 insertions(+), 46 deletions(-) diff --git a/lib/content-services/src/lib/search/components/search-date-range-advanced/search-date-range-advanced.component.ts b/lib/content-services/src/lib/search/components/search-date-range-advanced/search-date-range-advanced.component.ts index 60f7e504cd9..6a689169eae 100644 --- a/lib/content-services/src/lib/search/components/search-date-range-advanced/search-date-range-advanced.component.ts +++ b/lib/content-services/src/lib/search/components/search-date-range-advanced/search-date-range-advanced.component.ts @@ -1,19 +1,11 @@ -import { Component, OnDestroy, OnInit, ViewEncapsulation } from '@angular/core'; +import { Component, OnInit, ViewEncapsulation } from '@angular/core'; import { SearchWidget } from '../../models/search-widget.interface'; import { SearchWidgetSettings } from '../../models/search-widget-settings.interface'; import { SearchQueryBuilderService } from '../../services/search-query-builder.service'; -import { DateAdapter, MAT_DATE_FORMATS, MAT_DATE_LOCALE } from '@angular/material/core'; -import { Moment } from 'moment'; import { Subject } from 'rxjs'; -import { - MOMENT_DATE_FORMATS, - MomentDateAdapter, TranslationService, - UserPreferencesService, - UserPreferenceValues -} from '@alfresco/adf-core'; -import { takeUntil } from 'rxjs/operators'; - -declare let moment: any; +import { TranslationService } from '@alfresco/adf-core'; +import { endOfDay, format, formatISO, parse, startOfDay } from 'date-fns'; +import { DateAdapter, NativeDateAdapter } from '@angular/material/core'; enum DateRangeType { ANY = 'ANY', @@ -33,20 +25,19 @@ interface SearchDateRangeAdvanced { [indexer: string]: any; } -const DEFAULT_FORMAT_DATE: string = 'DD/MM/YYYY'; +const DEFAULT_DATE_DISPLAY_FORMAT: string = 'dd-MMM-yyyy'; @Component({ selector: 'adf-search-date-range-advanced', templateUrl: './search-date-range-advanced.component.html', styleUrls: ['./search-date-range-advanced.component.scss'], providers: [ - {provide: DateAdapter, useClass: MomentDateAdapter, deps: [MAT_DATE_LOCALE]}, - {provide: MAT_DATE_FORMATS, useValue: MOMENT_DATE_FORMATS} + {provide: DateAdapter, useClass: NativeDateAdapter}, ], encapsulation: ViewEncapsulation.None, host: {class: 'adf-search-date-range-advanced'} }) -export class SearchDateRangeAdvancedComponent implements SearchWidget, OnInit, OnDestroy { +export class SearchDateRangeAdvancedComponent implements SearchWidget, OnInit { displayValue$: Subject = new Subject(); isActive: boolean; @@ -67,43 +58,24 @@ export class SearchDateRangeAdvancedComponent implements SearchWidget, OnInit, O private datePickerFormat: string; - private onDestroy$ = new Subject(); - - constructor(private dateAdapter: DateAdapter, - private translate: TranslationService, - private userPreferencesService: UserPreferencesService) { + constructor(private translate: TranslationService) { } ngOnInit(): void { - this.datePickerFormat = this.settings?.dateFormat ? this.settings.dateFormat : DEFAULT_FORMAT_DATE; - if (this.settings && this.settings.maxDate) { - if (this.settings.maxDate === 'today') { - this.maxDate = this.dateAdapter.today().endOf('day'); + this.datePickerFormat = this.settings?.dateFormat ? this.settings.dateFormat : DEFAULT_DATE_DISPLAY_FORMAT; + if (this.settings) { + if (!this.settings.maxDate || this.settings.maxDate === 'today') { + this.maxDate = endOfDay(new Date()); } else { - this.maxDate = moment(this.settings.maxDate).endOf('day'); + this.maxDate = endOfDay(parse(this.settings.maxDate, this.datePickerFormat, new Date())); } } - this.userPreferencesService - .select(UserPreferenceValues.Locale) - .pipe(takeUntil(this.onDestroy$)) - .subscribe(locale => this.setLocale(locale)); - if (this.startValue) { this.setValue(this.startValue); } } - ngOnDestroy(): void { - this.onDestroy$.next(); - this.onDestroy$.complete(); - } - - setLocale(locale) { - this.dateAdapter.setLocale(locale); - moment.locale(locale); - } - getCurrentValue(): SearchDateRangeAdvanced { let currentValue = {}; switch (this.dateRangeTypeValue) { @@ -191,8 +163,8 @@ export class SearchDateRangeAdvancedComponent implements SearchWidget, OnInit, O break; case DateRangeType.BETWEEN: if (this.hasValidValue()) { - const start = moment(this.betweenStartDate).startOf('day').format(); - const end = moment(this.betweenEndDate).endOf('day').format(); + const start = formatISO(startOfDay(this.betweenStartDate)); + const end = formatISO(endOfDay(this.betweenEndDate)); query = `${this.settings.field}:['${start}' TO '${end}']`; } } @@ -208,13 +180,13 @@ export class SearchDateRangeAdvancedComponent implements SearchWidget, OnInit, O switch (this.dateRangeTypeValue) { case DateRangeType.IN_LAST: if (this.hasValidValue()) { - displayLabel = this.translate.instant(`SEARCH.DATE_RANGE_ADVANCED.IN_LAST_DISPLAY_LABELS.${this.inLastValueType}`, { value: this.inLastValue }); + displayLabel = this.translate.instant(`SEARCH.DATE_RANGE_ADVANCED.IN_LAST_DISPLAY_LABELS.${this.inLastValueType}`, {value: this.inLastValue}); } break; case DateRangeType.BETWEEN: if (this.hasValidValue()) { - const start = moment(this.betweenStartDate).startOf('day').format(this.datePickerFormat); - const end = moment(this.betweenEndDate).endOf('day').format(this.datePickerFormat); + const start = format(startOfDay(this.betweenStartDate), this.datePickerFormat); + const end = format(endOfDay(this.betweenEndDate), this.datePickerFormat); displayLabel = `${start} - ${end}`; } break; @@ -228,5 +200,6 @@ export class SearchDateRangeAdvancedComponent implements SearchWidget, OnInit, O } } } + //TODO: Format dates for Between date range type From b45b1330cf9c57217498321dc4920ba1d921778d Mon Sep 17 00:00:00 2001 From: "swapnil.verma" Date: Wed, 14 Jun 2023 17:29:02 +0530 Subject: [PATCH 14/54] [ACS-4985] Updated test cases for SearchDateRangeAdvancedComponent from moment.js to date-fns --- ...arch-date-range-advanced.component.spec.ts | 28 ++++++++++--------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/lib/content-services/src/lib/search/components/search-date-range-advanced/search-date-range-advanced.component.spec.ts b/lib/content-services/src/lib/search/components/search-date-range-advanced/search-date-range-advanced.component.spec.ts index 083ffceb14e..84529ed8c31 100644 --- a/lib/content-services/src/lib/search/components/search-date-range-advanced/search-date-range-advanced.component.spec.ts +++ b/lib/content-services/src/lib/search/components/search-date-range-advanced/search-date-range-advanced.component.spec.ts @@ -4,6 +4,7 @@ import { SearchDateRangeAdvancedComponent } from './search-date-range-advanced.c import { By } from '@angular/platform-browser'; import { TranslateModule } from '@ngx-translate/core'; import { ContentTestingModule } from '../../../testing/content.testing.module'; +import { endOfDay, formatISO, startOfDay } from 'date-fns'; describe('SearchDateRangeAdvancedComponent', () => { let component: SearchDateRangeAdvancedComponent; @@ -21,6 +22,10 @@ describe('SearchDateRangeAdvancedComponent', () => { fixture = TestBed.createComponent(SearchDateRangeAdvancedComponent); component = fixture.componentInstance; component.id = 'date-range-advanced'; + component.settings = { + field: 'test-field', + hideDefaultAction: false + } component.context = { queryFragments: { date: '' @@ -72,7 +77,7 @@ describe('SearchDateRangeAdvancedComponent', () => { await selectDropdownOption('date-range-advanced-in-last-option-days') await clickElementByAutomationId('date-range-advanced-apply-btn'); fixture.detectChanges(); - let query = '[NOW/DAY-5DAYS TO NOW/DAY+1DAY]'; + let query = 'test-field:[NOW/DAY-5DAYS TO NOW/DAY+1DAY]'; expect(component.context.queryFragments[component.id]).toBe(query); expect(component.context.update).toHaveBeenCalled(); @@ -81,7 +86,7 @@ describe('SearchDateRangeAdvancedComponent', () => { await selectDropdownOption('date-range-advanced-in-last-option-weeks'); await clickElementByAutomationId('date-range-advanced-apply-btn'); fixture.detectChanges(); - query = '[NOW/DAY-3WEEKS TO NOW/DAY+1DAY]'; + query = 'test-field:[NOW/DAY-3WEEKS TO NOW/DAY+1DAY]'; expect(component.context.queryFragments[component.id]).toBe(query); expect(component.context.update).toHaveBeenCalled(); @@ -90,7 +95,7 @@ describe('SearchDateRangeAdvancedComponent', () => { await selectDropdownOption('date-range-advanced-in-last-option-months'); await clickElementByAutomationId('date-range-advanced-apply-btn'); fixture.detectChanges(); - query = '[NOW/DAY-6MONTHS TO NOW/DAY+1DAY]'; + query = 'test-field:[NOW/DAY-6MONTHS TO NOW/DAY+1DAY]'; expect(component.context.queryFragments[component.id]).toBe(query); expect(component.context.update).toHaveBeenCalled(); }); @@ -111,13 +116,12 @@ describe('SearchDateRangeAdvancedComponent', () => { }); it('should set proper date filter in context when Between option is selected', async () => { - // TODO might need to get updated with date-fns await clickElementByAutomationId('date-range-advanced-between'); - await enterValueInInputField('date-range-advanced-between-start-input', '05/06/2023'); - await enterValueInInputField('date-range-advanced-between-end-input', '10/06/2023'); + await enterValueInInputField('date-range-advanced-between-start-input', '6/5/2023'); + await enterValueInInputField('date-range-advanced-between-end-input', '6/10/2023'); await clickElementByAutomationId('date-range-advanced-apply-btn'); fixture.detectChanges(); - let query = '[NOW/DAY-5DAYS TO NOW/DAY+1DAY]'; + let query = `test-field:[${formatISO(startOfDay(component.betweenStartDate))} TO ${formatISO(endOfDay(component.betweenEndDate))}]`; expect(component.context.queryFragments[component.id]).toBe(query); expect(component.context.update).toHaveBeenCalled(); }); @@ -148,10 +152,9 @@ describe('SearchDateRangeAdvancedComponent', () => { await clickElementByAutomationId('date-range-advanced-apply-btn'); expect(component.displayValue$.next).toHaveBeenCalledWith('In the last 7 months'); - //TODO: Might need to be updated with date-fns await clickElementByAutomationId('date-range-advanced-between'); - await enterValueInInputField('date-range-advanced-between-start-input', '05/06/2023'); - await enterValueInInputField('date-range-advanced-between-end-input', '10/06/2023'); + await enterValueInInputField('date-range-advanced-between-start-input', '6/5/2023'); + await enterValueInInputField('date-range-advanced-between-end-input', '6/10/2023'); await clickElementByAutomationId('date-range-advanced-apply-btn'); expect(component.displayValue$.next).toHaveBeenCalledWith('Between 05-Jun-2023 - 10-Jun-2023'); }); @@ -197,11 +200,10 @@ describe('SearchDateRangeAdvancedComponent', () => { component.ngOnInit(); expect(component.getCurrentValue()).toBe(value); - //TODO: Might need to be changed after date-fns value = { dateRangeType: component.DateRangeType.BETWEEN, - betweenStartDate: '05/06/2023', - betweenEndDate: '10/06/2023' + betweenStartDate: '6/5/2023', + betweenEndDate: '6/10/2023' } component.startValue = value; component.ngOnInit(); From df598ea2e559ec54993e62ae6cc3d25f6b401430 Mon Sep 17 00:00:00 2001 From: "swapnil.verma" Date: Wed, 14 Jun 2023 17:49:35 +0530 Subject: [PATCH 15/54] [ACS-4985] Added license headers and re-ordered imports --- ...arch-date-range-advanced.component.spec.ts | 20 +++++++++++++-- .../search-date-range-advanced.component.ts | 25 ++++++++++++++++--- .../search-filter-tabbed.component.spec.ts | 22 +++++++++++++--- 3 files changed, 58 insertions(+), 9 deletions(-) diff --git a/lib/content-services/src/lib/search/components/search-date-range-advanced/search-date-range-advanced.component.spec.ts b/lib/content-services/src/lib/search/components/search-date-range-advanced/search-date-range-advanced.component.spec.ts index 84529ed8c31..06d7b489029 100644 --- a/lib/content-services/src/lib/search/components/search-date-range-advanced/search-date-range-advanced.component.spec.ts +++ b/lib/content-services/src/lib/search/components/search-date-range-advanced/search-date-range-advanced.component.spec.ts @@ -1,9 +1,25 @@ -import { ComponentFixture, TestBed } from '@angular/core/testing'; +/*! + * @license + * Copyright © 2005-2023 Hyland Software, Inc. and its affiliates. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ -import { SearchDateRangeAdvancedComponent } from './search-date-range-advanced.component'; +import { ComponentFixture, TestBed } from '@angular/core/testing'; import { By } from '@angular/platform-browser'; import { TranslateModule } from '@ngx-translate/core'; import { ContentTestingModule } from '../../../testing/content.testing.module'; +import { SearchDateRangeAdvancedComponent } from './search-date-range-advanced.component'; import { endOfDay, formatISO, startOfDay } from 'date-fns'; describe('SearchDateRangeAdvancedComponent', () => { diff --git a/lib/content-services/src/lib/search/components/search-date-range-advanced/search-date-range-advanced.component.ts b/lib/content-services/src/lib/search/components/search-date-range-advanced/search-date-range-advanced.component.ts index 6a689169eae..a6c24d6911b 100644 --- a/lib/content-services/src/lib/search/components/search-date-range-advanced/search-date-range-advanced.component.ts +++ b/lib/content-services/src/lib/search/components/search-date-range-advanced/search-date-range-advanced.component.ts @@ -1,11 +1,28 @@ +/*! + * @license + * Copyright © 2005-2023 Hyland Software, Inc. and its affiliates. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + import { Component, OnInit, ViewEncapsulation } from '@angular/core'; -import { SearchWidget } from '../../models/search-widget.interface'; -import { SearchWidgetSettings } from '../../models/search-widget-settings.interface'; -import { SearchQueryBuilderService } from '../../services/search-query-builder.service'; import { Subject } from 'rxjs'; -import { TranslationService } from '@alfresco/adf-core'; import { endOfDay, format, formatISO, parse, startOfDay } from 'date-fns'; import { DateAdapter, NativeDateAdapter } from '@angular/material/core'; +import { TranslationService } from '@alfresco/adf-core'; +import { SearchWidget } from '../../models/search-widget.interface'; +import { SearchWidgetSettings } from '../../models/search-widget-settings.interface'; +import { SearchQueryBuilderService } from '../../services/search-query-builder.service'; enum DateRangeType { ANY = 'ANY', diff --git a/lib/content-services/src/lib/search/components/search-filter-tabbed/search-filter-tabbed.component.spec.ts b/lib/content-services/src/lib/search/components/search-filter-tabbed/search-filter-tabbed.component.spec.ts index c46c71efc23..b61330393df 100644 --- a/lib/content-services/src/lib/search/components/search-filter-tabbed/search-filter-tabbed.component.spec.ts +++ b/lib/content-services/src/lib/search/components/search-filter-tabbed/search-filter-tabbed.component.spec.ts @@ -1,9 +1,25 @@ -import { ComponentFixture, TestBed } from '@angular/core/testing'; +/*! + * @license + * Copyright © 2005-2023 Hyland Software, Inc. and its affiliates. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ -import { SearchFilterTabbedComponent } from './search-filter-tabbed.component'; +import { ComponentFixture, TestBed } from '@angular/core/testing'; import { By } from '@angular/platform-browser'; -import { ContentTestingModule } from '../../../testing/content.testing.module'; import { TranslateModule } from '@ngx-translate/core'; +import { ContentTestingModule } from '../../../testing/content.testing.module'; +import { SearchFilterTabbedComponent } from './search-filter-tabbed.component'; describe('SearchFilterTabbedComponent', () => { let component: SearchFilterTabbedComponent; From 406e1e6303845a7b8b3f26371fe69d078d510994 Mon Sep 17 00:00:00 2001 From: "swapnil.verma" Date: Wed, 14 Jun 2023 17:50:13 +0530 Subject: [PATCH 16/54] [ACS-4985] Fixed erroneous imports --- .../search-widget-chip/search-widget-chip.component.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/content-services/src/lib/search/components/search-filter-chips/search-widget-chip/search-widget-chip.component.ts b/lib/content-services/src/lib/search/components/search-filter-chips/search-widget-chip/search-widget-chip.component.ts index 3845ac94949..29acaad85cd 100644 --- a/lib/content-services/src/lib/search/components/search-filter-chips/search-widget-chip/search-widget-chip.component.ts +++ b/lib/content-services/src/lib/search/components/search-filter-chips/search-widget-chip/search-widget-chip.component.ts @@ -16,10 +16,10 @@ */ import { Component, ElementRef, Input, ViewChild, ViewEncapsulation } from '@angular/core'; -import { SearchCategory } from '@alfresco/adf-content-services'; +import { SearchCategory } from '../../../models/search-category.interface'; import { ConfigurableFocusTrap, ConfigurableFocusTrapFactory } from '@angular/cdk/a11y'; import { MatMenuTrigger } from '@angular/material/menu'; -import { SearchWidgetContainerComponent } from '@alfresco/adf-content-services'; +import { SearchWidgetContainerComponent } from '../../search-widget-container/search-widget-container.component';; @Component({ selector: 'adf-search-widget-chip', From 482adfbdc77ea22df2da11c60746641272c73f25 Mon Sep 17 00:00:00 2001 From: "swapnil.verma" Date: Wed, 14 Jun 2023 18:40:49 +0530 Subject: [PATCH 17/54] [ACS-4985] Fixed test cases for SearchDateRangeAdvancedComponent. --- ...arch-date-range-advanced.component.spec.ts | 74 +++++++++++++------ .../search-date-range-advanced.component.ts | 3 +- 2 files changed, 51 insertions(+), 26 deletions(-) diff --git a/lib/content-services/src/lib/search/components/search-date-range-advanced/search-date-range-advanced.component.spec.ts b/lib/content-services/src/lib/search/components/search-date-range-advanced/search-date-range-advanced.component.spec.ts index 06d7b489029..05687f6cf62 100644 --- a/lib/content-services/src/lib/search/components/search-date-range-advanced/search-date-range-advanced.component.spec.ts +++ b/lib/content-services/src/lib/search/components/search-date-range-advanced/search-date-range-advanced.component.spec.ts @@ -22,7 +22,7 @@ import { ContentTestingModule } from '../../../testing/content.testing.module'; import { SearchDateRangeAdvancedComponent } from './search-date-range-advanced.component'; import { endOfDay, formatISO, startOfDay } from 'date-fns'; -describe('SearchDateRangeAdvancedComponent', () => { +fdescribe('SearchDateRangeAdvancedComponent', () => { let component: SearchDateRangeAdvancedComponent; let fixture: ComponentFixture; @@ -81,14 +81,18 @@ describe('SearchDateRangeAdvancedComponent', () => { }; it('should not set any date filter in context when Anytime option is selected', async () => { - await clickElementByAutomationId('date-range-advanced-anytime'); + component.dateRangeTypeValue = component.DateRangeType.ANY; + fixture.detectChanges(); + await fixture.whenStable(); await clickElementByAutomationId('date-range-advanced-apply-btn'); expect(component.context.queryFragments[component.id]).toBe(''); expect(component.context.update).toHaveBeenCalled(); }); it('should set proper date filter in context when In the last option is selected', async () => { - await clickElementByAutomationId('date-range-advanced-in-last'); + component.dateRangeTypeValue = component.DateRangeType.IN_LAST; + fixture.detectChanges(); + await fixture.whenStable(); await enterValueInInputField('date-range-advanced-in-last-input', '5'); await selectDropdownOption('date-range-advanced-in-last-option-days') await clickElementByAutomationId('date-range-advanced-apply-btn'); @@ -97,7 +101,9 @@ describe('SearchDateRangeAdvancedComponent', () => { expect(component.context.queryFragments[component.id]).toBe(query); expect(component.context.update).toHaveBeenCalled(); - await clickElementByAutomationId('date-range-advanced-in-last'); + component.dateRangeTypeValue = component.DateRangeType.IN_LAST; + fixture.detectChanges(); + await fixture.whenStable(); await enterValueInInputField('date-range-advanced-in-last-input', '3'); await selectDropdownOption('date-range-advanced-in-last-option-weeks'); await clickElementByAutomationId('date-range-advanced-apply-btn'); @@ -106,7 +112,9 @@ describe('SearchDateRangeAdvancedComponent', () => { expect(component.context.queryFragments[component.id]).toBe(query); expect(component.context.update).toHaveBeenCalled(); - await clickElementByAutomationId('date-range-advanced-in-last'); + component.dateRangeTypeValue = component.DateRangeType.IN_LAST; + fixture.detectChanges(); + await fixture.whenStable(); await enterValueInInputField('date-range-advanced-in-last-input', '6'); await selectDropdownOption('date-range-advanced-in-last-option-months'); await clickElementByAutomationId('date-range-advanced-apply-btn'); @@ -117,14 +125,18 @@ describe('SearchDateRangeAdvancedComponent', () => { }); it('should not set any date filter in context when In the last or Between option is selected, but no value is provided', async () => { - await clickElementByAutomationId('date-range-advanced-in-last'); + component.dateRangeTypeValue = component.DateRangeType.IN_LAST; + fixture.detectChanges(); + await fixture.whenStable(); await selectDropdownOption('date-range-advanced-in-last-option-weeks') await clickElementByAutomationId('date-range-advanced-apply-btn'); fixture.detectChanges(); expect(component.context.queryFragments[component.id]).toBe(''); expect(component.context.update).toHaveBeenCalled(); - await clickElementByAutomationId('date-range-advanced-between'); + component.dateRangeTypeValue = component.DateRangeType.BETWEEN; + fixture.detectChanges(); + await fixture.whenStable(); await clickElementByAutomationId('date-range-advanced-apply-btn'); fixture.detectChanges(); expect(component.context.queryFragments[component.id]).toBe(''); @@ -132,13 +144,15 @@ describe('SearchDateRangeAdvancedComponent', () => { }); it('should set proper date filter in context when Between option is selected', async () => { - await clickElementByAutomationId('date-range-advanced-between'); + component.dateRangeTypeValue = component.DateRangeType.BETWEEN; + fixture.detectChanges(); + await fixture.whenStable(); await enterValueInInputField('date-range-advanced-between-start-input', '6/5/2023'); await enterValueInInputField('date-range-advanced-between-end-input', '6/10/2023'); await clickElementByAutomationId('date-range-advanced-apply-btn'); fixture.detectChanges(); - let query = `test-field:[${formatISO(startOfDay(component.betweenStartDate))} TO ${formatISO(endOfDay(component.betweenEndDate))}]`; - expect(component.context.queryFragments[component.id]).toBe(query); + let query = `test-field:['${formatISO(startOfDay(component.betweenStartDate))}' TO '${formatISO(endOfDay(component.betweenEndDate))}']`; + expect(component.context.queryFragments[component.id]).toEqual(query); expect(component.context.update).toHaveBeenCalled(); }); @@ -152,33 +166,39 @@ describe('SearchDateRangeAdvancedComponent', () => { it('should update display label with proper text when In the last/Between option is selected and values are properly set', async () => { spyOn(component.displayValue$, 'next'); - await clickElementByAutomationId('date-range-advanced-in-last'); + component.dateRangeTypeValue = component.DateRangeType.IN_LAST; + fixture.detectChanges(); + await fixture.whenStable(); await enterValueInInputField('date-range-advanced-in-last-input', '5'); await selectDropdownOption('date-range-advanced-in-last-option-days') await clickElementByAutomationId('date-range-advanced-apply-btn'); - expect(component.displayValue$.next).toHaveBeenCalledWith('In the last 5 days'); + expect(component.displayValue$.next).toHaveBeenCalledWith('SEARCH.DATE_RANGE_ADVANCED.IN_LAST_DISPLAY_LABELS.DAYS'); await enterValueInInputField('date-range-advanced-in-last-input', '3'); await selectDropdownOption('date-range-advanced-in-last-option-weeks') await clickElementByAutomationId('date-range-advanced-apply-btn'); - expect(component.displayValue$.next).toHaveBeenCalledWith('In the last 3 weeks'); + expect(component.displayValue$.next).toHaveBeenCalledWith('SEARCH.DATE_RANGE_ADVANCED.IN_LAST_DISPLAY_LABELS.WEEKS'); await enterValueInInputField('date-range-advanced-in-last-input', '7'); await selectDropdownOption('date-range-advanced-in-last-option-months') await clickElementByAutomationId('date-range-advanced-apply-btn'); - expect(component.displayValue$.next).toHaveBeenCalledWith('In the last 7 months'); + expect(component.displayValue$.next).toHaveBeenCalledWith('SEARCH.DATE_RANGE_ADVANCED.IN_LAST_DISPLAY_LABELS.MONTHS'); - await clickElementByAutomationId('date-range-advanced-between'); + component.dateRangeTypeValue = component.DateRangeType.BETWEEN; + fixture.detectChanges(); + await fixture.whenStable(); await enterValueInInputField('date-range-advanced-between-start-input', '6/5/2023'); await enterValueInInputField('date-range-advanced-between-end-input', '6/10/2023'); await clickElementByAutomationId('date-range-advanced-apply-btn'); - expect(component.displayValue$.next).toHaveBeenCalledWith('Between 05-Jun-2023 - 10-Jun-2023'); + expect(component.displayValue$.next).toHaveBeenCalledWith('05-Jun-2023 - 10-Jun-2023'); }); it('should not update display label if anytime option is selected', async() => { spyOn(component.displayValue$, 'next'); - await clickElementByAutomationId('date-range-advanced-anytime'); + component.dateRangeTypeValue = component.DateRangeType.ANY; + fixture.detectChanges(); + await fixture.whenStable(); await clickElementByAutomationId('date-range-advanced-apply-btn'); fixture.detectChanges(); expect(component.displayValue$.next).toHaveBeenCalledWith(''); @@ -187,13 +207,17 @@ describe('SearchDateRangeAdvancedComponent', () => { it('should not update display label if no valid value was provided', async () => { spyOn(component.displayValue$, 'next'); - await clickElementByAutomationId('date-range-advanced-in-last'); + component.dateRangeTypeValue = component.DateRangeType.IN_LAST; + fixture.detectChanges(); + await fixture.whenStable(); await selectDropdownOption('date-range-advanced-in-last-option-weeks') await clickElementByAutomationId('date-range-advanced-apply-btn'); fixture.detectChanges(); expect(component.displayValue$.next).toHaveBeenCalledWith(''); - await clickElementByAutomationId('date-range-advanced-between'); + component.dateRangeTypeValue = component.DateRangeType.BETWEEN; + fixture.detectChanges(); + await fixture.whenStable(); await clickElementByAutomationId('date-range-advanced-apply-btn'); fixture.detectChanges(); expect(component.displayValue$.next).toHaveBeenCalledWith(''); @@ -205,7 +229,7 @@ describe('SearchDateRangeAdvancedComponent', () => { } component.startValue = value; component.ngOnInit(); - expect(component.getCurrentValue()).toBe(value); + expect(component.getCurrentValue()).toEqual(value); value = { dateRangeType: component.DateRangeType.IN_LAST, @@ -214,7 +238,7 @@ describe('SearchDateRangeAdvancedComponent', () => { } component.startValue = value; component.ngOnInit(); - expect(component.getCurrentValue()).toBe(value); + expect(component.getCurrentValue()).toEqual(value); value = { dateRangeType: component.DateRangeType.BETWEEN, @@ -223,10 +247,12 @@ describe('SearchDateRangeAdvancedComponent', () => { } component.startValue = value; component.ngOnInit(); - expect(component.getCurrentValue()).toBe(value); + expect(component.getCurrentValue()).toEqual(value); + }); + + it('should not allow selecting a date after the current date when Between option is selected, and no maxDate is provided', async () => { }); - it('should not allow selecting a date after the current date when Between option is selected', () => { - //TODO: Will need to be updated after date-fns + it('should not allow selecting a date after the maxDate when Between option is selected and maxDate is provided', async () => { }); }); diff --git a/lib/content-services/src/lib/search/components/search-date-range-advanced/search-date-range-advanced.component.ts b/lib/content-services/src/lib/search/components/search-date-range-advanced/search-date-range-advanced.component.ts index a6c24d6911b..3ba92548deb 100644 --- a/lib/content-services/src/lib/search/components/search-date-range-advanced/search-date-range-advanced.component.ts +++ b/lib/content-services/src/lib/search/components/search-date-range-advanced/search-date-range-advanced.component.ts @@ -164,7 +164,7 @@ export class SearchDateRangeAdvancedComponent implements SearchWidget, OnInit { break; case DateRangeType.BETWEEN: this.betweenStartDate = value.betweenStartDate; - this.betweenEndDate = value.betweeenEndDate; + this.betweenEndDate = value.betweenEndDate; break; } } @@ -219,4 +219,3 @@ export class SearchDateRangeAdvancedComponent implements SearchWidget, OnInit { } //TODO: Format dates for Between date range type - From f838267aca0a755c1c5f6ab94ec7294dcacafa42 Mon Sep 17 00:00:00 2001 From: "swapnil.verma" Date: Wed, 14 Jun 2023 19:57:03 +0530 Subject: [PATCH 18/54] [ACS-4985] Removed fdescribe test cases for SearchDateRangeAdvancedComponent. --- .../search-date-range-advanced.component.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/content-services/src/lib/search/components/search-date-range-advanced/search-date-range-advanced.component.spec.ts b/lib/content-services/src/lib/search/components/search-date-range-advanced/search-date-range-advanced.component.spec.ts index 05687f6cf62..f3fe739f656 100644 --- a/lib/content-services/src/lib/search/components/search-date-range-advanced/search-date-range-advanced.component.spec.ts +++ b/lib/content-services/src/lib/search/components/search-date-range-advanced/search-date-range-advanced.component.spec.ts @@ -22,7 +22,7 @@ import { ContentTestingModule } from '../../../testing/content.testing.module'; import { SearchDateRangeAdvancedComponent } from './search-date-range-advanced.component'; import { endOfDay, formatISO, startOfDay } from 'date-fns'; -fdescribe('SearchDateRangeAdvancedComponent', () => { +describe('SearchDateRangeAdvancedComponent', () => { let component: SearchDateRangeAdvancedComponent; let fixture: ComponentFixture; From 67ebf2979f6eb6e50bb22d678f30bfb2eedc0aa0 Mon Sep 17 00:00:00 2001 From: "swapnil.verma" Date: Wed, 14 Jun 2023 20:24:28 +0530 Subject: [PATCH 19/54] [ACS-4985] Updated date formats for SearchDateRangeAdvancedComponent --- .../search-date-range-advanced.component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/content-services/src/lib/search/components/search-date-range-advanced/search-date-range-advanced.component.ts b/lib/content-services/src/lib/search/components/search-date-range-advanced/search-date-range-advanced.component.ts index 3ba92548deb..f10c7f955c3 100644 --- a/lib/content-services/src/lib/search/components/search-date-range-advanced/search-date-range-advanced.component.ts +++ b/lib/content-services/src/lib/search/components/search-date-range-advanced/search-date-range-advanced.component.ts @@ -42,7 +42,7 @@ interface SearchDateRangeAdvanced { [indexer: string]: any; } -const DEFAULT_DATE_DISPLAY_FORMAT: string = 'dd-MMM-yyyy'; +const DEFAULT_DATE_DISPLAY_FORMAT: string = 'dd-MMM-yy'; @Component({ selector: 'adf-search-date-range-advanced', From 778809b505816ebf3173785a638e32f6f9ae77c3 Mon Sep 17 00:00:00 2001 From: "swapnil.verma" Date: Wed, 14 Jun 2023 20:38:55 +0530 Subject: [PATCH 20/54] [ACS-4985] Updated test cases for changed date format --- .../search-date-range-advanced.component.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/content-services/src/lib/search/components/search-date-range-advanced/search-date-range-advanced.component.spec.ts b/lib/content-services/src/lib/search/components/search-date-range-advanced/search-date-range-advanced.component.spec.ts index f3fe739f656..9be2fa0edd6 100644 --- a/lib/content-services/src/lib/search/components/search-date-range-advanced/search-date-range-advanced.component.spec.ts +++ b/lib/content-services/src/lib/search/components/search-date-range-advanced/search-date-range-advanced.component.spec.ts @@ -190,7 +190,7 @@ describe('SearchDateRangeAdvancedComponent', () => { await enterValueInInputField('date-range-advanced-between-start-input', '6/5/2023'); await enterValueInInputField('date-range-advanced-between-end-input', '6/10/2023'); await clickElementByAutomationId('date-range-advanced-apply-btn'); - expect(component.displayValue$.next).toHaveBeenCalledWith('05-Jun-2023 - 10-Jun-2023'); + expect(component.displayValue$.next).toHaveBeenCalledWith('05-Jun-23 - 10-Jun-23'); }); it('should not update display label if anytime option is selected', async() => { From b59ea2600a78efddcaee59a5182ff413d48d77b9 Mon Sep 17 00:00:00 2001 From: Aleksander Sklorz Date: Wed, 21 Jun 2023 14:13:46 +0200 Subject: [PATCH 21/54] ACS-4985 Fixed issue with nx build, some clean ups, using changes in configuration --- ...-date-range-advanced-tabbed.component.scss | 0 .../search-date-range-advanced.component.html | 46 ---- .../search-date-range-advanced.component.scss | 25 -- ...arch-date-range-advanced.component.spec.ts | 258 ------------------ .../search-date-range-advanced.component.ts | 221 --------------- .../search-filter-tab.directive.spec.ts | 8 + .../search-filter-tabbed.component.html | 9 - 7 files changed, 8 insertions(+), 559 deletions(-) create mode 100644 lib/content-services/src/lib/search/components/search-date-range-advanced-tabbed/search-date-range-advanced-tabbed.component.scss delete mode 100644 lib/content-services/src/lib/search/components/search-date-range-advanced/search-date-range-advanced.component.html delete mode 100644 lib/content-services/src/lib/search/components/search-date-range-advanced/search-date-range-advanced.component.scss delete mode 100644 lib/content-services/src/lib/search/components/search-date-range-advanced/search-date-range-advanced.component.spec.ts delete mode 100644 lib/content-services/src/lib/search/components/search-date-range-advanced/search-date-range-advanced.component.ts create mode 100644 lib/content-services/src/lib/search/components/search-filter-tabbed/search-filter-tab.directive.spec.ts diff --git a/lib/content-services/src/lib/search/components/search-date-range-advanced-tabbed/search-date-range-advanced-tabbed.component.scss b/lib/content-services/src/lib/search/components/search-date-range-advanced-tabbed/search-date-range-advanced-tabbed.component.scss new file mode 100644 index 00000000000..e69de29bb2d diff --git a/lib/content-services/src/lib/search/components/search-date-range-advanced/search-date-range-advanced.component.html b/lib/content-services/src/lib/search/components/search-date-range-advanced/search-date-range-advanced.component.html deleted file mode 100644 index 55c3abb993c..00000000000 --- a/lib/content-services/src/lib/search/components/search-date-range-advanced/search-date-range-advanced.component.html +++ /dev/null @@ -1,46 +0,0 @@ - - - - {{ 'SEARCH.DATE_RANGE_ADVANCED.OPTIONS.ANYTIME' | translate }} - - - - - {{ 'SEARCH.DATE_RANGE_ADVANCED.OPTIONS.IN_LAST' | translate }} - - - - - - - {{ 'SEARCH.DATE_RANGE_ADVANCED.IN_LAST_LABELS.DAYS' | translate }} - {{ 'SEARCH.DATE_RANGE_ADVANCED.IN_LAST_LABELS.WEEKS' | translate }} - {{ 'SEARCH.DATE_RANGE_ADVANCED.IN_LAST_LABELS.MONTHS' | translate }} - - - - - - {{ 'SEARCH.DATE_RANGE_ADVANCED.OPTIONS.BETWEEN' | translate }} - - - - - - - - - - - - -
- - -
diff --git a/lib/content-services/src/lib/search/components/search-date-range-advanced/search-date-range-advanced.component.scss b/lib/content-services/src/lib/search/components/search-date-range-advanced/search-date-range-advanced.component.scss deleted file mode 100644 index 28166f5b1e0..00000000000 --- a/lib/content-services/src/lib/search/components/search-date-range-advanced/search-date-range-advanced.component.scss +++ /dev/null @@ -1,25 +0,0 @@ -.adf-search-date-range-advanced { - .mat-radio-group { - display: flex; - flex-direction: column; - } - - .mat-radio-button { - margin: 5px; - } - - .adf-search-date-range-horizontal-container { - display: flex; - flex-direction: row; - align-items: center; - - .adf-search-date-range-input-field { - width: 75px; - } - - .adf-search-date-range-form-field { - padding-left: 10px; - flex: 1; - } - } -} diff --git a/lib/content-services/src/lib/search/components/search-date-range-advanced/search-date-range-advanced.component.spec.ts b/lib/content-services/src/lib/search/components/search-date-range-advanced/search-date-range-advanced.component.spec.ts deleted file mode 100644 index 9be2fa0edd6..00000000000 --- a/lib/content-services/src/lib/search/components/search-date-range-advanced/search-date-range-advanced.component.spec.ts +++ /dev/null @@ -1,258 +0,0 @@ -/*! - * @license - * Copyright © 2005-2023 Hyland Software, Inc. and its affiliates. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { ComponentFixture, TestBed } from '@angular/core/testing'; -import { By } from '@angular/platform-browser'; -import { TranslateModule } from '@ngx-translate/core'; -import { ContentTestingModule } from '../../../testing/content.testing.module'; -import { SearchDateRangeAdvancedComponent } from './search-date-range-advanced.component'; -import { endOfDay, formatISO, startOfDay } from 'date-fns'; - -describe('SearchDateRangeAdvancedComponent', () => { - let component: SearchDateRangeAdvancedComponent; - let fixture: ComponentFixture; - - beforeEach(async () => { - await TestBed.configureTestingModule({ - declarations: [SearchDateRangeAdvancedComponent], - imports: [ - TranslateModule.forRoot(), - ContentTestingModule - ] - }).compileComponents(); - - fixture = TestBed.createComponent(SearchDateRangeAdvancedComponent); - component = fixture.componentInstance; - component.id = 'date-range-advanced'; - component.settings = { - field: 'test-field', - hideDefaultAction: false - } - component.context = { - queryFragments: { - date: '' - }, - update: jasmine.createSpy() - } as any; - - fixture.detectChanges(); - }); - - const getElementByDataAutomationId = (dataAutomationId) => { - return fixture.debugElement.query(By.css(`[data-automation-id="${dataAutomationId}"]`)).nativeElement; - } - - const clickElementByAutomationId = async (elementDataAutomationId) => { - const el = getElementByDataAutomationId(elementDataAutomationId); - el.dispatchEvent(new Event('click')); - await fixture.whenStable(); - fixture.detectChanges(); - } - - const enterValueInInputField = async (inputElementId: string, value: string) => { - const inputField = getElementByDataAutomationId(inputElementId); - inputField.value = value; - inputField.dispatchEvent(new Event('input')); - await fixture.whenStable(); - fixture.detectChanges(); - } - - const selectDropdownOption = (itemId: string) => { - const matSelect = fixture.debugElement.query(By.css('[data-automation-id="date-range-advanced-in-last-dropdown"]')).nativeElement; - matSelect.click(); - fixture.detectChanges(); - const matOption = fixture.debugElement.query(By.css(`[data-automation-id="${itemId}"]`)).nativeElement; - matOption.click(); - fixture.detectChanges(); - }; - - it('should not set any date filter in context when Anytime option is selected', async () => { - component.dateRangeTypeValue = component.DateRangeType.ANY; - fixture.detectChanges(); - await fixture.whenStable(); - await clickElementByAutomationId('date-range-advanced-apply-btn'); - expect(component.context.queryFragments[component.id]).toBe(''); - expect(component.context.update).toHaveBeenCalled(); - }); - - it('should set proper date filter in context when In the last option is selected', async () => { - component.dateRangeTypeValue = component.DateRangeType.IN_LAST; - fixture.detectChanges(); - await fixture.whenStable(); - await enterValueInInputField('date-range-advanced-in-last-input', '5'); - await selectDropdownOption('date-range-advanced-in-last-option-days') - await clickElementByAutomationId('date-range-advanced-apply-btn'); - fixture.detectChanges(); - let query = 'test-field:[NOW/DAY-5DAYS TO NOW/DAY+1DAY]'; - expect(component.context.queryFragments[component.id]).toBe(query); - expect(component.context.update).toHaveBeenCalled(); - - component.dateRangeTypeValue = component.DateRangeType.IN_LAST; - fixture.detectChanges(); - await fixture.whenStable(); - await enterValueInInputField('date-range-advanced-in-last-input', '3'); - await selectDropdownOption('date-range-advanced-in-last-option-weeks'); - await clickElementByAutomationId('date-range-advanced-apply-btn'); - fixture.detectChanges(); - query = 'test-field:[NOW/DAY-3WEEKS TO NOW/DAY+1DAY]'; - expect(component.context.queryFragments[component.id]).toBe(query); - expect(component.context.update).toHaveBeenCalled(); - - component.dateRangeTypeValue = component.DateRangeType.IN_LAST; - fixture.detectChanges(); - await fixture.whenStable(); - await enterValueInInputField('date-range-advanced-in-last-input', '6'); - await selectDropdownOption('date-range-advanced-in-last-option-months'); - await clickElementByAutomationId('date-range-advanced-apply-btn'); - fixture.detectChanges(); - query = 'test-field:[NOW/DAY-6MONTHS TO NOW/DAY+1DAY]'; - expect(component.context.queryFragments[component.id]).toBe(query); - expect(component.context.update).toHaveBeenCalled(); - }); - - it('should not set any date filter in context when In the last or Between option is selected, but no value is provided', async () => { - component.dateRangeTypeValue = component.DateRangeType.IN_LAST; - fixture.detectChanges(); - await fixture.whenStable(); - await selectDropdownOption('date-range-advanced-in-last-option-weeks') - await clickElementByAutomationId('date-range-advanced-apply-btn'); - fixture.detectChanges(); - expect(component.context.queryFragments[component.id]).toBe(''); - expect(component.context.update).toHaveBeenCalled(); - - component.dateRangeTypeValue = component.DateRangeType.BETWEEN; - fixture.detectChanges(); - await fixture.whenStable(); - await clickElementByAutomationId('date-range-advanced-apply-btn'); - fixture.detectChanges(); - expect(component.context.queryFragments[component.id]).toBe(''); - expect(component.context.update).toHaveBeenCalled(); - }); - - it('should set proper date filter in context when Between option is selected', async () => { - component.dateRangeTypeValue = component.DateRangeType.BETWEEN; - fixture.detectChanges(); - await fixture.whenStable(); - await enterValueInInputField('date-range-advanced-between-start-input', '6/5/2023'); - await enterValueInInputField('date-range-advanced-between-end-input', '6/10/2023'); - await clickElementByAutomationId('date-range-advanced-apply-btn'); - fixture.detectChanges(); - let query = `test-field:['${formatISO(startOfDay(component.betweenStartDate))}' TO '${formatISO(endOfDay(component.betweenEndDate))}']`; - expect(component.context.queryFragments[component.id]).toEqual(query); - expect(component.context.update).toHaveBeenCalled(); - }); - - it('should clear context when widget is reset', async () => { - component.context.queryFragments[component.id] = '[NOW/DAY-5DAYS TO NOW/DAY+1DAY]'; - await clickElementByAutomationId('date-range-advanced-clear-btn'); - expect(component.context.queryFragments[component.id]).toBe(''); - expect(component.context.update).toHaveBeenCalled(); - }); - - it('should update display label with proper text when In the last/Between option is selected and values are properly set', async () => { - spyOn(component.displayValue$, 'next'); - - component.dateRangeTypeValue = component.DateRangeType.IN_LAST; - fixture.detectChanges(); - await fixture.whenStable(); - await enterValueInInputField('date-range-advanced-in-last-input', '5'); - await selectDropdownOption('date-range-advanced-in-last-option-days') - await clickElementByAutomationId('date-range-advanced-apply-btn'); - expect(component.displayValue$.next).toHaveBeenCalledWith('SEARCH.DATE_RANGE_ADVANCED.IN_LAST_DISPLAY_LABELS.DAYS'); - - await enterValueInInputField('date-range-advanced-in-last-input', '3'); - await selectDropdownOption('date-range-advanced-in-last-option-weeks') - await clickElementByAutomationId('date-range-advanced-apply-btn'); - expect(component.displayValue$.next).toHaveBeenCalledWith('SEARCH.DATE_RANGE_ADVANCED.IN_LAST_DISPLAY_LABELS.WEEKS'); - - await enterValueInInputField('date-range-advanced-in-last-input', '7'); - await selectDropdownOption('date-range-advanced-in-last-option-months') - await clickElementByAutomationId('date-range-advanced-apply-btn'); - expect(component.displayValue$.next).toHaveBeenCalledWith('SEARCH.DATE_RANGE_ADVANCED.IN_LAST_DISPLAY_LABELS.MONTHS'); - - component.dateRangeTypeValue = component.DateRangeType.BETWEEN; - fixture.detectChanges(); - await fixture.whenStable(); - await enterValueInInputField('date-range-advanced-between-start-input', '6/5/2023'); - await enterValueInInputField('date-range-advanced-between-end-input', '6/10/2023'); - await clickElementByAutomationId('date-range-advanced-apply-btn'); - expect(component.displayValue$.next).toHaveBeenCalledWith('05-Jun-23 - 10-Jun-23'); - }); - - it('should not update display label if anytime option is selected', async() => { - spyOn(component.displayValue$, 'next'); - - component.dateRangeTypeValue = component.DateRangeType.ANY; - fixture.detectChanges(); - await fixture.whenStable(); - await clickElementByAutomationId('date-range-advanced-apply-btn'); - fixture.detectChanges(); - expect(component.displayValue$.next).toHaveBeenCalledWith(''); - }); - - it('should not update display label if no valid value was provided', async () => { - spyOn(component.displayValue$, 'next'); - - component.dateRangeTypeValue = component.DateRangeType.IN_LAST; - fixture.detectChanges(); - await fixture.whenStable(); - await selectDropdownOption('date-range-advanced-in-last-option-weeks') - await clickElementByAutomationId('date-range-advanced-apply-btn'); - fixture.detectChanges(); - expect(component.displayValue$.next).toHaveBeenCalledWith(''); - - component.dateRangeTypeValue = component.DateRangeType.BETWEEN; - fixture.detectChanges(); - await fixture.whenStable(); - await clickElementByAutomationId('date-range-advanced-apply-btn'); - fixture.detectChanges(); - expect(component.displayValue$.next).toHaveBeenCalledWith(''); - }); - - it('should set values if initial value is provided', () => { - let value: any = { - dateRangeType: component.DateRangeType.ANY - } - component.startValue = value; - component.ngOnInit(); - expect(component.getCurrentValue()).toEqual(value); - - value = { - dateRangeType: component.DateRangeType.IN_LAST, - inLastValue: 5, - inLastValueType: component.InLastDateType.WEEKS - } - component.startValue = value; - component.ngOnInit(); - expect(component.getCurrentValue()).toEqual(value); - - value = { - dateRangeType: component.DateRangeType.BETWEEN, - betweenStartDate: '6/5/2023', - betweenEndDate: '6/10/2023' - } - component.startValue = value; - component.ngOnInit(); - expect(component.getCurrentValue()).toEqual(value); - }); - - it('should not allow selecting a date after the current date when Between option is selected, and no maxDate is provided', async () => { - }); - - it('should not allow selecting a date after the maxDate when Between option is selected and maxDate is provided', async () => { - }); -}); diff --git a/lib/content-services/src/lib/search/components/search-date-range-advanced/search-date-range-advanced.component.ts b/lib/content-services/src/lib/search/components/search-date-range-advanced/search-date-range-advanced.component.ts deleted file mode 100644 index f10c7f955c3..00000000000 --- a/lib/content-services/src/lib/search/components/search-date-range-advanced/search-date-range-advanced.component.ts +++ /dev/null @@ -1,221 +0,0 @@ -/*! - * @license - * Copyright © 2005-2023 Hyland Software, Inc. and its affiliates. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { Component, OnInit, ViewEncapsulation } from '@angular/core'; -import { Subject } from 'rxjs'; -import { endOfDay, format, formatISO, parse, startOfDay } from 'date-fns'; -import { DateAdapter, NativeDateAdapter } from '@angular/material/core'; -import { TranslationService } from '@alfresco/adf-core'; -import { SearchWidget } from '../../models/search-widget.interface'; -import { SearchWidgetSettings } from '../../models/search-widget-settings.interface'; -import { SearchQueryBuilderService } from '../../services/search-query-builder.service'; - -enum DateRangeType { - ANY = 'ANY', - IN_LAST = 'IN_LAST', - BETWEEN = 'BETWEEN', -} - -enum InLastDateType { - DAYS = 'DAYS', - WEEKS = 'WEEKS', - MONTHS = 'MONTHS' -} - -interface SearchDateRangeAdvanced { - dateRangeType: DateRangeType; - - [indexer: string]: any; -} - -const DEFAULT_DATE_DISPLAY_FORMAT: string = 'dd-MMM-yy'; - -@Component({ - selector: 'adf-search-date-range-advanced', - templateUrl: './search-date-range-advanced.component.html', - styleUrls: ['./search-date-range-advanced.component.scss'], - providers: [ - {provide: DateAdapter, useClass: NativeDateAdapter}, - ], - encapsulation: ViewEncapsulation.None, - host: {class: 'adf-search-date-range-advanced'} -}) -export class SearchDateRangeAdvancedComponent implements SearchWidget, OnInit { - displayValue$: Subject = new Subject(); - isActive: boolean; - - id: string; - settings?: SearchWidgetSettings; - context?: SearchQueryBuilderService; - startValue: SearchDateRangeAdvanced; - disableUpdateOnSubmit: boolean; - maxDate: any; - dateRangeTypeValue: DateRangeType = DateRangeType.ANY; - inLastValue: string; - inLastValueType: InLastDateType = InLastDateType.DAYS; - betweenStartDate: any; - betweenEndDate: any; - - DateRangeType = DateRangeType; - InLastDateType = InLastDateType; - - private datePickerFormat: string; - - constructor(private translate: TranslationService) { - } - - ngOnInit(): void { - this.datePickerFormat = this.settings?.dateFormat ? this.settings.dateFormat : DEFAULT_DATE_DISPLAY_FORMAT; - if (this.settings) { - if (!this.settings.maxDate || this.settings.maxDate === 'today') { - this.maxDate = endOfDay(new Date()); - } else { - this.maxDate = endOfDay(parse(this.settings.maxDate, this.datePickerFormat, new Date())); - } - } - - if (this.startValue) { - this.setValue(this.startValue); - } - } - - getCurrentValue(): SearchDateRangeAdvanced { - let currentValue = {}; - switch (this.dateRangeTypeValue) { - case DateRangeType.IN_LAST: - currentValue = { - inLastValue: this.inLastValue, - inLastValueType: this.inLastValueType - }; - break; - case DateRangeType.BETWEEN: - currentValue = { - betweenStartDate: this.betweenStartDate, - betweenEndDate: this.betweenEndDate - }; - break; - } - return { - dateRangeType: this.dateRangeTypeValue, - ...currentValue - }; - } - - hasValidValue(): boolean { - let isValid = false; - switch (this.dateRangeTypeValue) { - case DateRangeType.ANY: - isValid = true; - break; - case DateRangeType.IN_LAST: - if (this.inLastValue) { - isValid = true; - } - break; - case DateRangeType.BETWEEN: - if (this.betweenStartDate && this.betweenEndDate) { - isValid = true; - } - break; - default: - isValid = false; - } - return isValid; - } - - reset(): void { - this.isActive = false; - - this.dateRangeTypeValue = DateRangeType.ANY; - this.inLastValue = ''; - this.inLastValueType = InLastDateType.DAYS; - this.betweenStartDate = ''; - this.betweenEndDate = ''; - - if (this.id && this.context) { - this.context.queryFragments[this.id] = ''; - if (!this.disableUpdateOnSubmit) { - this.updateQuery(); - } - } - - } - - setValue(value: SearchDateRangeAdvanced) { - this.dateRangeTypeValue = value.dateRangeType ? value.dateRangeType : DateRangeType.ANY; - switch (this.dateRangeTypeValue) { - case DateRangeType.IN_LAST: - this.inLastValue = value.inLastValue; - this.inLastValueType = value.inLastValueType; - break; - case DateRangeType.BETWEEN: - this.betweenStartDate = value.betweenStartDate; - this.betweenEndDate = value.betweenEndDate; - break; - } - } - - submitValues(): void { - let query = ''; - this.isActive = true; - switch (this.dateRangeTypeValue) { - case DateRangeType.IN_LAST: - if (this.hasValidValue()) { - query = `${this.settings.field}:[NOW/DAY-${this.inLastValue}${this.inLastValueType} TO NOW/DAY+1DAY]`; - } - break; - case DateRangeType.BETWEEN: - if (this.hasValidValue()) { - const start = formatISO(startOfDay(this.betweenStartDate)); - const end = formatISO(endOfDay(this.betweenEndDate)); - query = `${this.settings.field}:['${start}' TO '${end}']`; - } - } - this.context.queryFragments[this.id] = query; - this.updateDisplayValue(); - if (!this.disableUpdateOnSubmit) { - this.updateQuery(); - } - } - - updateDisplayValue(): void { - let displayLabel = ''; - switch (this.dateRangeTypeValue) { - case DateRangeType.IN_LAST: - if (this.hasValidValue()) { - displayLabel = this.translate.instant(`SEARCH.DATE_RANGE_ADVANCED.IN_LAST_DISPLAY_LABELS.${this.inLastValueType}`, {value: this.inLastValue}); - } - break; - case DateRangeType.BETWEEN: - if (this.hasValidValue()) { - const start = format(startOfDay(this.betweenStartDate), this.datePickerFormat); - const end = format(endOfDay(this.betweenEndDate), this.datePickerFormat); - displayLabel = `${start} - ${end}`; - } - break; - } - this.displayValue$.next(displayLabel); - } - - private updateQuery() { - if (this.id && this.context) { - this.context.update(); - } - } -} - -//TODO: Format dates for Between date range type diff --git a/lib/content-services/src/lib/search/components/search-filter-tabbed/search-filter-tab.directive.spec.ts b/lib/content-services/src/lib/search/components/search-filter-tabbed/search-filter-tab.directive.spec.ts new file mode 100644 index 00000000000..3a39b91a5dd --- /dev/null +++ b/lib/content-services/src/lib/search/components/search-filter-tabbed/search-filter-tab.directive.spec.ts @@ -0,0 +1,8 @@ +import { SearchFilterTabDirective } from './search-filter-tab.directive'; + +describe('SearchFilterTabDirective', () => { + it('should create an instance', () => { + const directive = new SearchFilterTabDirective(); + expect(directive).toBeTruthy(); + }); +}); diff --git a/lib/content-services/src/lib/search/components/search-filter-tabbed/search-filter-tabbed.component.html b/lib/content-services/src/lib/search/components/search-filter-tabbed/search-filter-tabbed.component.html index 1040a4bb695..558c13b1eeb 100644 --- a/lib/content-services/src/lib/search/components/search-filter-tabbed/search-filter-tabbed.component.html +++ b/lib/content-services/src/lib/search/components/search-filter-tabbed/search-filter-tabbed.component.html @@ -3,12 +3,3 @@ - -
- - -
From 18586bb76095c070a4a67cec47e02c56477a553a Mon Sep 17 00:00:00 2001 From: "swapnil.verma" Date: Mon, 26 Jun 2023 13:26:30 +0530 Subject: [PATCH 22/54] [ACS-4985] Updated test cases for SearchDateRangeAdvancedComponent. Minor updates to the component template and logic. Component no longer uses getters and setters in template --- .../search-date-range-advanced.component.spec.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/content-services/src/lib/search/components/search-date-range-advanced-tabbed/search-date-range-advanced/search-date-range-advanced.component.spec.ts b/lib/content-services/src/lib/search/components/search-date-range-advanced-tabbed/search-date-range-advanced/search-date-range-advanced.component.spec.ts index fa570f6c6be..43fc7598254 100644 --- a/lib/content-services/src/lib/search/components/search-date-range-advanced-tabbed/search-date-range-advanced/search-date-range-advanced.component.spec.ts +++ b/lib/content-services/src/lib/search/components/search-date-range-advanced-tabbed/search-date-range-advanced/search-date-range-advanced.component.spec.ts @@ -63,12 +63,13 @@ describe('SearchDateRangeAdvancedComponent', () => { fixture.detectChanges(); }; - const selectDropdownOption = (itemId: string) => { + const selectDropdownOption = async (itemId: string) => { const matSelect = fixture.debugElement.query(By.css('[data-automation-id="date-range-advanced-in-last-dropdown"]')).nativeElement; matSelect.click(); fixture.detectChanges(); const matOption = fixture.debugElement.query(By.css(`[data-automation-id="${itemId}"]`)).nativeElement; matOption.click(); + await fixture.whenStable(); fixture.detectChanges(); }; From 5ca8856d1cf26dbb2c371a9d96e4d6d8389875db Mon Sep 17 00:00:00 2001 From: "swapnil.verma" Date: Mon, 26 Jun 2023 17:46:41 +0530 Subject: [PATCH 23/54] [ACS-4985] Updated test cases for SearchFilterTabbedComponent. Added safety checks to component --- .../search-filter-tabbed.component.spec.ts | 148 ++++++------------ 1 file changed, 49 insertions(+), 99 deletions(-) diff --git a/lib/content-services/src/lib/search/components/search-filter-tabbed/search-filter-tabbed.component.spec.ts b/lib/content-services/src/lib/search/components/search-filter-tabbed/search-filter-tabbed.component.spec.ts index b61330393df..5f0bade35a2 100644 --- a/lib/content-services/src/lib/search/components/search-filter-tabbed/search-filter-tabbed.component.spec.ts +++ b/lib/content-services/src/lib/search/components/search-filter-tabbed/search-filter-tabbed.component.spec.ts @@ -16,7 +16,6 @@ */ import { ComponentFixture, TestBed } from '@angular/core/testing'; -import { By } from '@angular/platform-browser'; import { TranslateModule } from '@ngx-translate/core'; import { ContentTestingModule } from '../../../testing/content.testing.module'; import { SearchFilterTabbedComponent } from './search-filter-tabbed.component'; @@ -26,122 +25,73 @@ describe('SearchFilterTabbedComponent', () => { let fixture: ComponentFixture; beforeEach(async () => { - TestBed.configureTestingModule({ + await TestBed.configureTestingModule({ declarations: [SearchFilterTabbedComponent], imports: [ TranslateModule.forRoot(), ContentTestingModule ] }); - fixture = TestBed.createComponent(SearchFilterTabbedComponent); component = fixture.componentInstance; - component.id = 'tabbed'; - component.context = { - queryFragments: { - field1: '', - field2: '' - }, - update: jasmine.createSpy() - } as any; - component.settings = { - field: undefined, - hideDefaultAction: true, - displayLabelSeparator: ';', - tabs: [ - { - id: 'widget1', - tabDisplayLabel: 'Widget1', - component: { - settings: { - field: 'field1' - } - } - }, - { - id: 'widget2', - tabDisplayLabel: 'Widget2', - component: { - settings: { - field: 'field2' - } - } - } - ] - }; fixture.detectChanges(); }); - function getButtonByDataAutomationId(buttonDataAutomationId: string) { - return fixture.debugElement.query(By.css(`[data-automation-id="${buttonDataAutomationId}"]`)).nativeElement; - } - - it('should update displayLabel when inner widgets display label is updated', async () => { - spyOn(component.displayValue$, 'next'); - fixture.detectChanges(); - component.widgetContainerComponentList.get(0).componentRef.instance.displayValue$.next('test-label-1'); - fixture.detectChanges(); - await fixture.whenStable(); - expect(component.displayValue$.next).toHaveBeenCalledWith('Widget1 test-label-1'); - - component.widgetContainerComponentList.get(1).componentRef.instance.displayValue$.next('test-label-2'); + it('should emit a single combined query when multiple queries are provided', () => { + spyOn(component.queriesCombined, 'emit'); + component.queries = { + testField1: 'test-query-1', + testField2: 'test-query-2', + testField3: 'test-query-3' + }; fixture.detectChanges(); - await fixture.whenStable(); - expect(component.displayValue$.next).toHaveBeenCalledWith('Widget1 test-label-1; Widget2 test-label-2'); + expect(component.queriesCombined.emit).toHaveBeenCalledWith('test-query-1 AND test-query-2 AND test-query-3'); }); - it('should call submitValues for inner widgets and update context when apply button is clicked', () => { - component.widgetContainerComponentList.forEach(widget => { - spyOn(widget, 'applyInnerWidget'); - }); - const resetButton = getButtonByDataAutomationId('tab-apply-btn'); - resetButton.dispatchEvent(new Event('click')); - fixture.detectChanges(); - component.widgetContainerComponentList.forEach(widget => { - expect(widget.applyInnerWidget).toHaveBeenCalled(); - }); - expect(component.context.update).toHaveBeenCalled(); + it ('should emit a single combined value to display when multiple display values are provided', () => { + spyOn(component.valuesToDisplayCombined, 'emit'); + component.settings = { + field: 'testField1, testField2, testField3', + displayedLabelsByField: { + testField1: 'Field 1', + testField2: 'Field 2', + testField3: 'Field 3' + } + } + component.valuesToDisplay = { + testField1: 'test-display-value-1', + testField2: 'test-display-value-2', + testField3: 'test-display-value-3' + }; + fixture.detectChanges(); + expect(component.valuesToDisplayCombined.emit).toHaveBeenCalledWith('FIELD 1: test-display-value-1 FIELD 2: test-display-value-2 FIELD 3: test-display-value-3'); }); - it('should reset inner widgets when clear button is clicked', () => { - component.widgetContainerComponentList.forEach(widget => { - spyOn(widget, 'resetInnerWidget'); - }); - const resetButton = getButtonByDataAutomationId('tab-clear-btn'); - resetButton.dispatchEvent(new Event('click')); + it('should emit translated display labels by field when settings are set', () => { + spyOn(component.displayedLabelsByFieldTranslated, 'emit'); + component.settings = { + field: 'testField1, testField2, testField3', + displayedLabelsByField: { + testField1: 'Field 1', + testField2: 'Field 2', + testField3: 'Field 3' + } + } fixture.detectChanges(); - component.widgetContainerComponentList.forEach(widget => { - expect(widget.resetInnerWidget).toHaveBeenCalled(); - }); - }); - - it('should have valid value when inner widgets have valid values', () => { - component.widgetContainerComponentList.forEach(widget => { - spyOn(widget, 'hasValueSelected').and.returnValue(true); - }); - expect(component.hasValidValue()).toBe(true); + const displayedLabelsMap = { + testField1: 'Field 1', + testField2: 'Field 2', + testField3: 'Field 3' + } + expect(component.displayedLabelsByFieldTranslated.emit).toHaveBeenCalledWith(displayedLabelsMap); }); - it('should set values on init for inner widgets if initial value is provided', () => { - component.widgetContainerComponentList.forEach(widget => { - spyOn(widget, 'setValue'); - }); - const valueForWidget1 = { - testStringValue: 'test value', - testNumberValue: 28 - } - const valueForWidget2 = { - testBooleanValue: false, - testStringValue: 'test value' - } - component.startValue = { - widget1: valueForWidget1, - widget2: valueForWidget2 - } - component.ngOnInit(); - component.widgetContainerComponentList.forEach(widget => { - const value = component.startValue[widget.id]; - expect(widget.setValue).toHaveBeenCalledWith(value); - }); + it('should emit an array of fields when all the fields are provided in a combined string via settings', () => { + spyOn(component.fieldsChanged, 'emit'); + component.settings = { + field: 'testField1, testField2, testField3' + }; + fixture.detectChanges(); + expect(component.fieldsChanged.emit).toHaveBeenCalledWith(['testField1', 'testField2', 'testField3']); }); }); From 131b2bcb52234ee726bc793b33bbc4e844933033 Mon Sep 17 00:00:00 2001 From: "swapnil.verma" Date: Mon, 26 Jun 2023 17:49:42 +0530 Subject: [PATCH 24/54] [ACS-4985] Added clear and apply button to SearchDateRangeAdvancedTabbedComponent. Moved logic from template to typescript file --- ...rch-date-range-advanced-tabbed.component.html | 10 ++++++++++ ...earch-date-range-advanced-tabbed.component.ts | 16 ++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/lib/content-services/src/lib/search/components/search-date-range-advanced-tabbed/search-date-range-advanced-tabbed.component.html b/lib/content-services/src/lib/search/components/search-date-range-advanced-tabbed/search-date-range-advanced-tabbed.component.html index 45047255aa2..95a1f9f4d5a 100644 --- a/lib/content-services/src/lib/search/components/search-date-range-advanced-tabbed/search-date-range-advanced-tabbed.component.html +++ b/lib/content-services/src/lib/search/components/search-date-range-advanced-tabbed/search-date-range-advanced-tabbed.component.html @@ -11,3 +11,13 @@ + +
+ + +
+ diff --git a/lib/content-services/src/lib/search/components/search-date-range-advanced-tabbed/search-date-range-advanced-tabbed.component.ts b/lib/content-services/src/lib/search/components/search-date-range-advanced-tabbed/search-date-range-advanced-tabbed.component.ts index 2e20e2b6105..24dbadb0766 100644 --- a/lib/content-services/src/lib/search/components/search-date-range-advanced-tabbed/search-date-range-advanced-tabbed.component.ts +++ b/lib/content-services/src/lib/search/components/search-date-range-advanced-tabbed/search-date-range-advanced-tabbed.component.ts @@ -168,4 +168,20 @@ export class SearchDateRangeAdvancedTabbedComponent implements SearchWidget, OnI } }); } + + onQueriesCombined(query: string) { + this.combinedQuery = query; + } + + onValuesToDisplayCombined(valuesToDisplay: string) { + this.combinedValuesToDisplay = valuesToDisplay; + } + + onTabValid(tabValid: boolean, field: string) { + this.tabsValidity[field] = tabValid; + } + + onDateRangedValueChanged(value: Partial, field: string) { + this.value[field] = value; + } } From 0b8a4d9f0f83a08e897a015e1f587e594ecd67a2 Mon Sep 17 00:00:00 2001 From: "swapnil.verma" Date: Tue, 27 Jun 2023 14:30:42 +0530 Subject: [PATCH 25/54] [ACS-4985] Added test cases for SearchDateRangeAdvancedTabbedComponent. Moved pending logic from template to typescript --- .../search-date-range-advanced-tabbed.component.html | 2 +- .../search-date-range-advanced-tabbed.component.spec.ts | 1 - .../search-date-range-advanced-tabbed.component.ts | 8 ++++++++ .../search-filter-tab.directive.spec.ts | 8 -------- 4 files changed, 9 insertions(+), 10 deletions(-) delete mode 100644 lib/content-services/src/lib/search/components/search-filter-tabbed/search-filter-tab.directive.spec.ts diff --git a/lib/content-services/src/lib/search/components/search-date-range-advanced-tabbed/search-date-range-advanced-tabbed.component.html b/lib/content-services/src/lib/search/components/search-date-range-advanced-tabbed/search-date-range-advanced-tabbed.component.html index 95a1f9f4d5a..8702520ae53 100644 --- a/lib/content-services/src/lib/search/components/search-date-range-advanced-tabbed/search-date-range-advanced-tabbed.component.html +++ b/lib/content-services/src/lib/search/components/search-date-range-advanced-tabbed/search-date-range-advanced-tabbed.component.html @@ -16,7 +16,7 @@ - diff --git a/lib/content-services/src/lib/search/components/search-date-range-advanced-tabbed/search-date-range-advanced-tabbed.component.spec.ts b/lib/content-services/src/lib/search/components/search-date-range-advanced-tabbed/search-date-range-advanced-tabbed.component.spec.ts index c57141917e8..6602811186b 100644 --- a/lib/content-services/src/lib/search/components/search-date-range-advanced-tabbed/search-date-range-advanced-tabbed.component.spec.ts +++ b/lib/content-services/src/lib/search/components/search-date-range-advanced-tabbed/search-date-range-advanced-tabbed.component.spec.ts @@ -82,7 +82,6 @@ describe('SearchDateRangeAdvancedTabbedComponent', () => { ] }); fixture = TestBed.createComponent(SearchDateRangeAdvancedTabbedComponent); - component = fixture.componentInstance; component.id = 'dateRangeAdvanced'; component.context = { diff --git a/lib/content-services/src/lib/search/components/search-date-range-advanced-tabbed/search-date-range-advanced-tabbed.component.ts b/lib/content-services/src/lib/search/components/search-date-range-advanced-tabbed/search-date-range-advanced-tabbed.component.ts index 24dbadb0766..cbcc39e26d1 100644 --- a/lib/content-services/src/lib/search/components/search-date-range-advanced-tabbed/search-date-range-advanced-tabbed.component.ts +++ b/lib/content-services/src/lib/search/components/search-date-range-advanced-tabbed/search-date-range-advanced-tabbed.component.ts @@ -184,4 +184,12 @@ export class SearchDateRangeAdvancedTabbedComponent implements SearchWidget, OnI onDateRangedValueChanged(value: Partial, field: string) { this.value[field] = value; } + + onFieldsChanged(fields: string[]) { + this.fields = fields; + } + + onDisplayLabelsByFieldsTranslated(displayedLabelsByField: { [p: string]: string }) { + this.displayedLabelsByField = displayedLabelsByField; + } } diff --git a/lib/content-services/src/lib/search/components/search-filter-tabbed/search-filter-tab.directive.spec.ts b/lib/content-services/src/lib/search/components/search-filter-tabbed/search-filter-tab.directive.spec.ts deleted file mode 100644 index 3a39b91a5dd..00000000000 --- a/lib/content-services/src/lib/search/components/search-filter-tabbed/search-filter-tab.directive.spec.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { SearchFilterTabDirective } from './search-filter-tab.directive'; - -describe('SearchFilterTabDirective', () => { - it('should create an instance', () => { - const directive = new SearchFilterTabDirective(); - expect(directive).toBeTruthy(); - }); -}); From 5574aef240dd924be35114e933b4551973ec9f31 Mon Sep 17 00:00:00 2001 From: "swapnil.verma" Date: Wed, 28 Jun 2023 12:03:05 +0530 Subject: [PATCH 26/54] [ACS-4985] Removed disableUpdateOnSubmit flag from search widgets --- .../search-check-list/search-check-list.component.ts | 9 ++------- .../search-date-range/search-date-range.component.ts | 9 ++------- .../search-datetime-range.component.ts | 9 ++------- .../search-number-range.component.ts | 11 +++-------- .../components/search-radio/search-radio.component.ts | 9 ++------- .../search-slider/search-slider.component.ts | 9 ++------- .../components/search-text/search-text.component.ts | 9 ++------- .../search-widget-container.component.ts | 3 --- .../src/lib/search/models/search-widget.interface.ts | 1 - 9 files changed, 15 insertions(+), 54 deletions(-) diff --git a/lib/content-services/src/lib/search/components/search-check-list/search-check-list.component.ts b/lib/content-services/src/lib/search/components/search-check-list/search-check-list.component.ts index 989e272b88c..7a4516e5209 100644 --- a/lib/content-services/src/lib/search/components/search-check-list/search-check-list.component.ts +++ b/lib/content-services/src/lib/search/components/search-check-list/search-check-list.component.ts @@ -48,7 +48,6 @@ export class SearchCheckListComponent implements SearchWidget, OnInit { pageSize = 5; isActive = false; enableChangeUpdate = true; - disableUpdateOnSubmit: boolean; displayValue$: Subject = new Subject(); constructor(private translationService: TranslationService) { @@ -95,9 +94,7 @@ export class SearchCheckListComponent implements SearchWidget, OnInit { this.clearOptions(); if (this.id && this.context) { this.updateDisplayValue(); - if (!this.disableUpdateOnSubmit) { - this.context.update(); - } + this.context.update(); } } @@ -145,9 +142,7 @@ export class SearchCheckListComponent implements SearchWidget, OnInit { if (this.id && this.context) { this.context.queryFragments[this.id] = query; this.updateDisplayValue(); - if(!this.disableUpdateOnSubmit) { - this.context.update(); - } + this.context.update(); } } } diff --git a/lib/content-services/src/lib/search/components/search-date-range/search-date-range.component.ts b/lib/content-services/src/lib/search/components/search-date-range/search-date-range.component.ts index be6e56008af..86ce7d7adb2 100644 --- a/lib/content-services/src/lib/search/components/search-date-range/search-date-range.component.ts +++ b/lib/content-services/src/lib/search/components/search-date-range/search-date-range.component.ts @@ -70,7 +70,6 @@ export class SearchDateRangeComponent implements SearchWidget, OnInit, OnDestroy isActive = false; startValue: any; enableChangeUpdate: boolean; - disableUpdateOnSubmit: boolean; displayValue$: Subject = new Subject(); private onDestroy$ = new Subject(); @@ -152,9 +151,7 @@ export class SearchDateRangeComponent implements SearchWidget, OnInit, OnDestroy this.context.queryFragments[this.id] = `${this.settings.field}:['${start}' TO '${end}']`; this.updateDisplayValue(); - if(!this.disableUpdateOnSubmit) { - this.context.update(); - } + this.context.update(); } } @@ -217,9 +214,7 @@ export class SearchDateRangeComponent implements SearchWidget, OnInit, OnDestroy private updateQuery() { if (this.id && this.context) { this.updateDisplayValue(); - if (!this.disableUpdateOnSubmit) { - this.context.update(); - } + this.context.update(); } } diff --git a/lib/content-services/src/lib/search/components/search-datetime-range/search-datetime-range.component.ts b/lib/content-services/src/lib/search/components/search-datetime-range/search-datetime-range.component.ts index 1fd12ce2319..11e32d6c360 100644 --- a/lib/content-services/src/lib/search/components/search-datetime-range/search-datetime-range.component.ts +++ b/lib/content-services/src/lib/search/components/search-datetime-range/search-datetime-range.component.ts @@ -65,7 +65,6 @@ export class SearchDatetimeRangeComponent implements SearchWidget, OnInit, OnDes isActive = false; startValue: any; enableChangeUpdate: boolean; - disableUpdateOnSubmit: boolean; displayValue$: Subject = new Subject(); private onDestroy$ = new Subject(); @@ -139,9 +138,7 @@ export class SearchDatetimeRangeComponent implements SearchWidget, OnInit, OnDes this.context.queryFragments[this.id] = `${this.settings.field}:['${start}' TO '${end}']`; this.updateDisplayValue(); - if(!this.disableUpdateOnSubmit) { - this.context.update(); - } + this.context.update(); } } @@ -205,9 +202,7 @@ export class SearchDatetimeRangeComponent implements SearchWidget, OnInit, OnDes private updateQuery() { if (this.id && this.context) { this.updateDisplayValue(); - if (!this.disableUpdateOnSubmit) { - this.context.update(); - } + this.context.update(); } } diff --git a/lib/content-services/src/lib/search/components/search-number-range/search-number-range.component.ts b/lib/content-services/src/lib/search/components/search-number-range/search-number-range.component.ts index c371d0531fa..6a842b875b4 100644 --- a/lib/content-services/src/lib/search/components/search-number-range/search-number-range.component.ts +++ b/lib/content-services/src/lib/search/components/search-number-range/search-number-range.component.ts @@ -41,7 +41,6 @@ export class SearchNumberRangeComponent implements SearchWidget, OnInit { id: string; settings?: SearchWidgetSettings; context?: SearchQueryBuilderService; - disableUpdateOnSubmit: boolean; field: string; format = '[{FROM} TO {TO}]'; @@ -99,9 +98,7 @@ export class SearchNumberRangeComponent implements SearchWidget, OnInit { const value = this.formatString(this.format, map); this.context.queryFragments[this.id] = `${this.field}:${value}`; - if (!this.disableUpdateOnSubmit) { - this.context.update(); - } + this.context.update(); } } @@ -161,10 +158,8 @@ export class SearchNumberRangeComponent implements SearchWidget, OnInit { reset() { this.clear(); - if (!this.disableUpdateOnSubmit) { - if (this.id && this.context) { - this.context.update(); - } + if (this.id && this.context) { + this.context.update(); } } } diff --git a/lib/content-services/src/lib/search/components/search-radio/search-radio.component.ts b/lib/content-services/src/lib/search/components/search-radio/search-radio.component.ts index ff8c10c184d..2c33ce85801 100644 --- a/lib/content-services/src/lib/search/components/search-radio/search-radio.component.ts +++ b/lib/content-services/src/lib/search/components/search-radio/search-radio.component.ts @@ -50,7 +50,6 @@ export class SearchRadioComponent implements SearchWidget, OnInit { isActive = false; startValue: any; enableChangeUpdate: boolean; - disableUpdateOnSubmit: boolean; displayValue$: Subject = new Subject(); constructor() { @@ -98,9 +97,7 @@ export class SearchRadioComponent implements SearchWidget, OnInit { submitValues() { this.setValue(this.value); this.updateDisplayValue(); - if(!this.disableUpdateOnSubmit) { - this.context.update(); - } + this.context.update(); } hasValidValue() { @@ -147,9 +144,7 @@ export class SearchRadioComponent implements SearchWidget, OnInit { if (initialValue !== null) { this.setValue(initialValue); this.updateDisplayValue(); - if (!this.disableUpdateOnSubmit) { - this.context.update(); - } + this.context.update(); } } } diff --git a/lib/content-services/src/lib/search/components/search-slider/search-slider.component.ts b/lib/content-services/src/lib/search/components/search-slider/search-slider.component.ts index 756998a3c6d..52c5c8121ad 100644 --- a/lib/content-services/src/lib/search/components/search-slider/search-slider.component.ts +++ b/lib/content-services/src/lib/search/components/search-slider/search-slider.component.ts @@ -41,7 +41,6 @@ export class SearchSliderComponent implements SearchWidget, OnInit { max: number; thumbLabel = false; enableChangeUpdate: boolean; - disableUpdateOnSubmit: boolean; displayValue$: Subject = new Subject(); /** The numeric value represented by the slider. */ @@ -91,9 +90,7 @@ export class SearchSliderComponent implements SearchWidget, OnInit { } submitValues() { - if(!this.disableUpdateOnSubmit) { - this.updateQuery(this.value); - } + this.updateQuery(this.value); } hasValidValue() { @@ -117,9 +114,7 @@ export class SearchSliderComponent implements SearchWidget, OnInit { } else { this.context.queryFragments[this.id] = `${this.settings.field}:[0 TO ${value}]`; } - if (!this.disableUpdateOnSubmit) { - this.context.update(); - } + this.context.update(); } } diff --git a/lib/content-services/src/lib/search/components/search-text/search-text.component.ts b/lib/content-services/src/lib/search/components/search-text/search-text.component.ts index 18843597750..c257c26debe 100644 --- a/lib/content-services/src/lib/search/components/search-text/search-text.component.ts +++ b/lib/content-services/src/lib/search/components/search-text/search-text.component.ts @@ -40,7 +40,6 @@ export class SearchTextComponent implements SearchWidget, OnInit { startValue: string; isActive = false; enableChangeUpdate = true; - disableUpdateOnSubmit: boolean; displayValue$: Subject = new Subject(); ngOnInit() { @@ -87,16 +86,12 @@ export class SearchTextComponent implements SearchWidget, OnInit { this.displayValue$.next(value); if (this.context && this.settings && this.settings.field) { this.context.queryFragments[this.id] = value ? `${this.settings.field}:'${this.getSearchPrefix()}${value}${this.getSearchSuffix()}'` : ''; - if (!this.disableUpdateOnSubmit) { - this.context.update(); - } + this.context.update(); } } submitValues() { - if(!this.disableUpdateOnSubmit) { - this.updateQuery(this.value); - } + this.updateQuery(this.value); } hasValidValue() { diff --git a/lib/content-services/src/lib/search/components/search-widget-container/search-widget-container.component.ts b/lib/content-services/src/lib/search/components/search-widget-container/search-widget-container.component.ts index 1e08a9423ac..a3bce952564 100644 --- a/lib/content-services/src/lib/search/components/search-widget-container/search-widget-container.component.ts +++ b/lib/content-services/src/lib/search/components/search-widget-container/search-widget-container.component.ts @@ -57,8 +57,6 @@ export class SearchWidgetContainerComponent implements OnInit, OnDestroy, OnChan @Input() value: any; - @Input() - disableUpdateOnSubmit = false; componentRef: ComponentRef; @@ -92,7 +90,6 @@ export class SearchWidgetContainerComponent implements OnInit, OnDestroy, OnChan ref.instance.id = this.id; ref.instance.settings = {...this.settings}; ref.instance.context = this.queryBuilder; - ref.instance.disableUpdateOnSubmit = this.disableUpdateOnSubmit; if (this.value) { ref.instance.isActive = true; ref.instance.startValue = this.value; diff --git a/lib/content-services/src/lib/search/models/search-widget.interface.ts b/lib/content-services/src/lib/search/models/search-widget.interface.ts index 233899de9dd..b7dcbf58b00 100644 --- a/lib/content-services/src/lib/search/models/search-widget.interface.ts +++ b/lib/content-services/src/lib/search/models/search-widget.interface.ts @@ -25,7 +25,6 @@ export interface SearchWidget { settings?: SearchWidgetSettings; context?: SearchQueryBuilderService; isActive?: boolean; - disableUpdateOnSubmit?: boolean; startValue: any; /* stream emit value on changes */ displayValue$: Subject; From a00375ad10794b96278477445c855b62b6050129 Mon Sep 17 00:00:00 2001 From: "swapnil.verma" Date: Wed, 28 Jun 2023 16:21:48 +0530 Subject: [PATCH 27/54] [ACS-4985] Resolved minor issues where switching between tabs could sometime cause the tab content to not show up --- .../search-filter-tabbed/search-filter-tabbed.component.scss | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/content-services/src/lib/search/components/search-filter-tabbed/search-filter-tabbed.component.scss b/lib/content-services/src/lib/search/components/search-filter-tabbed/search-filter-tabbed.component.scss index fa74c8d502d..f79be8036fe 100644 --- a/lib/content-services/src/lib/search/components/search-filter-tabbed/search-filter-tabbed.component.scss +++ b/lib/content-services/src/lib/search/components/search-filter-tabbed/search-filter-tabbed.component.scss @@ -17,4 +17,9 @@ adf-search-filter-tabbed { .mat-ink-bar { display: none; } + + .mat-tab-body.mat-tab-body-active .mat-tab-body-content { + display: block; + visibility: visible !important; + } } From 68047e4f1e91239384f32300f692de09e9d03cce Mon Sep 17 00:00:00 2001 From: "swapnil.verma" Date: Wed, 28 Jun 2023 16:52:54 +0530 Subject: [PATCH 28/54] [ACS-4985] Resolved linting and unit test issues --- .../search-date-range-advanced-tabbed.component.scss | 0 .../search-filter-tabbed.component.spec.ts | 6 +++--- 2 files changed, 3 insertions(+), 3 deletions(-) delete mode 100644 lib/content-services/src/lib/search/components/search-date-range-advanced-tabbed/search-date-range-advanced-tabbed.component.scss diff --git a/lib/content-services/src/lib/search/components/search-date-range-advanced-tabbed/search-date-range-advanced-tabbed.component.scss b/lib/content-services/src/lib/search/components/search-date-range-advanced-tabbed/search-date-range-advanced-tabbed.component.scss deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/lib/content-services/src/lib/search/components/search-filter-tabbed/search-filter-tabbed.component.spec.ts b/lib/content-services/src/lib/search/components/search-filter-tabbed/search-filter-tabbed.component.spec.ts index 5f0bade35a2..7939bb28b1e 100644 --- a/lib/content-services/src/lib/search/components/search-filter-tabbed/search-filter-tabbed.component.spec.ts +++ b/lib/content-services/src/lib/search/components/search-filter-tabbed/search-filter-tabbed.component.spec.ts @@ -57,7 +57,7 @@ describe('SearchFilterTabbedComponent', () => { testField2: 'Field 2', testField3: 'Field 3' } - } + }; component.valuesToDisplay = { testField1: 'test-display-value-1', testField2: 'test-display-value-2', @@ -76,13 +76,13 @@ describe('SearchFilterTabbedComponent', () => { testField2: 'Field 2', testField3: 'Field 3' } - } + }; fixture.detectChanges(); const displayedLabelsMap = { testField1: 'Field 1', testField2: 'Field 2', testField3: 'Field 3' - } + }; expect(component.displayedLabelsByFieldTranslated.emit).toHaveBeenCalledWith(displayedLabelsMap); }); From a75d6ebe15de3e4d1e665a39dac8986b1bb4689f Mon Sep 17 00:00:00 2001 From: "swapnil.verma" Date: Wed, 28 Jun 2023 17:18:59 +0530 Subject: [PATCH 29/54] [ACS-4985] Resolved PR review comments --- .../search-widget-chip/search-widget-chip.component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/content-services/src/lib/search/components/search-filter-chips/search-widget-chip/search-widget-chip.component.ts b/lib/content-services/src/lib/search/components/search-filter-chips/search-widget-chip/search-widget-chip.component.ts index 29acaad85cd..4ff847a7531 100644 --- a/lib/content-services/src/lib/search/components/search-filter-chips/search-widget-chip/search-widget-chip.component.ts +++ b/lib/content-services/src/lib/search/components/search-filter-chips/search-widget-chip/search-widget-chip.component.ts @@ -19,7 +19,7 @@ import { Component, ElementRef, Input, ViewChild, ViewEncapsulation } from '@ang import { SearchCategory } from '../../../models/search-category.interface'; import { ConfigurableFocusTrap, ConfigurableFocusTrapFactory } from '@angular/cdk/a11y'; import { MatMenuTrigger } from '@angular/material/menu'; -import { SearchWidgetContainerComponent } from '../../search-widget-container/search-widget-container.component';; +import { SearchWidgetContainerComponent } from '../../search-widget-container/search-widget-container.component'; @Component({ selector: 'adf-search-widget-chip', From 05f2524967a24f4aeff3101f8abbca78044d59ca Mon Sep 17 00:00:00 2001 From: "swapnil.verma" Date: Tue, 4 Jul 2023 15:28:08 +0530 Subject: [PATCH 30/54] [ACS-4985] Removed unused code from base-query-builder.service.ts --- .../services/base-query-builder.service.ts | 25 ++++--------------- 1 file changed, 5 insertions(+), 20 deletions(-) diff --git a/lib/content-services/src/lib/search/services/base-query-builder.service.ts b/lib/content-services/src/lib/search/services/base-query-builder.service.ts index 6979f3b118d..c0446f98a08 100644 --- a/lib/content-services/src/lib/search/services/base-query-builder.service.ts +++ b/lib/content-services/src/lib/search/services/base-query-builder.service.ts @@ -487,27 +487,12 @@ export abstract class BaseQueryBuilderService { let query = ''; this.categories.forEach((facet) => { - let customQuery: string; - - if (facet.component.selector === 'widget-composite') { - const widgetTabs: any[] = facet.component.settings.tabs; - widgetTabs.forEach(tab => { - customQuery = this.queryFragments[tab.id]; - if (customQuery) { - if (query.length > 0) { - query += ' AND '; - } - query += `(${customQuery})`; - } - }); - } else { - customQuery = this.queryFragments[facet.id]; - if (customQuery) { - if (query.length > 0) { - query += ' AND '; - } - query += `(${customQuery})`; + const customQuery = this.queryFragments[facet.id]; + if (customQuery) { + if (query.length > 0) { + query += ' AND '; } + query += `(${customQuery})`; } }); From b16fd582434d456c0b2fa0176591f485863709be Mon Sep 17 00:00:00 2001 From: "swapnil.verma" Date: Tue, 4 Jul 2023 15:57:49 +0530 Subject: [PATCH 31/54] [ACS-4985] Resolved PR review comments --- ...te-range-advanced-tabbed.component.spec.ts | 2 +- ...arch-date-range-advanced.component.spec.ts | 3 +-- .../search-date-range-advanced.component.ts | 23 +++++++++++++++++++ .../search-filter-tabbed.component.scss | 5 ++-- .../search-filter-tabbed.component.spec.ts | 10 ++++---- .../search-widget-container.component.ts | 1 - 6 files changed, 32 insertions(+), 12 deletions(-) diff --git a/lib/content-services/src/lib/search/components/search-date-range-advanced-tabbed/search-date-range-advanced-tabbed.component.spec.ts b/lib/content-services/src/lib/search/components/search-date-range-advanced-tabbed/search-date-range-advanced-tabbed.component.spec.ts index 6602811186b..4f5e41c99a0 100644 --- a/lib/content-services/src/lib/search/components/search-date-range-advanced-tabbed/search-date-range-advanced-tabbed.component.spec.ts +++ b/lib/content-services/src/lib/search/components/search-date-range-advanced-tabbed/search-date-range-advanced-tabbed.component.spec.ts @@ -62,7 +62,7 @@ export class MockSearchDateRangeAdvancedComponent { @Output() valid = new EventEmitter(); } -describe('SearchDateRangeAdvancedTabbedComponent', () => { +fdescribe('SearchDateRangeAdvancedTabbedComponent', () => { let component: SearchDateRangeAdvancedTabbedComponent; let fixture: ComponentFixture; let betweenMockData: SearchDateRangeAdvanced; diff --git a/lib/content-services/src/lib/search/components/search-date-range-advanced-tabbed/search-date-range-advanced/search-date-range-advanced.component.spec.ts b/lib/content-services/src/lib/search/components/search-date-range-advanced-tabbed/search-date-range-advanced/search-date-range-advanced.component.spec.ts index 43fc7598254..fa570f6c6be 100644 --- a/lib/content-services/src/lib/search/components/search-date-range-advanced-tabbed/search-date-range-advanced/search-date-range-advanced.component.spec.ts +++ b/lib/content-services/src/lib/search/components/search-date-range-advanced-tabbed/search-date-range-advanced/search-date-range-advanced.component.spec.ts @@ -63,13 +63,12 @@ describe('SearchDateRangeAdvancedComponent', () => { fixture.detectChanges(); }; - const selectDropdownOption = async (itemId: string) => { + const selectDropdownOption = (itemId: string) => { const matSelect = fixture.debugElement.query(By.css('[data-automation-id="date-range-advanced-in-last-dropdown"]')).nativeElement; matSelect.click(); fixture.detectChanges(); const matOption = fixture.debugElement.query(By.css(`[data-automation-id="${itemId}"]`)).nativeElement; matOption.click(); - await fixture.whenStable(); fixture.detectChanges(); }; diff --git a/lib/content-services/src/lib/search/components/search-date-range-advanced-tabbed/search-date-range-advanced/search-date-range-advanced.component.ts b/lib/content-services/src/lib/search/components/search-date-range-advanced-tabbed/search-date-range-advanced/search-date-range-advanced.component.ts index d0792a9c196..99c26ce011e 100644 --- a/lib/content-services/src/lib/search/components/search-date-range-advanced-tabbed/search-date-range-advanced/search-date-range-advanced.component.ts +++ b/lib/content-services/src/lib/search/components/search-date-range-advanced-tabbed/search-date-range-advanced/search-date-range-advanced.component.ts @@ -177,4 +177,27 @@ export class SearchDateRangeAdvancedComponent implements OnInit, OnDestroy { return true; } } + + // dateChanged(event: Event, formControl: FormControl) { + // clearTimeout(this.dateChangeDebounce); + // this.dateChangeDebounce = window.setTimeout(() => { + // if (!event?.target['value']) { + // formControl.errors.required = true; + // formControl.errors.dateFormatInvalid = false; + // } else { + // const date = parse(event.target['value'], this.datePickerFormat, new Date()); + // if(!isValid(date)) { + // formControl.errors.dateFormatInvalid = true; + // } else { + // formControl.errors.dateFormatInvalid = false; + // formControl.setValue(date); + // } + // } + // }, 500); + // } + + onLastDateValueChanged(event: Event) { + let value: string = event.target['value']; + event.target['value'] = value.replace(/[-.]*0*([1-9]*[0-9]*)/g, '$1'); + } } diff --git a/lib/content-services/src/lib/search/components/search-filter-tabbed/search-filter-tabbed.component.scss b/lib/content-services/src/lib/search/components/search-filter-tabbed/search-filter-tabbed.component.scss index f79be8036fe..ff0f0f82f5b 100644 --- a/lib/content-services/src/lib/search/components/search-filter-tabbed/search-filter-tabbed.component.scss +++ b/lib/content-services/src/lib/search/components/search-filter-tabbed/search-filter-tabbed.component.scss @@ -18,8 +18,7 @@ adf-search-filter-tabbed { display: none; } - .mat-tab-body.mat-tab-body-active .mat-tab-body-content { - display: block; - visibility: visible !important; + .mat-ink-bar { + display: none; } } diff --git a/lib/content-services/src/lib/search/components/search-filter-tabbed/search-filter-tabbed.component.spec.ts b/lib/content-services/src/lib/search/components/search-filter-tabbed/search-filter-tabbed.component.spec.ts index 7939bb28b1e..0f744fcd6df 100644 --- a/lib/content-services/src/lib/search/components/search-filter-tabbed/search-filter-tabbed.component.spec.ts +++ b/lib/content-services/src/lib/search/components/search-filter-tabbed/search-filter-tabbed.component.spec.ts @@ -20,12 +20,12 @@ import { TranslateModule } from '@ngx-translate/core'; import { ContentTestingModule } from '../../../testing/content.testing.module'; import { SearchFilterTabbedComponent } from './search-filter-tabbed.component'; -describe('SearchFilterTabbedComponent', () => { +fdescribe('SearchFilterTabbedComponent', () => { let component: SearchFilterTabbedComponent; let fixture: ComponentFixture; - beforeEach(async () => { - await TestBed.configureTestingModule({ + beforeEach(() => { + TestBed.configureTestingModule({ declarations: [SearchFilterTabbedComponent], imports: [ TranslateModule.forRoot(), @@ -49,7 +49,7 @@ describe('SearchFilterTabbedComponent', () => { }); it ('should emit a single combined value to display when multiple display values are provided', () => { - spyOn(component.valuesToDisplayCombined, 'emit'); + spyOn(component.valuesToDisplayCombined, 'emit'); component.settings = { field: 'testField1, testField2, testField3', displayedLabelsByField: { @@ -87,7 +87,7 @@ describe('SearchFilterTabbedComponent', () => { }); it('should emit an array of fields when all the fields are provided in a combined string via settings', () => { - spyOn(component.fieldsChanged, 'emit'); + spyOn(component.fieldsChanged, 'emit'); component.settings = { field: 'testField1, testField2, testField3' }; diff --git a/lib/content-services/src/lib/search/components/search-widget-container/search-widget-container.component.ts b/lib/content-services/src/lib/search/components/search-widget-container/search-widget-container.component.ts index a3bce952564..1455e456d2c 100644 --- a/lib/content-services/src/lib/search/components/search-widget-container/search-widget-container.component.ts +++ b/lib/content-services/src/lib/search/components/search-widget-container/search-widget-container.component.ts @@ -57,7 +57,6 @@ export class SearchWidgetContainerComponent implements OnInit, OnDestroy, OnChan @Input() value: any; - componentRef: ComponentRef; constructor( From 884568e13662104bf42e88155066223869e39290 Mon Sep 17 00:00:00 2001 From: "swapnil.verma" Date: Thu, 6 Jul 2023 12:01:36 +0530 Subject: [PATCH 32/54] [ACS-4985] Transferred business logic from SearchDateRangeAdvancedComponent and SearchFilterTabbedComponent to SearchDateRangeAdvancedTabbedComponent. Updated test cases accordingly --- ...-date-range-advanced-tabbed.component.html | 10 -- ...te-range-advanced-tabbed.component.spec.ts | 11 +- ...ch-date-range-advanced-tabbed.component.ts | 43 +++++-- ...arch-date-range-advanced.component.spec.ts | 121 ++++++++++++++++++ .../search-date-range-advanced.component.ts | 2 +- .../search-filter-tabbed.component.spec.ts | 97 -------------- 6 files changed, 166 insertions(+), 118 deletions(-) delete mode 100644 lib/content-services/src/lib/search/components/search-filter-tabbed/search-filter-tabbed.component.spec.ts diff --git a/lib/content-services/src/lib/search/components/search-date-range-advanced-tabbed/search-date-range-advanced-tabbed.component.html b/lib/content-services/src/lib/search/components/search-date-range-advanced-tabbed/search-date-range-advanced-tabbed.component.html index 8702520ae53..45047255aa2 100644 --- a/lib/content-services/src/lib/search/components/search-date-range-advanced-tabbed/search-date-range-advanced-tabbed.component.html +++ b/lib/content-services/src/lib/search/components/search-date-range-advanced-tabbed/search-date-range-advanced-tabbed.component.html @@ -11,13 +11,3 @@ - -
- - -
- diff --git a/lib/content-services/src/lib/search/components/search-date-range-advanced-tabbed/search-date-range-advanced-tabbed.component.spec.ts b/lib/content-services/src/lib/search/components/search-date-range-advanced-tabbed/search-date-range-advanced-tabbed.component.spec.ts index 4f5e41c99a0..065e683a6d9 100644 --- a/lib/content-services/src/lib/search/components/search-date-range-advanced-tabbed/search-date-range-advanced-tabbed.component.spec.ts +++ b/lib/content-services/src/lib/search/components/search-date-range-advanced-tabbed/search-date-range-advanced-tabbed.component.spec.ts @@ -47,7 +47,7 @@ export class MockSearchFilterTabbedComponent {} selector: 'adf-search-date-range-advanced', template: `` }) -export class MockSearchDateRangeAdvancedComponent { +class MockSearchDateRangeAdvancedComponent { @Input() dateFormat: string; @Input() @@ -62,7 +62,7 @@ export class MockSearchDateRangeAdvancedComponent { @Output() valid = new EventEmitter(); } -fdescribe('SearchDateRangeAdvancedTabbedComponent', () => { +describe('SearchDateRangeAdvancedTabbedComponent', () => { let component: SearchDateRangeAdvancedTabbedComponent; let fixture: ComponentFixture; let betweenMockData: SearchDateRangeAdvanced; @@ -82,6 +82,7 @@ fdescribe('SearchDateRangeAdvancedTabbedComponent', () => { ] }); fixture = TestBed.createComponent(SearchDateRangeAdvancedTabbedComponent); + component = fixture.componentInstance; component.id = 'dateRangeAdvanced'; component.context = { @@ -128,6 +129,10 @@ fdescribe('SearchDateRangeAdvancedTabbedComponent', () => { }; fixture.detectChanges(); + + const searchDateRangeAdvancedComponentList = fixture.debugElement.queryAll(By.directive(SearchDateRangeAdvancedComponent)); + createdDateRangeComponent = searchDateRangeAdvancedComponentList.find(searchDateRangeAdvancedComponent => (searchDateRangeAdvancedComponent.componentInstance as SearchDateRangeAdvancedComponent).field === 'createdDate').componentInstance; + // modifiedDateRangeComponent = searchDateRangeAdvancedComponentList.find(searchDateRangeAdvancedComponent => searchDateRangeAdvancedComponent.attributes['field'] === 'modifiedDate').componentInstance; }); it('should be able to generate separate fields on init', () => { @@ -232,4 +237,6 @@ fdescribe('SearchDateRangeAdvancedTabbedComponent', () => { expect(component.context.queryFragments['dateRangeAdvanced']).toEqual(''); expect(component.context.update).toHaveBeenCalled(); }); + + }); diff --git a/lib/content-services/src/lib/search/components/search-date-range-advanced-tabbed/search-date-range-advanced-tabbed.component.ts b/lib/content-services/src/lib/search/components/search-date-range-advanced-tabbed/search-date-range-advanced-tabbed.component.ts index cbcc39e26d1..f5123725bb8 100644 --- a/lib/content-services/src/lib/search/components/search-date-range-advanced-tabbed/search-date-range-advanced-tabbed.component.ts +++ b/lib/content-services/src/lib/search/components/search-date-range-advanced-tabbed/search-date-range-advanced-tabbed.component.ts @@ -177,19 +177,46 @@ export class SearchDateRangeAdvancedTabbedComponent implements SearchWidget, OnI this.combinedValuesToDisplay = valuesToDisplay; } - onTabValid(tabValid: boolean, field: string) { - this.tabsValidity[field] = tabValid; + private generateQuery(value: Partial, field: string): string { + let query = ''; + if (value.dateRangeType === DateRangeType.IN_LAST) { + query = `${field}:[NOW/DAY-${value.inLastValue}${value.inLastValueType} TO NOW/DAY+1DAY]`; + } else if (value.dateRangeType === DateRangeType.BETWEEN) { + query = `${field}:['${formatISO(startOfDay(value.betweenStartDate))}' TO '${formatISO(endOfDay(value.betweenEndDate))}']`; + } + return query; } - onDateRangedValueChanged(value: Partial, field: string) { - this.value[field] = value; + private generateDisplayValue(value: Partial): string { + let displayValue = ''; + if (value.dateRangeType === DateRangeType.IN_LAST && value.inLastValue) { + displayValue = this.translateService.instant(`SEARCH.DATE_RANGE_ADVANCED.IN_LAST_DISPLAY_LABELS.${value.inLastValueType}`, { + value: value.inLastValue + }); + } else if (value.dateRangeType === DateRangeType.BETWEEN && value.betweenStartDate && value.betweenEndDate) { + displayValue = `${format(startOfDay(value.betweenStartDate), this.settings.dateFormat)} - ${format(endOfDay(value.betweenEndDate), this.settings.dateFormat)}`; + } + return displayValue; } - onFieldsChanged(fields: string[]) { - this.fields = fields; + private updateQuery(value: Partial, field: string) { + this.combinedQuery = ''; + this.queryMapByField.set(field, this.generateQuery(value, field)); + this.queryMapByField.forEach((query: string) => { + if (query) { + this.combinedQuery = this.combinedQuery ? `${this.combinedQuery} AND ${query}` : `${query}`; + } + }); } - onDisplayLabelsByFieldsTranslated(displayedLabelsByField: { [p: string]: string }) { - this.displayedLabelsByField = displayedLabelsByField; + private updateDisplayValue(value: Partial, field: string) { + this.combinedDisplayValue = ''; + this.displayValueMapByField.set(field, this.generateDisplayValue(value)); + this.displayValueMapByField.forEach((displayValue: string, field: string) => { + if (displayValue) { + const displayLabelForField = `${this.translateService.instant(this.settings.displayedLabelsByField[field]).toUpperCase()}: ${displayValue}`; + this.combinedDisplayValue = this.combinedDisplayValue ? `${this.combinedDisplayValue} ${displayLabelForField}` : `${displayLabelForField}` + } + }); } } diff --git a/lib/content-services/src/lib/search/components/search-date-range-advanced-tabbed/search-date-range-advanced/search-date-range-advanced.component.spec.ts b/lib/content-services/src/lib/search/components/search-date-range-advanced-tabbed/search-date-range-advanced/search-date-range-advanced.component.spec.ts index fa570f6c6be..099d6509b12 100644 --- a/lib/content-services/src/lib/search/components/search-date-range-advanced-tabbed/search-date-range-advanced/search-date-range-advanced.component.spec.ts +++ b/lib/content-services/src/lib/search/components/search-date-range-advanced-tabbed/search-date-range-advanced/search-date-range-advanced.component.spec.ts @@ -278,4 +278,125 @@ describe('SearchDateRangeAdvancedComponent', () => { fixture.detectChanges(); expect(component.changed.emit).toHaveBeenCalledWith(value); }); + + it('should not be able to set zero or negative values in In the last input field', () => { + component.form.controls.dateRangeType.setValue(component.DateRangeType.IN_LAST); + fixture.detectChanges(); + enterValueInInputField('date-range-advanced-in-last-input', '-5'); + fixture.detectChanges(); + let inLastInputFieldValue = getElementBySelector('[data-automation-id="date-range-advanced-in-last-input"]').value; + expect(inLastInputFieldValue).toBe('5'); + + enterValueInInputField('date-range-advanced-in-last-input', '0'); + fixture.detectChanges(); + inLastInputFieldValue = getElementBySelector('[data-automation-id="date-range-advanced-in-last-input"]').value; + expect(inLastInputFieldValue).toBe(''); + }); + + it('should emit valid as false when form is invalid', () => { + spyOn(component.valid, 'emit'); + component.form.controls.dateRangeType.setValue(component.DateRangeType.IN_LAST); + fixture.detectChanges(); + enterValueInInputField('date-range-advanced-in-last-input', ''); + selectDropdownOption('date-range-advanced-in-last-option-weeks'); + fixture.detectChanges(); + expect(component.valid.emit).toHaveBeenCalledWith(false); + + component.form.controls.dateRangeType.setValue(component.DateRangeType.BETWEEN); + fixture.detectChanges(); + expect(component.valid.emit).toHaveBeenCalledWith(false); + }); + + it('should emit valid as true when form is valid', () => { + spyOn(component.valid, 'emit'); + component.form.controls.dateRangeType.setValue(component.DateRangeType.IN_LAST); + fixture.detectChanges(); + enterValueInInputField('date-range-advanced-in-last-input', '5'); + selectDropdownOption('date-range-advanced-in-last-option-weeks'); + fixture.detectChanges(); + expect(component.valid.emit).toHaveBeenCalledWith(true); + + component.form.controls.dateRangeType.setValue(component.DateRangeType.BETWEEN); + fixture.detectChanges(); + component.betweenStartDateFormControl.setValue(startDateSampleValue); + component.betweenEndDateFormControl.setValue(endDateSampleValue); + fixture.detectChanges(); + expect(component.valid.emit).toHaveBeenCalledWith(true); + }); + + it('should not emit values when form is invalid', () => { + spyOn(component.changed, 'emit'); + let value = { + dateRangeType: component.DateRangeType.IN_LAST, + inLastValueType: component.InLastDateType.WEEKS, + inLastValue: '', + betweenStartDate: undefined, + betweenEndDate: undefined + }; + let dateRangeTypeRadioButton = getElementBySelector('[data-automation-id="date-range-advanced-in-last"] .mat-radio-input'); + dateRangeTypeRadioButton.click(); + selectDropdownOption('date-range-advanced-in-last-option-weeks'); + enterValueInInputField('date-range-advanced-in-last-input', ''); + fixture.detectChanges(); + expect(component.changed.emit).not.toHaveBeenCalledWith(value); + + component.form.patchValue({ + dateRangeType: component.DateRangeType.ANY, + inLastValueType: component.InLastDateType.DAYS, + inLastValue: undefined, + betweenStartDate: undefined, + betweenEndDate: undefined + }); + + value = { + dateRangeType: component.DateRangeType.BETWEEN, + inLastValueType: component.InLastDateType.DAYS, + inLastValue: undefined, + betweenStartDate: '', + betweenEndDate: '' + } + dateRangeTypeRadioButton = getElementBySelector('[data-automation-id="date-range-advanced-between"] .mat-radio-input'); + dateRangeTypeRadioButton.click(); + fixture.detectChanges(); + expect(component.changed.emit).not.toHaveBeenCalledWith(value); + }); + + it('should emit values when form is valid', () => { + spyOn(component.changed, 'emit'); + let value = { + dateRangeType: component.DateRangeType.IN_LAST, + inLastValueType: component.InLastDateType.WEEKS, + inLastValue: 5, + betweenStartDate: null, + betweenEndDate: null + }; + let dateRangeTypeRadioButton = getElementBySelector('[data-automation-id="date-range-advanced-in-last"] .mat-radio-input'); + dateRangeTypeRadioButton.click(); + selectDropdownOption('date-range-advanced-in-last-option-weeks'); + enterValueInInputField('date-range-advanced-in-last-input', '5'); + fixture.detectChanges(); + expect(component.changed.emit).toHaveBeenCalledWith(value); + + component.form.patchValue({ + dateRangeType: component.DateRangeType.ANY, + inLastValueType: component.InLastDateType.DAYS, + inLastValue: undefined, + betweenStartDate: undefined, + betweenEndDate: undefined + }); + + value = { + dateRangeType: component.DateRangeType.BETWEEN, + inLastValueType: component.InLastDateType.DAYS, + inLastValue: undefined, + betweenStartDate: startDateSampleValue, + betweenEndDate: endDateSampleValue + } + dateRangeTypeRadioButton = getElementBySelector('[data-automation-id="date-range-advanced-between"] .mat-radio-input'); + dateRangeTypeRadioButton.click(); + component.betweenStartDateFormControl.setValue(startDateSampleValue); + component.betweenEndDateFormControl.setValue(endDateSampleValue); + fixture.detectChanges(); + expect(component.changed.emit).toHaveBeenCalledWith(value); + }); }); diff --git a/lib/content-services/src/lib/search/components/search-date-range-advanced-tabbed/search-date-range-advanced/search-date-range-advanced.component.ts b/lib/content-services/src/lib/search/components/search-date-range-advanced-tabbed/search-date-range-advanced/search-date-range-advanced.component.ts index 99c26ce011e..804c181a716 100644 --- a/lib/content-services/src/lib/search/components/search-date-range-advanced-tabbed/search-date-range-advanced/search-date-range-advanced.component.ts +++ b/lib/content-services/src/lib/search/components/search-date-range-advanced-tabbed/search-date-range-advanced/search-date-range-advanced.component.ts @@ -185,7 +185,7 @@ export class SearchDateRangeAdvancedComponent implements OnInit, OnDestroy { // formControl.errors.required = true; // formControl.errors.dateFormatInvalid = false; // } else { - // const date = parse(event.target['value'], this.datePickerFormat, new Date()); + // const date = parse(event.target['value'], this.dateFormat, new Date()); // if(!isValid(date)) { // formControl.errors.dateFormatInvalid = true; // } else { diff --git a/lib/content-services/src/lib/search/components/search-filter-tabbed/search-filter-tabbed.component.spec.ts b/lib/content-services/src/lib/search/components/search-filter-tabbed/search-filter-tabbed.component.spec.ts deleted file mode 100644 index 0f744fcd6df..00000000000 --- a/lib/content-services/src/lib/search/components/search-filter-tabbed/search-filter-tabbed.component.spec.ts +++ /dev/null @@ -1,97 +0,0 @@ -/*! - * @license - * Copyright © 2005-2023 Hyland Software, Inc. and its affiliates. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { ComponentFixture, TestBed } from '@angular/core/testing'; -import { TranslateModule } from '@ngx-translate/core'; -import { ContentTestingModule } from '../../../testing/content.testing.module'; -import { SearchFilterTabbedComponent } from './search-filter-tabbed.component'; - -fdescribe('SearchFilterTabbedComponent', () => { - let component: SearchFilterTabbedComponent; - let fixture: ComponentFixture; - - beforeEach(() => { - TestBed.configureTestingModule({ - declarations: [SearchFilterTabbedComponent], - imports: [ - TranslateModule.forRoot(), - ContentTestingModule - ] - }); - fixture = TestBed.createComponent(SearchFilterTabbedComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should emit a single combined query when multiple queries are provided', () => { - spyOn(component.queriesCombined, 'emit'); - component.queries = { - testField1: 'test-query-1', - testField2: 'test-query-2', - testField3: 'test-query-3' - }; - fixture.detectChanges(); - expect(component.queriesCombined.emit).toHaveBeenCalledWith('test-query-1 AND test-query-2 AND test-query-3'); - }); - - it ('should emit a single combined value to display when multiple display values are provided', () => { - spyOn(component.valuesToDisplayCombined, 'emit'); - component.settings = { - field: 'testField1, testField2, testField3', - displayedLabelsByField: { - testField1: 'Field 1', - testField2: 'Field 2', - testField3: 'Field 3' - } - }; - component.valuesToDisplay = { - testField1: 'test-display-value-1', - testField2: 'test-display-value-2', - testField3: 'test-display-value-3' - }; - fixture.detectChanges(); - expect(component.valuesToDisplayCombined.emit).toHaveBeenCalledWith('FIELD 1: test-display-value-1 FIELD 2: test-display-value-2 FIELD 3: test-display-value-3'); - }); - - it('should emit translated display labels by field when settings are set', () => { - spyOn(component.displayedLabelsByFieldTranslated, 'emit'); - component.settings = { - field: 'testField1, testField2, testField3', - displayedLabelsByField: { - testField1: 'Field 1', - testField2: 'Field 2', - testField3: 'Field 3' - } - }; - fixture.detectChanges(); - const displayedLabelsMap = { - testField1: 'Field 1', - testField2: 'Field 2', - testField3: 'Field 3' - }; - expect(component.displayedLabelsByFieldTranslated.emit).toHaveBeenCalledWith(displayedLabelsMap); - }); - - it('should emit an array of fields when all the fields are provided in a combined string via settings', () => { - spyOn(component.fieldsChanged, 'emit'); - component.settings = { - field: 'testField1, testField2, testField3' - }; - fixture.detectChanges(); - expect(component.fieldsChanged.emit).toHaveBeenCalledWith(['testField1', 'testField2', 'testField3']); - }); -}); From 33575c54b919c724d1e85dc94d573d751411a2d7 Mon Sep 17 00:00:00 2001 From: "swapnil.verma" Date: Thu, 6 Jul 2023 12:52:43 +0530 Subject: [PATCH 33/54] [ACS-4985] Updated test cases for SearchDateRangeAdvancedTabbedComponent --- .../search-date-range-advanced-tabbed.component.spec.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/content-services/src/lib/search/components/search-date-range-advanced-tabbed/search-date-range-advanced-tabbed.component.spec.ts b/lib/content-services/src/lib/search/components/search-date-range-advanced-tabbed/search-date-range-advanced-tabbed.component.spec.ts index 065e683a6d9..7309eff9d8a 100644 --- a/lib/content-services/src/lib/search/components/search-date-range-advanced-tabbed/search-date-range-advanced-tabbed.component.spec.ts +++ b/lib/content-services/src/lib/search/components/search-date-range-advanced-tabbed/search-date-range-advanced-tabbed.component.spec.ts @@ -47,7 +47,7 @@ export class MockSearchFilterTabbedComponent {} selector: 'adf-search-date-range-advanced', template: `` }) -class MockSearchDateRangeAdvancedComponent { +export class MockSearchDateRangeAdvancedComponent { @Input() dateFormat: string; @Input() @@ -237,6 +237,4 @@ describe('SearchDateRangeAdvancedTabbedComponent', () => { expect(component.context.queryFragments['dateRangeAdvanced']).toEqual(''); expect(component.context.update).toHaveBeenCalled(); }); - - }); From f937cbf2f5490b405a2148bd04292a96edd61ff4 Mon Sep 17 00:00:00 2001 From: "swapnil.verma" Date: Thu, 6 Jul 2023 17:48:16 +0530 Subject: [PATCH 34/54] [ACS-4985] Added borders to inputs --- .../search-date-range-advanced.component.scss | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/content-services/src/lib/search/components/search-date-range-advanced-tabbed/search-date-range-advanced/search-date-range-advanced.component.scss b/lib/content-services/src/lib/search/components/search-date-range-advanced-tabbed/search-date-range-advanced/search-date-range-advanced.component.scss index a24ad08732e..c6956c7245e 100644 --- a/lib/content-services/src/lib/search/components/search-date-range-advanced-tabbed/search-date-range-advanced/search-date-range-advanced.component.scss +++ b/lib/content-services/src/lib/search/components/search-date-range-advanced-tabbed/search-date-range-advanced/search-date-range-advanced.component.scss @@ -40,6 +40,7 @@ margin-top: 2em; } } + } } } From f62f74b098aeaf9a47908f36cc5ac9cc308a5b2e Mon Sep 17 00:00:00 2001 From: "swapnil.verma" Date: Mon, 10 Jul 2023 12:55:25 +0530 Subject: [PATCH 35/54] [ACS-4985] Fixed code smell in regex --- .../search-date-range-advanced.component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/content-services/src/lib/search/components/search-date-range-advanced-tabbed/search-date-range-advanced/search-date-range-advanced.component.ts b/lib/content-services/src/lib/search/components/search-date-range-advanced-tabbed/search-date-range-advanced/search-date-range-advanced.component.ts index 804c181a716..f6c6c2ff126 100644 --- a/lib/content-services/src/lib/search/components/search-date-range-advanced-tabbed/search-date-range-advanced/search-date-range-advanced.component.ts +++ b/lib/content-services/src/lib/search/components/search-date-range-advanced-tabbed/search-date-range-advanced/search-date-range-advanced.component.ts @@ -198,6 +198,6 @@ export class SearchDateRangeAdvancedComponent implements OnInit, OnDestroy { onLastDateValueChanged(event: Event) { let value: string = event.target['value']; - event.target['value'] = value.replace(/[-.]*0*([1-9]*[0-9]*)/g, '$1'); + event.target['value'] = value.replace(/[-.]*0*([1-9]*\d*)/g, '$1'); } } From c4aaa8ff590075d9ed186dc396f131977718bcd3 Mon Sep 17 00:00:00 2001 From: "swapnil.verma" Date: Mon, 10 Jul 2023 13:23:43 +0530 Subject: [PATCH 36/54] [ACS-4985] Resolved lint issues --- .../search-date-range-advanced-tabbed.component.ts | 6 +++--- .../search-date-range-advanced.component.scss | 1 - .../search-date-range-advanced.component.ts | 7 ++++++- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/content-services/src/lib/search/components/search-date-range-advanced-tabbed/search-date-range-advanced-tabbed.component.ts b/lib/content-services/src/lib/search/components/search-date-range-advanced-tabbed/search-date-range-advanced-tabbed.component.ts index f5123725bb8..8d4ed06a5c4 100644 --- a/lib/content-services/src/lib/search/components/search-date-range-advanced-tabbed/search-date-range-advanced-tabbed.component.ts +++ b/lib/content-services/src/lib/search/components/search-date-range-advanced-tabbed/search-date-range-advanced-tabbed.component.ts @@ -212,10 +212,10 @@ export class SearchDateRangeAdvancedTabbedComponent implements SearchWidget, OnI private updateDisplayValue(value: Partial, field: string) { this.combinedDisplayValue = ''; this.displayValueMapByField.set(field, this.generateDisplayValue(value)); - this.displayValueMapByField.forEach((displayValue: string, field: string) => { + this.displayValueMapByField.forEach((displayValue: string, fieldForDisplayLabel: string) => { if (displayValue) { - const displayLabelForField = `${this.translateService.instant(this.settings.displayedLabelsByField[field]).toUpperCase()}: ${displayValue}`; - this.combinedDisplayValue = this.combinedDisplayValue ? `${this.combinedDisplayValue} ${displayLabelForField}` : `${displayLabelForField}` + const displayLabelForField = `${this.translateService.instant(this.settings.displayedLabelsByField[fieldForDisplayLabel]).toUpperCase()}: ${displayValue}`; + this.combinedDisplayValue = this.combinedDisplayValue ? `${this.combinedDisplayValue} ${displayLabelForField}` : `${displayLabelForField}`; } }); } diff --git a/lib/content-services/src/lib/search/components/search-date-range-advanced-tabbed/search-date-range-advanced/search-date-range-advanced.component.scss b/lib/content-services/src/lib/search/components/search-date-range-advanced-tabbed/search-date-range-advanced/search-date-range-advanced.component.scss index c6956c7245e..a24ad08732e 100644 --- a/lib/content-services/src/lib/search/components/search-date-range-advanced-tabbed/search-date-range-advanced/search-date-range-advanced.component.scss +++ b/lib/content-services/src/lib/search/components/search-date-range-advanced-tabbed/search-date-range-advanced/search-date-range-advanced.component.scss @@ -40,7 +40,6 @@ margin-top: 2em; } } - } } } diff --git a/lib/content-services/src/lib/search/components/search-date-range-advanced-tabbed/search-date-range-advanced/search-date-range-advanced.component.ts b/lib/content-services/src/lib/search/components/search-date-range-advanced-tabbed/search-date-range-advanced/search-date-range-advanced.component.ts index f6c6c2ff126..f590acdc8c3 100644 --- a/lib/content-services/src/lib/search/components/search-date-range-advanced-tabbed/search-date-range-advanced/search-date-range-advanced.component.ts +++ b/lib/content-services/src/lib/search/components/search-date-range-advanced-tabbed/search-date-range-advanced/search-date-range-advanced.component.ts @@ -124,6 +124,11 @@ export class SearchDateRangeAdvancedComponent implements OnInit, OnDestroy { this.betweenStartDateFormControl.clearValidators(); this.betweenEndDateFormControl.clearValidators(); break; + default: + this.form.controls.inLastValue.clearValidators(); + this.betweenStartDateFormControl.clearValidators(); + this.betweenEndDateFormControl.clearValidators(); + break; } this.betweenStartDateFormControl.updateValueAndValidity(); this.betweenEndDateFormControl.updateValueAndValidity(); @@ -197,7 +202,7 @@ export class SearchDateRangeAdvancedComponent implements OnInit, OnDestroy { // } onLastDateValueChanged(event: Event) { - let value: string = event.target['value']; + const value: string = event.target['value']; event.target['value'] = value.replace(/[-.]*0*([1-9]*\d*)/g, '$1'); } } From d4de517a03397a6dd0852f2b83cd48f1ffa382be Mon Sep 17 00:00:00 2001 From: "swapnil.verma" Date: Mon, 10 Jul 2023 16:30:22 +0530 Subject: [PATCH 37/54] [ACS-4985] Updated query generation logic. Now both 'In the last' and 'Between' options use the start date to end date query format --- ...ch-date-range-advanced-tabbed.component.ts | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/lib/content-services/src/lib/search/components/search-date-range-advanced-tabbed/search-date-range-advanced-tabbed.component.ts b/lib/content-services/src/lib/search/components/search-date-range-advanced-tabbed/search-date-range-advanced-tabbed.component.ts index 8d4ed06a5c4..d35c0ce2b4b 100644 --- a/lib/content-services/src/lib/search/components/search-date-range-advanced-tabbed/search-date-range-advanced-tabbed.component.ts +++ b/lib/content-services/src/lib/search/components/search-date-range-advanced-tabbed/search-date-range-advanced-tabbed.component.ts @@ -180,9 +180,26 @@ export class SearchDateRangeAdvancedTabbedComponent implements SearchWidget, OnI private generateQuery(value: Partial, field: string): string { let query = ''; if (value.dateRangeType === DateRangeType.IN_LAST) { - query = `${field}:[NOW/DAY-${value.inLastValue}${value.inLastValueType} TO NOW/DAY+1DAY]`; + switch(value.inLastValueType) { + case InLastDateType.DAYS: + startDate = startOfDay(subDays(new Date(), parseInt(value.inLastValue))); + break; + case InLastDateType.WEEKS: + startDate = startOfWeek(subWeeks(new Date(), parseInt(value.inLastValue))); + break; + case InLastDateType.MONTHS: + startDate = startOfMonth(subMonths(new Date(), parseInt(value.inLastValue))); + break; + default: + break; + } + endDate = endOfToday(); } else if (value.dateRangeType === DateRangeType.BETWEEN) { - query = `${field}:['${formatISO(startOfDay(value.betweenStartDate))}' TO '${formatISO(endOfDay(value.betweenEndDate))}']`; + startDate = startOfDay(value.betweenStartDate); + endDate = endOfDay(value.betweenEndDate); + } + if (startDate && endDate) { + query = `${field}:['${formatISO(startDate)}' TO '${formatISO(endDate)}']`; } return query; } From fd2ee246baa7b924ab8c0f2c00702dfd4d8fa67c Mon Sep 17 00:00:00 2001 From: "swapnil.verma" Date: Mon, 10 Jul 2023 17:11:16 +0530 Subject: [PATCH 38/54] [ACS-4985] Added missing null check when generating query --- .../search-date-range-advanced-tabbed.component.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/content-services/src/lib/search/components/search-date-range-advanced-tabbed/search-date-range-advanced-tabbed.component.ts b/lib/content-services/src/lib/search/components/search-date-range-advanced-tabbed/search-date-range-advanced-tabbed.component.ts index d35c0ce2b4b..905d7db16d1 100644 --- a/lib/content-services/src/lib/search/components/search-date-range-advanced-tabbed/search-date-range-advanced-tabbed.component.ts +++ b/lib/content-services/src/lib/search/components/search-date-range-advanced-tabbed/search-date-range-advanced-tabbed.component.ts @@ -195,8 +195,10 @@ export class SearchDateRangeAdvancedTabbedComponent implements SearchWidget, OnI } endDate = endOfToday(); } else if (value.dateRangeType === DateRangeType.BETWEEN) { - startDate = startOfDay(value.betweenStartDate); - endDate = endOfDay(value.betweenEndDate); + if (value.betweenStartDate && value.betweenEndDate) { + startDate = startOfDay(value.betweenStartDate); + endDate = endOfDay(value.betweenEndDate); + } } if (startDate && endDate) { query = `${field}:['${formatISO(startDate)}' TO '${formatISO(endDate)}']`; From fb9c13a91a2c4c58c5b7fd0740a73c1012f5e632 Mon Sep 17 00:00:00 2001 From: "swapnil.verma" Date: Tue, 11 Jul 2023 16:17:58 +0530 Subject: [PATCH 39/54] [ACS-4985] Resolved issue where typing a special character after adding some numbers in the 'In the last' input field would clear out the field --- .../search-date-range-advanced.component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/content-services/src/lib/search/components/search-date-range-advanced-tabbed/search-date-range-advanced/search-date-range-advanced.component.ts b/lib/content-services/src/lib/search/components/search-date-range-advanced-tabbed/search-date-range-advanced/search-date-range-advanced.component.ts index f590acdc8c3..ccb6947089e 100644 --- a/lib/content-services/src/lib/search/components/search-date-range-advanced-tabbed/search-date-range-advanced/search-date-range-advanced.component.ts +++ b/lib/content-services/src/lib/search/components/search-date-range-advanced-tabbed/search-date-range-advanced/search-date-range-advanced.component.ts @@ -203,6 +203,6 @@ export class SearchDateRangeAdvancedComponent implements OnInit, OnDestroy { onLastDateValueChanged(event: Event) { const value: string = event.target['value']; - event.target['value'] = value.replace(/[-.]*0*([1-9]*\d*)/g, '$1'); + event.target['value'] = value.replace(/\D*0*([1-9]*\d*)/g, '$1'); } } From 456b9d019ee6bc76bd4ab3fb6b38b9528e040c11 Mon Sep 17 00:00:00 2001 From: "swapnil.verma" Date: Fri, 14 Jul 2023 13:10:26 +0530 Subject: [PATCH 40/54] [ACS-4985] Added documentation to versionIndex.md and README.md --- docs/versionIndex.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/versionIndex.md b/docs/versionIndex.md index 887aa2fd8b0..0e3f747370e 100644 --- a/docs/versionIndex.md +++ b/docs/versionIndex.md @@ -65,6 +65,9 @@ backend services have been tested with each released version of ADF. - [Search Chip Autocomplete Input component](content-services/components/search-chip-autocomplete-input.component.md) - [Search Filter Autocomplete Chips component](content-services/components/search-filter-autocomplete-chips.component.md) - [Is Included pipe](content-services/pipes/is-included.pipe.md) +- [Search Date Range Advanced Component](content-services/components/search-date-range-advanced.component.md) +- [Search Date Range Advanced Tabbed Component](content-services/components/search-date-range-advanced-tabbed.component.md) +- [Search Filter Tabbed Component](content-services/components/search-filter-tabbed.component.md) From 3a954458b3ffb815154d73d40163ebda3470271a Mon Sep 17 00:00:00 2001 From: "swapnil.verma" Date: Fri, 14 Jul 2023 13:33:55 +0530 Subject: [PATCH 41/54] [ACS-4985] Moved new components to v6.2.0 in versionIndex.md --- docs/versionIndex.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/docs/versionIndex.md b/docs/versionIndex.md index 0e3f747370e..887aa2fd8b0 100644 --- a/docs/versionIndex.md +++ b/docs/versionIndex.md @@ -65,9 +65,6 @@ backend services have been tested with each released version of ADF. - [Search Chip Autocomplete Input component](content-services/components/search-chip-autocomplete-input.component.md) - [Search Filter Autocomplete Chips component](content-services/components/search-filter-autocomplete-chips.component.md) - [Is Included pipe](content-services/pipes/is-included.pipe.md) -- [Search Date Range Advanced Component](content-services/components/search-date-range-advanced.component.md) -- [Search Date Range Advanced Tabbed Component](content-services/components/search-date-range-advanced-tabbed.component.md) -- [Search Filter Tabbed Component](content-services/components/search-filter-tabbed.component.md) From 8dd9ff5f246c17865634dd716bf853f7c05f6480 Mon Sep 17 00:00:00 2001 From: "swapnil.verma" Date: Wed, 19 Jul 2023 12:19:26 +0530 Subject: [PATCH 42/54] [ACS-4985] Resolved e2e test failures --- e2e/search/search.config.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/e2e/search/search.config.ts b/e2e/search/search.config.ts index 89c50d1247b..863d86c882a 100644 --- a/e2e/search/search.config.ts +++ b/e2e/search/search.config.ts @@ -159,6 +159,23 @@ export class SearchConfiguration { } } }, + { + id: 'createdModifiedDateRange', + name: 'Date', + enabled: true, + component: { + selector: 'date-range-advanced', + settings: { + dateFormat: 'dd-MMM-yy', + maxDate: 'today', + field: 'cm:created, cm:modified', + displayedLabelsByField: { + "cm:created": 'Created Date', + "cm:modified": 'Modified Date' + } + } + } + }, { id: 'queryType', name: 'Type', From 354b5a472f950dd35b5b61c15b9b93d087049895 Mon Sep 17 00:00:00 2001 From: "swapnil.verma" Date: Wed, 19 Jul 2023 13:52:24 +0530 Subject: [PATCH 43/54] Testing global install of webdriver-manager for e2e webdriver fix --- scripts/test-e2e-lib.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/test-e2e-lib.sh b/scripts/test-e2e-lib.sh index 1dd2ca64bb8..a13dc6d2303 100755 --- a/scripts/test-e2e-lib.sh +++ b/scripts/test-e2e-lib.sh @@ -143,6 +143,7 @@ rm -rf ./e2e-output/ echo "====== BROWSER_RUN: $BROWSER_RUN ======" echo "====== Update webdriver-manager =====" if [ "$CI" = "true" ]; then + npm install -g webdriver-manager export chrome=$(google-chrome --product-version) echo "Updating wedriver-manager with chromedriver: $chrome." ./node_modules/protractor/bin/webdriver-manager update --gecko=false --versions.chrome=$chrome From b08093a10894c4703783855bd8b190e0dd8978b3 Mon Sep 17 00:00:00 2001 From: "swapnil.verma" Date: Thu, 20 Jul 2023 18:03:05 +0530 Subject: [PATCH 44/54] [ACS-4985] Revert test fix for e2e execution. Updated search.config.ts for e2e test cases --- e2e/search/search.config.ts | 17 ----------------- scripts/test-e2e-lib.sh | 1 - 2 files changed, 18 deletions(-) diff --git a/e2e/search/search.config.ts b/e2e/search/search.config.ts index 863d86c882a..89c50d1247b 100644 --- a/e2e/search/search.config.ts +++ b/e2e/search/search.config.ts @@ -159,23 +159,6 @@ export class SearchConfiguration { } } }, - { - id: 'createdModifiedDateRange', - name: 'Date', - enabled: true, - component: { - selector: 'date-range-advanced', - settings: { - dateFormat: 'dd-MMM-yy', - maxDate: 'today', - field: 'cm:created, cm:modified', - displayedLabelsByField: { - "cm:created": 'Created Date', - "cm:modified": 'Modified Date' - } - } - } - }, { id: 'queryType', name: 'Type', diff --git a/scripts/test-e2e-lib.sh b/scripts/test-e2e-lib.sh index a13dc6d2303..1dd2ca64bb8 100755 --- a/scripts/test-e2e-lib.sh +++ b/scripts/test-e2e-lib.sh @@ -143,7 +143,6 @@ rm -rf ./e2e-output/ echo "====== BROWSER_RUN: $BROWSER_RUN ======" echo "====== Update webdriver-manager =====" if [ "$CI" = "true" ]; then - npm install -g webdriver-manager export chrome=$(google-chrome --product-version) echo "Updating wedriver-manager with chromedriver: $chrome." ./node_modules/protractor/bin/webdriver-manager update --gecko=false --versions.chrome=$chrome From aa7daae6b931dd9c2feeba62b271190332f7bd46 Mon Sep 17 00:00:00 2001 From: Jatin_Chugh Date: Tue, 11 Jul 2023 13:35:59 +0530 Subject: [PATCH 45/54] mat-datepicker component added and removed old mat-datetimepicker component --- .../card-view-dateitem.component.html | 161 ++++++++++-------- .../card-view-dateitem.component.ts | 2 +- 2 files changed, 88 insertions(+), 75 deletions(-) diff --git a/lib/core/src/lib/card-view/components/card-view-dateitem/card-view-dateitem.component.html b/lib/core/src/lib/card-view/components/card-view-dateitem/card-view-dateitem.component.html index 8399d648a97..da4b19a0001 100644 --- a/lib/core/src/lib/card-view/components/card-view-dateitem/card-view-dateitem.component.html +++ b/lib/core/src/lib/card-view/components/card-view-dateitem/card-view-dateitem.component.html @@ -1,100 +1,113 @@ -