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 0000000000..e69de29bb2
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 55c3abb993..0000000000
--- 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 28166f5b1e..0000000000
--- 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 9be2fa0edd..0000000000
--- 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 f10c7f955c..0000000000
--- 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 0000000000..3a39b91a5d
--- /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 1040a4bb69..558c13b1ee 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 @@
-
-
-
-
-