#9 new 'folderChange' event

- introduce new ‘folderChange’ event
- deprecated ‘folderClick’ event
- improved automation-id generation for cells
This commit is contained in:
Denys Vuika 2016-05-31 16:05:34 +01:00
parent a0cc7d6587
commit 366d147d53
4 changed files with 48 additions and 29 deletions

View File

@ -1,9 +1,12 @@
<alfresco-upload-drag-area [showUploadDialog]="true" currentFolderPath="{{absolutePath}}" uploaddirectory="{{relativePath}}" <alfresco-upload-drag-area
[showUploadDialog]="true"
currentFolderPath="{{absolutePath}}"
uploaddirectory="{{relativePath}}"
(onSuccess)="refreshDocumentList($event)"> (onSuccess)="refreshDocumentList($event)">
<alfresco-document-list <alfresco-document-list
(folderClick)="refreshDirectyory($event)" [currentFolderPath]="absolutePath"
currentFolderPath="{{absolutePath}}" [breadcrumb]="breadcrumb"
[breadcrumb]="breadcrumb"> (folderChange)="onFolderChanged($event)">
<content-columns> <content-columns>
<content-column source="$thumbnail"></content-column> <content-column source="$thumbnail"></content-column>
<content-column <content-column
@ -96,6 +99,13 @@
</label> </label>
</div> </div>
<div class="p-10">
<ul>
<li>Relative path: {{relativePath}}</li>
<li>Absolute path: {{absolutePath}}</li>
</ul>
</div>
<h5>Single file upload</h5> <h5>Single file upload</h5>
<alfresco-upload-button data-automation-id="single-file-upload" uploaddirectory="{{relativePath}}" currentFolderPath="{{absolutePath}}" <alfresco-upload-button data-automation-id="single-file-upload" uploaddirectory="{{relativePath}}" currentFolderPath="{{absolutePath}}"
(onSuccess)="refreshDocumentList($event)"></alfresco-upload-button> (onSuccess)="refreshDocumentList($event)"></alfresco-upload-button>

View File

@ -38,7 +38,6 @@ declare let __moduleName: string;
export class FilesComponent { export class FilesComponent {
breadcrumb: boolean = false; breadcrumb: boolean = false;
navigation: boolean = true; navigation: boolean = true;
events: any[] = [];
absolutePath: string = '/Sites/swsdp/documentLibrary'; absolutePath: string = '/Sites/swsdp/documentLibrary';
relativePath: string = ''; relativePath: string = '';
@ -60,20 +59,14 @@ export class FilesComponent {
alert('Custom folder action for ' + event.value.displayName); alert('Custom folder action for ' + event.value.displayName);
} }
refreshDirectyory(event: any) { refreshDocumentList() {
this.absolutePath = event.value;
this.relativePath = this.getRelativeDirectory(this.absolutePath);
}
refreshDocumentList(event: Object) {
this.absolutePath += '/'; this.absolutePath += '/';
} }
getRelativeDirectory(currentFolderPath: string): string { onFolderChanged(event?: any) {
if (currentFolderPath.indexOf('/Sites/swsdp/documentLibrary/') !== -1) { if (event) {
return currentFolderPath.replace('/Sites/swsdp/documentLibrary/', ''); this.absolutePath = event.absolutePath;
} else { this.relativePath = event.relativePath;
return currentFolderPath.replace('/Sites/swsdp/documentLibrary', '');
} }
} }
} }

View File

