Joeri de Gooijer pushed to branch feature/cmng-psp1 at cms-community / 
hippo-addon-channel-manager


Commits:
685d1dd7 by Canh Ngo at 2016-03-08T10:38:44+01:00
CHANNELMGR-469: added 'delete' button to send 'delete-component' event to 
AngularApp

- - - - -
30a1751a by Canh Ngo at 2016-03-08T15:26:40+01:00
CHANNELMGR-469: removed component at back-end, meta-data and 
pageStructureService

- - - - -
41866afb by Canh Ngo at 2016-03-09T10:24:44+01:00
CHANNELMGR-469: added test cases for PageStructureService#removeComponent()

- - - - -
f94d29de by Canh Ngo at 2016-03-09T12:18:17+01:00
CHANNELMGR-469: created test-case for HippoIframeController#deleteComponent()

- - - - -
0602905b by Joeri de Gooijer at 2016-03-10T14:10:08+01:00
CHANNELMGR-469 merge feature/cmng-psp1 into feature/cmng-psp1-CHANNELMGR-469

- - - - -
0ec5185f by Joeri de Gooijer at 2016-03-14T21:53:09+01:00
CHANNELMGR-469 merge feature/cmng-psp1

- - - - -
ce9e1679 by Joeri de Gooijer at 2016-03-15T10:33:10+01:00
CHANNELMGR-469 update to latest hippo-build

- - - - -
db73341a by Joeri de Gooijer at 2016-03-15T10:33:19+01:00
CHANNELMGR-469 Merge branch 'feature/cmng-psp1' into 
feature/cmng-psp1-CHANNELMGR-469

- - - - -
1d8d7e28 by Joeri de Gooijer at 2016-03-15T12:28:47+01:00
CHANNELMGR-469 write unit tests for deleting component for hippo iframe 
controller

- - - - -
15dc04af by Joeri de Gooijer at 2016-03-15T12:54:37+01:00
CHANNELMGR-469 clean up karma config

- - - - -
072bbd64 by Joeri de Gooijer at 2016-03-15T13:18:52+01:00
CHANNELMGR-469 Merge branch 'feature/cmng-psp1' into 
feature/cmng-psp1-CHANNELMGR-469

- - - - -
a2fa6417 by Joeri de Gooijer at 2016-03-15T13:19:02+01:00
CHANNELMGR-469 Merge branch 'feature/cmng-psp1-CHANNELMGR-469' into 
feature/cmng-psp1

- - - - -


14 changed files:

- frontend-ng/karma.conf.js
- frontend-ng/src/angularjs/channel/hippoIframe/hippoIframe.controller.js
- + frontend-ng/src/angularjs/channel/hippoIframe/hippoIframe.controller.spec.js
- frontend-ng/src/angularjs/channel/page/element/componentElement.js
- frontend-ng/src/angularjs/channel/page/element/containerElement.js
- frontend-ng/src/angularjs/channel/page/pageStructure.service.js
- frontend-ng/src/angularjs/channel/page/pageStructure.service.spec.js
- frontend-ng/src/i18n/hippo-cm.en.json
- frontend-ng/src/i18n/hippo-cm.nl.json
- 
frontend/src/main/resources/org/onehippo/cms7/channelmanager/channeleditor/ChannelEditor.js
- 
frontend/src/main/resources/org/onehippo/cms7/channelmanager/channeleditor/ChannelEditor.properties
- 
frontend/src/main/resources/org/onehippo/cms7/channelmanager/channeleditor/ChannelEditor_nl.properties
- 
frontend/src/main/resources/org/onehippo/cms7/channelmanager/channeleditor/ComponentPropertiesPanel.js
- 
frontend/src/main/resources/org/onehippo/cms7/channelmanager/channeleditor/ComponentPropertiesWindow.js


Changes:

