mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-06-30 18:15:11 +00:00
[AAE-19610] Submit query on change event for search date range tabbed 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
This commit is contained in:
parent
720fbb98ca
commit
fdab441d45
@ -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>
|
@ -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();
|
||||||
|
});
|
||||||
|
});
|
@ -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();
|
||||||
|
}
|
||||||
|
}
|
@ -17,11 +17,9 @@
|
|||||||
{{ category.name | translate }}
|
{{ category.name | translate }}
|
||||||
</mat-panel-title>
|
</mat-panel-title>
|
||||||
</mat-expansion-panel-header>
|
</mat-expansion-panel-header>
|
||||||
<adf-search-widget-container
|
<adf-search-filter-card
|
||||||
[id]="category.id"
|
[category]="category">
|
||||||
[selector]="category.component.selector"
|
</adf-search-filter-card>
|
||||||
[settings]="category.component.settings">
|
|
||||||
</adf-search-widget-container>
|
|
||||||
</mat-expansion-panel>
|
</mat-expansion-panel>
|
||||||
|
|
||||||
<ng-container *ngIf="facetFiltersService.tabbedFacet && showContextFacets">
|
<ng-container *ngIf="facetFiltersService.tabbedFacet && showContextFacets">
|
||||||
|
@ -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-check-list/search-check-list.component';
|
||||||
export * from './components/search-chip-list/search-chip-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.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-filter-container/search-filter-container.component';
|
||||||
export * from './components/search-number-range/search-number-range.component';
|
export * from './components/search-number-range/search-number-range.component';
|
||||||
export * from './components/search-radio/search-radio.component';
|
export * from './components/search-radio/search-radio.component';
|
||||||
|
@ -28,6 +28,7 @@ import { SearchComponent } from './components/search.component';
|
|||||||
import { EmptySearchResultComponent } from './components/empty-search-result.component';
|
import { EmptySearchResultComponent } from './components/empty-search-result.component';
|
||||||
import { SearchWidgetContainerComponent } from './components/search-widget-container/search-widget-container.component';
|
import { SearchWidgetContainerComponent } from './components/search-widget-container/search-widget-container.component';
|
||||||
import { SearchFilterComponent } from './components/search-filter/search-filter.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 { SearchChipListComponent } from './components/search-chip-list/search-chip-list.component';
|
||||||
import { SearchTextComponent } from './components/search-text/search-text.component';
|
import { SearchTextComponent } from './components/search-text/search-text.component';
|
||||||
import { SearchChipAutocompleteInputComponent } from './components/search-chip-autocomplete-input/search-chip-autocomplete-input.component';
|
import { SearchChipAutocompleteInputComponent } from './components/search-chip-autocomplete-input/search-chip-autocomplete-input.component';
|
||||||
@ -73,6 +74,7 @@ import { SearchFacetTabbedContentComponent } from './components/search-filter-ch
|
|||||||
SearchControlComponent,
|
SearchControlComponent,
|
||||||
EmptySearchResultComponent,
|
EmptySearchResultComponent,
|
||||||
SearchFilterComponent,
|
SearchFilterComponent,
|
||||||
|
SearchFilterCardComponent,
|
||||||
SearchChipListComponent,
|
SearchChipListComponent,
|
||||||
SearchWidgetContainerComponent,
|
SearchWidgetContainerComponent,
|
||||||
SearchTextComponent,
|
SearchTextComponent,
|
||||||
@ -107,6 +109,7 @@ import { SearchFacetTabbedContentComponent } from './components/search-filter-ch
|
|||||||
SearchControlComponent,
|
SearchControlComponent,
|
||||||
EmptySearchResultComponent,
|
EmptySearchResultComponent,
|
||||||
SearchFilterComponent,
|
SearchFilterComponent,
|
||||||
|
SearchFilterCardComponent,
|
||||||
SearchChipListComponent,
|
SearchChipListComponent,
|
||||||
SearchWidgetContainerComponent,
|
SearchWidgetContainerComponent,
|
||||||
SearchTextComponent,
|
SearchTextComponent,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user