@ -39,7 +39,7 @@
<td *ngFor="#col of columns" [ngSwitch]="col.source" <td *ngFor="#col of columns" [ngSwitch]="col.source"
class="mdl-data-table__cell--non-numeric {{content.entry.isFolder ? 'folder-row-cell' : 'document-row-cell'}} {{col.cssClass}}" class="mdl-data-table__cell--non-numeric {{content.entry.isFolder ? 'folder-row-cell' : 'document-row-cell'}} {{col.cssClass}}"
(click)="onItemClick(content, $event)" (click)="onItemClick(content, $event)"
[attr.data-automation-id]="col.source === '$thumbnail' ? '$thumbnail' : getObjectValue(content.entry, col.source)"> [attr.data-automation-id]="col.source === '$thumbnail' ? '$thumbnail' : col.source + '_' + getObjectValue(content.entry, col.source)">
<div *ngSwitchWhen="'$thumbnail'"> <div *ngSwitchWhen="'$thumbnail'">
<div *ngIf="content.entry.isFolder"> <div *ngIf="content.entry.isFolder">
<i class="material-icons folder-thumbnail">{{folderIcon || 'folder_open'}}</i> <i class="material-icons folder-thumbnail">{{folderIcon || 'folder_open'}}</i>

View File

@ -57,7 +57,7 @@ export class DocumentList implements OnInit, AfterViewChecked, AfterContentInit
itemClick: EventEmitter<any> = new EventEmitter(); itemClick: EventEmitter<any> = new EventEmitter();
@Output() @Output()
folderClick: EventEmitter<any> = new EventEmitter(); folderChange: EventEmitter<any> = new EventEmitter();
rootFolder = { rootFolder = {
name: '', name: '',
@ -67,14 +67,30 @@ export class DocumentList implements OnInit, AfterViewChecked, AfterContentInit
@Input() @Input()
currentFolderPath: string = ''; currentFolderPath: string = '';
folder: NodePaging;
errorMessage; errorMessage;
route: any[] = []; route: any[] = [];
actions: ContentActionModel[] = []; actions: ContentActionModel[] = [];
columns: ContentColumnModel[] = []; columns: ContentColumnModel[] = [];
private _folder: NodePaging;
get folder(): NodePaging {
return this._folder;
}
set folder(value: NodePaging) {
let isChanged = this._folder !== value;
this._folder = value;
if (isChanged) {
this.folderChange.emit({
value: value,
absolutePath: this.currentFolderPath,
relativePath: this.getRelativePath(this.currentFolderPath)
});
}
}
sorting: ColumnSortingModel = { sorting: ColumnSortingModel = {
key: 'name', key: 'name',
direction: 'asc' direction: 'asc'
@ -158,9 +174,6 @@ export class DocumentList implements OnInit, AfterViewChecked, AfterContentInit
this.route.pop(); this.route.pop();
let parent = this.route.length > 0 ? this.route[this.route.length - 1] : this.rootFolder; let parent = this.route.length > 0 ? this.route[this.route.length - 1] : this.rootFolder;
if (parent) { if (parent) {
this.folderClick.emit({
value: parent.path
});
this.displayFolderContent(parent.path); this.displayFolderContent(parent.path);
} }
} }
@ -183,11 +196,6 @@ export class DocumentList implements OnInit, AfterViewChecked, AfterContentInit
if (this.navigate && item && item.entry) { if (this.navigate && item && item.entry) {
if (item.entry.isFolder) { if (item.entry.isFolder) {
let path = this.getNodePath(item); let path = this.getNodePath(item);
this.folderClick.emit({
value: path
});
this.route.push({ this.route.push({
name: item.entry.name, name: item.entry.name,
path: path path: path
@ -376,4 +384,12 @@ export class DocumentList implements OnInit, AfterViewChecked, AfterContentInit
private _isSortableColumn(column: ContentColumnModel) { private _isSortableColumn(column: ContentColumnModel) {
return column && column.source && !column.source.startsWith('$'); return column && column.source && !column.source.startsWith('$');
} }
private getRelativePath(path: string): string {
if (path.indexOf('/Sites/swsdp/documentLibrary/') !== -1) {
return path.replace('/Sites/swsdp/documentLibrary/', '');
} else {
return path.replace('/Sites/swsdp/documentLibrary', '');
}
}
} }