mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
#46 refresh documentList after file uploaded
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
<alfresco-upload-drag-area [showUploadDialog]="true" uploaddirectory="{{relativePath}}" >
|
<alfresco-upload-drag-area [showUploadDialog]="true" uploaddirectory="{{relativePath}}"
|
||||||
<alfresco-document-list (folderClick)="refreshDirectyory($event)">
|
(onSuccess)="refreshDocumentList($event)">
|
||||||
|
<alfresco-document-list (folderClick)="refreshDirectyory($event)" currentFolderPath="{{absolutePath}}">
|
||||||
<content-columns>
|
<content-columns>
|
||||||
<content-column source="$thumbnail"></content-column>
|
<content-column source="$thumbnail"></content-column>
|
||||||
<content-column
|
<content-column
|
||||||
|
@@ -39,7 +39,7 @@ export class FilesComponent {
|
|||||||
breadcrumb: boolean = false;
|
breadcrumb: boolean = false;
|
||||||
navigation: boolean = true;
|
navigation: boolean = true;
|
||||||
events: any[] = [];
|
events: any[] = [];
|
||||||
absolutePath: string = '';
|
absolutePath: string = '/Sites/swsdp/documentLibrary';
|
||||||
relativePath: string = '';
|
relativePath: string = '';
|
||||||
|
|
||||||
constructor(documentActions: DocumentActionsService) {
|
constructor(documentActions: DocumentActionsService) {
|
||||||
@@ -63,11 +63,15 @@ export class FilesComponent {
|
|||||||
this.relativePath = this.getRelativeDirectory(this.absolutePath);
|
this.relativePath = this.getRelativeDirectory(this.absolutePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
refreshDocumentList(event: Object) {
|
||||||
|
this.absolutePath += '/';
|
||||||
|
}
|
||||||
|
|
||||||
getRelativeDirectory(currentFolderPath: string): string {
|
getRelativeDirectory(currentFolderPath: string): string {
|
||||||
if(currentFolderPath.indexOf('swsdp/documentLibrary/') !=-1) {
|
if(currentFolderPath.indexOf('/Sites/swsdp/documentLibrary/') !=-1) {
|
||||||
return currentFolderPath.replace('swsdp/documentLibrary/', '')
|
return currentFolderPath.replace('/Sites/swsdp/documentLibrary/', '')
|
||||||
} else {
|
} else {
|
||||||
return currentFolderPath.replace('swsdp/documentLibrary', '')
|
return currentFolderPath.replace('/Sites/swsdp/documentLibrary', '')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -41,6 +41,8 @@ declare let __moduleName: string;
|
|||||||
})
|
})
|
||||||
export class DocumentList implements OnInit, AfterViewChecked, AfterContentInit {
|
export class DocumentList implements OnInit, AfterViewChecked, AfterContentInit {
|
||||||
|
|
||||||
|
const DEFAULT_ROOT_FOLDER: string = "/Sites/swsdp/documentLibrary";
|
||||||
|
|
||||||
@Input()
|
@Input()
|
||||||
navigate: boolean = true;
|
navigate: boolean = true;
|
||||||
|
|
||||||
@@ -57,10 +59,13 @@ export class DocumentList implements OnInit, AfterViewChecked, AfterContentInit
|
|||||||
folderClick: EventEmitter<any> = new EventEmitter();
|
folderClick: EventEmitter<any> = new EventEmitter();
|
||||||
|
|
||||||
rootFolder = {
|
rootFolder = {
|
||||||
name: 'Document Library',
|
name: '',
|
||||||
path: 'Sites/swsdp/documentLibrary'
|
path: ''
|
||||||
};
|
};
|
||||||
currentFolderPath: string = 'swsdp/documentLibrary';
|
|
||||||
|
@Input()
|
||||||
|
currentFolderPath: string;
|
||||||
|
|
||||||
folder: NodePaging;
|
folder: NodePaging;
|
||||||
errorMessage;
|
errorMessage;
|
||||||
|
|
||||||
@@ -81,11 +86,26 @@ export class DocumentList implements OnInit, AfterViewChecked, AfterContentInit
|
|||||||
constructor(private _alfrescoService: AlfrescoService) {
|
constructor(private _alfrescoService: AlfrescoService) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_createRootFolder(): Object {
|
||||||
|
let folderArray = this.currentFolderPath.split('/');
|
||||||
|
let nameFolder = folderArray[folderArray.length -1] ;
|
||||||
|
return {
|
||||||
|
name: nameFolder,
|
||||||
|
path: this.currentFolderPath
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
this.currentFolderPath = this.currentFolderPath || this.DEFAULT_ROOT_FOLDER;
|
||||||
|
this.rootFolder = this._createRootFolder();
|
||||||
this.route.push(this.rootFolder);
|
this.route.push(this.rootFolder);
|
||||||
this.displayFolderContent(this.rootFolder.path);
|
this.displayFolderContent(this.rootFolder.path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ngOnChanges(change) {
|
||||||
|
this.reload(this.currentFolderPath);
|
||||||
|
}
|
||||||
|
|
||||||
ngAfterContentInit() {
|
ngAfterContentInit() {
|
||||||
if (!this.columns || this.columns.length === 0) {
|
if (!this.columns || this.columns.length === 0) {
|
||||||
this.setupDefaultColumns();
|
this.setupDefaultColumns();
|
||||||
@@ -132,6 +152,9 @@ 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user