upgrade 'create folder' action

This commit is contained in:
Denys Vuika 2017-01-03 21:13:17 +00:00
parent 44906157a0
commit 71877aa8d0
3 changed files with 18 additions and 28 deletions

View File

@ -1,5 +1,6 @@
<alfresco-document-menu-action *ngIf="creationMenuActions" <alfresco-document-menu-action
[currentFolderPath]="currentFolderPath" *ngIf="creationMenuActions"
[folderId]="currentFolderId"
(success)="onActionMenuSuccess($event)" (success)="onActionMenuSuccess($event)"
(error)="onActionMenuError($event)"> (error)="onActionMenuError($event)">
</alfresco-document-menu-action> </alfresco-document-menu-action>

View File

@ -15,16 +15,10 @@
* limitations under the License. * limitations under the License.
*/ */
import { import { Component, Input, Output, EventEmitter, ViewChild } from '@angular/core';
Component,
OnInit,
Input,
Output,
EventEmitter,
ViewChild
} from '@angular/core';
import { DocumentListService } from './../services/document-list.service';
import { AlfrescoTranslateService } from 'ng2-alfresco-core'; import { AlfrescoTranslateService } from 'ng2-alfresco-core';
import { MinimalNodeEntity } from 'alfresco-js-api';
import { DocumentListService } from './../services/document-list.service';
import { ContentActionModel } from './../models/content-action.model'; import { ContentActionModel } from './../models/content-action.model';
declare let dialogPolyfill: any; declare let dialogPolyfill: any;
@ -37,10 +31,10 @@ const ERROR_FOLDER_ALREADY_EXIST = 409;
styleUrls: ['./document-menu-action.css'], styleUrls: ['./document-menu-action.css'],
templateUrl: './document-menu-action.html' templateUrl: './document-menu-action.html'
}) })
export class DocumentMenuAction implements OnInit { export class DocumentMenuAction {
@Input() @Input()
currentFolderPath: string; folderId: string;
@Output() @Output()
success = new EventEmitter(); success = new EventEmitter();
@ -66,16 +60,14 @@ export class DocumentMenuAction implements OnInit {
} }
} }
ngOnInit() {}
public createFolder(name: string) { public createFolder(name: string) {
this.cancel(); this.cancel();
this.documentListService.createFolder(name, this.currentFolderPath) this.documentListService.createFolder(name, this.folderId)
.subscribe( .subscribe(
res => { (res: MinimalNodeEntity) => {
let relativeDir = this.currentFolderPath;
this.folderName = ''; this.folderName = '';
this.success.emit({value: relativeDir}); console.log(res.entry);
this.success.emit({node: res.entry});
}, },
error => { error => {
let errorMessagePlaceholder = this.getErrorMessage(error.response); let errorMessagePlaceholder = this.getErrorMessage(error.response);

View File

@ -96,15 +96,12 @@ export class DocumentListService {
/** /**
* Create a new folder in the path. * Create a new folder in the path.
* @param name * @param name Folder name
* @param path * @param parentId Parent folder ID
* @returns {any} * @returns {any}
*/ */
createFolder(name: string, path: string): Observable<any> { createFolder(name: string, parentId: string): Observable<MinimalNodeEntity> {
return Observable.fromPromise(this.apiService.getInstance().nodes.createFolder(name, path)) return Observable.fromPromise(this.apiService.getInstance().nodes.createFolder(name, '/', parentId))
.map(res => {
return res;
})
.catch(this.handleError); .catch(this.handleError);
} }