From 27073fe9d7d09db46828f0319c04f538f95b278f Mon Sep 17 00:00:00 2001 From: Dani Herrero Date: Tue, 23 May 2017 14:36:54 +0200 Subject: [PATCH] =?UTF-8?q?leftMenu=20:=20estado=20activo,=20Routes.json:?= =?UTF-8?q?=20nueva=20jerarqu=C3=ADa=20de=20rutas?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/client/routes.json | 34 ++++++++++++------- client/client/src/addresses/index.html | 4 +-- client/client/src/notes/index.js | 2 +- .../salix/src/components/left-menu/actions.js | 28 ++++++++++++++- .../src/components/left-menu/menu-item.html | 2 +- .../salix/src/components/left-menu/style.css | 3 ++ 6 files changed, 56 insertions(+), 17 deletions(-) diff --git a/client/client/routes.json b/client/client/routes.json index b1f7c7ffd..bac7d2ffe 100644 --- a/client/client/routes.json +++ b/client/client/routes.json @@ -37,15 +37,28 @@ }, "description": "Datos facturaciĆ³n", "icon": "assignment" - }, { + },{ "url": "/addresses", "state": "clientCard.addresses", + "component": "ui-view", + "abstract": true + }, { + "url": "/list", + "state": "clientCard.addresses.list", "component": "vn-client-addresses", "params": { "client": "card.client" }, "description": "Consignatarios", "icon": "local_shipping" + }, { + "url": "/create", + "state": "clientCard.addresses.create", + "component": "vn-address-create" + }, { + "url": "/:addressId/edit", + "state": "clientCard.addresses.edit", + "component": "vn-address-edit" }, { "url": "/web-access", "state": "clientCard.webAccess", @@ -55,9 +68,14 @@ }, "description": "Acceso web", "icon": "language" - }, { + },{ "url": "/notes", "state": "clientCard.notes", + "component": "ui-view", + "abstract": true + }, { + "url": "/list", + "state": "clientCard.notes.list", "component": "vn-client-notes", "params": { "client": "card.client" @@ -65,21 +83,13 @@ "description": "Notas", "icon": "insert_drive_file" }, { - "url": "/new-note", - "state": "clientCard.newNote", + "url": "/create", + "state": "clientCard.notes.create", "component": "vn-new-note" },{ "url": "/create", "state": "create", "component": "vn-client-create" - }, { - "url": "/address/create", - "state": "clientCard.addressCreate", - "component": "vn-address-create" - }, { - "url": "/address/:addressId", - "state": "clientCard.addressEdit", - "component": "vn-address-edit" } ] } diff --git a/client/client/src/addresses/index.html b/client/client/src/addresses/index.html index 197c7ace5..1b11b1931 100644 --- a/client/client/src/addresses/index.html +++ b/client/client/src/addresses/index.html @@ -15,7 +15,7 @@
{{i.city}}, {{i.province}}
{{i.phone}}, {{i.mobile}}
- + @@ -26,7 +26,7 @@ diff --git a/client/client/src/notes/index.js b/client/client/src/notes/index.js index 7f3fffa90..d7fc78bf1 100644 --- a/client/client/src/notes/index.js +++ b/client/client/src/notes/index.js @@ -26,7 +26,7 @@ export const COMPONENT = { }; this.newObservation = () => { - $state.go("clientCard.newNote", {id: this.client.id}); + $state.go("clientCard.notes.create", {id: this.client.id}); }; } }; diff --git a/client/salix/src/components/left-menu/actions.js b/client/salix/src/components/left-menu/actions.js index 54d72cb7c..096c09049 100644 --- a/client/salix/src/components/left-menu/actions.js +++ b/client/salix/src/components/left-menu/actions.js @@ -1,8 +1,34 @@ import ngModule from '../../module'; +export default class MenuActions { + constructor($state, $transitions) { + this.$state = $state; + this.deregisterCallback = $transitions.onSuccess({}, + transition => this.switchItem()); + } + switchItem() { + if (!this.items || !this.items.length) return; + + let stateName = this.$state.current.name.replace('create', 'list').replace('edit', 'list'); + + for (let i = 0; i < this.items.length; i++) { + this.items[i].active = (this.items[i].href === stateName); + } + } + $onInit() { + this.switchItem(); + } + $onDestroy() { + this.deregisterCallback(); + } + +} +MenuActions.$inject = ['$state', '$transitions']; + ngModule.component('vnActions', { template: require('./actions.html'), bindings: { items: '<' - } + }, + controller: MenuActions }); diff --git a/client/salix/src/components/left-menu/menu-item.html b/client/salix/src/components/left-menu/menu-item.html index be1519e93..b3315b2fa 100644 --- a/client/salix/src/components/left-menu/menu-item.html +++ b/client/salix/src/components/left-menu/menu-item.html @@ -1,4 +1,4 @@ -
  • +
  • keyboard_arrow_right {{$ctrl.item.icon}} diff --git a/client/salix/src/components/left-menu/style.css b/client/salix/src/components/left-menu/style.css index 31f3d8578..8d44e4a70 100644 --- a/client/salix/src/components/left-menu/style.css +++ b/client/salix/src/components/left-menu/style.css @@ -2,3 +2,6 @@ vn-menu-item a:hover { color: white !important; background-color: #424242; } +vn-menu-item li.active{ + background-color: #E6E6E6; +}