[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
This commit is contained in:
Denys Vuika 2017-07-07 16:17:26 +01:00 committed by Eugenio Romano
parent 183dd3c990
commit 3b8cf27862
6 changed files with 99 additions and 81 deletions

View File

@ -57,21 +57,6 @@
title="{{'DOCUMENT_LIST.COLUMNS.DISPLAY_NAME' | translate}}"
key="name"
class="full-width ellipsis-cell">
<!-- Example #1: using custom template with implicit access to data context -->
<!--
<ng-template let-entry="$implicit">
<span>Hi! {{entry.data.getValue(entry.row, entry.col)}}</span>
</ng-template>
-->
<!-- Example #2: using custom template with value access -->
<!--
<ng-template let-value="value">
<span>Hi! {{value}}</span>
</ng-template>
-->
</data-column>
<!-- Notes: has performance overhead due to multiple files/folders causing separate HTTP calls to get tags -->
<!--
@ -85,42 +70,45 @@
</data-column>
-->
<data-column
title="{{'DOCUMENT_LIST.COLUMNS.CREATED_BY' | translate}}"
key="createdByUser.displayName"
class="desktop-only">
title="{{'DOCUMENT_LIST.COLUMNS.CREATED_BY' | translate}}"
key="createdByUser.displayName"
class="desktop-only">
</data-column>
<data-column
title="{{'DOCUMENT_LIST.COLUMNS.CREATED_ON' | translate}}"
key="createdAt"
type="date"
format="medium"
class="desktop-only">
title="{{'DOCUMENT_LIST.COLUMNS.CREATED_ON' | translate}}"
key="createdAt"
type="date"
format="medium"
class="desktop-only">
</data-column>
</data-columns>
<content-actions>
<!-- folder actions -->
<content-action
target="folder"
permission="delete"
[disableWithNoPermission]="true"
title="{{'DOCUMENT_LIST.ACTIONS.FOLDER.DELETE' | translate}}"
(permissionEvent)="handlePermissionError($event)"
handler="delete">
icon="delete"
target="folder"
permission="delete"
[disableWithNoPermission]="true"
title="{{'DOCUMENT_LIST.ACTIONS.FOLDER.DELETE' | translate}}"
(permissionEvent)="handlePermissionError($event)"
handler="delete">
</content-action>
<!-- document actions -->
<content-action
target="document"
title="{{'DOCUMENT_LIST.ACTIONS.DOCUMENT.DOWNLOAD' | translate}}"
handler="download">
icon="file_download"
target="document"
title="{{'DOCUMENT_LIST.ACTIONS.DOCUMENT.DOWNLOAD' | translate}}"
handler="download">
</content-action>
<content-action
target="document"
permission="delete"
[disableWithNoPermission]="true"
(permissionEvent)="handlePermissionError($event)"
title="{{'DOCUMENT_LIST.ACTIONS.DOCUMENT.DELETE' | translate}}"
handler="delete">
icon="delete"
target="document"
permission="delete"
[disableWithNoPermission]="true"
(permissionEvent)="handlePermissionError($event)"
title="{{'DOCUMENT_LIST.ACTIONS.DOCUMENT.DELETE' | translate}}"
handler="delete">
</content-action>
</content-actions>
</alfresco-document-list>

View File

@ -39,19 +39,19 @@
<!-- Actions (left) -->
<td *ngIf="actions && actionsPosition === 'left'" class="alfresco-datatable__actions-cell">
<button [id]="'action_menu_' + idx" alfresco-mdl-button class="mdl-button--icon"
[attr.data-automation-id]="'action_menu_' + idx">
<i class="material-icons">more_vert</i>
<button md-icon-button [mdMenuTriggerFor]="menu"
[attr.data-automation-id]="'action_menu_' + idx">
<md-icon>more_vert</md-icon>
</button>
<ul alfresco-mdl-menu class="mdl-menu--bottom-left"
[attr.for]="'action_menu_' + idx">
<li class="mdl-menu__item" [attr.disabled]="action.disabled"
<md-menu #menu="mdMenu">
<button md-menu-item *ngFor="let action of getRowActions(row)"
[attr.data-automation-id]="action.title"
*ngFor="let action of getRowActions(row)"
[disabled]="action.disabled"
(click)="onExecuteRowAction(row, action)">
{{action.title}}
</li>
</ul>
<md-icon *ngIf="action.icon">{{ action.icon }}</md-icon>
<span>{{ action.title }}</span>
</button>
</md-menu>
</td>
<td *ngIf="multiselect">
@ -102,19 +102,19 @@
<!-- Actions (right) -->
<td *ngIf="actions && actionsPosition === 'right'" class="alfresco-datatable__actions-cell">
<button [id]="'action_menu_' + idx" alfresco-mdl-button class="mdl-button--icon"
[attr.data-automation-id]="'action_menu_' + idx">
<i class="material-icons">more_vert</i>
<button md-icon-button [mdMenuTriggerFor]="menu"
[attr.data-automation-id]="'action_menu_' + idx">
<md-icon>more_vert</md-icon>
</button>
<ul alfresco-mdl-menu class="mdl-menu--bottom-right"
[attr.for]="'action_menu_' + idx">
<li class="mdl-menu__item" [attr.disabled]="action.disabled || undefined"
<md-menu #menu="mdMenu">
<button md-menu-item *ngFor="let action of getRowActions(row)"
[attr.data-automation-id]="action.title"
*ngFor="let action of getRowActions(row)"
[disabled]="action.disabled"
(click)="onExecuteRowAction(row, action)">
{{action.title}}
</li>
</ul>
<md-icon *ngIf="action.icon">{{ action.icon }}</md-icon>
<span>{{ action.title }}</span>
</button>
</md-menu>
</td>
</tr>

View File

@ -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,

View File

@ -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 {

View File

@ -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,

View File

@ -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 {}