Skip to content

Commit

Permalink
[AAE-19610] Submit query on change event for search date range tabbed…
Browse files Browse the repository at this point in the history
… widget (#9256)

* [AAE-19610] Add default actions to search date range tabbed widget

* [AAE-19610] Update filter on change

* [AAE-19610] Add tests

* [AAE-19610] Fix lint issue

* [AAE-19610] Add debounceTime

* [AAE-19610] Add wrapper to search-filter

* [AAE-19610] Fix lint

* [AAE-19610] Remove leftover changes
  • Loading branch information
DiogoABastos authored Jan 23, 2024
1 parent 720fbb9 commit fdab441
Show file tree
Hide file tree
Showing 6 changed files with 151 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<div class="adf-search-filter-card">
<adf-search-widget-container
[id]="category.id"
[selector]="category.component.selector"
[settings]="category.component.settings">
</adf-search-widget-container>
<div class="adf-search-filter-card-actions">
<button mat-button class="adf-search-action-button" (click)="clear()" id="clear-filter-button">
{{ 'SEARCH.FILTER.BUTTONS.CLEAR' | translate }}
</button>
<button mat-flat-button class="adf-search-action-button" color="primary" (click)="apply()" id="apply-filter-button">
{{ 'SEARCH.FILTER.BUTTONS.APPLY' | translate }}
</button>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
/*!
* @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 { SearchFilterCardComponent } from './search-filter-card.component';

describe('SearchFilterCardComponent', () => {
let component: SearchFilterCardComponent;
let fixture: ComponentFixture<SearchFilterCardComponent>;

const mockCategory = {
id: 'test-id',
name: 'test-name',
enabled: true,
expanded: false,
component: {
selector: 'date-range',
settings: {
pattern: 'test-pattern',
field: 'test-field',
placeholder: 'test-placeholder'
}
}
};

beforeEach(() => {
TestBed.configureTestingModule({
imports: [
TranslateModule.forRoot(),
ContentTestingModule
]
});
fixture = TestBed.createComponent(SearchFilterCardComponent);
component = fixture.componentInstance;
component.category = mockCategory;
fixture.detectChanges();
});

it('should call clear method on clear button click', () => {
spyOn(component, 'clear');

const clearButton = fixture.debugElement.nativeElement.querySelector('#clear-filter-button');
clearButton.click();

expect(component.clear).toHaveBeenCalled();
});

it('should call apply method on apply button click', () => {
spyOn(component, 'apply');

const applyButton = fixture.debugElement.nativeElement.querySelector('#apply-filter-button');
applyButton.click();

expect(component.apply).toHaveBeenCalled();
});

it('should call resetInnerWidget method on clear', () => {
spyOn(component.widgetContainerComponent, 'resetInnerWidget');

component.clear();

expect(component.widgetContainerComponent.resetInnerWidget).toHaveBeenCalled();
});

it('should call applyInnerWidget method on apply', () => {
spyOn(component.widgetContainerComponent, 'applyInnerWidget');

component.apply();

expect(component.widgetContainerComponent.applyInnerWidget).toHaveBeenCalled();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*!
* @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, Input, ViewChild, ViewEncapsulation } from '@angular/core';
import { SearchWidgetContainerComponent } from '../../search-widget-container/search-widget-container.component';
import { SearchCategory } from '../../../models/search-category.interface';

@Component({
selector: 'adf-search-filter-card',
templateUrl: './search-filter-card.component.html',
encapsulation: ViewEncapsulation.None
})
export class SearchFilterCardComponent {
@Input()
category: SearchCategory;

@ViewChild(SearchWidgetContainerComponent, { static: false })
widgetContainerComponent: SearchWidgetContainerComponent;

clear() {
this.widgetContainerComponent.resetInnerWidget();
}

apply() {
this.widgetContainerComponent.applyInnerWidget();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,9 @@
{{ category.name | translate }}
</mat-panel-title>
</mat-expansion-panel-header>
<adf-search-widget-container
[id]="category.id"
[selector]="category.component.selector"
[settings]="category.component.settings">
</adf-search-widget-container>
<adf-search-filter-card
[category]="category">
</adf-search-filter-card>
</mat-expansion-panel>

<ng-container *ngIf="facetFiltersService.tabbedFacet && showContextFacets">
Expand Down
1 change: 1 addition & 0 deletions lib/content-services/src/lib/search/public-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export * from './components/search-panel/search-panel.component';
export * from './components/search-check-list/search-check-list.component';
export * from './components/search-chip-list/search-chip-list.component';
export * from './components/search-filter/search-filter.component';
export * from './components/search-filter/search-filter-card/search-filter-card.component';
export * from './components/search-filter-container/search-filter-container.component';
export * from './components/search-number-range/search-number-range.component';
export * from './components/search-radio/search-radio.component';
Expand Down
3 changes: 3 additions & 0 deletions lib/content-services/src/lib/search/search.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import { SearchComponent } from './components/search.component';
import { EmptySearchResultComponent } from './components/empty-search-result.component';
import { SearchWidgetContainerComponent } from './components/search-widget-container/search-widget-container.component';
import { SearchFilterComponent } from './components/search-filter/search-filter.component';
import { SearchFilterCardComponent } from './components/search-filter/search-filter-card/search-filter-card.component';
import { SearchChipListComponent } from './components/search-chip-list/search-chip-list.component';
import { SearchTextComponent } from './components/search-text/search-text.component';
import { SearchChipAutocompleteInputComponent } from './components/search-chip-autocomplete-input/search-chip-autocomplete-input.component';
Expand Down Expand Up @@ -73,6 +74,7 @@ import { SearchFacetTabbedContentComponent } from './components/search-filter-ch
SearchControlComponent,
EmptySearchResultComponent,
SearchFilterComponent,
SearchFilterCardComponent,
SearchChipListComponent,
SearchWidgetContainerComponent,
SearchTextComponent,
Expand Down Expand Up @@ -107,6 +109,7 @@ import { SearchFacetTabbedContentComponent } from './components/search-filter-ch
SearchControlComponent,
EmptySearchResultComponent,
SearchFilterComponent,
SearchFilterCardComponent,
SearchChipListComponent,
SearchWidgetContainerComponent,
SearchTextComponent,
Expand Down

0 comments on commit fdab441

Please sign in to comment.