From 2f77d371e9d13d454c8f2e8706e85afe5c0ced59 Mon Sep 17 00:00:00 2001 From: nelo Date: Tue, 13 Dec 2016 09:31:50 +0100 Subject: [PATCH] params config routes cargamos clientes --- @salix/app/src/configroutes.js | 20 ++++++++++++++++++-- @salix/crud/src/client/basic-data/index.html | 18 +++++++++--------- @salix/crud/src/client/basic-data/index.js | 3 +++ @salix/crud/src/client/card/card.html | 2 +- @salix/crud/src/client/card/card.js | 17 ++++++++++------- @salix/crud/src/client/routes.js | 3 +++ 6 files changed, 44 insertions(+), 19 deletions(-) diff --git a/@salix/app/src/configroutes.js b/@salix/app/src/configroutes.js index ab96122a0..1cd9004b5 100644 --- a/@salix/app/src/configroutes.js +++ b/@salix/app/src/configroutes.js @@ -13,6 +13,20 @@ function loader(module) { }; } +function getParams(route){ + var params = "", + temporalParams=[]; + + if(!route.params){ + return params; + } + + Object.keys(route.params).forEach((key)=>{ + temporalParams.push(key + `= "${route.params[key]}"`); + }); + return temporalParams.join(" "); +} + function config($stateProvider, $urlRouterProvider) { core.splitingRegister.registerGraph(deps); $urlRouterProvider.otherwise('/clients'); @@ -25,14 +39,16 @@ function config($stateProvider, $urlRouterProvider) { fileRoutes.forEach(function(route) { $stateProvider.state(route.state, { url: route.url, - template: `<${route.component} full-height>`, + template: `<${route.component} full-height ${getParams(route)}>`, resolve: { loader: loader(module) - } + } }) }); } } + + config.$inject = ['$stateProvider', '$urlRouterProvider']; core.module.config(config); diff --git a/@salix/crud/src/client/basic-data/index.html b/@salix/crud/src/client/basic-data/index.html index 9cd76e86a..92558f1c9 100644 --- a/@salix/crud/src/client/basic-data/index.html +++ b/@salix/crud/src/client/basic-data/index.html @@ -1,20 +1,20 @@ -
+ Datos básicos - - + + - - + + - - + + - - + + diff --git a/@salix/crud/src/client/basic-data/index.js b/@salix/crud/src/client/basic-data/index.js index 0e9d540b2..55d981204 100644 --- a/@salix/crud/src/client/basic-data/index.js +++ b/@salix/crud/src/client/basic-data/index.js @@ -4,6 +4,9 @@ import {module} from '../../module'; export const NAME = 'vnClientBasicData'; export const COMPONENT = { template: template, + bindings: { + client: '<' + }, controller: function($http) { this.submit = function() { $http.post('/client/api/Clients', this.model).then( diff --git a/@salix/crud/src/client/card/card.html b/@salix/crud/src/client/card/card.html index 7a97ad5cf..137c36488 100644 --- a/@salix/crud/src/client/card/card.html +++ b/@salix/crud/src/client/card/card.html @@ -5,7 +5,7 @@ - + diff --git a/@salix/crud/src/client/card/card.js b/@salix/crud/src/client/card/card.js index 3c70a6f9f..f11246d0e 100644 --- a/@salix/crud/src/client/card/card.js +++ b/@salix/crud/src/client/card/card.js @@ -8,11 +8,18 @@ export const COMPONENT = { template: template, controller: function($http, $stateParams) { let clientRoutes = routes['src/client/routes.js'].routes; - this.client = []; this.items = []; + this.client = null; $http.get(`/client/api/Clients/${$stateParams.id}`).then( - (json) => {this.client = json.data;}, + (json) => { + this.client = json.data; + this.descriptor = { + clientId: this.client.id, + name: this.client.name, + phone: this.client.phone + }; + }, (json) => console.error (json.data.error.message) ); @@ -25,11 +32,7 @@ export const COMPONENT = { }); }); - this.descriptor = { - clientId: "Cliente 1231", - name: "Floristeria Lola", - phone: "987 654 321" - }; + } }; COMPONENT.controller.$inject = ['$http', '$stateParams']; diff --git a/@salix/crud/src/client/routes.js b/@salix/crud/src/client/routes.js index 4730c72aa..a4abf2907 100644 --- a/@salix/crud/src/client/routes.js +++ b/@salix/crud/src/client/routes.js @@ -12,6 +12,9 @@ url: "/basic-data", state: "clientCard.basicData", component: "vn-client-basic-data", + params: { + client: "$ctrl.client" + }, description: "Datos básicos", icon: "person" },{