Mathijs den Burger pushed to branch master at cms-community / hippo-addon-channel-manager
Commits: 66008ff6 by Mathijs den Burger at 2018-02-13T10:34:24+01:00 CHANNELMGR-1726 Fix picking a relative path for manage content parameter The picker should always pick an absolute path. The HstComponentService makes the path relative (to the given basePath) when the parameter is relative. ManageContentLink#isParameterValueRelativePath assumed that the property was a boolean while it was in fact a string (like all other "boolean" values in HTML comments). So we should compare it to the string 'true'. - - - - - 3 changed files: - frontend-ng/src/app/channel/page/element/manageContentLink.js - frontend-ng/src/app/channel/page/pageStructure.service.fixture.html - frontend-ng/src/app/channel/page/pageStructure.service.spec.js Changes: ===================================== frontend-ng/src/app/channel/page/element/manageContentLink.js ===================================== --- a/frontend-ng/src/app/channel/page/element/manageContentLink.js +++ b/frontend-ng/src/app/channel/page/element/manageContentLink.js @@ -34,7 +34,7 @@ class ManageContentLink extends EmbeddedLink { } isParameterValueRelativePath() { - return this.metaData.parameterValueIsRelativePath; + return this.metaData.parameterValueIsRelativePath === 'true'; } getPickerConfig() { @@ -44,7 +44,7 @@ class ManageContentLink extends EmbeddedLink { return { configuration: this.metaData.pickerConfiguration, initialPath: this.metaData.pickerInitialPath, - isRelativePath: this.metaData.parameterValueIsRelativePath === 'true', + isRelativePath: false, // the path is made relative in HstComponentService#saveParameter, and not by the picker remembersLastVisited: this.metaData.pickerRemembersLastVisited === 'true', rootPath: this.metaData.pickerRootPath, selectableNodeTypes: this.metaData.pickerSelectableNodeTypes ? ===================================== frontend-ng/src/app/channel/page/pageStructure.service.fixture.html ===================================== --- a/frontend-ng/src/app/channel/page/pageStructure.service.fixture.html +++ b/frontend-ng/src/app/channel/page/pageStructure.service.fixture.html @@ -110,6 +110,22 @@ "templateQuery": "new-test-document" } --> </div> +<div id="manage-content-with-absolute-path"> + <!-- { + "HST-Type": "MANAGE_CONTENT_LINK", + "defaultPath": "test-default-path", + "parameterName": "test-component-parameter", + "parameterValue": "test-component-value", + "parameterValueIsRelativePath": "false", + "pickerConfiguration": "test-component-picker configuration", + "pickerInitialPath": "test-component-picker-initial-path", + "pickerRemembersLastVisited": "false", + "pickerRootPath": "test-component-picker-root-path", + "pickerSelectableNodeTypes": "test-node-type-1,test-node-type-2", + "rootPath": "test-root-path", + "templateQuery": "new-test-document" + } --> +</div> <div id="processed-head-contributions"> <!--{"HST-Type":"HST_PROCESSED_HEAD_CONTRIBUTIONS","headElements":["<title>processed</title>", "<script>window.processed = true</script>"]}--> </div> ===================================== frontend-ng/src/app/channel/page/pageStructure.service.spec.js ===================================== --- a/frontend-ng/src/app/channel/page/pageStructure.service.spec.js +++ b/frontend-ng/src/app/channel/page/pageStructure.service.spec.js @@ -239,7 +239,6 @@ describe('PageStructureService', () => { it('registers manage content links', () => { registerEmbeddedLink('#manage-content-in-page'); const manageContentLinks = PageStructureService.getEmbeddedLinks(); - expect(manageContentLinks.length).toBe(1); const manageContentLink = manageContentLinks[0]; expect(manageContentLink.getTemplateQuery()).toBe('new-test-document'); expect(manageContentLink.getDefaultPath()).toBe('test-default-path'); @@ -249,11 +248,32 @@ describe('PageStructureService', () => { expect(manageContentLink.getPickerConfig()).toEqual({ configuration: 'test-component-picker configuration', initialPath: 'test-component-picker-initial-path', - isRelativePath: true, + isRelativePath: false, remembersLastVisited: false, rootPath: 'test-component-picker-root-path', selectableNodeTypes: ['test-node-type-1', 'test-node-type-2'], }); + expect(manageContentLink.isParameterValueRelativePath()).toBe(true); + }); + + it('recognizes a manage content link for a parameter that stores an absolute path', () => { + registerEmbeddedLink('#manage-content-with-absolute-path'); + const manageContentLinks = PageStructureService.getEmbeddedLinks(); + const manageContentLink = manageContentLinks[0]; + expect(manageContentLink.getTemplateQuery()).toBe('new-test-document'); + expect(manageContentLink.getDefaultPath()).toBe('test-default-path'); + expect(manageContentLink.getRootPath()).toBe('test-root-path'); + expect(manageContentLink.getParameterName()).toBe('test-component-parameter'); + expect(manageContentLink.getParameterValue()).toBe('test-component-value'); + expect(manageContentLink.getPickerConfig()).toEqual({ + configuration: 'test-component-picker configuration', + initialPath: 'test-component-picker-initial-path', + isRelativePath: false, + remembersLastVisited: false, + rootPath: 'test-component-picker-root-path', + selectableNodeTypes: ['test-node-type-1', 'test-node-type-2'], + }); + expect(manageContentLink.isParameterValueRelativePath()).toBe(false); }); it('registers processed and unprocessed head contributions', () => { View it on GitLab: https://code.onehippo.org/cms-community/hippo-addon-channel-manager/commit/66008ff6e2e0fe722949445cdfbaf2c2510d4895 --- View it on GitLab: https://code.onehippo.org/cms-community/hippo-addon-channel-manager/commit/66008ff6e2e0fe722949445cdfbaf2c2510d4895 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