Create Folder directive enhancement: custom nodeType (#3214)

This commit is contained in:
Popovics András
2018-04-19 13:03:38 +01:00
committed by Eugenio Romano
parent 0ff0573401
commit deb09e4d5f
7 changed files with 138 additions and 72 deletions

View File

@@ -299,7 +299,30 @@ describe('FolderDialogComponent', () => {
properties: {
'cm:title': 'folder-name-update',
'cm:description': 'folder-description-update'
}
},
nodeType: 'cm:folder'
}
);
});
it('should submit updated values if form is valid (with custom nodeType)', () => {
spyOn(nodesApi, 'createFolder').and.returnValue(Observable.of({}));
component.form.controls['name'].setValue('folder-name-update');
component.form.controls['description'].setValue('folder-description-update');
component.nodeType = 'cm:sushi';
component.submit();
expect(nodesApi.createFolder).toHaveBeenCalledWith(
'parentNodeId',
{
name: 'folder-name-update',
properties: {
'cm:title': 'folder-name-update',
'cm:description': 'folder-description-update'
},
nodeType: 'cm:sushi'
}
);
});

View File

@@ -47,6 +47,7 @@ export class FolderDialogComponent implements OnInit {
editTitle = 'CORE.FOLDER_DIALOG.EDIT_FOLDER_TITLE';
createTitle = 'CORE.FOLDER_DIALOG.CREATE_FOLDER_TITLE';
nodeType = 'cm:folder';
constructor(
private formBuilder: FormBuilder,
@@ -60,6 +61,7 @@ export class FolderDialogComponent implements OnInit {
if (data) {
this.editTitle = data.editTitle || this.editTitle;
this.createTitle = data.createTitle || this.createTitle;
this.nodeType = data.nodeType || this.nodeType;
}
}
@@ -116,8 +118,8 @@ export class FolderDialogComponent implements OnInit {
}
private create(): Observable<MinimalNodeEntryEntity> {
const { name, properties, nodesApi, data: { parentNodeId} } = this;
return nodesApi.createFolder(parentNodeId, { name, properties });
const { name, properties, nodeType, nodesApi, data: { parentNodeId} } = this;
return nodesApi.createFolder(parentNodeId, { name, properties, nodeType });
}
private edit(): Observable<MinimalNodeEntryEntity> {