Arthur Bogaart pushed to branch feature/create-content at cms-community / hippo-addon-channel-manager
Commits: f998f56a by Arthur Bogaart at 2017-11-20T14:06:01+01:00 CHANNELMGR-1596 Store defaultPath in DocumentLocationFieldComponent - - - - - 4 changed files: - frontend-ng/src/app/channel/sidePanels/rightSidePanel/create-content/document-location/document-location-field.component.spec.ts - frontend-ng/src/app/channel/sidePanels/rightSidePanel/create-content/document-location/document-location-field.component.ts - frontend-ng/src/app/channel/sidePanels/rightSidePanel/create-content/step-1/step-1.component.spec.ts - frontend-ng/src/app/channel/sidePanels/rightSidePanel/create-content/step-1/step-1.component.ts Changes: ===================================== frontend-ng/src/app/channel/sidePanels/rightSidePanel/create-content/document-location/document-location-field.component.spec.ts ===================================== --- a/frontend-ng/src/app/channel/sidePanels/rightSidePanel/create-content/document-location/document-location-field.component.spec.ts +++ b/frontend-ng/src/app/channel/sidePanels/rightSidePanel/create-content/document-location/document-location-field.component.spec.ts @@ -115,6 +115,14 @@ describe('DocumentLocationField Component', () => { component.ngOnInit(); expect(component.documentLocation).toBe('/root/path'); }); + + it('stores the value of defaultPath returned by the create-content-service', () => { + component.rootPath = '/root'; + const folders = [{name: 'root'}, {name: 'default'}, {name: 'path'}]; + getFolderSpy.and.returnValue(Observable.of(folders)); + component.ngOnInit(); + expect(component.defaultPath).toBe('default/path'); + }); }); describe('setting the document location label', () => { ===================================== frontend-ng/src/app/channel/sidePanels/rightSidePanel/create-content/document-location/document-location-field.component.ts ===================================== --- a/frontend-ng/src/app/channel/sidePanels/rightSidePanel/create-content/document-location/document-location-field.component.ts +++ b/frontend-ng/src/app/channel/sidePanels/rightSidePanel/create-content/document-location/document-location-field.component.ts @@ -107,6 +107,10 @@ export class DocumentLocationFieldComponent implements OnInit { this.documentLocationLabel = this.calculateDocumentLocationLabel(folders); this.documentLocation = lastFolder.path; this.changeLocale.emit(lastFolder.locale); + this.defaultPath = folders + .filter((folder, index) => index >= this.rootPathDepth) + .map(folder => folder.name) + .join('/'); } private onError(error, unknownErrorMessage) { ===================================== frontend-ng/src/app/channel/sidePanels/rightSidePanel/create-content/step-1/step-1.component.spec.ts ===================================== --- a/frontend-ng/src/app/channel/sidePanels/rightSidePanel/create-content/step-1/step-1.component.spec.ts +++ b/frontend-ng/src/app/channel/sidePanels/rightSidePanel/create-content/step-1/step-1.component.spec.ts @@ -143,7 +143,7 @@ describe('Create content step 1 component', () => { component.nameUrlFields.urlField = 'new-doc'; component.documentType = 'hap:contentdocument'; component.documentLocationField.rootPath = '/content/documents/hap/news'; - component.documentLocationField.documentLocation = '/content/documents/hap/news/2017/12'; + component.documentLocationField.defaultPath = '2017/12'; const data = { name: 'New doc', ===================================== frontend-ng/src/app/channel/sidePanels/rightSidePanel/create-content/step-1/step-1.component.ts ===================================== --- a/frontend-ng/src/app/channel/sidePanels/rightSidePanel/create-content/step-1/step-1.component.ts +++ b/frontend-ng/src/app/channel/sidePanels/rightSidePanel/create-content/step-1/step-1.component.ts @@ -80,17 +80,13 @@ export class CreateContentComponent implements OnInit { } submit() { - const rootPath = this.documentLocationField.rootPath; - const location = this.documentLocationField.documentLocation; - const defaultPath = location ? location.substring(rootPath.length + 1) : ''; - const document: DocumentDetails = { name: this.nameUrlFields.nameField, slug: this.nameUrlFields.urlField, templateQuery: this.options.templateQuery, documentTypeId: this.documentType, - rootPath, - defaultPath, + rootPath: this.documentLocationField.rootPath, + defaultPath: this.documentLocationField.defaultPath, }; this.createContentService .createDraft(document) View it on GitLab: https://code.onehippo.org/cms-community/hippo-addon-channel-manager/commit/f998f56a57ceb431877f332d84640d35d21fae03 --- View it on GitLab: https://code.onehippo.org/cms-community/hippo-addon-channel-manager/commit/f998f56a57ceb431877f332d84640d35d21fae03 You're receiving this email because of your account on code.onehippo.org.
_______________________________________________ Hippocms-svn mailing list Hippocms-svn@lists.onehippo.org https://lists.onehippo.org/mailman/listinfo/hippocms-svn