Arthur Bogaart pushed to branch feature/cmng-psp1-CHANNELMGR-637 at 
cms-community / hippo-addon-channel-manager


Commits:
461f668d by Arthur Bogaart at 2016-05-20T16:14:25+02:00
CHANNELMGR-637 Implement move menu-item

Select item that was moved if move is successful.

Added translation for MOVE and SAVE errors.

- - - - -


3 changed files:

- frontend-ng/src/angularjs/api/siteMenu.service.js
- frontend-ng/src/angularjs/channel/menu/editor.controller.js
- frontend-ng/src/i18n/hippo-cm.en.json


Changes:

=====================================
frontend-ng/src/angularjs/api/siteMenu.service.js
=====================================
--- a/frontend-ng/src/angularjs/api/siteMenu.service.js
+++ b/frontend-ng/src/angularjs/api/siteMenu.service.js
@@ -39,6 +39,10 @@ export class SiteMenuService {
     return this._loadMenu(menuId).then((menu) => 
this._findMenuItem(menu.items, menuItemId));
   }
 
+  moveMenuItem(menuId, menuItemId, parentId, position) {
+    return this.HstService.doPost({}, menuId, 'move', menuItemId, parentId, 
String(position));
+  }
+
   _loadMenu(menuId) {
     if (this.loadMenuPromise === null) {
       this.loadMenuPromise = this.HstService.doGet(menuId)


=====================================
frontend-ng/src/angularjs/channel/menu/editor.controller.js
=====================================
--- a/frontend-ng/src/angularjs/channel/menu/editor.controller.js
+++ b/frontend-ng/src/angularjs/channel/menu/editor.controller.js
@@ -60,7 +60,8 @@ export class MenuEditorCtrl {
         const destId = destNodesScope.$nodeScope ? 
destNodesScope.$nodeScope.$modelValue.id : this.menuUuid;
 
         if (source.nodesScope !== destNodesScope || source.index !== 
dest.index) {
-          SiteMenuService.moveMenuItem(sourceId, destId, dest.index);
+          SiteMenuService.moveMenuItem(this.menuUuid, sourceId, destId, 
dest.index)
+            .catch(() => this.onError({ key: 'ERROR_MENU_MOVE_FAILED' }));
         }
 
         if (this.selectedItem.id !== sourceId) {
@@ -85,6 +86,12 @@ export class MenuEditorCtrl {
     }
   }
 
-  editItem() {
+  editItem(itemId) {
+    if (this.selectedItem && this.selectedItem.id !== itemId) {
+      this.SiteMenuService.getMenuItem(this.menuUuid, itemId)
+        .then((item) => {
+          this.selectedItem = item;
+        });
+    }
   }
 }


=====================================
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
@@ -23,6 +23,8 @@
   "ERROR_DELETE_PAGE": "Failed to delete page.",
   "ERROR_ENTER_EDIT": "Failed to enter Edit mode.",
   "ERROR_MENU_LOAD_FAILED": "Failed to load menu.",
+  "ERROR_MENU_MOVE_FAILED": "Failed to move menu item.",
+  "ERROR_MENU_SAVE_FAILED": "Failed to save menu.",
   "ERROR_MOVE_COMPONENT_FAILED": "Failed to move component '{{component}}'",
   "ERROR_PAGE_ADD_FAILED": "Failed to create a new page",
   "ERROR_PAGE_COPY_FAILED": "Failed to copy page.",



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

Reply via email to