#46 refresh documentList after file uploaded

This commit is contained in:
mauriziovitale84
2016-05-14 21:21:55 +01:00
parent bbcd83b377
commit 82c1621edd
3 changed files with 37 additions and 9 deletions

View File

@@ -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

View File

@@ -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', '')
} }
} }
} }

View File

@@ -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);
} }
} }