From 35b6ec269ee2870a27bc933498f1ffae4763e455 Mon Sep 17 00:00:00 2001 From: Denys Vuika Date: Tue, 12 Jul 2016 10:39:25 +0100 Subject: [PATCH 1/9] #70 Pagination type definition --- .../src/models/document-library.model.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/ng2-components/ng2-alfresco-documentlist/src/models/document-library.model.ts b/ng2-components/ng2-alfresco-documentlist/src/models/document-library.model.ts index 71cab49dcb..13f99549c9 100644 --- a/ng2-components/ng2-alfresco-documentlist/src/models/document-library.model.ts +++ b/ng2-components/ng2-alfresco-documentlist/src/models/document-library.model.ts @@ -22,6 +22,7 @@ export class NodePaging { } export class NodePagingList { + pagination: Pagination; entries: MinimalNodeEntity[]; } @@ -29,6 +30,14 @@ export class MinimalNodeEntity { entry: MinimalNodeEntryEntity; } +export class Pagination { + count: number; + hasMoreItems: boolean; + totalItems: number; + skipCount: number; + maxItems: number; +} + export class MinimalNodeEntryEntity { id: string; parentId: string; From 9c5ae7c05e2b20ee74d90076b9ec31983d8ac5ee Mon Sep 17 00:00:00 2001 From: Denys Vuika Date: Tue, 12 Jul 2016 11:09:34 +0100 Subject: [PATCH 2/9] #70 better component partitioning --- ng2-components/ng2-alfresco-documentlist/index.ts | 4 ++-- .../breadcrumb.component.css} | 0 .../breadcrumb.component.html} | 0 .../breadcrumb.component.spec.ts} | 4 ++-- .../breadcrumb.component.ts} | 6 +++--- .../src/models/document-library.model.ts | 2 ++ .../src/services/document-list.service.ts | 5 ++--- 7 files changed, 11 insertions(+), 10 deletions(-) rename ng2-components/ng2-alfresco-documentlist/src/components/{document-list-breadcrumb.component.css => breadcrumb/breadcrumb.component.css} (100%) rename ng2-components/ng2-alfresco-documentlist/src/components/{document-list-breadcrumb.component.html => breadcrumb/breadcrumb.component.html} (100%) rename ng2-components/ng2-alfresco-documentlist/src/components/{document-list-breadcrumb.component.spec.ts => breadcrumb/breadcrumb.component.spec.ts} (97%) rename ng2-components/ng2-alfresco-documentlist/src/components/{document-list-breadcrumb.component.ts => breadcrumb/breadcrumb.component.ts} (94%) diff --git a/ng2-components/ng2-alfresco-documentlist/index.ts b/ng2-components/ng2-alfresco-documentlist/index.ts index 946923d327..7c2f142c61 100644 --- a/ng2-components/ng2-alfresco-documentlist/index.ts +++ b/ng2-components/ng2-alfresco-documentlist/index.ts @@ -21,7 +21,7 @@ import { ContentColumnList } from './src/components/content-column-list'; import { ContentAction } from './src/components/content-action'; import { ContentActionList } from './src/components/content-action-list'; import { EmptyFolderContent } from './src/components/empty-folder-content'; -import { DocumentListBreadcrumb } from './src/components/document-list-breadcrumb.component'; +import { DocumentListBreadcrumb } from './src/components/breadcrumb/breadcrumb.component'; import { FolderActionsService } from './src/services/folder-actions.service'; import { DocumentActionsService } from './src/services/document-actions.service'; @@ -34,7 +34,7 @@ export * from './src/components/content-column-list'; export * from './src/components/content-action'; export * from './src/components/content-action-list'; export * from './src/components/empty-folder-content'; -export * from './src/components/document-list-breadcrumb.component'; +export * from './src/components/breadcrumb/breadcrumb.component'; // services export * from './src/services/folder-actions.service'; diff --git a/ng2-components/ng2-alfresco-documentlist/src/components/document-list-breadcrumb.component.css b/ng2-components/ng2-alfresco-documentlist/src/components/breadcrumb/breadcrumb.component.css similarity index 100% rename from ng2-components/ng2-alfresco-documentlist/src/components/document-list-breadcrumb.component.css rename to ng2-components/ng2-alfresco-documentlist/src/components/breadcrumb/breadcrumb.component.css diff --git a/ng2-components/ng2-alfresco-documentlist/src/components/document-list-breadcrumb.component.html b/ng2-components/ng2-alfresco-documentlist/src/components/breadcrumb/breadcrumb.component.html similarity index 100% rename from ng2-components/ng2-alfresco-documentlist/src/components/document-list-breadcrumb.component.html rename to ng2-components/ng2-alfresco-documentlist/src/components/breadcrumb/breadcrumb.component.html diff --git a/ng2-components/ng2-alfresco-documentlist/src/components/document-list-breadcrumb.component.spec.ts b/ng2-components/ng2-alfresco-documentlist/src/components/breadcrumb/breadcrumb.component.spec.ts similarity index 97% rename from ng2-components/ng2-alfresco-documentlist/src/components/document-list-breadcrumb.component.spec.ts rename to ng2-components/ng2-alfresco-documentlist/src/components/breadcrumb/breadcrumb.component.spec.ts index 47a688a106..aad08a8088 100644 --- a/ng2-components/ng2-alfresco-documentlist/src/components/document-list-breadcrumb.component.spec.ts +++ b/ng2-components/ng2-alfresco-documentlist/src/components/breadcrumb/breadcrumb.component.spec.ts @@ -25,8 +25,8 @@ import { import { DocumentListBreadcrumb, PathNode -} from './document-list-breadcrumb.component'; -import { DocumentList } from './document-list'; +} from './breadcrumb.component'; +import { DocumentList } from '../document-list'; describe('DocumentListBreadcrumb', () => { diff --git a/ng2-components/ng2-alfresco-documentlist/src/components/document-list-breadcrumb.component.ts b/ng2-components/ng2-alfresco-documentlist/src/components/breadcrumb/breadcrumb.component.ts similarity index 94% rename from ng2-components/ng2-alfresco-documentlist/src/components/document-list-breadcrumb.component.ts rename to ng2-components/ng2-alfresco-documentlist/src/components/breadcrumb/breadcrumb.component.ts index 40e1c13308..2cbce772ee 100644 --- a/ng2-components/ng2-alfresco-documentlist/src/components/document-list-breadcrumb.component.ts +++ b/ng2-components/ng2-alfresco-documentlist/src/components/breadcrumb/breadcrumb.component.ts @@ -21,15 +21,15 @@ import { Output, EventEmitter } from '@angular/core'; -import { DocumentList } from './document-list'; +import { DocumentList } from '../document-list'; declare let __moduleName: string; @Component({ moduleId: __moduleName, selector: 'alfresco-document-list-breadcrumb', - templateUrl: './document-list-breadcrumb.component.html', - styleUrls: ['./document-list-breadcrumb.component.css'] + templateUrl: './breadcrumb.component.html', + styleUrls: ['./breadcrumb.component.css'] }) export class DocumentListBreadcrumb { diff --git a/ng2-components/ng2-alfresco-documentlist/src/models/document-library.model.ts b/ng2-components/ng2-alfresco-documentlist/src/models/document-library.model.ts index 13f99549c9..3db16122ae 100644 --- a/ng2-components/ng2-alfresco-documentlist/src/models/document-library.model.ts +++ b/ng2-components/ng2-alfresco-documentlist/src/models/document-library.model.ts @@ -26,6 +26,7 @@ export class NodePagingList { entries: MinimalNodeEntity[]; } +// TODO: rename to NodeMinimalEntry export class MinimalNodeEntity { entry: MinimalNodeEntryEntity; } @@ -38,6 +39,7 @@ export class Pagination { maxItems: number; } +// TODO: rename to NodeMinimal export class MinimalNodeEntryEntity { id: string; parentId: string; diff --git a/ng2-components/ng2-alfresco-documentlist/src/services/document-list.service.ts b/ng2-components/ng2-alfresco-documentlist/src/services/document-list.service.ts index 6a78992fd7..dccc26840c 100644 --- a/ng2-components/ng2-alfresco-documentlist/src/services/document-list.service.ts +++ b/ng2-components/ng2-alfresco-documentlist/src/services/document-list.service.ts @@ -82,7 +82,6 @@ export class DocumentListService { }; return apiInstance.getNodeChildren(nodeId, opts); } - deleteNode(nodeId: string) { let client = this.getAlfrescoClient(); let nodesApi = new AlfrescoApi.Core.NodesApi(client); @@ -95,7 +94,7 @@ export class DocumentListService { * @param folder Path to folder. * @returns {Observable} Folder entity. */ - getFolder(folder: string) { + getFolder(folder: string): Observable { return Observable.fromPromise(this.getNodesPromise(folder)) .map(res => res) // .do(data => console.log('Node data', data)) // eyeball results in the console @@ -107,7 +106,7 @@ export class DocumentListService { * @param node Node to get URL for. * @returns {string} URL address. */ - getDocumentThumbnailUrl(node: MinimalNodeEntity) { + getDocumentThumbnailUrl(node: MinimalNodeEntity): string { if (node && this.contentService) { return this.contentService.getDocumentThumbnailUrl(node); } From aa6c9a988f1997d561bdd813a9e8fc604f429d00 Mon Sep 17 00:00:00 2001 From: Denys Vuika Date: Tue, 12 Jul 2016 19:53:53 +0100 Subject: [PATCH 3/9] #70 pagination component (first cut), mdl directives --- .../app/components/files/files.component.html | 2 + ng2-components/ng2-alfresco-core/.gitignore | 2 +- ng2-components/ng2-alfresco-core/index.js.map | 1 - ng2-components/ng2-alfresco-core/index.ts | 15 ++- .../src/data/pagination-provider.ts | 47 ++++++++ .../src/material/mdl-button.directive.ts | 38 +++++++ .../src/material/mdl-menu.directive.ts | 38 +++++++ .../ng2-alfresco-documentlist/index.ts | 5 +- .../pagination/pagination.component.css | 64 +++++++++++ .../pagination/pagination.component.html | 23 ++++ .../pagination/pagination.component.ts | 55 ++++++++++ .../src/data/share-datatable-adapter.ts | 100 +++++++++++++----- .../src/services/document-list.service.ts | 1 + 13 files changed, 362 insertions(+), 29 deletions(-) delete mode 100644 ng2-components/ng2-alfresco-core/index.js.map create mode 100644 ng2-components/ng2-alfresco-core/src/data/pagination-provider.ts create mode 100644 ng2-components/ng2-alfresco-core/src/material/mdl-button.directive.ts create mode 100644 ng2-components/ng2-alfresco-core/src/material/mdl-menu.directive.ts create mode 100644 ng2-components/ng2-alfresco-documentlist/src/components/pagination/pagination.component.css create mode 100644 ng2-components/ng2-alfresco-documentlist/src/components/pagination/pagination.component.html create mode 100644 ng2-components/ng2-alfresco-documentlist/src/components/pagination/pagination.component.ts diff --git a/demo-shell-ng2/app/components/files/files.component.html b/demo-shell-ng2/app/components/files/files.component.html index 119653aa46..0f4a862066 100644 --- a/demo-shell-ng2/app/components/files/files.component.html +++ b/demo-shell-ng2/app/components/files/files.component.html @@ -92,6 +92,8 @@ + + diff --git a/ng2-components/ng2-alfresco-core/.gitignore b/ng2-components/ng2-alfresco-core/.gitignore index bf980cac93..13324e66b9 100644 --- a/ng2-components/ng2-alfresco-core/.gitignore +++ b/ng2-components/ng2-alfresco-core/.gitignore @@ -11,5 +11,5 @@ demo/**/*.js demo/**/*.js.map demo/**/*.d.ts index.js -index.map +index.js.map !systemjs.config.js diff --git a/ng2-components/ng2-alfresco-core/index.js.map b/ng2-components/ng2-alfresco-core/index.js.map deleted file mode 100644 index 1015c095d3..0000000000 --- a/ng2-components/ng2-alfresco-core/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;;;;;QAwBU,uBAAuB,EAUvB,sBAAsB,EAItB,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAdvB,qCAAA,uBAAuB,GAAU;gBAC1C,qEAA6B;gBAC7B,uDAAsB;gBACtB,yDAAuB;gBACvB,6DAAyB;gBACzB,+DAA0B;gBAC1B,qDAAqB;gBACrB,yCAAkB;aACrB,CAAA,CAAC;YAEW,oCAAA,sBAAsB,GAAU;gBACzC,yCAAkB;aACrB,CAAA,CAAC;YAEW,qCAAA,uBAAuB,GAAU;gBAC1C,0DAA0B;gBAC1B,6CAAoB;aACvB,CAAA,CAAC"} \ No newline at end of file diff --git a/ng2-components/ng2-alfresco-core/index.ts b/ng2-components/ng2-alfresco-core/index.ts index 5c70878787..62059dff40 100644 --- a/ng2-components/ng2-alfresco-core/index.ts +++ b/ng2-components/ng2-alfresco-core/index.ts @@ -24,19 +24,27 @@ import { AlfrescoContentService } from './src/services/AlfrescoContentService.se import { ContextMenuService } from './src/services/context-menu.service'; import { ContextMenuHolderComponent } from './src/components/context-menu-holder.component'; import { ContextMenuDirective } from './src/components/context-menu.directive'; +import { MDL } from './src/material/MaterialDesignLiteUpgradeElement'; +import { AlfrescoMdlButtonDirective } from './src/material/mdl-button.directive'; +import { AlfrescoMdlMenuDirective } from './src/material/mdl-menu.directive'; export * from './src/services/AlfrescoSettingsService.service'; export * from './src/services/AlfrescoTranslationLoader.service'; export * from './src/services/AlfrescoTranslationService.service'; export * from './src/services/AlfrescoPipeTranslate.service'; -export * from './src/material/MaterialDesignLiteUpgradeElement'; export * from './src/services/AlfrescoAuthenticationService.service'; export * from './src/services/AlfrescoContentService.service'; +// Material Design Lite integration +export * from './src/material/MaterialDesignLiteUpgradeElement'; +export * from './src/material/mdl-button.directive'; +export * from './src/material/mdl-menu.directive'; + export * from './src/services/context-menu.service'; export * from './src/components/context-menu-holder.component'; export * from './src/components/context-menu.directive'; +export * from './src/data/pagination-provider'; export * from './src/utils/object-utils'; export const ALFRESCO_CORE_PROVIDERS: [any] = [ @@ -58,3 +66,8 @@ export const CONTEXT_MENU_DIRECTIVES: [any] = [ ContextMenuDirective ]; +export const MATERIAL_DESIGN_DIRECTIVES: [any] = [ + MDL, + AlfrescoMdlButtonDirective, + AlfrescoMdlMenuDirective +]; diff --git a/ng2-components/ng2-alfresco-core/src/data/pagination-provider.ts b/ng2-components/ng2-alfresco-core/src/data/pagination-provider.ts new file mode 100644 index 0000000000..c4e58a66e9 --- /dev/null +++ b/ng2-components/ng2-alfresco-core/src/data/pagination-provider.ts @@ -0,0 +1,47 @@ +/*! + * @license + * Copyright 2016 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. + */ + +export interface PaginationProvider { + + /** + * The number of objects in the collection. + */ + count: number; + + /** + * A boolean value which is true if there are more entities in the collection beyond those in this response. + * A true value means a request with a larger value for the skipCount or the maxItems parameter will return more entities. + */ + hasMoreItems: boolean; + + /** + * An integer describing the total number of entities in the collection. + * The API might not be able to determine this value, in which case this property will not be present. + */ + totalItems?: number; + + /** + * An integer describing how many entities exist in the collection before those included in this list. + */ + skipCount: number; + + /** + * The value of the maxItems parameter used to generate this list, + * or if there was no maxItems parameter the default value is 100. + */ + maxItems: number; +} diff --git a/ng2-components/ng2-alfresco-core/src/material/mdl-button.directive.ts b/ng2-components/ng2-alfresco-core/src/material/mdl-button.directive.ts new file mode 100644 index 0000000000..96f82aad74 --- /dev/null +++ b/ng2-components/ng2-alfresco-core/src/material/mdl-button.directive.ts @@ -0,0 +1,38 @@ +/*! + * @license + * Copyright 2016 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, ElementRef, AfterViewInit } from '@angular/core'; + +declare var componentHandler; + +@Directive({ + selector: '[alfresco-mdl-button]' +}) +export class AlfrescoMdlButtonDirective implements AfterViewInit { + + constructor(private element: ElementRef) {} + + ngAfterViewInit() { + if (componentHandler) { + let el = this.element.nativeElement; + el.classList.add('mdl-button'); + el.classList.add('mdl-js-button'); + el.classList.add('mdl-js-ripple-effect'); + componentHandler.upgradeElement(el, 'MaterialButton'); + } + } +} diff --git a/ng2-components/ng2-alfresco-core/src/material/mdl-menu.directive.ts b/ng2-components/ng2-alfresco-core/src/material/mdl-menu.directive.ts new file mode 100644 index 0000000000..370665234b --- /dev/null +++ b/ng2-components/ng2-alfresco-core/src/material/mdl-menu.directive.ts @@ -0,0 +1,38 @@ +/*! + * @license + * Copyright 2016 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, ElementRef, AfterViewInit } from '@angular/core'; + +declare var componentHandler; + +@Directive({ + selector: '[alfresco-mdl-menu]' +}) +export class AlfrescoMdlMenuDirective implements AfterViewInit { + + constructor(private element: ElementRef) {} + + ngAfterViewInit() { + if (componentHandler) { + let el = this.element.nativeElement; + el.classList.add('mdl-menu'); + el.classList.add('mdl-js-menu'); + el.classList.add('mdl-js-ripple-effect'); + componentHandler.upgradeElement(el, 'MaterialMenu'); + } + } +} diff --git a/ng2-components/ng2-alfresco-documentlist/index.ts b/ng2-components/ng2-alfresco-documentlist/index.ts index 7c2f142c61..0678520b1f 100644 --- a/ng2-components/ng2-alfresco-documentlist/index.ts +++ b/ng2-components/ng2-alfresco-documentlist/index.ts @@ -22,6 +22,7 @@ import { ContentAction } from './src/components/content-action'; import { ContentActionList } from './src/components/content-action-list'; import { EmptyFolderContent } from './src/components/empty-folder-content'; import { DocumentListBreadcrumb } from './src/components/breadcrumb/breadcrumb.component'; +import { DocumentListPagination } from './src/components/pagination/pagination.component'; import { FolderActionsService } from './src/services/folder-actions.service'; import { DocumentActionsService } from './src/services/document-actions.service'; @@ -35,6 +36,7 @@ export * from './src/components/content-action'; export * from './src/components/content-action-list'; export * from './src/components/empty-folder-content'; export * from './src/components/breadcrumb/breadcrumb.component'; +export * from './src/components/pagination/pagination.component'; // services export * from './src/services/folder-actions.service'; @@ -48,7 +50,8 @@ export const DOCUMENT_LIST_DIRECTIVES: [any] = [ ContentAction, ContentActionList, EmptyFolderContent, - DocumentListBreadcrumb + DocumentListBreadcrumb, + DocumentListPagination ]; export const DOCUMENT_LIST_PROVIDERS: [any] = [ diff --git a/ng2-components/ng2-alfresco-documentlist/src/components/pagination/pagination.component.css b/ng2-components/ng2-alfresco-documentlist/src/components/pagination/pagination.component.css new file mode 100644 index 0000000000..221ad85823 --- /dev/null +++ b/ng2-components/ng2-alfresco-documentlist/src/components/pagination/pagination.component.css @@ -0,0 +1,64 @@ +.mdl-paging { + color: rgba(0, 0, 0, 0.54); + display: -webkit-flex; + display: -ms-flexbox; + display: flex; + -webkit-justify-content: flex-end; + -ms-flex-pack: end; + justify-content: flex-end; + -webkit-align-items: center; + -ms-flex-align: center; + align-items: center; + height: 56px; + -webkit-flex-flow: row wrap; + -ms-flex-flow: row wrap; + flex-flow: row wrap; +} + +.mdl-paging > * { + -webkit-flex: none; + -ms-flex: none; + flex: none; +} + +.mdl-list + .mdl-paging { + margin: 0; +} + +.mdl-paging__per-page { + position: relative; +} + +.mdl-paging__per-page-label { + margin-right: 40px; +} + +.mdl-paging__per-page-value { + position: absolute; + right: 36px; + top: 6px; +} + +.mdl-paging__per-page + .mdl-paging__count { + margin-left: 24px; +} + +.mdl-paging .mdl-menu { + min-width: 64px; +} + +.mdl-paging__prev:last-child { + margin-right: 44px; +} + +.mdl-paging__count + .mdl-paging__prev { + margin-left: 24px; +} + +.mdl-paging__prev + .mdl-paging__next { + margin-left: 12px; +} + +.mdl-paging__count + .mdl-paging__next { + margin-left: 68px; +} diff --git a/ng2-components/ng2-alfresco-documentlist/src/components/pagination/pagination.component.html b/ng2-components/ng2-alfresco-documentlist/src/components/pagination/pagination.component.html new file mode 100644 index 0000000000..fd075193d7 --- /dev/null +++ b/ng2-components/ng2-alfresco-documentlist/src/components/pagination/pagination.component.html @@ -0,0 +1,23 @@ +
+ + Rows per page: + {{pageSize}} + +
    +
  • + {{size}} +
  • +
