add possible future configurability display mode document list and datatable (#2998)

This commit is contained in:
Eugenio Romano
2018-02-26 03:04:19 +00:00
committed by GitHub
parent 76cf4f178e
commit 97a10bde78
10 changed files with 54 additions and 35 deletions

View File

@@ -11,7 +11,7 @@
<adf-document-list <adf-document-list
[currentFolderId]="'-recent-'" [currentFolderId]="'-recent-'"
locationFormat="/files" locationFormat="/files"
[cardview]="true" [display]="'gallery'"
[showHeader]="false" [showHeader]="false"
[maxItems]="5" [maxItems]="5"
(preview)="showFile($event)" (preview)="showFile($event)"
@@ -67,8 +67,9 @@
<button <button
mat-icon-button mat-icon-button
title="{{ 'DOCUMENT_LIST.TOOLBAR.CARDVIEW' | translate }}" title="{{ 'DOCUMENT_LIST.TOOLBAR.CARDVIEW' | translate }}"
(click)="toogleCardview()"> (click)="toogleGalleryView()">
<mat-icon>view_comfy</mat-icon> <mat-icon *ngIf="displayMode === 'list'" >view_comfy</mat-icon>
<mat-icon *ngIf="displayMode === 'gallery'">list</mat-icon>
</button> </button>
<button <button
mat-icon-button mat-icon-button
@@ -130,8 +131,9 @@
</button> </button>
<mat-menu #menu="matMenu"> <mat-menu #menu="matMenu">
<button mat-menu-item <button mat-menu-item
(click)="toogleCardview()"> (click)="toogleGalleryView()">
<mat-icon>view_comfy</mat-icon> <mat-icon *ngIf="displayMode === 'list'" >view_comfy</mat-icon>
<mat-icon *ngIf="displayMode === 'gallery'">list</mat-icon>
<span>{{ 'DOCUMENT_LIST.TOOLBAR.CARDVIEW' | translate }}</span> <span>{{ 'DOCUMENT_LIST.TOOLBAR.CARDVIEW' | translate }}</span>
</button> </button>
<button mat-menu-item <button mat-menu-item
@@ -171,7 +173,7 @@
[allowDropFiles]="true" [allowDropFiles]="true"
[selectionMode]="selectionMode" [selectionMode]="selectionMode"
[multiselect]="multiselect" [multiselect]="multiselect"
[cardview]="cardview" [display]="displayMode"
[node]="nodeResult" [node]="nodeResult"
(error)="onNavigationError($event)" (error)="onNavigationError($event)"
(success)="resetError()" (success)="resetError()"

View File

@@ -21,12 +21,19 @@ import {
} from '@angular/core'; } from '@angular/core';
import { MatDialog } from '@angular/material'; import { MatDialog } from '@angular/material';
import { ActivatedRoute, Params, Router } from '@angular/router'; import { ActivatedRoute, Params, Router } from '@angular/router';
import { MinimalNodeEntity, NodePaging, Pagination, PathElementEntity, MinimalNodeEntryEntity, SiteEntry } from 'alfresco-js-api'; import {
MinimalNodeEntity,
NodePaging,
Pagination,
PathElementEntity,
MinimalNodeEntryEntity,
SiteEntry
} from 'alfresco-js-api';
import { import {
AuthenticationService, ContentService, TranslationService, AuthenticationService, ContentService, TranslationService,
FileUploadEvent, FolderCreatedEvent, LogService, NotificationService, FileUploadEvent, FolderCreatedEvent, LogService, NotificationService,
UploadService, DataColumn, DataRow, UserPreferencesService, UploadService, DataColumn, DataRow, UserPreferencesService,
PaginationComponent, FormValues PaginationComponent, FormValues, DisplayMode
} from '@alfresco/adf-core'; } from '@alfresco/adf-core';
import { DocumentListComponent, PermissionStyleModel } from '@alfresco/adf-content-services'; import { DocumentListComponent, PermissionStyleModel } from '@alfresco/adf-content-services';
@@ -50,7 +57,7 @@ export class FilesComponent implements OnInit, OnChanges, OnDestroy {
fileNodeId: any; fileNodeId: any;
showViewer = false; showViewer = false;
showVersions = false; showVersions = false;
cardview = false; displayMode = DisplayMode.List;
toolbarColor = 'default'; toolbarColor = 'default';
@@ -441,7 +448,11 @@ export class FilesComponent implements OnInit, OnChanges, OnDestroy {
this.turnedPreviousPage.emit(event); this.turnedPreviousPage.emit(event);
} }
toogleCardview(event: Pagination): void { toogleGalleryView(): void {
this.cardview = !this.cardview; if (this.displayMode === DisplayMode.List) {
this.displayMode = DisplayMode.Gallery;
} else {
this.displayMode = DisplayMode.List;
}
} }
} }

View File

