-
Notifications
You must be signed in to change notification settings - Fork 261
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* [ACA-3430] Add style to filter and hide action buttons from facet widgets * [ACA-3430] Update eventEmitter created in the DL and create unit tests for the search-header Co-authored-by: BaptisteMahe <mahe.baptiste.19@gmail.com>
- Loading branch information
1 parent
63ee4dd
commit 5c86120
Showing
16 changed files
with
239 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -207,11 +207,4 @@ | |
} | ||
} | ||
} | ||
|
||
.adf-filter-button { | ||
mat-icon { | ||
height: 18px; | ||
width: 18px; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 16 additions & 14 deletions
30
lib/content-services/src/lib/search/components/search-header/search-header.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,25 @@ | ||
<button mat-icon-button [matMenuTriggerFor]="filter" | ||
(click)="onMenuButtonClick($event)" | ||
class="adf-filter-button" | ||
matTooltip="{{ 'SEARCH.SEARCH_HEADER.FILTER_BY' | translate:{category: col.title} }}"> | ||
<adf-icon value="adf:filter" color="primary"></adf-icon> | ||
</button> | ||
<div *ngIf="!!category" class="adf-filter"> | ||
<button mat-icon-button [matMenuTriggerFor]="filter" | ||
(click)="onMenuButtonClick($event)" | ||
class="adf-filter-button" | ||
matTooltip="{{ 'SEARCH.SEARCH_HEADER.FILTER_BY' | translate: { category: col.title || 'Type' } }}"> | ||
<adf-icon value="adf:filter" color="primary"></adf-icon> | ||
</button> | ||
|
||
<mat-menu #filter="matMenu"> | ||
<div (click)="onMenuButtonClick($event)"> | ||
<mat-menu #filter="matMenu" class="adf-filter-menu"> | ||
<div (click)="onMenuClick($event)" class="adf-filter-container"> | ||
<div class="adf-filter-title">{{ 'SEARCH.SEARCH_HEADER.TITLE' | translate }}</div> | ||
<adf-search-widget-container | ||
[id]="category.id" | ||
[selector]="category.component.selector" | ||
[settings]="category.component.settings"> | ||
</adf-search-widget-container> | ||
<mat-dialog-actions> | ||
<button mat-button>{{ 'SEARCH.SEARCH_HEADER.CLEAR' | translate | uppercase }} | ||
</button> | ||
<button mat-button (click)="onApplyButtonClick()">{{ 'SEARCH.SEARCH_HEADER.APPLY' | translate | uppercase }} | ||
</button> | ||
</mat-dialog-actions> | ||
</div> | ||
<mat-dialog-actions class="adf-filter-actions"> | ||
<button mat-button>{{ 'SEARCH.SEARCH_HEADER.CLEAR' | translate | uppercase }} | ||
</button> | ||
<button mat-button color="primary" class="adf-filter-apply-button" (click)="onApplyButtonClick()">{{ 'SEARCH.SEARCH_HEADER.APPLY' | translate | uppercase }} | ||
</button> | ||
</mat-dialog-actions> | ||
</mat-menu> | ||
</div> |
57 changes: 57 additions & 0 deletions
57
lib/content-services/src/lib/search/components/search-header/search-header.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
@mixin adf-filter-menu-theme($theme) { | ||
$background: map-get($theme, background); | ||
|
||
.adf-filter { | ||
|
||
&-button { | ||
|
||
.adf-icon { | ||
opacity: 1; | ||
} | ||
|
||
.mat-icon { | ||
height: 18px; | ||
width: 18px; | ||
} | ||
} | ||
|
||
&-container { | ||
display: flex; | ||
flex-direction: column; | ||
padding: 10px; | ||
|
||
.adf-facet-buttons { | ||
display: none; | ||
} | ||
|
||
.adf-search-check-list { | ||
padding: 5px 0; | ||
} | ||
} | ||
|
||
&-title { | ||
font-size: 1.1em; | ||
padding-bottom: 5px; | ||
} | ||
|
||
&-actions { | ||
background-color: mat-color($background, background); | ||
display: flex; | ||
justify-content: flex-end; | ||
padding: 5px 10px; | ||
|
||
> button { | ||
font-size: 0.9em; | ||
} | ||
} | ||
|
||
&-apply-button { | ||
background-color: mat-color($background, hover); | ||
} | ||
} | ||
|
||
.mat-menu-panel.adf-filter-menu .mat-menu-content { | ||
min-width: 250px; | ||
padding: 0; | ||
} | ||
} |
98 changes: 98 additions & 0 deletions
98
lib/content-services/src/lib/search/components/search-header/search-header.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
/*! | ||
* @license | ||
* Copyright 2019 Alfresco Software, Ltd. | ||
* | ||
* 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 { Subject } from 'rxjs'; | ||
import { EventEmitter } from '@angular/core'; | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
import { TranslateModule } from '@ngx-translate/core'; | ||
import { NodePaging } from '@alfresco/js-api'; | ||
import { AppConfigService, SearchService, setupTestBed } from '@alfresco/adf-core'; | ||
import { SearchHeaderComponent } from './search-header.component'; | ||
import { SearchQueryBuilderService } from '../../search-query-builder.service'; | ||
import { SearchHeaderQueryBuilderService } from '../../search-header-query-builder.service'; | ||
import { ContentTestingModule } from '../../../testing/content.testing.module'; | ||
import { fakeNodePaging } from '../../../mock'; | ||
|
||
const mockCategory: any = { | ||
'id': 'queryName', | ||
'name': 'Name', | ||
'columnKey': 'name', | ||
'enabled': true, | ||
'expanded': true, | ||
'component': { | ||
'selector': 'text', | ||
'settings': { | ||
'pattern': "cm:name:'(.*?)'", | ||
'field': 'cm:name', | ||
'placeholder': 'Enter the name' | ||
} | ||
} | ||
}; | ||
|
||
describe('SearchHeaderComponent', () => { | ||
let fixture: ComponentFixture<SearchHeaderComponent>; | ||
let component: SearchHeaderComponent; | ||
let queryBuilder: SearchHeaderQueryBuilderService; | ||
let appConfigService: AppConfigService; | ||
const searchMock: any = { | ||
dataLoaded: new Subject() | ||
}; | ||
|
||
setupTestBed({ | ||
imports: [ | ||
TranslateModule.forRoot(), | ||
ContentTestingModule | ||
], | ||
providers: [ | ||
{ | ||
provide: SearchService, | ||
useValue: searchMock | ||
}, | ||
{ | ||
provide: SearchQueryBuilderService, | ||
useClass: SearchHeaderQueryBuilderService | ||
} | ||
] | ||
}); | ||
|
||
beforeEach(() => { | ||
queryBuilder = TestBed.get(SearchHeaderQueryBuilderService); | ||
fixture = TestBed.createComponent(SearchHeaderComponent); | ||
appConfigService = TestBed.get(AppConfigService); | ||
component = fixture.componentInstance; | ||
component.col = {key: '123', type: 'text'}; | ||
component.update = new EventEmitter(); | ||
spyOn(queryBuilder, 'getCategoryForColumn').and.returnValue(mockCategory); | ||
fixture.detectChanges(); | ||
}); | ||
|
||
afterEach(() => fixture.destroy()); | ||
|
||
it('should emit the node paging received from the queryBuilder after the filter gets applied', (done) => { | ||
const mockNodePaging: NodePaging = <NodePaging> fakeNodePaging; | ||
spyOn(queryBuilder, 'execute').and.callFake(() => { | ||
queryBuilder.executed.next(mockNodePaging); | ||
}); | ||
|
||
const applyButton = fixture.debugElement.nativeElement.querySelector('.adf-filter-button'); | ||
applyButton.click(); | ||
|
||
component.update.subscribe((newNodePaging) => { | ||
expect(newNodePaging).toBe(mockNodePaging); | ||
done(); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.