+
+ 1-10 of 25 + + +
diff --git a/ng2-components/ng2-alfresco-documentlist/src/components/pagination/pagination.component.ts b/ng2-components/ng2-alfresco-documentlist/src/components/pagination/pagination.component.ts new file mode 100644 index 0000000000..3461255dbd --- /dev/null +++ b/ng2-components/ng2-alfresco-documentlist/src/components/pagination/pagination.component.ts @@ -0,0 +1,55 @@ +/*! + * @license + * Copyright 2016 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, Input, OnInit } from '@angular/core'; +import { + MATERIAL_DESIGN_DIRECTIVES, + PaginationProvider +} from 'ng2-alfresco-core'; + +declare let __moduleName: string; + +@Component({ + moduleId: __moduleName, + selector: 'alfresco-document-list-pagination', + templateUrl: './pagination.component.html', + styleUrls: ['./pagination.component.css'], + directives: [MATERIAL_DESIGN_DIRECTIVES] +}) +export class DocumentListPagination implements OnInit { + + @Input() + supportedPageSizes: number[] = [5, 10, 20, 50, 100]; + + @Input() + provider: PaginationProvider; + + @Input() + pageSize: number = 10; + + constructor() {} + + setPageSize(value: number) { + this.pageSize = value; + } + + ngOnInit() { + console.info(this.provider); + } +} + + diff --git a/ng2-components/ng2-alfresco-documentlist/src/data/share-datatable-adapter.ts b/ng2-components/ng2-alfresco-documentlist/src/data/share-datatable-adapter.ts index 66b88d63c5..7d3de45ec5 100644 --- a/ng2-components/ng2-alfresco-documentlist/src/data/share-datatable-adapter.ts +++ b/ng2-components/ng2-alfresco-documentlist/src/data/share-datatable-adapter.ts @@ -16,7 +16,7 @@ */ import { DatePipe } from '@angular/common'; -import { ObjectUtils } from 'ng2-alfresco-core'; +import { PaginationProvider, ObjectUtils } from 'ng2-alfresco-core'; import { DataTableAdapter, DataRow, DataColumn, DataSorting @@ -25,16 +25,24 @@ import { import { NodePaging, MinimalNodeEntity } from './../models/document-library.model'; import { DocumentListService } from './../services/document-list.service'; -export class ShareDataTableAdapter implements DataTableAdapter { +export class ShareDataTableAdapter implements DataTableAdapter, PaginationProvider { static ERR_ROW_NOT_FOUND: string = 'Row not found'; static ERR_COL_NOT_FOUND: string = 'Column not found'; static DEFAULT_DATE_FORMAT: string = 'medium'; + static DEFAULT_PAGE_SIZE: number = 100; private sorting: DataSorting; private rows: DataRow[]; private columns: DataColumn[]; + private page: NodePaging; + + private _count: number = 0; + private _hasMoreItems: boolean = false; + private _totalItems: number = 0; + private _skipCount: number = 0; + private _maxItems: number = ShareDataTableAdapter.DEFAULT_PAGE_SIZE; thumbnails: boolean = false; @@ -43,12 +51,34 @@ export class ShareDataTableAdapter implements DataTableAdapter { schema: DataColumn[]) { this.rows = []; this.columns = schema || []; + this.resetPagination(); + } + + get count(): number { + return this._count; + } + + get hasMoreItems(): boolean { + return this._hasMoreItems; + } + + get totalItems(): number { + return this._totalItems; + } + + get skipCount(): number { + return this._skipCount; + } + + get maxItems(): number { + return this._maxItems; } getRows(): Array { return this.rows; } + // TODO: disable this api setRows(rows: Array) { this.rows = rows || []; this.sort(); @@ -165,33 +195,53 @@ export class ShareDataTableAdapter implements DataTableAdapter { if (path && this.documentListService) { this.documentListService .getFolder(path) - .subscribe(val => { - let page = val; - let rows = []; - - if (page && page.list) { - let data = page.list.entries; - if (data && data.length > 0) { - rows = data.map(item => new ShareDataRow(item)); - - // Sort by first sortable or just first column - if (this.columns && this.columns.length > 0) { - let sortable = this.columns.filter(c => c.sortable); - if (sortable.length > 0) { - this.sort(sortable[0].key, 'asc'); - } else { - this.sort(this.columns[0].key, 'asc'); - } - } - } - } - - this.rows = rows; - }, + .subscribe(val => this.loadPage(val), error => console.error(error)); } } + private loadPage(page: NodePaging) { + this.page = page; + this.resetPagination(); + + let rows = []; + + if (page && page.list) { + let data = page.list.entries; + if (data && data.length > 0) { + rows = data.map(item => new ShareDataRow(item)); + + // Sort by first sortable or just first column + if (this.columns && this.columns.length > 0) { + let sortable = this.columns.filter(c => c.sortable); + if (sortable.length > 0) { + this.sort(sortable[0].key, 'asc'); + } else { + this.sort(this.columns[0].key, 'asc'); + } + } + } + + let pagination = page.list.pagination; + if (pagination) { + this._count = pagination.count; + this._hasMoreItems = pagination.hasMoreItems; + this._maxItems = pagination.maxItems; + this._skipCount = pagination.skipCount; + this._totalItems = pagination.totalItems; + } + } + + this.rows = rows; + } + + private resetPagination() { + this._count = 0; + this._hasMoreItems = false; + this._totalItems = 0; + this._skipCount = 0; + this._maxItems = ShareDataTableAdapter.DEFAULT_PAGE_SIZE; + } } export class ShareDataRow implements DataRow { diff --git a/ng2-components/ng2-alfresco-documentlist/src/services/document-list.service.ts b/ng2-components/ng2-alfresco-documentlist/src/services/document-list.service.ts index dccc26840c..c782d40a6f 100644 --- a/ng2-components/ng2-alfresco-documentlist/src/services/document-list.service.ts +++ b/ng2-components/ng2-alfresco-documentlist/src/services/document-list.service.ts @@ -89,6 +89,7 @@ export class DocumentListService { return Observable.fromPromise(nodesApi.deleteNode(nodeId, opts)); } + // TODO: rename to 'getFolderContent' /** * Gets the folder node with the content. * @param folder Path to folder. From 7849ef432349d508a9ff4a671e6058801f132bc7 Mon Sep 17 00:00:00 2001 From: Denys Vuika Date: Wed, 13 Jul 2016 12:13:25 +0100 Subject: [PATCH 4/9] #70 pagination support for document list --- .../src/components/document-list.ts | 15 +++--- .../pagination/pagination.component.html | 10 ++-- .../pagination/pagination.component.ts | 46 ++++++++++++++++--- .../src/data/share-datatable-adapter.spec.ts | 6 +-- .../src/data/share-datatable-adapter.ts | 40 ++++++++++++---- .../src/services/document-list.service.ts | 21 +++++++-- 6 files changed, 104 insertions(+), 34 deletions(-) diff --git a/ng2-components/ng2-alfresco-documentlist/src/components/document-list.ts b/ng2-components/ng2-alfresco-documentlist/src/components/document-list.ts index 26bb14d6b9..65568ef122 100644 --- a/ng2-components/ng2-alfresco-documentlist/src/components/document-list.ts +++ b/ng2-components/ng2-alfresco-documentlist/src/components/document-list.ts @@ -27,7 +27,8 @@ import { OnChanges, TemplateRef, NgZone, - ViewChild + ViewChild, + HostListener } from '@angular/core'; import { Subject } from 'rxjs/Rx'; import { CONTEXT_MENU_DIRECTIVES } from 'ng2-alfresco-core'; @@ -53,15 +54,13 @@ declare let __moduleName: string; styleUrls: ['./document-list.css'], templateUrl: './document-list.html', providers: [DocumentListService], - directives: [CONTEXT_MENU_DIRECTIVES, ALFRESCO_DATATABLE_DIRECTIVES], - host: { - '(contextmenu)': 'onShowContextMenu($event)' - } + directives: [CONTEXT_MENU_DIRECTIVES, ALFRESCO_DATATABLE_DIRECTIVES] }) export class DocumentList implements OnInit, AfterViewInit, AfterViewChecked, AfterContentInit, OnChanges { static SINGLE_CLICK_NAVIGATION: string = 'click'; static DOUBLE_CLICK_NAVIGATION: string = 'dblclick'; + static DEFAULT_PAGE_SIZE: number = 20; DEFAULT_ROOT_FOLDER: string = '/'; @@ -85,6 +84,9 @@ export class DocumentList implements OnInit, AfterViewInit, AfterViewChecked, Af @Input() contextMenuActions: boolean = false; + @Input() + pageSize: number = DocumentList.DEFAULT_PAGE_SIZE; + @Output() nodeClick: EventEmitter = new EventEmitter(); @@ -154,6 +156,7 @@ export class DocumentList implements OnInit, AfterViewInit, AfterViewChecked, Af ngOnInit() { this.data.thumbnails = this.thumbnails; + this.data.maxItems = this.pageSize; this.displayFolderContent(this.currentFolderPath); this.contextActionHandler.subscribe(val => this.contextActionCallback(val)); } @@ -211,6 +214,7 @@ export class DocumentList implements OnInit, AfterViewInit, AfterViewChecked, Af return []; } + @HostListener('contextmenu', ['$event']) onShowContextMenu(e?: Event) { if (e) { e.preventDefault(); @@ -365,5 +369,4 @@ export class DocumentList implements OnInit, AfterViewInit, AfterViewChecked, Af this.executeContentAction(node, action); } } - } diff --git a/ng2-components/ng2-alfresco-documentlist/src/components/pagination/pagination.component.html b/ng2-components/ng2-alfresco-documentlist/src/components/pagination/pagination.component.html index fd075193d7..0a39c8858e 100644 --- a/ng2-components/ng2-alfresco-documentlist/src/components/pagination/pagination.component.html +++ b/ng2-components/ng2-alfresco-documentlist/src/components/pagination/pagination.component.html @@ -13,11 +13,15 @@ - 1-10 of 25 - - diff --git a/ng2-components/ng2-alfresco-documentlist/src/components/pagination/pagination.component.ts b/ng2-components/ng2-alfresco-documentlist/src/components/pagination/pagination.component.ts index 3461255dbd..974e06b1ac 100644 --- a/ng2-components/ng2-alfresco-documentlist/src/components/pagination/pagination.component.ts +++ b/ng2-components/ng2-alfresco-documentlist/src/components/pagination/pagination.component.ts @@ -15,7 +15,7 @@ * limitations under the License. */ -import { Component, Input, OnInit } from '@angular/core'; +import { Component, Input } from '@angular/core'; import { MATERIAL_DESIGN_DIRECTIVES, PaginationProvider @@ -30,7 +30,9 @@ declare let __moduleName: string; styleUrls: ['./pagination.component.css'], directives: [MATERIAL_DESIGN_DIRECTIVES] }) -export class DocumentListPagination implements OnInit { +export class DocumentListPagination { + + DEFAULT_PAGE_SIZE: number = 20; @Input() supportedPageSizes: number[] = [5, 10, 20, 50, 100]; @@ -38,17 +40,47 @@ export class DocumentListPagination implements OnInit { @Input() provider: PaginationProvider; - @Input() - pageSize: number = 10; + get pageSize(): number { + if (this.provider) { + return this.provider.maxItems; + } + return this.DEFAULT_PAGE_SIZE; + } - constructor() {} + set pageSize(value: number) { + if (this.provider) { + this.provider.maxItems = value; + } + } setPageSize(value: number) { this.pageSize = value; } - ngOnInit() { - console.info(this.provider); + get summary(): string { + let from = this.provider.skipCount; + if (from === 0) { + from = 1; + } + let to = this.provider.skipCount + this.provider.count; + let of = this.provider.totalItems; + return `${from}-${to} of ${of}`; + } + + get nextPageAvail(): boolean { + return this.provider.hasMoreItems; + } + + get prevPageAvail(): boolean { + return this.provider.skipCount > 0; + } + + showNextPage() { + this.provider.skipCount += this.provider.maxItems; + } + + showPrevPage() { + this.provider.skipCount -= this.provider.maxItems; } } diff --git a/ng2-components/ng2-alfresco-documentlist/src/data/share-datatable-adapter.spec.ts b/ng2-components/ng2-alfresco-documentlist/src/data/share-datatable-adapter.spec.ts index 2478debb2d..240c7706f1 100644 --- a/ng2-components/ng2-alfresco-documentlist/src/data/share-datatable-adapter.spec.ts +++ b/ng2-components/ng2-alfresco-documentlist/src/data/share-datatable-adapter.spec.ts @@ -94,13 +94,13 @@ describe('ShareDataTableAdapter', () => { it('should fail when getting value for missing row', () => { let adapter = new ShareDataTableAdapter(null, null, null); let check = () => { return adapter.getValue(null, {}); }; - expect(check).toThrowError(ShareDataTableAdapter.ERR_ROW_NOT_FOUND); + expect(check).toThrowError(adapter.ERR_ROW_NOT_FOUND); }); it('should fail when getting value for missing column', () => { let adapter = new ShareDataTableAdapter(null, null, null); let check = () => { return adapter.getValue({}, null); }; - expect(check).toThrowError(ShareDataTableAdapter.ERR_COL_NOT_FOUND); + expect(check).toThrowError(adapter.ERR_COL_NOT_FOUND); }); it('should require path to load data', () => { @@ -283,7 +283,7 @@ describe('ShareDataTableAdapter', () => { }); it('should resolve file thumbnail', () => { - let imageUrl: 'http://'; + let imageUrl: string = 'http://'; spyOn(documentListService, 'getDocumentThumbnailUrl').and.returnValue(imageUrl); let adapter = new ShareDataTableAdapter(documentListService, basePath, null); diff --git a/ng2-components/ng2-alfresco-documentlist/src/data/share-datatable-adapter.ts b/ng2-components/ng2-alfresco-documentlist/src/data/share-datatable-adapter.ts index 7d3de45ec5..47eb0e4473 100644 --- a/ng2-components/ng2-alfresco-documentlist/src/data/share-datatable-adapter.ts +++ b/ng2-components/ng2-alfresco-documentlist/src/data/share-datatable-adapter.ts @@ -27,22 +27,24 @@ import { DocumentListService } from './../services/document-list.service'; export class ShareDataTableAdapter implements DataTableAdapter, PaginationProvider { - static ERR_ROW_NOT_FOUND: string = 'Row not found'; - static ERR_COL_NOT_FOUND: string = 'Column not found'; + ERR_ROW_NOT_FOUND: string = 'Row not found'; + ERR_COL_NOT_FOUND: string = 'Column not found'; - static DEFAULT_DATE_FORMAT: string = 'medium'; - static DEFAULT_PAGE_SIZE: number = 100; + DEFAULT_DATE_FORMAT: string = 'medium'; + DEFAULT_PAGE_SIZE: number = 20; + MIN_PAGE_SIZE: number = 5; private sorting: DataSorting; private rows: DataRow[]; private columns: DataColumn[]; private page: NodePaging; + private currentPath: string; private _count: number = 0; private _hasMoreItems: boolean = false; private _totalItems: number = 0; private _skipCount: number = 0; - private _maxItems: number = ShareDataTableAdapter.DEFAULT_PAGE_SIZE; + private _maxItems: number = this.DEFAULT_PAGE_SIZE; thumbnails: boolean = false; @@ -70,10 +72,24 @@ export class ShareDataTableAdapter implements DataTableAdapter, PaginationProvid return this._skipCount; } + set skipCount(value: number) { + if (value !== this._skipCount) { + this._skipCount = value > 0 ? value : 0; + this.loadPath(this.currentPath); + } + } + get maxItems(): number { return this._maxItems; } + set maxItems(value: number) { + if (value !== this._maxItems) { + this._maxItems = value > this.MIN_PAGE_SIZE ? value : this.MIN_PAGE_SIZE; + this.loadPath(this.currentPath); + } + } + getRows(): Array { return this.rows; } @@ -94,16 +110,16 @@ export class ShareDataTableAdapter implements DataTableAdapter, PaginationProvid getValue(row: DataRow, col: DataColumn): any { if (!row) { - throw new Error(ShareDataTableAdapter.ERR_ROW_NOT_FOUND); + throw new Error(this.ERR_ROW_NOT_FOUND); } if (!col) { - throw new Error(ShareDataTableAdapter.ERR_COL_NOT_FOUND); + throw new Error(this.ERR_COL_NOT_FOUND); } let value = row.getValue(col.key); if (col.type === 'date') { let datePipe = new DatePipe(); - let format = col.format || ShareDataTableAdapter.DEFAULT_DATE_FORMAT; + let format = col.format || this.DEFAULT_DATE_FORMAT; try { return datePipe.transform(value, format); } catch (err) { @@ -193,8 +209,12 @@ export class ShareDataTableAdapter implements DataTableAdapter, PaginationProvid loadPath(path: string) { if (path && this.documentListService) { + this.currentPath = path; this.documentListService - .getFolder(path) + .getFolder(path, { + maxItems: this._maxItems, + skipCount: this._skipCount + }) .subscribe(val => this.loadPage(val), error => console.error(error)); } @@ -240,7 +260,7 @@ export class ShareDataTableAdapter implements DataTableAdapter, PaginationProvid this._hasMoreItems = false; this._totalItems = 0; this._skipCount = 0; - this._maxItems = ShareDataTableAdapter.DEFAULT_PAGE_SIZE; + this._maxItems = this.DEFAULT_PAGE_SIZE; } } diff --git a/ng2-components/ng2-alfresco-documentlist/src/services/document-list.service.ts b/ng2-components/ng2-alfresco-documentlist/src/services/document-list.service.ts index c782d40a6f..34c54610c7 100644 --- a/ng2-components/ng2-alfresco-documentlist/src/services/document-list.service.ts +++ b/ng2-components/ng2-alfresco-documentlist/src/services/document-list.service.ts @@ -72,15 +72,25 @@ export class DocumentListService { return AlfrescoApi.getClientWithTicket(this.settings.getApiBaseUrl(), this.authService.getToken()); } - private getNodesPromise(folder: string) { + private getNodesPromise(folder: string, opts?: any) { let alfrescoClient = this.getAlfrescoClient(); let apiInstance = new AlfrescoApi.Core.NodesApi(alfrescoClient); let nodeId = '-root-'; - let opts = { + let params: any = { relativePath: folder, include: ['path'] }; - return apiInstance.getNodeChildren(nodeId, opts); + + if (opts) { + if (opts.maxItems) { + params.maxItems = opts.maxItems; + } + if (opts.skipCount) { + params.skipCount = opts.skipCount; + } + } + + return apiInstance.getNodeChildren(nodeId, params); } deleteNode(nodeId: string) { let client = this.getAlfrescoClient(); @@ -93,10 +103,11 @@ export class DocumentListService { /** * Gets the folder node with the content. * @param folder Path to folder. + * @param opts Options * @returns {Observable} Folder entity. */ - getFolder(folder: string): Observable { - return Observable.fromPromise(this.getNodesPromise(folder)) + getFolder(folder: string, opts?: any): Observable { + return Observable.fromPromise(this.getNodesPromise(folder, opts)) .map(res => res) // .do(data => console.log('Node data', data)) // eyeball results in the console .catch(this.handleError); From e49b00fab44fe18e9d9934cf3b9810bdd4c08091 Mon Sep 17 00:00:00 2001 From: Denys Vuika Date: Wed, 13 Jul 2016 12:32:03 +0100 Subject: [PATCH 5/9] #70 demo shell updates --- demo-shell-ng2/app/components/files/files.component.html | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/demo-shell-ng2/app/components/files/files.component.html b/demo-shell-ng2/app/components/files/files.component.html index 0f4a862066..4841e08d55 100644 --- a/demo-shell-ng2/app/components/files/files.component.html +++ b/demo-shell-ng2/app/components/files/files.component.html @@ -92,7 +92,9 @@ - + From 139f6a965e80a12a5e0fc51ef3a32d4ddf545995 Mon Sep 17 00:00:00 2001 From: Denys Vuika Date: Wed, 13 Jul 2016 16:29:15 +0100 Subject: [PATCH 6/9] Fix unit test --- .../src/data/share-datatable-adapter.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ng2-components/ng2-alfresco-documentlist/src/data/share-datatable-adapter.spec.ts b/ng2-components/ng2-alfresco-documentlist/src/data/share-datatable-adapter.spec.ts index 240c7706f1..42f9073d9f 100644 --- a/ng2-components/ng2-alfresco-documentlist/src/data/share-datatable-adapter.spec.ts +++ b/ng2-components/ng2-alfresco-documentlist/src/data/share-datatable-adapter.spec.ts @@ -123,7 +123,7 @@ describe('ShareDataTableAdapter', () => { let adapter = new ShareDataTableAdapter(documentListService, null, null); adapter.loadPath(path); - expect(documentListService.getFolder).toHaveBeenCalledWith(path); + expect(documentListService.getFolder).toHaveBeenCalledWith(path, jasmine.anything()); let rows = adapter.getRows(); expect(rows.length).toBe(1); From 6826f796fe76d7bfbdd0404a4d550abbf277ff2c Mon Sep 17 00:00:00 2001 From: Denys Vuika Date: Wed, 13 Jul 2016 18:37:07 +0100 Subject: [PATCH 7/9] Update icon size as per mockups --- .../src/components/datatable.component.css | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ng2-components/ng2-alfresco-datatable/src/components/datatable.component.css b/ng2-components/ng2-alfresco-datatable/src/components/datatable.component.css index 415a6264c9..7f76443680 100644 --- a/ng2-components/ng2-alfresco-datatable/src/components/datatable.component.css +++ b/ng2-components/ng2-alfresco-datatable/src/components/datatable.component.css @@ -1,13 +1,13 @@ :host .full-width { width: 100%; } :host .icon-cell { - font-size: 48px; + font-size: 24px; cursor: default; } :host .image-cell { - width: 48px; - height: 48px; + width: 24px; + height: 24px; cursor: default; } From 380652df83775e5f94e2743760b2ed1cfa98e8de Mon Sep 17 00:00:00 2001 From: Denys Vuika Date: Thu, 14 Jul 2016 12:04:30 +0100 Subject: [PATCH 8/9] Move 'pagination' to the core, barrel files for core --- .../app/components/files/files.component.html | 4 +- .../app/components/files/files.component.ts | 7 ++- ng2-components/ng2-alfresco-core/index.ts | 55 ++++--------------- ng2-components/ng2-alfresco-core/package.json | 3 +- .../context-menu-holder.component.spec.ts | 2 +- .../context-menu-holder.component.ts | 2 +- .../context-menu.directive.spec.ts | 2 +- .../context-menu.directive.ts | 2 +- .../context-menu.service.spec.ts | 0 .../context-menu}/context-menu.service.ts | 0 .../src/components/context-menu/index.ts | 33 +++++++++++ .../ng2-alfresco-core/src/components/index.ts | 20 +++++++ .../MaterialDesignLiteUpgradeElement.ts | 0 .../src/components/material/index.ts | 30 ++++++++++ .../material/mdl-button.directive.ts | 0 .../material/mdl-menu.directive.ts | 0 .../src/components/pagination/index.ts | 19 +++++++ .../pagination}/pagination-provider.ts | 0 .../pagination/pagination.component.css | 0 .../pagination/pagination.component.html | 0 .../pagination/pagination.component.ts | 11 ++-- .../ng2-alfresco-core/src/services/index.ts | 23 ++++++++ .../ng2-alfresco-core/src/utils/index.ts | 18 ++++++ .../ng2-alfresco-documentlist/index.ts | 5 +- 24 files changed, 174 insertions(+), 62 deletions(-) rename ng2-components/ng2-alfresco-core/src/components/{ => context-menu}/context-menu-holder.component.spec.ts (97%) rename ng2-components/ng2-alfresco-core/src/components/{ => context-menu}/context-menu-holder.component.ts (97%) rename ng2-components/ng2-alfresco-core/src/components/{ => context-menu}/context-menu.directive.spec.ts (96%) rename ng2-components/ng2-alfresco-core/src/components/{ => context-menu}/context-menu.directive.ts (94%) rename ng2-components/ng2-alfresco-core/src/{services => components/context-menu}/context-menu.service.spec.ts (100%) rename ng2-components/ng2-alfresco-core/src/{services => components/context-menu}/context-menu.service.ts (100%) create mode 100644 ng2-components/ng2-alfresco-core/src/components/context-menu/index.ts create mode 100644 ng2-components/ng2-alfresco-core/src/components/index.ts rename ng2-components/ng2-alfresco-core/src/{ => components}/material/MaterialDesignLiteUpgradeElement.ts (100%) create mode 100644 ng2-components/ng2-alfresco-core/src/components/material/index.ts rename ng2-components/ng2-alfresco-core/src/{ => components}/material/mdl-button.directive.ts (100%) rename ng2-components/ng2-alfresco-core/src/{ => components}/material/mdl-menu.directive.ts (100%) create mode 100644 ng2-components/ng2-alfresco-core/src/components/pagination/index.ts rename ng2-components/ng2-alfresco-core/src/{data => components/pagination}/pagination-provider.ts (100%) rename ng2-components/{ng2-alfresco-documentlist => ng2-alfresco-core}/src/components/pagination/pagination.component.css (100%) rename ng2-components/{ng2-alfresco-documentlist => ng2-alfresco-core}/src/components/pagination/pagination.component.html (100%) rename ng2-components/{ng2-alfresco-documentlist => ng2-alfresco-core}/src/components/pagination/pagination.component.ts (91%) create mode 100644 ng2-components/ng2-alfresco-core/src/services/index.ts create mode 100644 ng2-components/ng2-alfresco-core/src/utils/index.ts diff --git a/demo-shell-ng2/app/components/files/files.component.html b/demo-shell-ng2/app/components/files/files.component.html index 4841e08d55..e99f78a2c9 100644 --- a/demo-shell-ng2/app/components/files/files.component.html +++ b/demo-shell-ng2/app/components/files/files.component.html @@ -92,10 +92,10 @@ - - + diff --git a/demo-shell-ng2/app/components/files/files.component.ts b/demo-shell-ng2/app/components/files/files.component.ts index d10605b54e..828f9f5181 100644 --- a/demo-shell-ng2/app/components/files/files.component.ts +++ b/demo-shell-ng2/app/components/files/files.component.ts @@ -25,8 +25,10 @@ import { MDL, AlfrescoContentService, CONTEXT_MENU_DIRECTIVES, - AlfrescoPipeTranslate + AlfrescoPipeTranslate/*, + PaginationComponent*/ } from 'ng2-alfresco-core'; +import { PaginationComponent } from 'ng2-alfresco-core'; import { ALFRESCO_ULPOAD_COMPONENTS } from 'ng2-alfresco-upload'; import { VIEWERCOMPONENT } from 'ng2-alfresco-viewer'; @@ -42,7 +44,8 @@ declare let __moduleName: string; MDL, ALFRESCO_ULPOAD_COMPONENTS, VIEWERCOMPONENT, - CONTEXT_MENU_DIRECTIVES + CONTEXT_MENU_DIRECTIVES, + PaginationComponent ], providers: [DOCUMENT_LIST_PROVIDERS], pipes: [AlfrescoPipeTranslate] diff --git a/ng2-components/ng2-alfresco-core/index.ts b/ng2-components/ng2-alfresco-core/index.ts index 62059dff40..231df2fe5b 100644 --- a/ng2-components/ng2-alfresco-core/index.ts +++ b/ng2-components/ng2-alfresco-core/index.ts @@ -15,37 +15,20 @@ * limitations under the License. */ -import { AlfrescoSettingsService } from './src/services/AlfrescoSettingsService.service'; -import { AlfrescoTranslationLoader } from './src/services/AlfrescoTranslationLoader.service'; -import { AlfrescoTranslationService } from './src/services/AlfrescoTranslationService.service'; -import { AlfrescoPipeTranslate } from './src/services/AlfrescoPipeTranslate.service'; -import { AlfrescoAuthenticationService } from './src/services/AlfrescoAuthenticationService.service'; -import { AlfrescoContentService } from './src/services/AlfrescoContentService.service'; -import { ContextMenuService } from './src/services/context-menu.service'; -import { ContextMenuHolderComponent } from './src/components/context-menu-holder.component'; -import { ContextMenuDirective } from './src/components/context-menu.directive'; -import { MDL } from './src/material/MaterialDesignLiteUpgradeElement'; -import { AlfrescoMdlButtonDirective } from './src/material/mdl-button.directive'; -import { AlfrescoMdlMenuDirective } from './src/material/mdl-menu.directive'; +import { + AlfrescoSettingsService, + AlfrescoTranslationLoader, + AlfrescoTranslationService, + AlfrescoPipeTranslate, + AlfrescoAuthenticationService, + AlfrescoContentService +} from './src/services/index'; -export * from './src/services/AlfrescoSettingsService.service'; -export * from './src/services/AlfrescoTranslationLoader.service'; -export * from './src/services/AlfrescoTranslationService.service'; -export * from './src/services/AlfrescoPipeTranslate.service'; -export * from './src/services/AlfrescoAuthenticationService.service'; -export * from './src/services/AlfrescoContentService.service'; +import { ContextMenuService } from './src/components/context-menu/context-menu.service'; -// Material Design Lite integration -export * from './src/material/MaterialDesignLiteUpgradeElement'; -export * from './src/material/mdl-button.directive'; -export * from './src/material/mdl-menu.directive'; - -export * from './src/services/context-menu.service'; -export * from './src/components/context-menu-holder.component'; -export * from './src/components/context-menu.directive'; - -export * from './src/data/pagination-provider'; -export * from './src/utils/object-utils'; +export * from './src/services/index'; +export * from './src/components/index'; +export * from './src/utils/index'; export const ALFRESCO_CORE_PROVIDERS: [any] = [ AlfrescoAuthenticationService, @@ -57,17 +40,3 @@ export const ALFRESCO_CORE_PROVIDERS: [any] = [ ContextMenuService ]; -export const CONTEXT_MENU_PROVIDERS: [any] = [ - ContextMenuService -]; - -export const CONTEXT_MENU_DIRECTIVES: [any] = [ - ContextMenuHolderComponent, - ContextMenuDirective -]; - -export const MATERIAL_DESIGN_DIRECTIVES: [any] = [ - MDL, - AlfrescoMdlButtonDirective, - AlfrescoMdlMenuDirective -]; diff --git a/ng2-components/ng2-alfresco-core/package.json b/ng2-components/ng2-alfresco-core/package.json index 873eebc038..8209070b39 100644 --- a/ng2-components/ng2-alfresco-core/package.json +++ b/ng2-components/ng2-alfresco-core/package.json @@ -6,13 +6,14 @@ "scripts": { "clean": "rimraf dist node_modules typings", "typings": "typings install", - "build": "npm run tslint && typings install && rimraf dist && tsc && license-check", + "build": "npm run tslint && typings install && rimraf dist && tsc && npm run copy-static && license-check", "build:w": "npm run tslint && typings install && rimraf dist && npm run watch-task", "watch-task": "concurrently \"npm run tsc:w\" \"license-check\"", "tslint": "npm run tslint-src && npm run tslint-root", "tslint-src": "tslint -c tslint.json src/{,**/}**.ts", "tslint-root": "tslint -c tslint.json *.ts", "licensecheck": "license-check", + "copy-static": "cpx \"./src/**/*.{html,css}\" ./dist/src", "tsc": "tsc", "tsc:w": "tsc -w", "pretest": "npm run build", diff --git a/ng2-components/ng2-alfresco-core/src/components/context-menu-holder.component.spec.ts b/ng2-components/ng2-alfresco-core/src/components/context-menu/context-menu-holder.component.spec.ts similarity index 97% rename from ng2-components/ng2-alfresco-core/src/components/context-menu-holder.component.spec.ts rename to ng2-components/ng2-alfresco-core/src/components/context-menu/context-menu-holder.component.spec.ts index 496fac21e7..5ac723cc3d 100644 --- a/ng2-components/ng2-alfresco-core/src/components/context-menu-holder.component.spec.ts +++ b/ng2-components/ng2-alfresco-core/src/components/context-menu/context-menu-holder.component.spec.ts @@ -16,7 +16,7 @@ */ import { describe, it, beforeEach } from '@angular/core/testing'; -import { ContextMenuService } from './../services/context-menu.service'; +import { ContextMenuService } from './context-menu.service'; import { ContextMenuHolderComponent } from './context-menu-holder.component'; describe('ContextMenuHolderComponent', () => { diff --git a/ng2-components/ng2-alfresco-core/src/components/context-menu-holder.component.ts b/ng2-components/ng2-alfresco-core/src/components/context-menu/context-menu-holder.component.ts similarity index 97% rename from ng2-components/ng2-alfresco-core/src/components/context-menu-holder.component.ts rename to ng2-components/ng2-alfresco-core/src/components/context-menu/context-menu-holder.component.ts index 40a3d9960f..9f406ed117 100644 --- a/ng2-components/ng2-alfresco-core/src/components/context-menu-holder.component.ts +++ b/ng2-components/ng2-alfresco-core/src/components/context-menu/context-menu-holder.component.ts @@ -16,7 +16,7 @@ */ import { Component, HostListener } from '@angular/core'; -import { ContextMenuService } from './../services/context-menu.service'; +import { ContextMenuService } from './context-menu.service'; @Component({ selector:'context-menu-holder', diff --git a/ng2-components/ng2-alfresco-core/src/components/context-menu.directive.spec.ts b/ng2-components/ng2-alfresco-core/src/components/context-menu/context-menu.directive.spec.ts similarity index 96% rename from ng2-components/ng2-alfresco-core/src/components/context-menu.directive.spec.ts rename to ng2-components/ng2-alfresco-core/src/components/context-menu/context-menu.directive.spec.ts index 7c1e56ccb9..b8b7b169f1 100644 --- a/ng2-components/ng2-alfresco-core/src/components/context-menu.directive.spec.ts +++ b/ng2-components/ng2-alfresco-core/src/components/context-menu/context-menu.directive.spec.ts @@ -17,7 +17,7 @@ import { describe, it, beforeEach } from '@angular/core/testing'; import { ContextMenuDirective } from './context-menu.directive'; -import { ContextMenuService } from './../services/context-menu.service'; +import { ContextMenuService } from './context-menu.service'; describe('ContextMenuDirective', () => { diff --git a/ng2-components/ng2-alfresco-core/src/components/context-menu.directive.ts b/ng2-components/ng2-alfresco-core/src/components/context-menu/context-menu.directive.ts similarity index 94% rename from ng2-components/ng2-alfresco-core/src/components/context-menu.directive.ts rename to ng2-components/ng2-alfresco-core/src/components/context-menu/context-menu.directive.ts index 05be1f4309..2859e76cd7 100644 --- a/ng2-components/ng2-alfresco-core/src/components/context-menu.directive.ts +++ b/ng2-components/ng2-alfresco-core/src/components/context-menu/context-menu.directive.ts @@ -16,7 +16,7 @@ */ import { Directive, Input, HostListener } from '@angular/core'; -import { ContextMenuService } from './../services/context-menu.service'; +import { ContextMenuService } from './context-menu.service'; @Directive({ selector:'[context-menu]' diff --git a/ng2-components/ng2-alfresco-core/src/services/context-menu.service.spec.ts b/ng2-components/ng2-alfresco-core/src/components/context-menu/context-menu.service.spec.ts similarity index 100% rename from ng2-components/ng2-alfresco-core/src/services/context-menu.service.spec.ts rename to ng2-components/ng2-alfresco-core/src/components/context-menu/context-menu.service.spec.ts diff --git a/ng2-components/ng2-alfresco-core/src/services/context-menu.service.ts b/ng2-components/ng2-alfresco-core/src/components/context-menu/context-menu.service.ts similarity index 100% rename from ng2-components/ng2-alfresco-core/src/services/context-menu.service.ts rename to ng2-components/ng2-alfresco-core/src/components/context-menu/context-menu.service.ts diff --git a/ng2-components/ng2-alfresco-core/src/components/context-menu/index.ts b/ng2-components/ng2-alfresco-core/src/components/context-menu/index.ts new file mode 100644 index 0000000000..a6b21baf9d --- /dev/null +++ b/ng2-components/ng2-alfresco-core/src/components/context-menu/index.ts @@ -0,0 +1,33 @@ +/*! + * @license + * Copyright 2016 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 { ContextMenuService } from './context-menu.service'; +import { ContextMenuHolderComponent } from './context-menu-holder.component'; +import { ContextMenuDirective } from './context-menu.directive'; + +export * from './context-menu.service'; +export * from './context-menu-holder.component'; +export * from './context-menu.directive'; + +export const CONTEXT_MENU_PROVIDERS: [any] = [ + ContextMenuService +]; + +export const CONTEXT_MENU_DIRECTIVES: [any] = [ + ContextMenuHolderComponent, + ContextMenuDirective +]; diff --git a/ng2-components/ng2-alfresco-core/src/components/index.ts b/ng2-components/ng2-alfresco-core/src/components/index.ts new file mode 100644 index 0000000000..7c6259e8a1 --- /dev/null +++ b/ng2-components/ng2-alfresco-core/src/components/index.ts @@ -0,0 +1,20 @@ +/*! + * @license + * Copyright 2016 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. + */ + +export * from './context-menu/index'; +export * from './material/index'; +export * from './pagination/index'; diff --git a/ng2-components/ng2-alfresco-core/src/material/MaterialDesignLiteUpgradeElement.ts b/ng2-components/ng2-alfresco-core/src/components/material/MaterialDesignLiteUpgradeElement.ts similarity index 100% rename from ng2-components/ng2-alfresco-core/src/material/MaterialDesignLiteUpgradeElement.ts rename to ng2-components/ng2-alfresco-core/src/components/material/MaterialDesignLiteUpgradeElement.ts diff --git a/ng2-components/ng2-alfresco-core/src/components/material/index.ts b/ng2-components/ng2-alfresco-core/src/components/material/index.ts new file mode 100644 index 0000000000..63ce268538 --- /dev/null +++ b/ng2-components/ng2-alfresco-core/src/components/material/index.ts @@ -0,0 +1,30 @@ +/*! + * @license + * Copyright 2016 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 { MDL } from './MaterialDesignLiteUpgradeElement'; +import { AlfrescoMdlButtonDirective } from './mdl-button.directive'; +import { AlfrescoMdlMenuDirective } from './mdl-menu.directive'; + +export * from './MaterialDesignLiteUpgradeElement'; +export * from './mdl-button.directive'; +export * from './mdl-menu.directive'; + +export const MATERIAL_DESIGN_DIRECTIVES: [any] = [ + MDL, + AlfrescoMdlButtonDirective, + AlfrescoMdlMenuDirective +]; diff --git a/ng2-components/ng2-alfresco-core/src/material/mdl-button.directive.ts b/ng2-components/ng2-alfresco-core/src/components/material/mdl-button.directive.ts similarity index 100% rename from ng2-components/ng2-alfresco-core/src/material/mdl-button.directive.ts rename to ng2-components/ng2-alfresco-core/src/components/material/mdl-button.directive.ts diff --git a/ng2-components/ng2-alfresco-core/src/material/mdl-menu.directive.ts b/ng2-components/ng2-alfresco-core/src/components/material/mdl-menu.directive.ts similarity index 100% rename from ng2-components/ng2-alfresco-core/src/material/mdl-menu.directive.ts rename to ng2-components/ng2-alfresco-core/src/components/material/mdl-menu.directive.ts diff --git a/ng2-components/ng2-alfresco-core/src/components/pagination/index.ts b/ng2-components/ng2-alfresco-core/src/components/pagination/index.ts new file mode 100644 index 0000000000..9e25a61495 --- /dev/null +++ b/ng2-components/ng2-alfresco-core/src/components/pagination/index.ts @@ -0,0 +1,19 @@ +/*! + * @license + * Copyright 2016 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. + */ + +export * from './pagination-provider'; +export * from './pagination.component'; diff --git a/ng2-components/ng2-alfresco-core/src/data/pagination-provider.ts b/ng2-components/ng2-alfresco-core/src/components/pagination/pagination-provider.ts similarity index 100% rename from ng2-components/ng2-alfresco-core/src/data/pagination-provider.ts rename to ng2-components/ng2-alfresco-core/src/components/pagination/pagination-provider.ts diff --git a/ng2-components/ng2-alfresco-documentlist/src/components/pagination/pagination.component.css b/ng2-components/ng2-alfresco-core/src/components/pagination/pagination.component.css similarity index 100% rename from ng2-components/ng2-alfresco-documentlist/src/components/pagination/pagination.component.css rename to ng2-components/ng2-alfresco-core/src/components/pagination/pagination.component.css diff --git a/ng2-components/ng2-alfresco-documentlist/src/components/pagination/pagination.component.html b/ng2-components/ng2-alfresco-core/src/components/pagination/pagination.component.html similarity index 100% rename from ng2-components/ng2-alfresco-documentlist/src/components/pagination/pagination.component.html rename to ng2-components/ng2-alfresco-core/src/components/pagination/pagination.component.html diff --git a/ng2-components/ng2-alfresco-documentlist/src/components/pagination/pagination.component.ts b/ng2-components/ng2-alfresco-core/src/components/pagination/pagination.component.ts similarity index 91% rename from ng2-components/ng2-alfresco-documentlist/src/components/pagination/pagination.component.ts rename to ng2-components/ng2-alfresco-core/src/components/pagination/pagination.component.ts index 974e06b1ac..01a5c2bb08 100644 --- a/ng2-components/ng2-alfresco-documentlist/src/components/pagination/pagination.component.ts +++ b/ng2-components/ng2-alfresco-core/src/components/pagination/pagination.component.ts @@ -16,21 +16,20 @@ */ import { Component, Input } from '@angular/core'; -import { - MATERIAL_DESIGN_DIRECTIVES, - PaginationProvider -} from 'ng2-alfresco-core'; + +import { MATERIAL_DESIGN_DIRECTIVES } from './../material/index'; +import { PaginationProvider } from './pagination-provider'; declare let __moduleName: string; @Component({ moduleId: __moduleName, - selector: 'alfresco-document-list-pagination', + selector: 'alfresco-pagination', templateUrl: './pagination.component.html', styleUrls: ['./pagination.component.css'], directives: [MATERIAL_DESIGN_DIRECTIVES] }) -export class DocumentListPagination { +export class PaginationComponent { DEFAULT_PAGE_SIZE: number = 20; diff --git a/ng2-components/ng2-alfresco-core/src/services/index.ts b/ng2-components/ng2-alfresco-core/src/services/index.ts new file mode 100644 index 0000000000..bdde5bffd4 --- /dev/null +++ b/ng2-components/ng2-alfresco-core/src/services/index.ts @@ -0,0 +1,23 @@ +/*! + * @license + * Copyright 2016 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. + */ + +export * from './AlfrescoSettingsService.service'; +export * from './AlfrescoTranslationLoader.service'; +export * from './AlfrescoTranslationService.service'; +export * from './AlfrescoPipeTranslate.service'; +export * from './AlfrescoAuthenticationService.service'; +export * from './AlfrescoContentService.service'; diff --git a/ng2-components/ng2-alfresco-core/src/utils/index.ts b/ng2-components/ng2-alfresco-core/src/utils/index.ts new file mode 100644 index 0000000000..f3ae4ef189 --- /dev/null +++ b/ng2-components/ng2-alfresco-core/src/utils/index.ts @@ -0,0 +1,18 @@ +/*! + * @license + * Copyright 2016 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. + */ + +export * from './object-utils'; diff --git a/ng2-components/ng2-alfresco-documentlist/index.ts b/ng2-components/ng2-alfresco-documentlist/index.ts index 0678520b1f..7c2f142c61 100644 --- a/ng2-components/ng2-alfresco-documentlist/index.ts +++ b/ng2-components/ng2-alfresco-documentlist/index.ts @@ -22,7 +22,6 @@ import { ContentAction } from './src/components/content-action'; import { ContentActionList } from './src/components/content-action-list'; import { EmptyFolderContent } from './src/components/empty-folder-content'; import { DocumentListBreadcrumb } from './src/components/breadcrumb/breadcrumb.component'; -import { DocumentListPagination } from './src/components/pagination/pagination.component'; import { FolderActionsService } from './src/services/folder-actions.service'; import { DocumentActionsService } from './src/services/document-actions.service'; @@ -36,7 +35,6 @@ export * from './src/components/content-action'; export * from './src/components/content-action-list'; export * from './src/components/empty-folder-content'; export * from './src/components/breadcrumb/breadcrumb.component'; -export * from './src/components/pagination/pagination.component'; // services export * from './src/services/folder-actions.service'; @@ -50,8 +48,7 @@ export const DOCUMENT_LIST_DIRECTIVES: [any] = [ ContentAction, ContentActionList, EmptyFolderContent, - DocumentListBreadcrumb, - DocumentListPagination + DocumentListBreadcrumb ]; export const DOCUMENT_LIST_PROVIDERS: [any] = [ From f4f5d74eca72267926f808965cd9e1480acf828b Mon Sep 17 00:00:00 2001 From: Denys Vuika Date: Thu, 14 Jul 2016 12:22:23 +0100 Subject: [PATCH 9/9] build:w support for core --- ng2-components/ng2-alfresco-core/package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ng2-components/ng2-alfresco-core/package.json b/ng2-components/ng2-alfresco-core/package.json index 8209070b39..349d0ee108 100644 --- a/ng2-components/ng2-alfresco-core/package.json +++ b/ng2-components/ng2-alfresco-core/package.json @@ -7,13 +7,14 @@ "clean": "rimraf dist node_modules typings", "typings": "typings install", "build": "npm run tslint && typings install && rimraf dist && tsc && npm run copy-static && license-check", - "build:w": "npm run tslint && typings install && rimraf dist && npm run watch-task", + "build:w": "npm run tslint && typings install && rimraf dist && tsc && npm run copy-static:w && npm run watch-task", "watch-task": "concurrently \"npm run tsc:w\" \"license-check\"", "tslint": "npm run tslint-src && npm run tslint-root", "tslint-src": "tslint -c tslint.json src/{,**/}**.ts", "tslint-root": "tslint -c tslint.json *.ts", "licensecheck": "license-check", "copy-static": "cpx \"./src/**/*.{html,css}\" ./dist/src", + "copy-static:w": "cpx \"./src/**/*.{html,css}\" ./dist/src -w", "tsc": "tsc", "tsc:w": "tsc -w", "pretest": "npm run build",