[ADF-2769] Added example page for content node selector (#3498)

* content node selector test page

* [ADF-2769] start adding more examples to node selector page

* [ADF-2769] added more example for node selector page

* [ADF-2769] added examples on node selector page
This commit is contained in:
Vito 2018-06-25 17:11:19 +01:00 committed by Eugenio Romano
parent e3bd400803
commit d9c792230f
10 changed files with 353 additions and 4 deletions

View File

@ -52,6 +52,7 @@
"APP_LAYOUT": {
"APP_NAME": "ADF Demo Application",
"HOME": "Home",
"NODE-SELECTOR": "Node Selector",
"CONTENT_SERVICES": "Content Services",
"BREADCRUMB": "Breadcrumb",
"PROCESS_SERVICES": "Process Services",

View File

@ -52,6 +52,7 @@ import { SharedLinkViewComponent } from './components/shared-link-view/shared-li
import { DemoPermissionComponent } from './components/permissions/demo-permissions.component';
import { PreviewService } from './services/preview.service';
import { BreadcrumbDemoComponent } from './components/breadcrumb-demo/breadcrumb-demo.component';
import { ContentNodeSelectorComponent } from './components/content-node-selector/content-node-selector.component';
import { NotificationsComponent } from './components/notifications/notifications.component';
@NgModule({
@ -106,7 +107,8 @@ import { NotificationsComponent } from './components/notifications/notifications
FormLoadingComponent,
BlobPreviewComponent,
BreadcrumbDemoComponent,
NotificationsComponent
NotificationsComponent,
ContentNodeSelectorComponent
],
providers: [
{ provide: AppConfigService, useClass: DebugAppConfigService }, // not use this service in production

View File

@ -50,6 +50,7 @@ import { DemoPermissionComponent } from './components/permissions/demo-permissio
import { BlobPreviewComponent } from './components/blob-preview/blob-preview.component';
import { BreadcrumbDemoComponent } from './components/breadcrumb-demo/breadcrumb-demo.component';
import { NotificationsComponent } from './components/notifications/notifications.component';
import { ContentNodeSelectorComponent } from './components/content-node-selector/content-node-selector.component';
export const appRoutes: Routes = [
{ path: 'login', component: LoginComponent },
@ -86,6 +87,10 @@ export const appRoutes: Routes = [
path: 'home',
component: HomeComponent
},
{
path: 'node-selector',
component: ContentNodeSelectorComponent
},
{
path: 'settings-layout',
component: SettingsComponent

View File

@ -34,6 +34,7 @@ export class AppLayoutComponent implements OnInit {
{ href: '/files', icon: 'folder_open', title: 'APP_LAYOUT.CONTENT_SERVICES' },
{ href: '/breadcrumb', icon: 'label', title: 'APP_LAYOUT.BREADCRUMB' },
{ href: '/notifications', icon: 'alarm', title: 'APP_LAYOUT.NOTIFICATIONS'},
{ href: '/node-selector', icon: 'attachment', title: 'APP_LAYOUT.NODE-SELECTOR' },
{ href: '/activiti', icon: 'device_hub', title: 'APP_LAYOUT.PROCESS_SERVICES' },
{ href: '/login', icon: 'vpn_key', title: 'APP_LAYOUT.LOGIN' },
{ href: '/trashcan', icon: 'delete', title: 'APP_LAYOUT.TRASHCAN' },

View File

@ -19,7 +19,7 @@ import { Component } from '@angular/core';
@Component({
templateUrl: './breadcrumb-demo.component.html',
styleUrls: [`./breadcrumb-demo.component.scss`],
styleUrls: [`./breadcrumb-demo.component.scss`]
})
export class BreadcrumbDemoComponent {

View File

@ -0,0 +1,198 @@
<main>
<h1>Object picker</h1>
<mat-accordion>
<mat-expansion-panel>
<mat-expansion-panel-header>
<mat-panel-title>
<h2>Plain picker</h2>
</mat-panel-title>
<mat-panel-description>
<label class="content-node-selector-demo-basic-label">
dropdownHideMyFiles: {{dropdownHideMyFiles}}
</label>
</mat-panel-description>
</mat-expansion-panel-header>
<div class="content-node-selector-demo-basic-table">
<adf-content-node-selector-panel
[currentFolderId]="'-root-'">
</adf-content-node-selector-panel>
</div>
</mat-expansion-panel>
<mat-expansion-panel>
<mat-expansion-panel-header>
<mat-panel-title>
<h2>Hide My files</h2>
</mat-panel-title>
<mat-panel-description>
<label class="content-node-selector-demo-basic-label">
My Files site will be hided from dropdown
</label>
</mat-panel-description>
</mat-expansion-panel-header>
<div class="content-node-selector-demo-basic-table">
<adf-content-node-selector-panel
[currentFolderId]="'-root-'"
[dropdownHideMyFiles]="true">
</adf-content-node-selector-panel>
</div>
</mat-expansion-panel>
<mat-expansion-panel>
<mat-expansion-panel-header>
<mat-panel-title>
<h2>Custom Site List</h2>
</mat-panel-title>
<mat-panel-description>
<label class="content-node-selector-demo-basic-label">
Adding a custom site list
</label>
</mat-panel-description>
</mat-expansion-panel-header>
<div>
<mat-list>
<h3 mat-subheader>Add Site</h3>
<form class="content-node-selector-demo-example-form">
<mat-form-field>
<label>Site Guid</label>
<input matInput [(ngModel)]="customSideGuid" [ngModelOptions]="{standalone: true}">
</mat-form-field>
<mat-form-field>
<label>Site Title</label>
<input matInput [(ngModel)]="customSideTitle" [ngModelOptions]="{standalone: true}">
</mat-form-field>
</form>
<button mat-button color="primary" (click)="onClickAddSite()">Add</button>
<button mat-button color="primary" (click)="onClickResetSite()">Reset</button>
<mat-divider></mat-divider>
<h3 mat-subheader>Custom Sites Added</h3>
<mat-list-item *ngFor="let customSite of customSites.list.entries">
<mat-icon mat-list-icon>shopping_basket</mat-icon>
<h4 mat-line>{{customSite.entry.title}}</h4>
<p mat-line> {{customSite.entry.guid}} </p>
</mat-list-item>
</mat-list>
</div>
<div class="content-node-selector-demo-basic-table">
<adf-content-node-selector-panel
[currentFolderId]="'-root-'"
[dropdownSiteList]="customSites">
</adf-content-node-selector-panel>
</div>
</mat-expansion-panel>
<mat-expansion-panel>
<mat-expansion-panel-header>
<mat-panel-title>
<h2>Row Filtering</h2>
</mat-panel-title>
<mat-panel-description>
<label class="content-node-selector-demo-basic-label">
Will automatically filter the row on the list
</label>
</mat-panel-description>
</mat-expansion-panel-header>
<mat-slide-toggle color="primary" [(ngModel)]="showFiles" (click)="recreateRowFilterFunction()">
Show Files
</mat-slide-toggle>
<mat-slide-toggle color="primary" [(ngModel)]="showFolders" (click)="recreateRowFilterFunction()">
Slide Folders
</mat-slide-toggle>
<div class="content-node-selector-demo-basic-table">
<adf-content-node-selector-panel
[rowFilter]="rowFilterFunction"
[currentFolderId]="'-root-'">
</adf-content-node-selector-panel>
</div>
</mat-expansion-panel>
<mat-expansion-panel>
<mat-expansion-panel-header>
<mat-panel-title>
<h2>Custom Image Resolving</h2>
</mat-panel-title>
<mat-panel-description>
<label class="content-node-selector-demo-basic-label">
A function to manage the way folder/file icons and thumbnails are resolved
</label>
</mat-panel-description>
</mat-expansion-panel-header>
<mat-slide-toggle color="primary" (click)="recreateImageResolverFunction()">
Add Custom Images Resolver
</mat-slide-toggle>
<div class="content-node-selector-demo-basic-table">
<adf-content-node-selector-panel
[imageResolver]="customImageResolver"
[currentFolderId]="'-root-'">
</adf-content-node-selector-panel>
</div>
</mat-expansion-panel>
<mat-expansion-panel>
<mat-expansion-panel-header>
<mat-panel-title>
<h2>Set Page Size</h2>
</mat-panel-title>
<mat-panel-description>
<label class="content-node-selector-demo-basic-label">
Number of items shown per page in the list. actual page {{actualPageSize}}
</label>
</mat-panel-description>
</mat-expansion-panel-header>
<div class="content-node-selector-demo-basic-table">
<adf-content-node-selector-panel
[currentFolderId]="'-root-'"
[pageSize]="actualPageSize"
>
</adf-content-node-selector-panel>
</div>
</mat-expansion-panel>
<mat-expansion-panel>
<mat-expansion-panel-header>
<mat-panel-title>
<h2>Is Valid Selection Function </h2>
</mat-panel-title>
<mat-panel-description>
<label class="content-node-selector-demo-basic-label">
Function used to decide if the selected node has permission to be selected
</label>
</mat-panel-description>
</mat-expansion-panel-header>
<label>Only folder starting with the letter 'a' or 'A' are valid selections</label>
<label>Actual Selection is : {{validSelection}}</label>
<div class="content-node-selector-demo-basic-table">
<adf-content-node-selector-panel
(select)="onNodeSelect($event)"
[isSelectionValid]="customIsValidFunction"
[currentFolderId]="'-root-'">
</adf-content-node-selector-panel>
</div>
</mat-expansion-panel>
<mat-expansion-panel>
<mat-expansion-panel-header>
<mat-panel-title>
<h2>BreadCrumb Transform Function </h2>
</mat-panel-title>
<mat-panel-description>
<label class="content-node-selector-demo-basic-label">
Transformation to be performed on the chosen/folder node before building the breadcrumb UI
</label>
</mat-panel-description>
</mat-expansion-panel-header>
<label>Folder starting with letter 'd' or 'D' won't be displayed in the breadcrumb dropdown</label>
<div class="content-node-selector-demo-basic-table">
<adf-content-node-selector-panel
[breadcrumbTransform]="customBreadcrumbFunction"
[currentFolderId]="'-root-'">
</adf-content-node-selector-panel>
</div>
</mat-expansion-panel>
</mat-accordion>
</main>

View File

@ -0,0 +1,27 @@
.content-node-selector-demo {
&-main {
display: flex;
flex-direction: column;
justify-content: space-around;
align-content: center;
align-self: center;
align-items: center;
}
&-basic-table {
height:400px;
width:700px
}
&-basic-label {
display: flex;
align-self: center;
}
&-example-form {
display: flex;
flex-direction: column;
align-items: flex-start;
}
}

View File

@ -0,0 +1,115 @@
/*!
* @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, ViewEncapsulation } from '@angular/core';
import { SitePaging, SiteEntry, MinimalNodeEntryEntity } from 'alfresco-js-api';
import { ShareDataRow } from '@alfresco/adf-content-services';
import { DataRow, DataColumn, ThumbnailService } from '@alfresco/adf-core';
@Component({
templateUrl: './content-node-selector.component.html',
styleUrls: [`./content-node-selector.component.scss`],
encapsulation: ViewEncapsulation.None
})
export class ContentNodeSelectorComponent {
constructor(private thumbnailService: ThumbnailService) {
}
dropdownHideMyFiles = false;
showFiles = false;
showFolders = false;
enableImageResolver = false;
validSelection = false;
customSideGuid = '';
customSideTitle = '';
actualPageSize = 2;
rowFilterFunction: any = null;
customImageResolver: any = null;
defaultSites: SiteEntry[] = [
{ entry: { title: 'MINE', guid: '-my-' } },
{ entry: { title: 'ROOTY', guid: '-root-' } }];
customSites: SitePaging = {
list: {
entries: [
{ entry: { title: 'MINE', guid: '-my-' } },
{ entry: { title: 'ROOTY', guid: '-root-' } }],
pagination: {}
}
};
onClickAddSite() {
const newSiteEntry: SiteEntry = { entry: { title: this.customSideTitle, guid: this.customSideGuid } };
this.customSites.list.entries.push(newSiteEntry);
this.customSideGuid = '';
this.customSideTitle = '';
}
onClickResetSite() {
this.customSites.list.entries = this.defaultSites;
this.customSideGuid = '';
this.customSideTitle = '';
}
recreateRowFilterFunction() {
this.rowFilterFunction = this.rowFilteringExample.bind(this);
}
recreateImageResolverFunction() {
this.enableImageResolver = !this.enableImageResolver;
if (this.enableImageResolver) {
this.customImageResolver = this.customImageResolverExample.bind(this);
} else {
this.customImageResolver = null;
}
}
rowFilteringExample(row: ShareDataRow) {
let showNode = true;
const node: MinimalNodeEntryEntity = row.node.entry;
if (this.showFiles) {
showNode = node.isFile;
}
if (this.showFolders) {
showNode = node.isFolder;
}
return showNode;
}
customImageResolverExample(row: DataRow, col: DataColumn) {
return this.thumbnailService.getMimeTypeIcon('video/quicktime');
}
onNodeSelect(node: MinimalNodeEntryEntity) {
this.validSelection = !!node;
}
customIsValidFunction(entry: MinimalNodeEntryEntity): boolean {
return entry.name.startsWith('a') || entry.name.startsWith('A');
}
customBreadcrumbFunction(node: MinimalNodeEntryEntity) {
if (node && node.path && node.path.elements) {
node.path.elements = node.path.elements.filter((element) => !element.name.toLocaleLowerCase().startsWith('d') ? element : null );
}
return node;
}
}

View File

@ -153,7 +153,7 @@
}
& .adf-name-location-cell-name {
padding: 18px 0 2px 0;
padding: 5px 0 2px 0;
}
&.adf-content-selector-modified-cell {

View File

@ -416,7 +416,7 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte
if (changes.node && changes.node.currentValue) {
this.data.loadPage(changes.node.currentValue);
this.onDataReady(changes.node.currentValue);
} else if (changes.rowFilter) {
} else if (changes.rowFilter && changes.rowFilter.currentValue !== changes.rowFilter.previousValue) {
this.data.setFilter(changes.rowFilter.currentValue);
if (this.currentFolderId) {
this.loadFolderNodesByFolderNodeId(this.currentFolderId, this.pagination.getValue()).catch(err => this.error.emit(err));