diff --git a/demo-shell/resources/i18n/en.json b/demo-shell/resources/i18n/en.json
index a9b1c809e2b..d0f5dc74c11 100644
--- a/demo-shell/resources/i18n/en.json
+++ b/demo-shell/resources/i18n/en.json
@@ -350,7 +350,5 @@
"ACTION_TYPE": "Action Type"
}
},
- "SEARCH_FORMS": {
- "ALL": "All"
- }
+ "DEFAULT_SEARCH": "Default"
}
diff --git a/demo-shell/src/app.config.json b/demo-shell/src/app.config.json
index b5095858655..c5b322fcaa4 100644
--- a/demo-shell/src/app.config.json
+++ b/demo-shell/src/app.config.json
@@ -366,8 +366,258 @@
}
]
},
- "name": "SEARCH_FORMS.ALL",
+ "name": "DEFAULT_SEARCH",
"default": true
+ },
+ {
+ "filterWithContains": true,
+ "app:fields": [
+ "cm:name",
+ "cm:title",
+ "cm:description",
+ "ia:whatEvent",
+ "ia:descriptionEvent",
+ "lnk:title",
+ "lnk:description",
+ "TEXT",
+ "TAG"
+ ],
+ "include": [
+ "path",
+ "allowableOperations",
+ "properties"
+ ],
+ "sorting": {
+ "options": [
+ {
+ "key": "name",
+ "label": "Name",
+ "type": "FIELD",
+ "field": "cm:name",
+ "ascending": true
+ },
+ {
+ "key": "content.sizeInBytes",
+ "label": "Size",
+ "type": "FIELD",
+ "field": "content.size",
+ "ascending": true
+ },
+ {
+ "key": "createdByUser",
+ "label": "Author",
+ "type": "FIELD",
+ "field": "cm:creator",
+ "ascending": true
+ },
+ {
+ "key": "createdAt",
+ "label": "Created",
+ "type": "FIELD",
+ "field": "cm:created",
+ "ascending": true
+ },
+ {
+ "key": "score",
+ "label": "Relevance",
+ "type": "SCORE",
+ "field": "score",
+ "ascending": false
+ }
+ ],
+ "defaults": [
+ {
+ "key": "score",
+ "type": "FIELD",
+ "field": "score",
+ "ascending": false
+ }
+ ]
+ },
+ "resetButton": true,
+ "filterQueries": [
+ {
+ "query": "TYPE:'cm:folder'"
+ },
+ {
+ "query": "NOT cm:creator:System"
+ }
+ ],
+ "facetFields": {
+ "expanded": true,
+ "fields": [
+ {
+ "field": "content.size",
+ "mincount": 1,
+ "label": "Folder Size",
+ "settings": {
+ "allowUpdateOnChange": false,
+ "hideDefaultAction": true,
+ "unit": "Bytes"
+ }
+ },
+ {
+ "field": "creator",
+ "mincount": 1,
+ "label": "Field created",
+ "settings": {
+ "allowUpdateOnChange": false,
+ "hideDefaultAction": true
+ }
+ },
+ {
+ "field": "modifier",
+ "mincount": 1,
+ "label": "Folder Modifier",
+ "settings": {
+ "allowUpdateOnChange": false,
+ "hideDefaultAction": true
+ }
+ },
+ {
+ "field": "created",
+ "mincount": 1,
+ "label": "Folder Created",
+ "settings": {
+ "allowUpdateOnChange": false,
+ "hideDefaultAction": true
+ }
+ }
+ ]
+ },
+ "facetQueries": {
+ "label": "SEARCH.FACET_QUERIES.MY_FACET_QUERIES",
+ "pageSize": 5,
+ "expanded": true,
+ "mincount": 1,
+ "queries": [
+ {
+ "query": "created:2019",
+ "label": "SEARCH.FACET_QUERIES.CREATED_THIS_YEAR"
+ },
+ {
+ "query": "content.mimetype:text/html",
+ "label": "SEARCH.FACET_QUERIES.MIMETYPE",
+ "group": "Type facet queries"
+ },
+ {
+ "query": "content.size:[0 TO 10240]",
+ "label": "SEARCH.FACET_QUERIES.XTRASMALL",
+ "group": "Size facet queries"
+ },
+ {
+ "query": "content.size:[10240 TO 102400]",
+ "label": "SEARCH.FACET_QUERIES.SMALL",
+ "group": "Size facet queries"
+ },
+ {
+ "query": "content.size:[102400 TO 1048576]",
+ "label": "SEARCH.FACET_QUERIES.MEDIUM",
+ "group": "Size facet queries"
+ },
+ {
+ "query": "content.size:[1048576 TO 16777216]",
+ "label": "SEARCH.FACET_QUERIES.LARGE",
+ "group": "Size facet queries"
+ },
+ {
+ "query": "content.size:[16777216 TO 134217728]",
+ "label": "SEARCH.FACET_QUERIES.XTRALARGE",
+ "group": "Size facet queries"
+ },
+ {
+ "query": "content.size:[134217728 TO MAX]",
+ "label": "SEARCH.FACET_QUERIES.XXTRALARGE",
+ "group": "Size facet queries"
+ }
+ ],
+ "settings": {
+ "allowUpdateOnChange": false,
+ "hideDefaultAction": true
+ }
+ },
+ "facetIntervals": {
+ "expanded": true,
+ "intervals": [
+ {
+ "label": "The Created",
+ "field": "cm:created",
+ "sets": [
+ {
+ "label": "lastYear",
+ "start": "2018",
+ "end": "2019",
+ "endInclusive": false
+ },
+ {
+ "label": "currentYear",
+ "start": "NOW/YEAR",
+ "end": "NOW/YEAR+1YEAR"
+ },
+ {
+ "label": "earlier",
+ "start": "*",
+ "end": "2018",
+ "endInclusive": false
+ }
+ ],
+ "settings": {
+ "allowUpdateOnChange": false,
+ "hideDefaultAction": true
+ }
+ },
+ {
+ "label": "The Modified",
+ "field": "cm:modified",
+ "sets": [
+ {
+ "label": "2017",
+ "start": "2017",
+ "end": "2018",
+ "endInclusive": false
+ },
+ {
+ "label": "2017-2018",
+ "start": "2017",
+ "end": "2018",
+ "endInclusive": true
+ },
+ {
+ "label": "currentYear",
+ "start": "NOW/YEAR",
+ "end": "NOW/YEAR+1YEAR"
+ },
+ {
+ "label": "earlierThan2017",
+ "start": "*",
+ "end": "2017",
+ "endInclusive": false
+ }
+ ],
+ "settings": {
+ "allowUpdateOnChange": false,
+ "hideDefaultAction": true
+ }
+ }
+ ]
+ },
+ "categories": [],
+ "highlight": {
+ "prefix": " ",
+ "postfix": " ",
+ "mergeContiguous": true,
+ "fields": [
+ {
+ "field": "cm:title"
+ },
+ {
+ "field": "description",
+ "prefix": "(",
+ "postfix": ")"
+ }
+ ]
+ },
+ "name": "Folder"
}],
"search-headers": {
"filterWithContains": true,
diff --git a/demo-shell/src/app/app.module.ts b/demo-shell/src/app/app.module.ts
index feb9cfe531e..713e2d8a0ea 100644
--- a/demo-shell/src/app/app.module.ts
+++ b/demo-shell/src/app/app.module.ts
@@ -114,6 +114,7 @@ import localeDa from '@angular/common/locales/da';
import localeSv from '@angular/common/locales/sv';
import { setupAppNotifications } from './services/app-notifications-factory';
import { AppNotificationsService } from './services/app-notifications.service';
+import { SearchFilterChipsComponent } from './components/search/search-filter-chips.component';
registerLocaleData(localeFr);
registerLocaleData(localeDe);
@@ -204,7 +205,8 @@ registerLocaleData(localeSv);
CustomEditorComponent,
CustomWidgetComponent,
ProcessCloudLayoutComponent,
- ServiceTaskListCloudDemoComponent
+ ServiceTaskListCloudDemoComponent,
+ SearchFilterChipsComponent
],
providers: [
{
diff --git a/demo-shell/src/app/app.routes.ts b/demo-shell/src/app/app.routes.ts
index c7e5caff1e8..21456908946 100644
--- a/demo-shell/src/app/app.routes.ts
+++ b/demo-shell/src/app/app.routes.ts
@@ -55,6 +55,7 @@ import { FilteredSearchComponent } from './components/files/filtered-search.comp
import { ProcessCloudLayoutComponent } from './components/cloud/process-cloud-layout.component';
import { ServiceTaskListCloudDemoComponent } from './components/cloud/service-task-list-cloud-demo.component';
import { AspectListSampleComponent } from './components/aspect-list-sample/aspect-list-sample.component';
+import { SearchFilterChipsComponent } from './components/search/search-filter-chips.component';
export const appRoutes: Routes = [
{ path: 'login', loadChildren: () => import('./components/login/login.module').then(m => m.AppLoginModule) },
@@ -325,6 +326,11 @@ export const appRoutes: Routes = [
component: SearchResultComponent,
canActivate: [AuthGuardEcm]
},
+ {
+ path: 'search-filter-chips',
+ component: SearchFilterChipsComponent,
+ canActivate: [AuthGuardEcm]
+ },
{
path: 'extendedSearch',
component: SearchExtendedComponent,
diff --git a/demo-shell/src/app/components/search/search-filter-chips.component.html b/demo-shell/src/app/components/search/search-filter-chips.component.html
new file mode 100644
index 00000000000..2bb8461a9f3
--- /dev/null
+++ b/demo-shell/src/app/components/search/search-filter-chips.component.html
@@ -0,0 +1,39 @@
+
+
+
+
+
+
+
+
+
+
+
refresh
+
+
+
+
+
+
+
diff --git a/demo-shell/src/app/components/search/search-filter-chips.component.scss b/demo-shell/src/app/components/search/search-filter-chips.component.scss
new file mode 100644
index 00000000000..cf0453de25f
--- /dev/null
+++ b/demo-shell/src/app/components/search/search-filter-chips.component.scss
@@ -0,0 +1,44 @@
+.app-search-results {
+ display: flex;
+ margin-left: 5px;
+
+ .app-search-settings {
+ width: 260px;
+ border: 1px solid #eee;
+ }
+
+ &__facets {
+ margin: 5px;
+ }
+
+ &__content {
+ flex: 1;
+ }
+
+ &__sorting {
+ padding-top: 16px;
+ padding-bottom: 16px;
+ display: flex;
+ }
+}
+
+div.app-search-results-container {
+ padding: 0 20px 20px;
+}
+
+.app-search-title {
+ font-size: 22px;
+ padding: 15px 0;
+}
+
+@media screen and (max-width: 600px) {
+ :host .app-col-display-name {
+ min-width: 100px;
+ }
+ :host .app-col-modified-at, :host .app-col-modified-by {
+ display: none;
+ }
+ :host div.app-search-results-container table {
+ width: 100%;
+ }
+}
diff --git a/demo-shell/src/app/components/search/search-filter-chips.component.ts b/demo-shell/src/app/components/search/search-filter-chips.component.ts
new file mode 100644
index 00000000000..2cb883fb846
--- /dev/null
+++ b/demo-shell/src/app/components/search/search-filter-chips.component.ts
@@ -0,0 +1,143 @@
+/*!
+ * @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 { Component, OnDestroy, OnInit } from '@angular/core';
+import { ActivatedRoute, Params, Router } from '@angular/router';
+import { Pagination, ResultSetPaging } from '@alfresco/js-api';
+import { SearchForm, SearchQueryBuilderService } from '@alfresco/adf-content-services';
+import { SearchService, ShowHeaderMode, UserPreferencesService } from '@alfresco/adf-core';
+import { combineLatest, Subject } from 'rxjs';
+import { takeUntil } from 'rxjs/operators';
+
+@Component({
+ selector: 'app-search-filter-chips',
+ templateUrl: './search-filter-chips.component.html',
+ styleUrls: [ './search-filter-chips.component.scss' ],
+ providers: [SearchService]
+})
+export class SearchFilterChipsComponent implements OnInit, OnDestroy {
+
+ queryParamName = 'q';
+ searchedWord = '';
+ data: ResultSetPaging;
+ pagination: Pagination;
+ isLoading = true;
+
+ sorting = ['name', 'asc'];
+ searchForms: SearchForm[];
+ showHeader = ShowHeaderMode.Always;
+
+ private onDestroy$ = new Subject();
+
+ constructor(public router: Router,
+ private preferences: UserPreferencesService,
+ private queryBuilder: SearchQueryBuilderService,
+ private route: ActivatedRoute) {
+ combineLatest([this.route.params, this.queryBuilder.configUpdated])
+ .pipe(takeUntil(this.onDestroy$))
+ .subscribe(([params, searchConfig]) => {
+ this.searchedWord = params.hasOwnProperty(this.queryParamName) ? params[this.queryParamName] : null;
+ const query = this.formatSearchQuery(this.searchedWord, searchConfig['app:fields']);
+ if (query) {
+ this.queryBuilder.userQuery = query;
+ }
+ });
+
+ queryBuilder.paging = {
+ maxItems: this.preferences.paginationSize,
+ skipCount: 0
+ };
+ }
+
+ ngOnInit() {
+ this.queryBuilder.resetToDefaults();
+
+ this.sorting = this.getSorting();
+
+ this.queryBuilder.updated
+ .pipe(takeUntil(this.onDestroy$))
+ .subscribe(() => {
+ this.sorting = this.getSorting();
+ this.isLoading = true;
+ });
+
+ this.queryBuilder.executed
+ .pipe(takeUntil(this.onDestroy$))
+ .subscribe((resultSetPaging: ResultSetPaging) => {
+ this.queryBuilder.paging.skipCount = 0;
+
+ this.onSearchResultLoaded(resultSetPaging);
+ this.isLoading = false;
+ });
+
+ if (this.route) {
+ this.route.params.forEach((params: Params) => {
+ this.searchedWord = params.hasOwnProperty(this.queryParamName) ? params[this.queryParamName] : null;
+ if (this.searchedWord) {
+ this.queryBuilder.update();
+ } else {
+ this.queryBuilder.userQuery = null;
+ this.queryBuilder.executed.next(new ResultSetPaging({
+ list: {
+ pagination: { totalItems: 0 },
+ entries: []
+ }
+ }));
+ }
+ });
+ }
+ }
+
+ private formatSearchQuery(userInput: string, fields = ['cm:name']) {
+ if (!userInput) {
+ return null;
+ }
+ return fields.map((field) => `${field}:"${userInput}*"`).join(' OR ');
+ }
+
+ ngOnDestroy() {
+ this.onDestroy$.next(true);
+ this.onDestroy$.complete();
+ }
+
+ onSearchResultLoaded(resultSetPaging: ResultSetPaging) {
+ this.data = resultSetPaging;
+ this.pagination = { ...resultSetPaging.list.pagination };
+ }
+
+ onRefreshPagination(pagination: Pagination) {
+ this.queryBuilder.paging = {
+ maxItems: pagination.maxItems,
+ skipCount: pagination.skipCount
+ };
+ this.queryBuilder.update();
+ }
+
+ onDeleteElementSuccess() {
+ this.queryBuilder.execute();
+ }
+
+ private getSorting(): string[] {
+ const primary = this.queryBuilder.getPrimarySorting();
+
+ if (primary) {
+ return [primary.key, primary.ascending ? 'asc' : 'desc'];
+ }
+
+ return ['name', 'asc'];
+ }
+}
diff --git a/demo-shell/src/app/components/search/search-result.component.html b/demo-shell/src/app/components/search/search-result.component.html
index 41d1a3cf400..19d32193cbb 100644
--- a/demo-shell/src/app/components/search/search-result.component.html
+++ b/demo-shell/src/app/components/search/search-result.component.html
@@ -10,7 +10,9 @@
-
+
+
+
+```
+
+### Properties
+
+| Name | Type | Default value | Description |
+| ---- | ---- | ------------- | ----------- |
+| showContextFacets | `boolean` | true | Toggles whether to show or not the context facet filters |
+
+## Details
+
+This component is chip based layout for searching. it just alternate component for [expanded panel search filter](./search-filter.component.md)
+
+You may find it useful to check out the following resources for background information
+before customizing the search UI:
+
+- [Search API](https://docs.alfresco.com/5.2/concepts/search-api.html)
+- [Alfresco Full Text Search Reference](https://docs.alfresco.com/5.2/concepts/rm-searchsyntax-intro.html)
+- [ACS API Explorer](https://api-explorer.alfresco.com/api-explorer/#!/search/search)
+
+## See also
+
+- [Search Filter Component](./search-filter.component.md)
+- [Search Query Builder service](../services/search-query-builder.service.md)
+- [Search Widget Interface](../interfaces/search-widget.interface.md)
+- [Search check list component](search-check-list.component.md)
+- [Search date range component](search-date-range.component.md)
+- [Search number range component](search-number-range.component.md)
+- [Search radio component](search-radio.component.md)
+- [Search slider component](search-slider.component.md)
+- [Search text component](search-text.component.md)
diff --git a/docs/content-services/components/search-number-range.component.md b/docs/content-services/components/search-number-range.component.md
index 387da57000a..cfde74960f0 100644
--- a/docs/content-services/components/search-number-range.component.md
+++ b/docs/content-services/components/search-number-range.component.md
@@ -40,6 +40,7 @@ Implements a number range [widget](../../../lib/testing/src/lib/core/pages/form/
| ---- | ---- | ----------- |
| field | string | Field to to use |
| format | string | Value format. Uses string substitution to allow all sorts of [range queries](https://docs.alfresco.com/5.2/concepts/rm-searchsyntax-ranges.html). |
+| hideDefaultAction | boolean | Show/hide the widget actions. By default is false.
## Details
diff --git a/docs/content-services/components/search-radio.component.md b/docs/content-services/components/search-radio.component.md
index 22af04cdb60..29f59917650 100644
--- a/docs/content-services/components/search-radio.component.md
+++ b/docs/content-services/components/search-radio.component.md
@@ -45,6 +45,8 @@ Implements a radio button list [widget](../../../lib/testing/src/lib/core/pages/
| Name | Type | Description |
| ---- | ---- | ----------- |
| options | `array` | Array of objects with `name` and `value` properties. Each object defines a radio button, labelled with `name`, that adds the query fragment in `value` to the query when enabled. |
+| allowUpdateOnChange | `boolean` | Enable/Disable the update fire event when text has been changed. By default is true.
+| hideDefaultAction | `boolean` | Show/hide the widget actions. By default is false.
## Details
diff --git a/docs/content-services/components/search-slider.component.md b/docs/content-services/components/search-slider.component.md
index 713b7cec120..0f229506798 100644
--- a/docs/content-services/components/search-slider.component.md
+++ b/docs/content-services/components/search-slider.component.md
@@ -46,6 +46,8 @@ Implements a numeric slider [widget](../../../lib/testing/src/lib/core/pages/for
| max | number | Maximum numeric value at the right end of the slider |
| step | number | The step between adjacent positions on the slider |
| thumbLabel | boolean | Toggles whether the "thumb" of the slider should show the current value |
+| allowUpdateOnChange | boolean | Enable/Disable the update fire event when text has been changed. By default is true.
+| hideDefaultAction | boolean | Show/hide the widget actions. By default is false.
## Details
diff --git a/docs/content-services/components/search-text.component.md b/docs/content-services/components/search-text.component.md
index e950e323d14..a34068c4470 100644
--- a/docs/content-services/components/search-text.component.md
+++ b/docs/content-services/components/search-text.component.md
@@ -49,6 +49,7 @@ Implements a text input [widget](../../../lib/testing/src/lib/core/pages/form/wi
| searchSuffix | string | Text to append always in the search of a string|
| searchPrefix | string | Text to prepend always in the search of a string|
| allowUpdateOnChange | `boolean` | Enable/Disable the update fire event when text has been changed. By default is true.
+| hideDefaultAction | boolean | Show/hide the widget actions. By default is false.
## Details
diff --git a/docs/docassets/images/search-filter-chip-widget.png b/docs/docassets/images/search-filter-chip-widget.png
new file mode 100644
index 00000000000..3c2bbcc35ce
Binary files /dev/null and b/docs/docassets/images/search-filter-chip-widget.png differ
diff --git a/docs/docassets/images/search-filter-chips.png b/docs/docassets/images/search-filter-chips.png
new file mode 100644
index 00000000000..5f7e2fb5d9f
Binary files /dev/null and b/docs/docassets/images/search-filter-chips.png differ
diff --git a/lib/content-services/src/lib/content-node-selector/content-node-selector-panel.component.ts b/lib/content-services/src/lib/content-node-selector/content-node-selector-panel.component.ts
index 35157f7c9c8..a8076730d00 100644
--- a/lib/content-services/src/lib/content-node-selector/content-node-selector-panel.component.ts
+++ b/lib/content-services/src/lib/content-node-selector/content-node-selector-panel.component.ts
@@ -50,7 +50,7 @@ import { CustomResourcesService } from '../document-list/services/custom-resourc
import { NodeEntryEvent, ShareDataRow } from '../document-list';
import { Subject } from 'rxjs';
import { SEARCH_QUERY_SERVICE_TOKEN } from '../search/search-query-service.token';
-import { SearchQueryBuilderService } from '../search/search-query-builder.service';
+import { SearchQueryBuilderService } from '../search/services/search-query-builder.service';
import { ContentNodeSelectorPanelService } from './content-node-selector-panel.service';
export type ValidationFunction = (entry: Node) => boolean;
diff --git a/lib/content-services/src/lib/content-node-selector/content-node-selector.module.ts b/lib/content-services/src/lib/content-node-selector/content-node-selector.module.ts
index 096921b4828..6795339f8cb 100644
--- a/lib/content-services/src/lib/content-node-selector/content-node-selector.module.ts
+++ b/lib/content-services/src/lib/content-node-selector/content-node-selector.module.ts
@@ -29,7 +29,7 @@ import { CoreModule } from '@alfresco/adf-core';
import { DocumentListModule } from '../document-list/document-list.module';
import { NameLocationCellComponent } from './name-location-cell/name-location-cell.component';
import { UploadModule } from '../upload/upload.module';
-import { SearchQueryBuilderService } from '../search/search-query-builder.service';
+import { SearchQueryBuilderService } from '../search/services/search-query-builder.service';
import { ContentDirectiveModule } from '../directives/content-directive.module';
@NgModule({
diff --git a/lib/content-services/src/lib/document-list/components/filter-header/filter-header.component.spec.ts b/lib/content-services/src/lib/document-list/components/filter-header/filter-header.component.spec.ts
index 26755732fa9..20bff33a15b 100644
--- a/lib/content-services/src/lib/document-list/components/filter-header/filter-header.component.spec.ts
+++ b/lib/content-services/src/lib/document-list/components/filter-header/filter-header.component.spec.ts
@@ -21,7 +21,7 @@ import { TranslateModule } from '@ngx-translate/core';
import { SearchService, setupTestBed, DataTableComponent, DataSorting } from '@alfresco/adf-core';
import { ContentTestingModule } from '../../../testing/content.testing.module';
import { SimpleChange } from '@angular/core';
-import { SearchHeaderQueryBuilderService } from './../../../search/search-header-query-builder.service';
+import { SearchHeaderQueryBuilderService } from './../../../search/services/search-header-query-builder.service';
import { SEARCH_QUERY_SERVICE_TOKEN } from './../../../search/search-query-service.token';
import { DocumentListComponent } from './../document-list.component';
import { FilterHeaderComponent } from './filter-header.component';
diff --git a/lib/content-services/src/lib/document-list/components/filter-header/filter-header.component.ts b/lib/content-services/src/lib/document-list/components/filter-header/filter-header.component.ts
index 0e25b5f662e..8c348ac6479 100644
--- a/lib/content-services/src/lib/document-list/components/filter-header/filter-header.component.ts
+++ b/lib/content-services/src/lib/document-list/components/filter-header/filter-header.component.ts
@@ -19,7 +19,7 @@ import { Component, Inject, OnInit, OnChanges, SimpleChanges, Input, Output, Eve
import { PaginationModel, DataSorting } from '@alfresco/adf-core';
import { DocumentListComponent } from '../document-list.component';
import { SEARCH_QUERY_SERVICE_TOKEN } from '../../../search/search-query-service.token';
-import { SearchHeaderQueryBuilderService } from '../../../search/search-header-query-builder.service';
+import { SearchHeaderQueryBuilderService } from '../../../search/services/search-header-query-builder.service';
import { FilterSearch } from './../../../search/models/filter-search.interface';
import { Subject } from 'rxjs';
import { takeUntil } from 'rxjs/operators';
diff --git a/lib/content-services/src/lib/i18n/en.json b/lib/content-services/src/lib/i18n/en.json
index d0c6687cdf7..54302f26551 100644
--- a/lib/content-services/src/lib/i18n/en.json
+++ b/lib/content-services/src/lib/i18n/en.json
@@ -223,14 +223,17 @@
},
"FILTER": {
"ACTIONS": {
+ "SEARCH": "Search",
"CLEAR": "Clear",
"APPLY": "Apply",
"CLEAR-ALL": "Clear all",
"SHOW-MORE": "Show more",
- "SHOW-LESS": "Show less",
- "FILTER-CATEGORY": "Filter category"
+ "SHOW-LESS": "Show less"
},
"BUTTONS": {
+ "CLOSE": "Close",
+ "REMOVE": "Remove",
+ "APPLY": "Apply",
"CLEAR-ALL": {
"LABEL": "Clear all",
"TOOLTIP": "This will remove all selections"
@@ -290,8 +293,7 @@
}
}
},
- "FORMS": "Search Forms",
- "UNKNOWN_FORM": "Unknown Configuration",
+ "UNKNOWN_CONFIGURATION": "Unknown Configuration",
"SEARCH_HEADER" : {
"TITLE":"Filter",
"TYPE": "Type",
diff --git a/lib/content-services/src/lib/mock/search-filter-mock.ts b/lib/content-services/src/lib/mock/search-filter-mock.ts
index 3b492c2585f..d886b5b9618 100644
--- a/lib/content-services/src/lib/mock/search-filter-mock.ts
+++ b/lib/content-services/src/lib/mock/search-filter-mock.ts
@@ -15,6 +15,8 @@
* limitations under the License.
*/
+import { SearchCategory } from '../search';
+
export const expandableCategories = [
{
id: 'cat-1',
@@ -68,7 +70,7 @@ export const expandedCategories = [
}
];
-export const simpleCategories = [
+export const simpleCategories: SearchCategory[] = [
{
id: 'queryName',
name: 'Name',
@@ -76,7 +78,9 @@ export const simpleCategories = [
enabled: true,
component: {
selector: 'text',
- settings: {}
+ settings: {
+ field: ''
+ }
}
},
{
@@ -87,7 +91,7 @@ export const simpleCategories = [
component: {
selector: 'check-list',
settings: {
- 'field': null,
+ 'field': 'check-list',
'pageSize': 5,
'options': [
{ 'name': 'Folder', 'value': "TYPE:'cm:folder'" },
@@ -624,6 +628,7 @@ export const mockContentSizeResponseBucket = {
};
export function getMockSearchResultWithResponseBucket() {
- mockSearchResult.list.context.facets[3].buckets.push(mockContentSizeResponseBucket);
- return mockSearchResult;
+ const cloneResult = JSON.parse(JSON.stringify( mockSearchResult));
+ cloneResult.list.context.facets[3].buckets.push(mockContentSizeResponseBucket);
+ return cloneResult;
}
diff --git a/lib/content-services/src/lib/search/components/reset-search.directive.spec.ts b/lib/content-services/src/lib/search/components/reset-search.directive.spec.ts
new file mode 100644
index 00000000000..4d592693c98
--- /dev/null
+++ b/lib/content-services/src/lib/search/components/reset-search.directive.spec.ts
@@ -0,0 +1,58 @@
+/*!
+ * @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 { Component } from '@angular/core';
+import { ComponentFixture, TestBed } from '@angular/core/testing';
+import { setupTestBed } from '@alfresco/adf-core';
+import { TranslateModule } from '@ngx-translate/core';
+import { ContentTestingModule } from '../../testing/content.testing.module';
+import { SearchFacetFiltersService } from '../services/search-facet-filters.service';
+import { SearchQueryBuilderService } from '../services/search-query-builder.service';
+
+@Component({
+ template: ``
+})
+class TestComponent {
+}
+
+describe('Directive: ResetSearchDirective', () => {
+ let fixture: ComponentFixture;
+ let searchFacetFiltersService: SearchFacetFiltersService;
+ let queryBuilder: SearchQueryBuilderService;
+
+ setupTestBed({
+ imports: [
+ TranslateModule.forRoot(),
+ ContentTestingModule
+ ],
+ declarations: [TestComponent]
+ });
+
+ beforeEach(() => {
+ fixture = TestBed.createComponent(TestComponent);
+ searchFacetFiltersService = TestBed.inject(SearchFacetFiltersService);
+ queryBuilder = TestBed.inject(SearchQueryBuilderService);
+ });
+
+ it('should reset the search on click', () => {
+ spyOn(queryBuilder, 'resetToDefaults');
+ searchFacetFiltersService.responseFacets = [ { type: 'field', label: 'f1' } ] as any;
+ fixture.nativeElement.querySelector('button').click();
+ expect(searchFacetFiltersService.responseFacets).toEqual([]);
+ expect(queryBuilder.resetToDefaults).toHaveBeenCalled();
+ });
+});
diff --git a/lib/content-services/src/lib/search/components/reset-search.directive.ts b/lib/content-services/src/lib/search/components/reset-search.directive.ts
new file mode 100644
index 00000000000..f3ca809b975
--- /dev/null
+++ b/lib/content-services/src/lib/search/components/reset-search.directive.ts
@@ -0,0 +1,31 @@
+/*!
+ * @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 { Directive, HostListener } from '@angular/core';
+import { SearchFacetFiltersService } from '../services/search-facet-filters.service';
+
+@Directive({
+ selector: '[adf-reset-search]'
+})
+export class ResetSearchDirective {
+ @HostListener('click')
+ onClick() {
+ this.filterService.reset();
+ }
+
+ constructor(private filterService: SearchFacetFiltersService) { }
+}
diff --git a/lib/content-services/src/lib/search/components/search-check-list/search-check-list.component.html b/lib/content-services/src/lib/search/components/search-check-list/search-check-list.component.html
index c1c0c1ee9a9..e21a26f0461 100644
--- a/lib/content-services/src/lib/search/components/search-check-list/search-check-list.component.html
+++ b/lib/content-services/src/lib/search/components/search-check-list/search-check-list.component.html
@@ -6,8 +6,7 @@
[attr.data-automation-id]="'checkbox-' + (option.name)"
(change)="changeHandler($event, option)"
class="adf-facet-filter">
-
{{ option.name | translate }}
@@ -15,9 +14,9 @@
-
-