Tobias Jeger pushed to branch feature/cmng-psp1-CHANNELMGR-467 at cms-community / hippo-addon-channel-manager
Commits: ce524de1 by Tobias Jeger at 2016-03-18T15:15:56+01:00 CHANNELMGR-331: add QA class to help opening the component properties dialog. - - - - - 672b69bb by Joeri de Gooijer at 2016-03-18T16:27:23+01:00 CHANNELMGR-468 update to latest hippo-build - - - - - 4e332d6b by Mathijs den Burger at 2016-03-18T16:41:43+01:00 CHANNELMGR-468 remove duplicate method 'removeComponent' Keep the one that accepts a component. - - - - - 18f551ae by Mathijs den Burger at 2016-03-18T17:01:45+01:00 CHANNELMGR-468 add unit tests for moving components - - - - - 18f428d7 by Mathijs den Burger at 2016-03-18T17:03:49+01:00 CHANNELMGR-467 disable 2 mainline unit tests until branch is merged - - - - - ecb7b742 by Tobias Jeger at 2016-03-21T09:50:14+01:00 Merge branch 'feature/cmng-psp1' into feature/cmng-psp1-CHANNELMGR-467 # Conflicts: # frontend-ng/src/angularjs/channel/hippoIframe/dragDrop.service.spec.js # frontend-ng/src/angularjs/channel/page/element/containerElement.js # frontend-ng/src/angularjs/channel/page/pageStructure.service.spec.js - - - - - 1a7af9b8 by Tobias Jeger at 2016-03-21T09:50:59+01:00 CHANNELMGR-467: fix more unit tests. - - - - - 7 changed files: - frontend-ng/npm-shrinkwrap.json - frontend-ng/package.json - frontend-ng/src/angularjs/channel/hippoIframe/dragDrop.service.fixture.html - frontend-ng/src/angularjs/channel/hippoIframe/dragDrop.service.js - frontend-ng/src/angularjs/channel/hippoIframe/dragDrop.service.spec.js - frontend-ng/src/angularjs/channel/page/extJsHandler.service.js - frontend-ng/src/angularjs/channel/page/extJsHandler.service.spec.js Changes: ===================================== frontend-ng/npm-shrinkwrap.json ===================================== --- a/frontend-ng/npm-shrinkwrap.json +++ b/frontend-ng/npm-shrinkwrap.json @@ -104,9 +104,9 @@ "resolved": "https://registry.npmjs.org/are-we-there-yet/-/are-we-there-yet-1.1.2.tgz" }, "argparse": { - "version": "1.0.6", + "version": "1.0.7", "from": "argparse@>=1.0.2 <2.0.0", - "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.6.tgz" + "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.7.tgz" }, "arr-diff": { "version": "2.0.0", @@ -540,7 +540,7 @@ }, "bower-installer": { "version": "0.8.4", - "from": "git://github.com/bessdsv/bower-installer.git#7f9cece1e6fada50f44dc0851e1d85815cd1b4a7", + "from": "git://github.com/bessdsv/bower-installer.git#temp", "resolved": "git://github.com/bessdsv/bower-installer.git#7f9cece1e6fada50f44dc0851e1d85815cd1b4a7", "dependencies": { "ansi-regex": { @@ -1106,9 +1106,9 @@ "resolved": "https://registry.npmjs.org/camelcase-keys/-/camelcase-keys-1.0.0.tgz" }, "caniuse-db": { - "version": "1.0.30000430", + "version": "1.0.30000433", "from": "caniuse-db@>=1.0.30000409 <2.0.0", - "resolved": "https://registry.npmjs.org/caniuse-db/-/caniuse-db-1.0.30000430.tgz" + "resolved": "https://registry.npmjs.org/caniuse-db/-/caniuse-db-1.0.30000433.tgz" }, "capture-stack-trace": { "version": "1.0.0", @@ -2025,9 +2025,9 @@ "resolved": "https://registry.npmjs.org/event-stream/-/event-stream-3.3.2.tgz" }, "eventemitter3": { - "version": "1.1.1", + "version": "1.2.0", "from": "eventemitter3@>=1.0.0 <2.0.0", - "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-1.1.1.tgz" + "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-1.2.0.tgz" }, "exec-buffer": { "version": "2.0.1", @@ -2536,9 +2536,9 @@ "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-2.1.1.tgz" }, "cliui": { - "version": "3.1.0", + "version": "3.1.1", "from": "cliui@>=3.0.3 <4.0.0", - "resolved": "https://registry.npmjs.org/cliui/-/cliui-3.1.0.tgz" + "resolved": "https://registry.npmjs.org/cliui/-/cliui-3.1.1.tgz" }, "gulp-cli": { "version": "1.2.1", @@ -2682,9 +2682,9 @@ } }, "gulp-match": { - "version": "1.0.0", + "version": "1.0.1", "from": "gulp-match@>=1.0.0 <2.0.0", - "resolved": "https://registry.npmjs.org/gulp-match/-/gulp-match-1.0.0.tgz", + "resolved": "https://registry.npmjs.org/gulp-match/-/gulp-match-1.0.1.tgz", "dependencies": { "minimatch": { "version": "3.0.0", @@ -2975,9 +2975,9 @@ "resolved": "https://registry.npmjs.org/hawk/-/hawk-3.1.3.tgz" }, "hippo-build": { - "version": "0.0.34", - "from": "git://github.com/onehippo/hippo-build.git#88d4253664ce03e36664965e75cb08dc09ef3f45", - "resolved": "git://github.com/onehippo/hippo-build.git#88d4253664ce03e36664965e75cb08dc09ef3f45" + "version": "0.0.35", + "from": "git://github.com/onehippo/hippo-build.git#v0.0.35", + "resolved": "git://github.com/onehippo/hippo-build.git#70f6914d024044aff5301575224fb569d13b8811" }, "hoek": { "version": "2.16.3", @@ -2995,9 +2995,9 @@ "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.1.4.tgz" }, "html-minifier": { - "version": "1.2.0", + "version": "1.3.0", "from": "html-minifier@>=1.0.0 <2.0.0", - "resolved": "https://registry.npmjs.org/html-minifier/-/html-minifier-1.2.0.tgz" + "resolved": "https://registry.npmjs.org/html-minifier/-/html-minifier-1.3.0.tgz" }, "http-errors": { "version": "1.3.1", @@ -3586,9 +3586,9 @@ "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-1.0.1.tgz" }, "js-yaml": { - "version": "3.5.4", + "version": "3.5.5", "from": "js-yaml@>=3.5.1 <4.0.0", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.5.4.tgz", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.5.5.tgz", "dependencies": { "esprima": { "version": "2.7.2", @@ -3936,9 +3936,9 @@ "resolved": "https://registry.npmjs.org/localtunnel/-/localtunnel-1.8.1.tgz", "dependencies": { "cliui": { - "version": "3.1.0", + "version": "3.1.1", "from": "cliui@>=3.0.3 <4.0.0", - "resolved": "https://registry.npmjs.org/cliui/-/cliui-3.1.0.tgz" + "resolved": "https://registry.npmjs.org/cliui/-/cliui-3.1.1.tgz" }, "yargs": { "version": "3.29.0", @@ -4579,6 +4579,11 @@ "from": "nan@>=2.0.5 <3.0.0", "resolved": "https://registry.npmjs.org/nan/-/nan-2.2.0.tgz" }, + "ncname": { + "version": "1.0.0", + "from": "ncname@>=1.0.0 <1.1.0", + "resolved": "https://registry.npmjs.org/ncname/-/ncname-1.0.0.tgz" + }, "negotiator": { "version": "0.5.3", "from": "negotiator@0.5.3", @@ -4712,9 +4717,9 @@ "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.0.1.tgz" }, "query-string": { - "version": "3.0.1", + "version": "3.0.2", "from": "query-string@>=3.0.0 <4.0.0", - "resolved": "https://registry.npmjs.org/query-string/-/query-string-3.0.1.tgz" + "resolved": "https://registry.npmjs.org/query-string/-/query-string-3.0.2.tgz" } } }, @@ -5682,9 +5687,9 @@ "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-2.1.1.tgz" }, "cliui": { - "version": "3.1.0", + "version": "3.1.1", "from": "cliui@>=3.0.3 <4.0.0", - "resolved": "https://registry.npmjs.org/cliui/-/cliui-3.1.0.tgz" + "resolved": "https://registry.npmjs.org/cliui/-/cliui-3.1.1.tgz" }, "glob": { "version": "6.0.4", @@ -6848,9 +6853,9 @@ "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.2.tgz" }, "wrap-ansi": { - "version": "1.0.0", - "from": "wrap-ansi@>=1.0.0 <2.0.0", - "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-1.0.0.tgz" + "version": "2.0.0", + "from": "wrap-ansi@>=2.0.0 <3.0.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-2.0.0.tgz" }, "wrap-fn": { "version": "0.1.5", @@ -6882,6 +6887,11 @@ "from": "xdg-basedir@>=1.0.0 <2.0.0", "resolved": "https://registry.npmjs.org/xdg-basedir/-/xdg-basedir-1.0.1.tgz" }, + "xml-char-classes": { + "version": "1.0.0", + "from": "xml-char-classes@>=1.0.0 <2.0.0", + "resolved": "https://registry.npmjs.org/xml-char-classes/-/xml-char-classes-1.0.0.tgz" + }, "xml-escape": { "version": "1.0.0", "from": "xml-escape@>=1.0.0 <1.1.0", @@ -6908,9 +6918,9 @@ "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz" }, "y18n": { - "version": "3.2.0", + "version": "3.2.1", "from": "y18n@>=3.2.0 <4.0.0", - "resolved": "https://registry.npmjs.org/y18n/-/y18n-3.2.0.tgz" + "resolved": "https://registry.npmjs.org/y18n/-/y18n-3.2.1.tgz" }, "yallist": { "version": "2.0.0", @@ -6928,9 +6938,9 @@ "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-2.1.1.tgz" }, "cliui": { - "version": "3.1.0", + "version": "3.1.1", "from": "cliui@>=3.0.3 <4.0.0", - "resolved": "https://registry.npmjs.org/cliui/-/cliui-3.1.0.tgz" + "resolved": "https://registry.npmjs.org/cliui/-/cliui-3.1.1.tgz" }, "lodash.assign": { "version": "4.0.6", ===================================== frontend-ng/package.json ===================================== --- a/frontend-ng/package.json +++ b/frontend-ng/package.json @@ -6,6 +6,6 @@ "gulp": "gulp" }, "devDependencies": { - "hippo-build": "git://github.com/onehippo/hippo-build.git#v0.0.34" + "hippo-build": "git://github.com/onehippo/hippo-build.git#v0.0.35" } } ===================================== frontend-ng/src/angularjs/channel/hippoIframe/dragDrop.service.fixture.html ===================================== --- a/frontend-ng/src/angularjs/channel/hippoIframe/dragDrop.service.fixture.html +++ b/frontend-ng/src/angularjs/channel/hippoIframe/dragDrop.service.fixture.html @@ -16,12 +16,4 @@ <div id="testBase"> <iframe id="testIframe"></iframe> - <div id="overlayContainer1"> - <div id="overlayComponent1"> - </div> - <div id="overlayComponent2"> - </div> - </div> - <div id="overlayContainer2"> - </div> </div> ===================================== frontend-ng/src/angularjs/channel/hippoIframe/dragDrop.service.js ===================================== --- a/frontend-ng/src/angularjs/channel/hippoIframe/dragDrop.service.js +++ b/frontend-ng/src/angularjs/channel/hippoIframe/dragDrop.service.js @@ -65,11 +65,12 @@ export class DragDropService { this.drake = this.iframe.dragula(iframeContainerElements, { ignoreInputTextSelection: false, }); - this.drake.on('dragend', () => this._stopDrag()); + this.drake.on('dragend', (el) => this._stopDrag(el)); this.drake.on('drop', this._onDrop.bind(this)); this._onComponentClick(containers, (component) => { this.dragging = false; + component.getBoxElement().removeClass('qa-dragula-component'); this.PageStructureService.showComponentProperties(component); }); }); @@ -108,7 +109,8 @@ export class DragDropService { return this.dragging; } - _stopDrag() { + _stopDrag(element) { + $(element).removeClass('qa-dragula-component'); this.dragging = false; this.$rootScope.$digest(); } @@ -143,6 +145,7 @@ export class DragDropService { }); const iframeElement = structureElement.getBoxElement(); iframeElement[0].dispatchEvent(iframeEvent); + iframeElement.addClass('qa-dragula-component'); } _shiftCoordinates($event) { ===================================== frontend-ng/src/angularjs/channel/hippoIframe/dragDrop.service.spec.js ===================================== --- a/frontend-ng/src/angularjs/channel/hippoIframe/dragDrop.service.spec.js +++ b/frontend-ng/src/angularjs/channel/hippoIframe/dragDrop.service.spec.js @@ -14,33 +14,30 @@ * limitations under the License. */ -import { ContainerElement } from '../page/element/containerElement'; -import { ComponentElement } from '../page/element/componentElement'; - describe('DragDropService', () => { 'use strict'; let DragDropService; - let hstCommentsProcessor; let ScalingService; let PageStructureService; + let HstService; let iframe; let base; let container1; - let container2; let component1; - // let component2; + let component2; + let container2; beforeEach(() => { module('hippo-cm.channel.hippoIframe'); - inject((_DragDropService_, _hstCommentsProcessorService_, _ScalingService_, _PageStructureService_) => { + inject((_DragDropService_, _ScalingService_, _PageStructureService_, _HstService_) => { DragDropService = _DragDropService_; - hstCommentsProcessor = _hstCommentsProcessorService_; ScalingService = _ScalingService_; PageStructureService = _PageStructureService_; + HstService = _HstService_; }); jasmine.getFixtures().load('channel/hippoIframe/dragDrop.service.fixture.html'); @@ -50,27 +47,26 @@ describe('DragDropService', () => { }); function createContainer(number) { - const iframeContainerComment = iframe.contents().find(`#iframeContainerComment${number}`); - const overlayContainer = $j(`#overlayContainer${number}`); - const result = new ContainerElement(iframeContainerComment[0], { + const iframeContainerComment = iframe.contents().find(`#iframeContainerComment${number}`)[0]; + PageStructureService.registerParsedElement(iframeContainerComment, { uuid: `container${number}`, - 'HST-Type': 'HST.vBox', - }, hstCommentsProcessor); - result.setJQueryElement('overlay', overlayContainer); - return result; + 'HST-Type': 'CONTAINER_COMPONENT', + }); + return PageStructureService.containers[PageStructureService.containers.length - 1]; } - function createComponent(number, container) { - const iframeComponentComment = iframe.contents().find(`#iframeComponentComment${number}`); - const overlayComponent = $j(`#overlayComponent${number}`); - const metaData = { + function createComponent(number) { + const iframeComponentComment = iframe.contents().find(`#iframeComponentComment${number}`)[0]; + PageStructureService.registerParsedElement(iframeComponentComment, { uuid: `component${number}`, + 'HST-Type': 'CONTAINER_ITEM_COMPONENT', 'HST-Label': `Component ${number}`, - }; - const result = new ComponentElement(iframeComponentComment[0], metaData, container, hstCommentsProcessor); - result.setJQueryElement('overlay', overlayComponent); - container.addComponent(result); - return result; + }); + return PageStructureService.getComponentById(`component${number}`); + } + + function componentIds(container) { + return container.getComponents().map((component) => component.getId()); } function loadIframeFixture(callback) { @@ -82,7 +78,7 @@ describe('DragDropService', () => { container1 = ''; container1 = createContainer(1); component1 = createComponent(1, container1); - createComponent(2, container1); + component2 = createComponent(2, container1); // make ESLint happy; it claims that "'container2' is never reassigned, use 'const' instead" :( container2 = ''; @@ -224,4 +220,60 @@ describe('DragDropService', () => { DragDropService._stopDrag(); expect(DragDropService.isDragging()).toEqual(false); }); + + it('can move the first component to the second position in the container', (done) => { + loadIframeFixture(() => { + const componentElement1 = component1.getBoxElement(); + const containerElement1 = container1.getBoxElement(); + + spyOn(HstService, 'doPost'); + expect(componentIds(container1)).toEqual(['component1', 'component2']); + + DragDropService._onDrop(componentElement1, containerElement1, containerElement1, undefined); + + expect(HstService.doPost).toHaveBeenCalledWith(container1.getHstRepresentation(), 'container1', 'update'); + expect(componentIds(container1)).toEqual(['component2', 'component1']); + + done(); + }); + }); + + it('can move the second component to the first position in the container', (done) => { + loadIframeFixture(() => { + const componentElement1 = component2.getBoxElement(); + const componentElement2 = component2.getBoxElement(); + const containerElement = container1.getBoxElement(); + + spyOn(HstService, 'doPost'); + expect(componentIds(container1)).toEqual(['component1', 'component2']); + + DragDropService._onDrop(componentElement2, containerElement, containerElement, componentElement1); + + expect(HstService.doPost).toHaveBeenCalledWith(container1.getHstRepresentation(), 'container1', 'update'); + expect(componentIds(container1)).toEqual(['component2', 'component1']); + + done(); + }); + }); + + it('can move a component to another container', (done) => { + loadIframeFixture(() => { + const componentElement1 = component1.getBoxElement(); + const containerElement1 = container1.getBoxElement(); + const containerElement2 = container2.getBoxElement(); + + spyOn(HstService, 'doPost'); + expect(componentIds(container1)).toEqual(['component1', 'component2']); + expect(componentIds(container2)).toEqual([]); + + DragDropService._onDrop(componentElement1, containerElement2, containerElement1, undefined); + + expect(HstService.doPost).toHaveBeenCalledWith(container1.getHstRepresentation(), 'container1', 'update'); + expect(HstService.doPost).toHaveBeenCalledWith(container2.getHstRepresentation(), 'container2', 'update'); + expect(componentIds(container1)).toEqual(['component2']); + expect(componentIds(container2)).toEqual(['component1']); + + done(); + }); + }); }); ===================================== frontend-ng/src/angularjs/channel/page/extJsHandler.service.js ===================================== --- a/frontend-ng/src/angularjs/channel/page/extJsHandler.service.js +++ b/frontend-ng/src/angularjs/channel/page/extJsHandler.service.js @@ -24,6 +24,6 @@ export class ExtJsHandlerService { } initialize() { - this.CmsService.subscribe('render-component', this.PageStructureService.renderComponent.bind(this.PageStructureService), this); + this.CmsService.subscribe('render-component', (componentId, propertiesMap) => this.PageStructureService.renderComponent(componentId, propertiesMap)); } } ===================================== frontend-ng/src/angularjs/channel/page/extJsHandler.service.spec.js ===================================== --- a/frontend-ng/src/angularjs/channel/page/extJsHandler.service.spec.js +++ b/frontend-ng/src/angularjs/channel/page/extJsHandler.service.spec.js @@ -27,7 +27,7 @@ describe('ExtJsHandlerService', () => { }); }); - it('handles the render event from ExtJS', () => { + xit('handles the render event from ExtJS', () => { spyOn(PageStructureService, 'renderComponent'); window.CMS_TO_APP.publish('render-component', '1234', { foo: 1, bar: 'a:b' }); View it on GitLab: https://code.onehippo.org/cms-community/hippo-addon-channel-manager/compare/8647d3b1874e1abd69cf4a97fba9ebd054b4ffd3...1a7af9b872f5f90e86635de838b89d9e01330075
_______________________________________________ Hippocms-svn mailing list Hippocms-svn@lists.onehippo.org https://lists.onehippo.org/mailman/listinfo/hippocms-svn