[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}}" title="{{'DOCUMENT_LIST.COLUMNS.DISPLAY_NAME' | translate}}"
key="name" key="name"
class="full-width ellipsis-cell"> 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> </data-column>
<!-- Notes: has performance overhead due to multiple files/folders causing separate HTTP calls to get tags --> <!-- Notes: has performance overhead due to multiple files/folders causing separate HTTP calls to get tags -->
<!-- <!--
@ -101,6 +86,7 @@
<content-actions> <content-actions>
<!-- folder actions --> <!-- folder actions -->
<content-action <content-action
icon="delete"
target="folder" target="folder"
permission="delete" permission="delete"
[disableWithNoPermission]="true" [disableWithNoPermission]="true"
@ -110,11 +96,13 @@
</content-action> </content-action>
<!-- document actions --> <!-- document actions -->
<content-action <content-action
icon="file_download"
target="document" target="document"
title="{{'DOCUMENT_LIST.ACTIONS.DOCUMENT.DOWNLOAD' | translate}}" title="{{'DOCUMENT_LIST.ACTIONS.DOCUMENT.DOWNLOAD' | translate}}"
handler="download"> handler="download">
</content-action> </content-action>
<content-action <content-action
icon="delete"
target="document" target="document"
permission="delete" permission="delete"
[disableWithNoPermission]="true" [disableWithNoPermission]="true"

View File

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

View File

@ -17,8 +17,9 @@
import { SimpleChange } from '@angular/core'; import { SimpleChange } from '@angular/core';
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; 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 { CoreModule } from 'ng2-alfresco-core';
import { MaterialModule } from '../../material.module';
import { import {
DataColumn, DataColumn,
DataRow, DataRow,
@ -40,7 +41,7 @@ describe('DataTable', () => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
imports: [ imports: [
CoreModule.forRoot(), CoreModule.forRoot(),
MdCheckboxModule MaterialModule
], ],
declarations: [ declarations: [
DataTableCellComponent, DataTableCellComponent,

View File

@ -16,7 +16,6 @@
*/ */
import { ModuleWithProviders, NgModule } from '@angular/core'; import { ModuleWithProviders, NgModule } from '@angular/core';
import { MdButtonModule, MdIconModule, MdMenuModule, MdProgressSpinnerModule } from '@angular/material';
import { CoreModule } from 'ng2-alfresco-core'; import { CoreModule } from 'ng2-alfresco-core';
import { DataTableModule } from 'ng2-alfresco-datatable'; 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 { DocumentListComponent } from './src/components/document-list.component';
import { DocumentMenuActionComponent } from './src/components/document-menu-action.component'; import { DocumentMenuActionComponent } from './src/components/document-menu-action.component';
import { EmptyFolderContentComponent } from './src/components/empty-folder/empty-folder-content.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 { DocumentActionsService } from './src/services/document-actions.service';
import { DocumentListService } from './src/services/document-list.service'; import { DocumentListService } from './src/services/document-list.service';
@ -77,10 +77,7 @@ export const DOCUMENT_LIST_PROVIDERS: any[] = [
imports: [ imports: [
CoreModule, CoreModule,
DataTableModule, DataTableModule,
MdMenuModule, MaterialModule
MdButtonModule,
MdIconModule,
MdProgressSpinnerModule
], ],
declarations: [ declarations: [
...DOCUMENT_LIST_DIRECTIVES ...DOCUMENT_LIST_DIRECTIVES
@ -91,9 +88,7 @@ export const DOCUMENT_LIST_PROVIDERS: any[] = [
exports: [ exports: [
DataTableModule, DataTableModule,
...DOCUMENT_LIST_DIRECTIVES, ...DOCUMENT_LIST_DIRECTIVES,
MdMenuModule, MaterialModule
MdButtonModule,
MdIconModule
] ]
}) })
export class DocumentListModule { export class DocumentListModule {

View File

@ -16,25 +16,25 @@
*/ */
import { NgZone, SimpleChange, TemplateRef } from '@angular/core'; import { NgZone, SimpleChange, TemplateRef } from '@angular/core';
import { DataTableComponent, DataColumn, DataRowEvent } from 'ng2-alfresco-datatable'; import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { ComponentFixture, TestBed, async } from '@angular/core/testing'; import { AlfrescoTranslationService, CoreModule } from 'ng2-alfresco-core';
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 { DataTableModule } from 'ng2-alfresco-datatable'; 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 { Observable, Subject } from 'rxjs/Rx';
import { FileNode, FolderNode } from '../assets/document-library.model.mock';
import { import {
fakeNodeAnswerWithNOEntries,
fakeNodeAnswerWithEntries, fakeNodeAnswerWithEntries,
fakeNodeAnswerWithNOEntries,
fakeNodeWithCreatePermission, fakeNodeWithCreatePermission,
fakeNodeWithNoPermission fakeNodeWithNoPermission
} from '../assets/document-list.component.mock'; } 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; declare let jasmine: any;
@ -54,7 +54,7 @@ describe('DocumentList', () => {
imports: [ imports: [
CoreModule.forRoot(), CoreModule.forRoot(),
DataTableModule.forRoot(), DataTableModule.forRoot(),
MdProgressSpinnerModule MaterialModule
], ],
declarations: [ declarations: [
DocumentListComponent, 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 {}