From bda48488fc7bebb0de19aca6ee06f25ca17fde56 Mon Sep 17 00:00:00 2001 From: Dani Herrero Date: Tue, 23 May 2017 09:20:21 +0200 Subject: [PATCH] =?UTF-8?q?Client=20card,=20uso=20de=20mgCrud.=20Routes:?= =?UTF-8?q?=20a=C3=B1adido=20estado=20abstract?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/client/routes.json | 1 + client/client/src/card/index.html | 1 + client/client/src/card/index.js | 30 +++++++++++++++--------------- client/salix/src/configroutes.js | 3 +++ package.json | 2 +- 5 files changed, 21 insertions(+), 16 deletions(-) diff --git a/client/client/routes.json b/client/client/routes.json index 0b1273ea1..bf686e6e1 100644 --- a/client/client/routes.json +++ b/client/client/routes.json @@ -8,6 +8,7 @@ }, { "url": "/clients/:id", "state": "clientCard", + "abstract": true, "component": "vn-client-card" }, { "url": "/basic-data", diff --git a/client/client/src/card/index.html b/client/client/src/card/index.html index 0adc9a513..0b8976616 100644 --- a/client/client/src/card/index.html +++ b/client/client/src/card/index.html @@ -1,4 +1,5 @@ + diff --git a/client/client/src/card/index.js b/client/client/src/card/index.js index a3c21dca4..270d95c21 100644 --- a/client/client/src/card/index.js +++ b/client/client/src/card/index.js @@ -5,22 +5,22 @@ export const NAME = 'vnClientCard'; export const COMPONENT = { template: require('./index.html'), controllerAs: 'card', - controller: function($http, $stateParams) { - this.client = null; - $http.get(`/client/api/Clients/${$stateParams.id}/card`).then( - json => this.client = json.data - ); + controller: function() { + var self = this; + self.client = null; + self.items = []; - this.items = []; - routes.client.routes.forEach(i => { - if (i.description) - this.items.push({ - description: i.description, - icon: i.icon, - href: i.state - }); - }); + self.$onInit = function() { + routes.client.routes.forEach(i => { + if (i.description) + self.items.push({ + description: i.description, + icon: i.icon, + href: i.state + }); + }); + }; } }; -COMPONENT.controller.$inject = ['$http', '$stateParams']; + module.component(NAME, COMPONENT); diff --git a/client/salix/src/configroutes.js b/client/salix/src/configroutes.js index 939d92207..f80a70e75 100644 --- a/client/salix/src/configroutes.js +++ b/client/salix/src/configroutes.js @@ -29,6 +29,8 @@ function config($stateProvider, $urlRouterProvider) { return temporalParams.join(' '); } + $urlRouterProvider.otherwise('/'); + for (let file in routes) { let fileRoutes = routes[file].routes; let moduleName = routes[file].module; @@ -36,6 +38,7 @@ function config($stateProvider, $urlRouterProvider) { fileRoutes.forEach(function(route) { $stateProvider.state(route.state, { url: route.url, + abstract: route.abstract || false, template: `<${route.component} ${getParams(route)}>`, resolve: { loader: loader(moduleName) diff --git a/package.json b/package.json index 4d38ac2c9..34809a942 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ "devDependencies": { "babel": "^6.5.2", "babel-core": "^6.22.1", - "babel-loader": "^6.2.10", + "babel-loader": "^6.4.1", "babel-preset-es2015": "^6.22.0", "cors": "^2.8.1", "css-loader": "^0.25.0",