@@ -138,7 +138,7 @@ export class DataTableDemo {
| allowDropFiles | boolean | false | Toggle file drop support for rows (see **ng2-alfresco-core/UploadDirective** for more details) | | allowDropFiles | boolean | false | Toggle file drop support for rows (see **ng2-alfresco-core/UploadDirective** for more details) |
| loading | boolean | false | Flag that indicates if the datatable is in loading state and needs to show the loading template. Read the documentation above to see how to configure a loading template | | loading | boolean | false | Flag that indicates if the datatable is in loading state and needs to show the loading template. Read the documentation above to see how to configure a loading template |
| showHeader | boolean | true | Toggles header visibility | | showHeader | boolean | true | Toggles header visibility |
| cardview | boolean | true | enable the cardview mode | | display | string | 'list' | change the display mode can be one of the values provided by the enum : **list**, **gallery** |
| selection | DataRow\[] | \[] | Contains selected rows | | selection | DataRow\[] | \[] | Contains selected rows |
### Events ### Events
@@ -205,7 +205,7 @@ If you want enable the card view mode you need to set to true the input paramete
```html ```html
<adf-datatable <adf-datatable
[data]="data" [data]="data"
[cardview]="true"> [display]="'gallery'">
</adf-datatable </adf-datatable
``` ```

View File

@@ -79,7 +79,7 @@ Displays the documents from a repository.
| skipCount | `number` | `0` | Number of elements to skip over for pagination purposes | | skipCount | `number` | `0` | Number of elements to skip over for pagination purposes |
| enableInfiniteScrolling | `boolean` | `false` | Set document list to work in infinite scrolling mode | | enableInfiniteScrolling | `boolean` | `false` | Set document list to work in infinite scrolling mode |
| showHeader | `boolean` | `true` | Toggles header visibility | | showHeader | `boolean` | `true` | Toggles header visibility |
| cardview | `boolean` | `false` | Enable the cardview mode | | display | string | 'list' | change the display mode can be one of the values provided by the enum : **list**, **gallery** |
### Events ### Events
@@ -141,7 +141,7 @@ If you want enable the card view mode you need to set to true the input paramete
```html ```html
<adf-document-list <adf-document-list
[currentFolderId]="'-my-'" [currentFolderId]="'-my-'"
[cardview]="true"> [display]="'gallery'">
</adf-document-list> </adf-document-list>
``` ```

View File

@@ -9,7 +9,7 @@
[rowStyle]="rowStyle" [rowStyle]="rowStyle"
[rowStyleClass]="rowStyleClass" [rowStyleClass]="rowStyleClass"
[loading]="loading" [loading]="loading"
[cardview]="cardview" [display]="display"
[noPermission]="noPermission" [noPermission]="noPermission"
[showHeader]="!isEmpty() && showHeader" [showHeader]="!isEmpty() && showHeader"
(showRowContextMenu)="onShowRowContextMenu($event)" (showRowContextMenu)="onShowRowContextMenu($event)"

View File

@@ -220,7 +220,7 @@ describe('DocumentList', () => {
}); });
it('should use the cardview style if cardview is true', (done) => { it('should use the cardview style if cardview is true', (done) => {
documentList.cardview = true; documentList.display = 'gallery';
fixture.detectChanges(); fixture.detectChanges();
@@ -232,7 +232,7 @@ describe('DocumentList', () => {
}); });
it('should use the base document list style if cardview is false', (done) => { it('should use the base document list style if cardview is false', (done) => {
documentList.cardview = false; documentList.display = 'list';
fixture.detectChanges(); fixture.detectChanges();

View File

@@ -21,6 +21,7 @@ import {
DataRowActionEvent, DataRowActionEvent,
DataSorting, DataSorting,
DataTableComponent, DataTableComponent,
DisplayMode,
ObjectDataColumn, ObjectDataColumn,
PaginatedComponent, PaginatedComponent,
PaginationQueryParams PaginationQueryParams
@@ -71,9 +72,9 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte
@ContentChild(DataColumnListComponent) columnList: DataColumnListComponent; @ContentChild(DataColumnListComponent) columnList: DataColumnListComponent;
/* Enable the cardview mode */ /* change the display mode of the table list or gallery */
@Input() @Input()
cardview: boolean = false; display: string = DisplayMode.List;
/** Define a set of CSS styles styles to apply depending on the permission /** Define a set of CSS styles styles to apply depending on the permission
* of the user on that node. See the Permission Style model * of the user on that node. See the Permission Style model

View File

@@ -1,9 +1,9 @@
<div <div
*ngIf="data" class="full-width adf-data-table-card" *ngIf="data" class="full-width"
[class.adf-data-table-card]="cardview" [class.adf-data-table-card]="display === 'gallery'"
[class.adf-data-table]="!cardview"> [class.adf-data-table]="display === 'list'">
<div *ngIf="showHeader && !loading" class="adf-datatable-header"> <div *ngIf="showHeader && !loading" class="adf-datatable-header">
<div class="adf-datatable-row" *ngIf="!cardview"> <div class="adf-datatable-row" *ngIf="display === 'list'">
<!-- Actions (left) --> <!-- Actions (left) -->
<div *ngIf="actions && actionsPosition === 'left'" class="actions-column adf-datatable-table-cell-header"> <div *ngIf="actions && actionsPosition === 'left'" class="actions-column adf-datatable-table-cell-header">
<span class="sr-only">Actions</span> <span class="sr-only">Actions</span>
@@ -31,7 +31,7 @@
<span class="sr-only">Actions</span> <span class="sr-only">Actions</span>
</div> </div>
</div> </div>
<mat-form-field *ngIf="cardview"> <mat-form-field *ngIf="display === 'gallery'">
<mat-select [value]="getSortingKey()"> <mat-select [value]="getSortingKey()">
<mat-option *ngFor="let col of getSortableColumns()" <mat-option *ngFor="let col of getSortableColumns()"
[value]="col.key" [value]="col.key"
@@ -174,8 +174,8 @@
</div> </div>
<div *ngIf="data.getRows().length === 0" <div *ngIf="data.getRows().length === 0"
[class.adf-datatable-row]="!cardview" [class.adf-datatable-row]="display === 'list'"
[class.adf-data-table-card-empty]="cardview"> [class.adf-data-table-card-empty]="display === 'gallery'">
<div class="adf-no-content-container adf-datatable-table-cell" <div class="adf-no-content-container adf-datatable-table-cell"
[attr.colspan]="1 + data.getColumns().length"> [attr.colspan]="1 + data.getColumns().length">
<ng-template *ngIf="noContentTemplate" <ng-template *ngIf="noContentTemplate"
@@ -187,8 +187,8 @@
</div> </div>
</ng-container> </ng-container>
<div *ngIf="!loading && noPermission" <div *ngIf="!loading && noPermission"
[class.adf-datatable-row]="!cardview" [class.adf-datatable-row]="display === 'list'"
[class.adf-data-table-card-permissions]="cardview"> [class.adf-data-table-card-permissions]="display === 'gallery'">
class="adf-no-permission__row"> class="adf-no-permission__row">
<div class="adf-no-permission__cell adf-no-content-container adf-datatable-table-cell"> <div class="adf-no-permission__cell adf-no-content-container adf-datatable-table-cell">
<ng-template *ngIf="noPermissionTemplate" <ng-template *ngIf="noPermissionTemplate"
@@ -198,8 +198,8 @@
</div> </div>
</div> </div>
<div *ngIf="loading" <div *ngIf="loading"
[class.adf-datatable-row]="!cardview" [class.adf-datatable-row]="display === 'list'"
[class.adf-data-table-card-loading]="cardview"> [class.adf-data-table-card-loading]="display === 'gallery'">
<div class="adf-datatable-table-cell" <div class="adf-datatable-table-cell"
[attr.colspan]="1 + data.getColumns().length"> [attr.colspan]="1 + data.getColumns().length">
<ng-template *ngIf="loadingTemplate" <ng-template *ngIf="loadingTemplate"

View File

@@ -60,7 +60,7 @@ describe('DataTable', () => {
[new ObjectDataColumn({ key: 'name' })] [new ObjectDataColumn({ key: 'name' })]
); );
dataTable.cardview = true; dataTable.display = 'gallery';
dataTable.ngOnChanges({ dataTable.ngOnChanges({
data: new SimpleChange(null, newData, false) data: new SimpleChange(null, newData, false)
}); });
@@ -80,7 +80,7 @@ describe('DataTable', () => {
[new ObjectDataColumn({ key: 'name' })] [new ObjectDataColumn({ key: 'name' })]
); );
dataTable.cardview = false;
dataTable.ngOnChanges({ dataTable.ngOnChanges({
data: new SimpleChange(null, newData, false) data: new SimpleChange(null, newData, false)
}); });

View File

@@ -38,6 +38,11 @@ import 'rxjs/add/operator/debounceTime';
import 'rxjs/add/operator/buffer'; import 'rxjs/add/operator/buffer';
import 'rxjs/add/operator/filter'; import 'rxjs/add/operator/filter';
export enum DisplayMode {
List = 'list',
Gallery = 'gallery'
}
@Component({ @Component({
selector: 'adf-datatable', selector: 'adf-datatable',
styleUrls: ['./datatable.component.scss'], styleUrls: ['./datatable.component.scss'],
@@ -53,9 +58,9 @@ export class DataTableComponent implements AfterContentInit, OnChanges, DoCheck
@Input() @Input()
data: DataTableAdapter; data: DataTableAdapter;
/* Enable the cardview mode */ /* change the display mode of the table list or gallery */
@Input() @Input()
cardview: boolean = false; display: string = DisplayMode.List;
/* The rows that the datatable will show */ /* The rows that the datatable will show */
@Input() @Input()