=====================================
frontend-ng/karma.conf.js
=====================================
--- a/frontend-ng/karma.conf.js
+++ b/frontend-ng/karma.conf.js
@@ -31,9 +31,7 @@ module.exports = function karmaConfig(config) {
     
`${cfg.bowerDir}/angular-translate-loader-static-files/angular-translate-loader-static-files.js`,
     `${cfg.bowerDir}/angular-mocks/angular-mocks.js`,
     `${cfg.bowerDir}/jquery/dist/jquery.js`,
-    `${cfg.npmDir}/babel-core/external-helpers.js`,
-    `${cfg.npmDir}/systemjs/dist/system-polyfills.js`,
-    `${cfg.npmDir}/systemjs/dist/system-register-only.js`,
+    `${cfg.bowerDir}/velocity/velocity.js`,
   ];
 
   options.files = [


=====================================
frontend-ng/src/angularjs/channel/hippoIframe/hippoIframe.controller.js
=====================================
--- a/frontend-ng/src/angularjs/channel/hippoIframe/hippoIframe.controller.js
+++ b/frontend-ng/src/angularjs/channel/hippoIframe/hippoIframe.controller.js
@@ -15,13 +15,29 @@
  */
 
 export class HippoIframeCtrl {
-  constructor($rootScope, $scope, $element, linkProcessorService, 
hstCommentsProcessorService, ChannelService,
-              PageStructureService, OverlaySyncService, ScalingService, 
DragDropService) {
+  constructor(
+    $element,
+    $mdDialog,
+    $rootScope,
+    $scope,
+    $translate,
+    ChannelService,
+    CmsService,
+    DragDropService,
+    hstCommentsProcessorService,
+    linkProcessorService,
+    OverlaySyncService,
+    PageStructureService,
+    ScalingService,
+  ) {
     'ngInject';
 
     this.$rootScope = $rootScope;
+    this.$translate = $translate;
+    this.$mdDialog = $mdDialog;
     this.linkProcessorService = linkProcessorService;
     this.hstCommentsProcessorService = hstCommentsProcessorService;
+    this.CmsService = CmsService;
     this.ChannelService = ChannelService;
     this.PageStructureService = PageStructureService;
     this.OverlaySyncService = OverlaySyncService;
@@ -34,6 +50,10 @@ export class HippoIframeCtrl {
     ScalingService.init($element);
     DragDropService.init(this.iframeJQueryElement, 
$element.find('.channel-iframe-base'));
 
+    CmsService.subscribe('delete-component', (componentId) => {
+      this.deleteComponent(componentId);
+    });
+
     $scope.$watch('iframe.editMode', () => this._enableDragDrop());
   }
 
@@ -44,6 +64,32 @@ export class HippoIframeCtrl {
     });
   }
 
+  showComponentProperties(structureElement) {
+    this.selectedComponent = structureElement;
+    this.PageStructureService.showComponentProperties(this.selectedComponent);
+  }
+
+  deleteComponent(componentId) {
+    this._confirmDelete().then(() => {
+      this.PageStructureService.removeComponent(componentId);
+    }, () => {
+      
this.PageStructureService.showComponentProperties(this.selectedComponent);
+    });
+  }
+
+  _confirmDelete() {
+    const confirm = this.$mdDialog
+      .confirm()
+      .title(this.$translate.instant('CONFIRM_DELETE_COMPONENT_TITLE'))
+      .textContent(this.$translate.instant('CONFIRM_DELETE_COMPONENT_MESSAGE', 
{
+        component: this.selectedComponent.getLabel(),
+      }))
+      .ok(this.$translate.instant('BUTTON_YES'))
+      .cancel(this.$translate.instant('BUTTON_NO'));
+
+    return this.$mdDialog.show(confirm);
+  }
+
   _enableDragDrop() {
     if (this.editMode) {
       this.DragDropService.enable(this.PageStructureService.containers);
@@ -61,23 +107,28 @@ export class HippoIframeCtrl {
   }
 
   _parseHstComments() {
-    const iframeDom = this.iframeJQueryElement.contents()[0];
+    const iframeDom = this._getIframeDOM(this);
 
     this.PageStructureService.clearParsedElements();
-    this.hstCommentsProcessorService.run(iframeDom,
-      
this.PageStructureService.registerParsedElement.bind(this.PageStructureService));
+    this.hstCommentsProcessorService.run(
+      iframeDom,
+      
this.PageStructureService.registerParsedElement.bind(this.PageStructureService)
+    );
     this.PageStructureService.printParsedElements();
   }
 
+  _getIframeDOM() {
+    return this.iframeJQueryElement.contents()[0];
+  }
+
   _parseLinks() {
-    const iframeDom = this.iframeJQueryElement.contents()[0];
-    const schemeAndHost = 
`${iframeDom.location.protocol}//${iframeDom.location.host}`;
-    const previewUrl = 
`${schemeAndHost}${this.ChannelService.getPreviewPath()}`;
-    this.linkProcessorService.run(iframeDom, previewUrl);
+    const iframeDom = this._getIframeDOM();
+    const internalLinkPrefix = 
`${iframeDom.location.protocol}//${iframeDom.location.host}${this.ChannelService.getUrl()}`;
+
+    this.linkProcessorService.run(iframeDom, internalLinkPrefix);
   }
 
   getContainers() {
     return this.editMode ? this.PageStructureService.containers : [];
   }
-
 }


=====================================
frontend-ng/src/angularjs/channel/hippoIframe/hippoIframe.controller.spec.js
=====================================
--- /dev/null
+++ 
b/frontend-ng/src/angularjs/channel/hippoIframe/hippoIframe.controller.spec.js
@@ -0,0 +1,103 @@
+/*
+ *
+ *  * Copyright 2016 Hippo B.V. (http://www.onehippo.com)
+ *  *
+ *  * Licensed under the Apache License, Version 2.0 (the "License");
+ *  * you may not use this file except in compliance with the License.
+ *  * You may obtain a copy of the License at
+ *  *
+ *  *  http://www.apache.org/licenses/LICENSE-2.0
+ *  *
+ *  * Unless required by applicable law or agreed to in writing, software
+ *  * distributed under the License is distributed on an "AS IS" BASIS,
+ *  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  * See the License for the specific language governing permissions and
+ *  * limitations under the License.
+ *
+ */
+
+describe('hippoIframeCtrl', function () {
+  'use strict';
+
+  var PageStructureService;
+  var $mdDialog;
+  var hippoIframeCtrl;
+  var scope;
+  var $q;
+  var ScalingService;
+  var DragDropService;
+  var OverlaySyncService;
+
+  beforeEach(function () {
+    var el;
+    var $compile;
+    module('hippo-cm');
+
+    inject(function (
+        $controller,
+        $rootScope,
+        _$compile_,
+        _$mdDialog_,
+        _$q_,
+        _DragDropService_,
+        _OverlaySyncService_,
+        _PageStructureService_,
+        _ScalingService_
+      ) {
+      $compile = _$compile_;
+      $mdDialog = _$mdDialog_;
+      $q = _$q_;
+      DragDropService = _DragDropService_;
+      OverlaySyncService = _OverlaySyncService_;
+      PageStructureService = _PageStructureService_;
+      ScalingService = _ScalingService_;
+      scope = $rootScope.$new();
+    });
+
+    spyOn(ScalingService, 'init');
+    spyOn(DragDropService, 'init');
+    spyOn(OverlaySyncService, 'init');
+
+    scope.testPath = '/';
+    scope.testEditMode = false;
+
+    el = angular.element('<hippo-iframe path="testPath" 
edit-mode="testEditMode"></hippo-iframe>');
+    $compile(el)(scope);
+    scope.$digest();
+
+    hippoIframeCtrl = el.controller('hippo-iframe');
+    hippoIframeCtrl.selectedComponent = {
+      getLabel: function () {
+        return 'testLabel';
+      },
+    };
+  });
+
+  it('shows the confirmation dialog and deletes selected component on 
confirmation', function () {
+    spyOn(PageStructureService, 'removeComponent');
+    spyOn($mdDialog, 'show').and.returnValue($q.resolve());
+    spyOn($mdDialog, 'confirm').and.callThrough();
+
+    hippoIframeCtrl.deleteComponent('1234');
+
+    scope.$digest();
+
+    expect($mdDialog.confirm).toHaveBeenCalled();
+    expect($mdDialog.show).toHaveBeenCalled();
+    expect(PageStructureService.removeComponent).toHaveBeenCalledWith('1234');
+  });
+
+  it('shows component properties dialog after rejecting the delete operation', 
function () {
+    spyOn(PageStructureService, 'showComponentProperties');
+    spyOn($mdDialog, 'show').and.returnValue($q.reject());
+    spyOn($mdDialog, 'confirm').and.callThrough();
+
+    hippoIframeCtrl.deleteComponent('1234');
+
+    scope.$digest();
+
+    expect($mdDialog.confirm).toHaveBeenCalled();
+    expect($mdDialog.show).toHaveBeenCalled();
+    
expect(PageStructureService.showComponentProperties).toHaveBeenCalledWith(hippoIframeCtrl.selectedComponent);
+  });
+});


=====================================
frontend-ng/src/angularjs/channel/page/element/componentElement.js
=====================================
--- a/frontend-ng/src/angularjs/channel/page/element/componentElement.js
+++ b/frontend-ng/src/angularjs/channel/page/element/componentElement.js
@@ -34,21 +34,25 @@ import { PageStructureElement } from 
'./pageStructureElement';
  */
 function extractDomRoot(commentDomElement, metaData, commentProcessor) {
   let nextSibling = commentDomElement.nextSibling;
-  let domRoot;
+  let componentDomRoot;
 
   while (nextSibling !== null) {
-    if (nextSibling.nodeType === 1 && !domRoot) {
-      domRoot = nextSibling; // use the first element of type 1 as component 
DOM root.
+    if (nextSibling.nodeType === 1 && !componentDomRoot) {
+      componentDomRoot = nextSibling; // use the first element of type 1 as 
component DOM root.
     }
     if (commentProcessor.isEndMarker(nextSibling, metaData.uuid)) {
-      if (!domRoot) {
+      const commentEndMarker = nextSibling;
+      if (!componentDomRoot) {
         // this component currently renders no DOM root element.
         // We put a mark on the component and register the comment DOM element 
instead.
         metaData.hasNoDom = true;
-        domRoot = commentDomElement;
+        componentDomRoot = commentDomElement;
       }
 
-      return domRoot;
+      return {
+        componentDomRoot,
+        commentEndMarker,
+      };
     }
     nextSibling = nextSibling.nextSibling;
   }
@@ -60,9 +64,12 @@ function extractDomRoot(commentDomElement, metaData, 
commentProcessor) {
 export class ComponentElement extends PageStructureElement {
   constructor(commentDomElement, metaData, container, commentProcessor) {
     let jQueryElement;
+    let commentEndMarker;
 
     if (PageStructureElement.isTransparentXType(container.metaData)) {
-      jQueryElement = $(extractDomRoot(commentDomElement, metaData, 
commentProcessor));
+      const domRoot = extractDomRoot(commentDomElement, metaData, 
commentProcessor);
+      jQueryElement = $(domRoot.componentDomRoot);
+      commentEndMarker = $(domRoot.commentEndMarker);
     } else {
       jQueryElement = $(commentDomElement).parent();
     }
@@ -70,6 +77,34 @@ export class ComponentElement extends PageStructureElement {
     super('component', jQueryElement, metaData);
 
     this.container = container;
+    this.commentStartMarker = $(commentDomElement);
+    this.commentEndMarker = commentEndMarker;
+  }
+
+  /**
+   * Remove both the component's rendering element and its HST meta-data 
comment element
+   */
+  removeFromDOM() {
+    this._removeJQueryElement('iframe');
+    this._removeCommentElements();
+  }
+
+  _removeJQueryElement(type) {
+    const jQueryElement = this.getJQueryElement(type);
+    if (jQueryElement) {
+      jQueryElement.remove();
+    }
+  }
+
+  _removeCommentElements() {
+    this._removeElement(this.commentStartMarker);
+    this._removeElement(this.commentEndMarker);
+  }
+
+  _removeElement(e) {
+    if (e) {
+      e.remove();
+    }
   }
 
   getContainer() {


=====================================
frontend-ng/src/angularjs/channel/page/element/containerElement.js
=====================================
--- a/frontend-ng/src/angularjs/channel/page/element/containerElement.js
+++ b/frontend-ng/src/angularjs/channel/page/element/containerElement.js
@@ -56,6 +56,7 @@ export class ContainerElement extends PageStructureElement {
     } else {
       this.items.push(component);
     }
+
     component.setContainer(this);
   }
 
@@ -75,6 +76,21 @@ export class ContainerElement extends PageStructureElement {
     return this.items.find((item) => item.getId() === componentId);
   }
 
+  /**
+   * Remove the component identified by given Id from its container
+   * @param componentId
+   * @returns {*} the removed component
+   */
+  removeComponent(componentId) {
+    const component = this.getComponent(componentId);
+    if (component) {
+      this.items.splice(this.items.indexOf(component), 1);
+      return component;
+    }
+
+    return null;
+  }
+
   getComponentByIframeElement(iframeElement) {
     return this.items.find((item) => 
item.getJQueryElement('iframe').is(iframeElement));
   }
@@ -88,5 +104,4 @@ export class ContainerElement extends PageStructureElement {
       },
     };
   }
-
 }


=====================================
frontend-ng/src/angularjs/channel/page/pageStructure.service.js
=====================================
--- a/frontend-ng/src/angularjs/channel/page/pageStructure.service.js
+++ b/frontend-ng/src/angularjs/channel/page/pageStructure.service.js
@@ -19,13 +19,15 @@ import { ComponentElement } from 
'./element/componentElement';
 
 export class PageStructureService {
 
-  constructor($log, $q, HstConstants, hstCommentsProcessorService, 
ChannelService, CmsService, PageMetaDataService) {
+  constructor($log, $q, HstConstants, hstCommentsProcessorService, 
ChannelService, CmsService, PageMetaDataService, HstService) {
     'ngInject';
 
     // Injected
+    this.$q = $q;
     this.$log = $log;
     this.$q = $q;
     this.HST = HstConstants;
+    this.HstService = HstService;
     this.ChannelService = ChannelService;
     this.CmsService = CmsService;
     this.hstCommentsProcessorService = hstCommentsProcessorService;
@@ -58,6 +60,7 @@ export class PageStructureService {
         } catch (exception) {
           this.$log.debug(exception, metaData);
         }
+
         break;
       }
       case this.HST.TYPE_PAGE: {
@@ -71,6 +74,7 @@ export class PageStructureService {
             this.ChannelService.switchToChannel(channelId);
           }
         }
+
         break;
       }
       default:
@@ -87,6 +91,34 @@ export class PageStructureService {
     return component;
   }
 
+  /**
+   * Remove the component identified by given Id
+   * @param componentId
+   * @returns {*} a promise with removed successfully component
+   */
+  removeComponent(componentId) {
+    let component = null;
+    const foundContainer = this.containers.find((container) => {
+      component = container.removeComponent(componentId);
+      return component;
+    });
+
+    if (!foundContainer) {
+      return this.$q.reject();
+    }
+
+    // request back-end to remove component
+    return this._removeHstComponent(foundContainer.getId(), componentId)
+      .then(() => {
+        component.removeFromDOM();
+        return component;
+      });
+  }
+
+  _removeHstComponent(containerId, componentId) {
+    return this.HstService.doGet(containerId, 'delete', componentId);
+  }
+
   getContainerByIframeElement(containerIFrameElement) {
     return this.containers.find((container) => 
container.getJQueryElement('iframe').is(containerIFrameElement));
   }


=====================================
frontend-ng/src/angularjs/channel/page/pageStructure.service.spec.js
=====================================
--- a/frontend-ng/src/angularjs/channel/page/pageStructure.service.spec.js
+++ b/frontend-ng/src/angularjs/channel/page/pageStructure.service.spec.js
@@ -20,20 +20,26 @@ describe('PageStructureService', function () {
   var PageStructureService;
   var PageMetaDataService;
   var ChannelService;
+  var HstService;
   var $document;
+  var $q;
   var $log;
   var $window;
+  var $rootScope;
 
   beforeEach(function () {
     module('hippo-cm.channel.page');
 
-    inject(function (_$log_, _$document_, _$window_, _PageStructureService_, 
_PageMetaDataService_, _ChannelService_) {
+    inject(function (_$q_, _$rootScope_, _$log_, _$document_, _$window_, 
_PageStructureService_, _PageMetaDataService_, _ChannelService_, _HstService_) {
+      $q = _$q_;
+      $rootScope = _$rootScope_;
       $log = _$log_;
       $document = _$document_;
       $window = _$window_;
       PageStructureService = _PageStructureService_;
       PageMetaDataService = _PageMetaDataService_;
       ChannelService = _ChannelService_;
+      HstService = _HstService_;
     });
   });
 
@@ -285,6 +291,78 @@ describe('PageStructureService', function () {
     expect(PageStructureService.getComponent('no-such-component')).toBeNull();
   });
 
+  it('removes a valid component and calls HST successfully', function () {
+    var container = $j('#container1', $document);
+    var component = $j('#componentA', $document);
+
+    PageStructureService.registerParsedElement(container[0].previousSibling, {
+      'HST-Type': 'CONTAINER_COMPONENT',
+      uuid: 'container-123',
+    });
+    PageStructureService.registerParsedElement(component[0].childNodes[0], {
+      'HST-Type': 'CONTAINER_ITEM_COMPONENT',
+      'HST-Label': 'Test Component',
+      uuid: 'component-1234',
+    });
+    spyOn(HstService, 'doGet').and.returnValue($q.when([]));
+
+    PageStructureService.removeComponent('component-1234').then(function 
(removedComponent) {
+      expect(removedComponent.getId()).toEqual('component-1234');
+    });
+
+    $rootScope.$digest();
+
+    expect(HstService.doGet).toHaveBeenCalledWith('container-123', 'delete', 
'component-1234');
+  });
+
+  it('removes a valid component but fails to call HST', function () {
+    var handler = jasmine.createSpy('success');
+    var container = $j('#container1', $document);
+    var component = $j('#componentA', $document);
+
+    PageStructureService.registerParsedElement(container[0].previousSibling, {
+      'HST-Type': 'CONTAINER_COMPONENT',
+      uuid: 'container-123',
+    });
+    PageStructureService.registerParsedElement(component[0].childNodes[0], {
+      'HST-Type': 'CONTAINER_ITEM_COMPONENT',
+      'HST-Label': 'Test Component',
+      uuid: 'component-1234',
+    });
+
+    // mock the call to HST to be failed
+    spyOn(HstService, 'doGet').and.returnValue($q.reject());
+
+    PageStructureService.removeComponent('component-1234').then(handler);
+    $rootScope.$digest();
+
+    expect(HstService.doGet).toHaveBeenCalledWith('container-123', 'delete', 
'component-1234');
+    expect(handler).not.toHaveBeenCalled();
+  });
+
+  it('removes an invalid component', function () {
+    var handler = jasmine.createSpy('success');
+    var container = $j('#container1', $document);
+    var component = $j('#componentA', $document);
+
+    PageStructureService.registerParsedElement(container[0].previousSibling, {
+      'HST-Type': 'CONTAINER_COMPONENT',
+      uuid: 'container-123',
+    });
+    PageStructureService.registerParsedElement(component[0].childNodes[0], {
+      'HST-Type': 'CONTAINER_ITEM_COMPONENT',
+      'HST-Label': 'Test Component',
+      uuid: 'component-1234',
+    });
+    spyOn(HstService, 'doGet').and.returnValue($q.when([]));
+
+    PageStructureService.removeComponent('component-123').then(handler);
+    $rootScope.$digest();
+
+    expect(handler).not.toHaveBeenCalled();
+    expect(HstService.doGet).not.toHaveBeenCalled();
+  });
+
   it('returns a container by iframe element', function () {
     var container1 = $j('#container1', $document);
     var container2 = $j('#container2', $document);


=====================================
frontend-ng/src/i18n/hippo-cm.en.json
=====================================
--- a/frontend-ng/src/i18n/hippo-cm.en.json
+++ b/frontend-ng/src/i18n/hippo-cm.en.json
@@ -3,5 +3,9 @@
   "TOOLBAR_SWITCH_VIEWER_MODE": "Viewer mode",
   "TOOLBAR_SWITCH_VIEWER_MODE_EDIT": "Edit",
   "TOOLBAR_SWITCH_VIEWER_MODE_VIEW": "View",
-  "CONFIRM_OPEN_EXTERNAL_LINK": "This external link will be opened in a new 
tab.\nDo you want to continue?"
+  "CONFIRM_OPEN_EXTERNAL_LINK": "This external link will be opened in a new 
tab.\nDo you want to continue?",
+  "CONFIRM_DELETE_COMPONENT_TITLE": "Confirm remove",
+  "CONFIRM_DELETE_COMPONENT_MESSAGE": "Are you sure you want to remove the 
component '{{component}}' from this template?",
+  "BUTTON_YES": "Yes",
+  "BUTTON_NO": "No"
 }


=====================================
frontend-ng/src/i18n/hippo-cm.nl.json
=====================================
--- a/frontend-ng/src/i18n/hippo-cm.nl.json
+++ b/frontend-ng/src/i18n/hippo-cm.nl.json
@@ -3,5 +3,9 @@
   "TOOLBAR_SWITCH_VIEWER_MODE": "Viewer modus",
   "TOOLBAR_SWITCH_VIEWER_MODE_EDIT": "Bewerk",
   "TOOLBAR_SWITCH_VIEWER_MODE_VIEW": "Bekijk",
-  "CONFIRM_OPEN_EXTERNAL_LINK": "Deze externe link zal in een nieuwe tab 
worden geopened.\nWilt u doorgaan?"
+  "CONFIRM_OPEN_EXTERNAL_LINK": "Deze externe link zal in een nieuwe tab 
worden geopened.\nWilt u doorgaan?",
+  "CONFIRM_DELETE_COMPONENT_TITLE": "Bevestig het verwijderen",
+  "CONFIRM_DELETE_COMPONENT_MESSAGE": "Weet u zeker dat u {0} wilt 
verwijderen?",
+  "BUTTON_YES": "Ja",
+  "BUTTON_NO": "Nee"
 }


=====================================
frontend/src/main/resources/org/onehippo/cms7/channelmanager/channeleditor/ChannelEditor.js
=====================================
--- 
a/frontend/src/main/resources/org/onehippo/cms7/channelmanager/channeleditor/ChannelEditor.js
+++ 
b/frontend/src/main/resources/org/onehippo/cms7/channelmanager/channeleditor/ChannelEditor.js
@@ -103,6 +103,7 @@
             console.log('TODO: re-render saved component');
             // old code: this.fireEvent('channelChanged');
           },
+          deleteComponent: this._deleteComponent,
           deleteVariant: function() {
             console.log('TODO: delete variant');
             // old code: this.fireEvent('channelChanged');
@@ -130,6 +131,10 @@
       });
     },
 
+    _deleteComponent: function (componentId) {
+      this.hostToIFrame.publish('delete-component', componentId);
+    },
+
     _showComponentProperties: function(selected) {
       this.componentPropertiesWindow.showComponent(
         selected.component,


=====================================
frontend/src/main/resources/org/onehippo/cms7/channelmanager/channeleditor/ChannelEditor.properties
=====================================
--- 
a/frontend/src/main/resources/org/onehippo/cms7/channelmanager/channeleditor/ChannelEditor.properties
+++ 
b/frontend/src/main/resources/org/onehippo/cms7/channelmanager/channeleditor/ChannelEditor.properties
@@ -21,4 +21,5 @@ properties-form-no-properties=No editable properties found 
for this component
 
 properties-window-button-close=Close
 properties-window-button-save=Save
+properties-window-button-delete=Delete
 properties-window-default-title=Properties


=====================================
frontend/src/main/resources/org/onehippo/cms7/channelmanager/channeleditor/ChannelEditor_nl.properties
=====================================
--- 
a/frontend/src/main/resources/org/onehippo/cms7/channelmanager/channeleditor/ChannelEditor_nl.properties
+++ 
b/frontend/src/main/resources/org/onehippo/cms7/channelmanager/channeleditor/ChannelEditor_nl.properties
@@ -21,4 +21,5 @@ properties-form-no-properties=Geen wijzigbare eigenschappen 
gevonden voor dit co
 
 properties-window-button-close=Sluit
 properties-window-button-save=Sla op
+properties-window-button-delete=Verwijder
 properties-window-default-title=Eigenschappen


=====================================
frontend/src/main/resources/org/onehippo/cms7/channelmanager/channeleditor/ComponentPropertiesPanel.js
=====================================
--- 
a/frontend/src/main/resources/org/onehippo/cms7/channelmanager/channeleditor/ComponentPropertiesPanel.js
+++ 
b/frontend/src/main/resources/org/onehippo/cms7/channelmanager/channeleditor/ComponentPropertiesPanel.js
@@ -522,6 +522,14 @@
         });
         return $.when.apply($, afterSavePromises);
       }.bind(this));
+    },
+
+    /**
+     * Fire the 'deleteComponent' event to delete current component
+     */
+    deleteComponent: function () {
+      this.fireEvent('deleteComponent', this.componentId);
+      this.fireEvent('close', this.componentId);
     }
   });
 


=====================================
frontend/src/main/resources/org/onehippo/cms7/channelmanager/channeleditor/ComponentPropertiesWindow.js
=====================================
--- 
a/frontend/src/main/resources/org/onehippo/cms7/channelmanager/channeleditor/ComponentPropertiesWindow.js
+++ 
b/frontend/src/main/resources/org/onehippo/cms7/channelmanager/channeleditor/ComponentPropertiesWindow.js
@@ -27,7 +27,7 @@
         windowWidth = config.width;
 
       this.componentPropertiesPanel = new 
Hippo.ChannelManager.ChannelEditor.ComponentPropertiesPanel({
-        bubbleEvents: ['save', 'deleteVariant', 'propertiesChanged'],
+        bubbleEvents: ['save', 'deleteComponent', 'deleteVariant', 
'propertiesChanged'],
         resources: config.resources,
         locale: config.locale,
         composerRestMountUrl: config.composerRestMountUrl,
@@ -64,8 +64,15 @@
         }
       });
 
-      buttons.push(this.saveButton);
-      buttons.push({
+      this.deleteButton = new Ext.Button({
+        xtype: 'button',
+        cls: 'btn btn-default qa-delete-button',
+        text: 
Hippo.ChannelManager.ChannelEditor.Resources['properties-window-button-delete'],
+        scope: this.componentPropertiesPanel,
+        handler: this.componentPropertiesPanel.deleteComponent
+      });
+
+      this.closeButon = new Ext.Button({
         xtype: 'button',
         cls: 'btn btn-default qa-close-button',
         text: 
Hippo.ChannelManager.ChannelEditor.Resources['properties-window-button-close'],
@@ -79,7 +86,13 @@
         layout: 'fit',
         width: windowWidth,
         items: this.componentPropertiesPanel,
-        buttons: buttons
+        buttonAlign: 'left',
+        buttons: [
+          this.deleteButton,
+          {xtype: 'tbfill'},
+          this.saveButton,
+          this.closeButon
+        ]
       }));
     },
 



View it on GitLab: 
https://code.onehippo.org/cms-community/hippo-addon-channel-manager/compare/3d224dc87b04f8b94f47b3781a72f01e9880ad8f...a2fa6417d77723f4c5ccb50d176da694c7aa4a9a
_______________________________________________
Hippocms-svn mailing list
Hippocms-svn@lists.onehippo.org
https://lists.onehippo.org/mailman/listinfo/hippocms-svn

Reply via email to