From 3b8cf2786218ea1bceddfac809c2803c5894e2f8 Mon Sep 17 00:00:00 2001 From: Denys Vuika Date: Fri, 7 Jul 2017 16:17:26 +0100 Subject: [PATCH] [ADF-770] upgrade to md-menu (#2060) * upgrade to md-menu - upgrade to md-menu - fix issue with missing icons - extend demo shell to show icons for actions - fix issue with border problems in Firefox - remove commented out samples in demo shell (there's readme for that instead) * fix unit tests * fix tests --- .../app/components/files/files.component.html | 64 ++++++++----------- .../datatable/datatable.component.html | 40 ++++++------ .../datatable/datatable.component.spec.ts | 5 +- .../ng2-alfresco-documentlist/index.ts | 11 +--- .../document-list.component.spec.ts | 26 ++++---- .../src/material.module.ts | 34 ++++++++++ 6 files changed, 99 insertions(+), 81 deletions(-) create mode 100644 ng2-components/ng2-alfresco-documentlist/src/material.module.ts diff --git a/demo-shell-ng2/app/components/files/files.component.html b/demo-shell-ng2/app/components/files/files.component.html index 2e672dfe38..abc49228e1 100644 --- a/demo-shell-ng2/app/components/files/files.component.html +++ b/demo-shell-ng2/app/components/files/files.component.html @@ -57,21 +57,6 @@ title="{{'DOCUMENT_LIST.COLUMNS.DISPLAY_NAME' | translate}}" key="name" class="full-width ellipsis-cell"> - - - - - - - + title="{{'DOCUMENT_LIST.COLUMNS.CREATED_BY' | translate}}" + key="createdByUser.displayName" + class="desktop-only"> + title="{{'DOCUMENT_LIST.COLUMNS.CREATED_ON' | translate}}" + key="createdAt" + type="date" + format="medium" + class="desktop-only"> + icon="delete" + target="folder" + permission="delete" + [disableWithNoPermission]="true" + title="{{'DOCUMENT_LIST.ACTIONS.FOLDER.DELETE' | translate}}" + (permissionEvent)="handlePermissionError($event)" + handler="delete"> + icon="file_download" + target="document" + title="{{'DOCUMENT_LIST.ACTIONS.DOCUMENT.DOWNLOAD' | translate}}" + handler="download"> + icon="delete" + target="document" + permission="delete" + [disableWithNoPermission]="true" + (permissionEvent)="handlePermissionError($event)" + title="{{'DOCUMENT_LIST.ACTIONS.DOCUMENT.DELETE' | translate}}" + handler="delete"> diff --git a/ng2-components/ng2-alfresco-datatable/src/components/datatable/datatable.component.html b/ng2-components/ng2-alfresco-datatable/src/components/datatable/datatable.component.html index ef0944480f..761ee50957 100644 --- a/ng2-components/ng2-alfresco-datatable/src/components/datatable/datatable.component.html +++ b/ng2-components/ng2-alfresco-datatable/src/components/datatable/datatable.component.html @@ -39,19 +39,19 @@ - - + {{ action.icon }} + {{ action.title }} + + @@ -102,19 +102,19 @@ - - + {{ action.icon }} + {{ action.title }} + + diff --git a/ng2-components/ng2-alfresco-datatable/src/components/datatable/datatable.component.spec.ts b/ng2-components/ng2-alfresco-datatable/src/components/datatable/datatable.component.spec.ts index bb9849d61f..bc3eb04784 100644 --- a/ng2-components/ng2-alfresco-datatable/src/components/datatable/datatable.component.spec.ts +++ b/ng2-components/ng2-alfresco-datatable/src/components/datatable/datatable.component.spec.ts @@ -17,8 +17,9 @@ import { SimpleChange } from '@angular/core'; import { async, ComponentFixture, TestBed } from '@angular/core/testing'; -import { MdCheckboxChange, MdCheckboxModule } from '@angular/material'; +import { MdCheckboxChange } from '@angular/material'; import { CoreModule } from 'ng2-alfresco-core'; +import { MaterialModule } from '../../material.module'; import { DataColumn, DataRow, @@ -40,7 +41,7 @@ describe('DataTable', () => { TestBed.configureTestingModule({ imports: [ CoreModule.forRoot(), - MdCheckboxModule + MaterialModule ], declarations: [ DataTableCellComponent, diff --git a/ng2-components/ng2-alfresco-documentlist/index.ts b/ng2-components/ng2-alfresco-documentlist/index.ts index f68d1ff500..477264d52c 100644 --- a/ng2-components/ng2-alfresco-documentlist/index.ts +++ b/ng2-components/ng2-alfresco-documentlist/index.ts @@ -16,7 +16,6 @@ */ import { ModuleWithProviders, NgModule } from '@angular/core'; -import { MdButtonModule, MdIconModule, MdMenuModule, MdProgressSpinnerModule } from '@angular/material'; import { CoreModule } from 'ng2-alfresco-core'; import { DataTableModule } from 'ng2-alfresco-datatable'; @@ -28,6 +27,7 @@ import { ContentColumnComponent } from './src/components/content-column/content- import { DocumentListComponent } from './src/components/document-list.component'; import { DocumentMenuActionComponent } from './src/components/document-menu-action.component'; import { EmptyFolderContentComponent } from './src/components/empty-folder/empty-folder-content.component'; +import { MaterialModule } from './src/material.module'; import { DocumentActionsService } from './src/services/document-actions.service'; import { DocumentListService } from './src/services/document-list.service'; @@ -77,10 +77,7 @@ export const DOCUMENT_LIST_PROVIDERS: any[] = [ imports: [ CoreModule, DataTableModule, - MdMenuModule, - MdButtonModule, - MdIconModule, - MdProgressSpinnerModule + MaterialModule ], declarations: [ ...DOCUMENT_LIST_DIRECTIVES @@ -91,9 +88,7 @@ export const DOCUMENT_LIST_PROVIDERS: any[] = [ exports: [ DataTableModule, ...DOCUMENT_LIST_DIRECTIVES, - MdMenuModule, - MdButtonModule, - MdIconModule + MaterialModule ] }) export class DocumentListModule { diff --git a/ng2-components/ng2-alfresco-documentlist/src/components/document-list.component.spec.ts b/ng2-components/ng2-alfresco-documentlist/src/components/document-list.component.spec.ts index 377746f473..021afd3bef 100644 --- a/ng2-components/ng2-alfresco-documentlist/src/components/document-list.component.spec.ts +++ b/ng2-components/ng2-alfresco-documentlist/src/components/document-list.component.spec.ts @@ -16,25 +16,25 @@ */ import { NgZone, SimpleChange, TemplateRef } from '@angular/core'; -import { DataTableComponent, DataColumn, DataRowEvent } from 'ng2-alfresco-datatable'; -import { ComponentFixture, TestBed, async } from '@angular/core/testing'; -import { CoreModule, AlfrescoTranslationService } from 'ng2-alfresco-core'; -import { DocumentListComponent } from './document-list.component'; -import { DocumentListService } from './../services/document-list.service'; -import { ContentActionModel } from '../models/content-action.model'; -import { FileNode, FolderNode } from '../assets/document-library.model.mock'; -import { NodeMinimalEntry, NodeMinimal, NodePaging } from '../models/document-library.model'; -import { ShareDataRow, RowFilter, ImageResolver } from './../data/share-datatable-adapter'; +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { AlfrescoTranslationService, CoreModule } from 'ng2-alfresco-core'; import { DataTableModule } from 'ng2-alfresco-datatable'; -import { DocumentMenuActionComponent } from './document-menu-action.component'; +import { DataColumn, DataRowEvent, DataTableComponent } from 'ng2-alfresco-datatable'; import { Observable, Subject } from 'rxjs/Rx'; +import { FileNode, FolderNode } from '../assets/document-library.model.mock'; import { - fakeNodeAnswerWithNOEntries, fakeNodeAnswerWithEntries, + fakeNodeAnswerWithNOEntries, fakeNodeWithCreatePermission, fakeNodeWithNoPermission } from '../assets/document-list.component.mock'; -import { MdProgressSpinnerModule } from '@angular/material'; +import { MaterialModule } from '../material.module'; +import { ContentActionModel } from '../models/content-action.model'; +import { NodeMinimal, NodeMinimalEntry, NodePaging } from '../models/document-library.model'; +import { ImageResolver, RowFilter, ShareDataRow } from './../data/share-datatable-adapter'; +import { DocumentListService } from './../services/document-list.service'; +import { DocumentListComponent } from './document-list.component'; +import { DocumentMenuActionComponent } from './document-menu-action.component'; declare let jasmine: any; @@ -54,7 +54,7 @@ describe('DocumentList', () => { imports: [ CoreModule.forRoot(), DataTableModule.forRoot(), - MdProgressSpinnerModule + MaterialModule ], declarations: [ DocumentListComponent, diff --git a/ng2-components/ng2-alfresco-documentlist/src/material.module.ts b/ng2-components/ng2-alfresco-documentlist/src/material.module.ts new file mode 100644 index 0000000000..977761ceda --- /dev/null +++ b/ng2-components/ng2-alfresco-documentlist/src/material.module.ts @@ -0,0 +1,34 @@ +/*! + * @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 { NgModule } from '@angular/core'; +import { MdButtonModule, MdIconModule, MdMenuModule, MdProgressSpinnerModule } from '@angular/material'; + +export function modules() { + return [ + MdMenuModule, + MdButtonModule, + MdIconModule, + MdProgressSpinnerModule + ]; +} + +@NgModule({ + imports: modules(), + exports: modules() +}) +export class MaterialModule {}