diff --git a/demo-shell/src/app/components/overlay-viewer/overlay-viewer.component.ts b/demo-shell/src/app/components/overlay-viewer/overlay-viewer.component.ts index f57b8e690a..e7498177e5 100644 --- a/demo-shell/src/app/components/overlay-viewer/overlay-viewer.component.ts +++ b/demo-shell/src/app/components/overlay-viewer/overlay-viewer.component.ts @@ -23,7 +23,7 @@ import { Component, Input } from '@angular/core'; export class OverlayViewerComponent { @Input() - showViewer: boolean = false; + showViewer = false; nodeId: string; 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 fd15e5ceff..7b429510a4 100644 --- a/demo-shell/src/app/components/search/search-result.component.html +++ b/demo-shell/src/app/components/search/search-result.component.html @@ -1,7 +1,7 @@ @@ -9,10 +9,11 @@ [currentFolderId]="null" [nodeResult]="resultNodePageList" [disableDragArea]="true" - (documentListReady)="refreshResults($event)" - (changedPageSize)="refreshPage($event)" - (changedPageNumber)="refreshPage($event)" - (turnedNextPage)="refreshPage($event)" - (loadNext)="refreshPage($event)" - (turnedPreviousPage)="refreshPage($event)"> + [pagination]="pagination" + (documentListReady)="onDocumentListReady($event)" + (changedPageSize)="onRefreshPagination($event)" + (changedPageNumber)="onRefreshPagination($event)" + (turnedNextPage)="onRefreshPagination($event)" + (loadNext)="onRefreshPagination($event)" + (turnedPreviousPage)="onRefreshPagination($event)"> diff --git a/demo-shell/src/app/components/search/search-result.component.ts b/demo-shell/src/app/components/search/search-result.component.ts index 8956450232..fd5a203110 100644 --- a/demo-shell/src/app/components/search/search-result.component.ts +++ b/demo-shell/src/app/components/search/search-result.component.ts @@ -31,15 +31,12 @@ export class SearchResultComponent implements OnInit { @ViewChild('search') search: SearchComponent; - fileNodeId: string; queryParamName = 'q'; searchedWord = ''; - fileShowed = false; - navigationMode = 'dblclick'; resultNodePageList: NodePaging; maxItems: number; skipCount = 0; - paging: Pagination; + pagination: Pagination; constructor(public router: Router, private preferences: UserPreferencesService, @@ -56,17 +53,17 @@ export class SearchResultComponent implements OnInit { this.maxItems = this.preferences.paginationSize; } - showSearchResult(event: NodePaging) { - this.resultNodePageList = event; - this.paging = event.list.pagination; + onSearchResultLoaded(nodePaging: NodePaging) { + this.resultNodePageList = nodePaging; + this.pagination = nodePaging.list.pagination; } - refreshResults(event: any) { - this.search.reload(); + onDocumentListReady() { + // this.search.reload(); } - refreshPage(event: Pagination) { - this.maxItems = event.maxItems; - this.skipCount = event.skipCount; + onRefreshPagination(pagination: Pagination) { + this.maxItems = pagination.maxItems; + this.skipCount = pagination.skipCount; } } diff --git a/demo-shell/src/app/components/webscript/webscript.component.ts b/demo-shell/src/app/components/webscript/webscript.component.ts index 9ec17018cf..8a42c6565e 100644 --- a/demo-shell/src/app/components/webscript/webscript.component.ts +++ b/demo-shell/src/app/components/webscript/webscript.component.ts @@ -24,8 +24,6 @@ import { LogService } from '@alfresco/adf-core'; }) export class WebscriptComponent { - currentPath = '/'; - host = 'http://127.0.0.1:8080'; scriptPath = 'sample/folder/Company%20Home'; contextRoot = 'alfresco'; servicePath = 'service'; diff --git a/docs/search-control.component.md b/docs/search-control.component.md index 1921e746d7..8e9fe6c9d1 100644 --- a/docs/search-control.component.md +++ b/docs/search-control.component.md @@ -39,7 +39,7 @@ Displays a input text which shows find-as-you-type suggestions. | expandable | boolean | true | Whether to use an expanding search control, if false then a regular input is used. | | liveSearchEnabled | boolean | true | Whether find-as-you-type suggestions should be offered for matching content items. Set to false to disable. | | liveSearchMaxResults | number | 5 | Maximum number of results to show in the live search. | -| customSearchNode | [QueryBody](https://github.com/Alfresco/alfresco-js-api/blob/1.6.0/src/alfresco-search-rest-api/docs/QueryBody.md) | | object which allow you to perform more elaborated query from the search api | +| customQueryBody | [QueryBody](https://github.com/Alfresco/alfresco-js-api/blob/1.6.0/src/alfresco-search-rest-api/docs/QueryBody.md) | | object which allow you to perform more elaborated query from the search api | ### Events diff --git a/docs/search.component.md b/docs/search.component.md index 7713dc08f9..63bb972fdf 100644 --- a/docs/search.component.md +++ b/docs/search.component.md @@ -32,7 +32,7 @@ | maxResults | number | 20 | Maximum number of results to show in the search. | | skipResults | number | 0 | Number of results to skip from the results pagination. | | displayWith | function | | Function that maps an option's value to its display value in the trigger | -| searchNode | [QueryBody](https://github.com/Alfresco/alfresco-js-api/blob/1.6.0/src/alfresco-search-rest-api/docs/QueryBody.md) | | object which allow you to perform more elaborated query from the search api | +| queryBody| [QueryBody](https://github.com/Alfresco/alfresco-js-api/blob/1.6.0/src/alfresco-search-rest-api/docs/QueryBody.md) | | object which allow you to perform more elaborated query from the search api | ### Events diff --git a/lib/content-services/document-list/components/document-list.component.ts b/lib/content-services/document-list/components/document-list.component.ts index 5c567ad588..f01d57a7a6 100644 --- a/lib/content-services/document-list/components/document-list.component.ts +++ b/lib/content-services/document-list/components/document-list.component.ts @@ -174,7 +174,6 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte noPermission: boolean = false; selection = new Array(); - // PaginatedComponent implementation pagination = new Subject(); private layoutPresets = {}; @@ -282,6 +281,7 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte if (changes.node && changes.node.currentValue) { this.resetSelection(); this.data.loadPage(changes.node.currentValue); + this.pagination.next(changes.node.currentValue.list.pagination); } else if (changes.rowFilter) { this.data.setFilter(changes.rowFilter.currentValue); if (this.currentFolderId) { @@ -862,7 +862,6 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte } } - // PaginatedComponent implementation updatePagination(params: PaginationQueryParams) { const needsReload = this.maxItems !== params.maxItems || this.skipCount !== params.skipCount; @@ -874,7 +873,6 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte } } - // PaginatedComponent implementation get supportedPageSizes(): number[] { return this.appConfig.get('document-list.supportedPageSizes', [5, 10, 15, 25]); } diff --git a/lib/content-services/mock/search.component.mock.ts b/lib/content-services/mock/search.component.mock.ts index 143e9871c2..c3bc5825f5 100644 --- a/lib/content-services/mock/search.component.mock.ts +++ b/lib/content-services/mock/search.component.mock.ts @@ -118,7 +118,7 @@ export let errorJson = { @Component({ template: ` - diff --git a/lib/content-services/search/components/search-control.component.html b/lib/content-services/search/components/search-control.component.html index a1efbae3e4..899e739fa8 100644 --- a/lib/content-services/search/components/search-control.component.html +++ b/lib/content-services/search/components/search-control.component.html @@ -28,7 +28,7 @@ diff --git a/lib/content-services/search/components/search-control.component.ts b/lib/content-services/search/components/search-control.component.ts index 7ada1a9c95..d279ad5431 100644 --- a/lib/content-services/search/components/search-control.component.ts +++ b/lib/content-services/search/components/search-control.component.ts @@ -64,7 +64,7 @@ export class SearchControlComponent implements OnInit, OnDestroy { liveSearchMaxResults: number = 5; @Input() - customSearchNode: QueryBody; + customQueryBody: QueryBody; @Output() submit: EventEmitter = new EventEmitter(); diff --git a/lib/content-services/search/components/search.component.ts b/lib/content-services/search/components/search.component.ts index 2ce43c757d..63d8ec2090 100644 --- a/lib/content-services/search/components/search.component.ts +++ b/lib/content-services/search/components/search.component.ts @@ -67,7 +67,7 @@ export class SearchComponent implements AfterContentInit, OnChanges { searchTerm: string = ''; @Input() - searchNode: QueryBody; + queryBody: QueryBody; @Input('class') set classList(classList: string) { @@ -100,14 +100,13 @@ export class SearchComponent implements AfterContentInit, OnChanges { _classList: { [key: string]: boolean } = {}; - constructor( - private searchService: SearchService, - private changeDetectorRef: ChangeDetectorRef, - private _elementRef: ElementRef) { + constructor(private searchService: SearchService, + private changeDetectorRef: ChangeDetectorRef, + private _elementRef: ElementRef) { this.keyPressedStream.asObservable() .debounceTime(200) .subscribe((searchedWord: string) => { - this.displaySearchResults(searchedWord); + this.loadSearchResults(searchedWord); }); } @@ -117,11 +116,13 @@ export class SearchComponent implements AfterContentInit, OnChanges { ngOnChanges(changes) { this.resetResults(); + if (changes.searchTerm && changes.searchTerm.currentValue) { - this.displaySearchResults(changes.searchTerm.currentValue); - } - if (changes.searchNode && changes.searchNode.currentValue) { - this.displaySearchResults(); + this.loadSearchResults(changes.searchTerm.currentValue); + } else if (changes.queryBody && changes.queryBody.currentValue) { + this.loadSearchResults(); + } else { + this.loadSearchResults(this.searchTerm); } } @@ -131,7 +132,7 @@ export class SearchComponent implements AfterContentInit, OnChanges { } reload() { - this.displaySearchResults(this.searchTerm); + this.loadSearchResults(this.searchTerm); } private cleanResults() { @@ -144,43 +145,43 @@ export class SearchComponent implements AfterContentInit, OnChanges { return searchOpts && searchOpts.query && searchOpts.query.query; } - private displaySearchResults(searchTerm?: string) { - let searchOpts: QueryBody = this.getSearchNode(searchTerm); + private loadSearchResults(searchTerm?: string) { + let searchOpts: QueryBody = this.getQueryBody(searchTerm); if (this.hasValidSearchQuery(searchOpts)) { this.searchService .search(searchOpts) .subscribe( - results => { - this.results = results; - this.resultLoaded.emit(this.results); - this.isOpen = true; - this.setVisibility(); - }, - error => { - if (error.status !== 400) { - this.results = null; - this.error.emit(error); - } - }); + results => { + this.results = results; + this.resultLoaded.emit(this.results); + this.isOpen = true; + this.setVisibility(); + }, + error => { + if (error.status !== 400) { + this.results = null; + this.error.emit(error); + } + }); } else { this.cleanResults(); } } - private getSearchNode(searchTerm: string): QueryBody { - if (this.searchNode) { - if (!this.searchNode.query.query && searchTerm) { - this.searchNode.query.query = searchTerm; + private getQueryBody(searchTerm: string): QueryBody { + if (this.queryBody) { + if (!this.queryBody.query.query && searchTerm) { + this.queryBody.query.query = searchTerm; } - return this.searchNode; + return this.queryBody; } else { return this.generateDefaultSearchNode(searchTerm); } } private generateDefaultSearchNode(searchTerm: string): QueryBody { - let defaultSearchNode: QueryBody = { + let defaultQueryBody: QueryBody = { query: { query: searchTerm ? `${searchTerm}* OR name:${searchTerm}*` : searchTerm }, @@ -193,7 +194,8 @@ export class SearchComponent implements AfterContentInit, OnChanges { { query: "TYPE:'cm:folder' OR TYPE:'cm:content'" }, { query: 'NOT cm:creator:System' }] }; - return defaultSearchNode; + + return defaultQueryBody; } hidePanel() {