mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[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:
@@ -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;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user