params config routes

cargamos clientes
This commit is contained in:
nelo 2016-12-13 09:31:50 +01:00
parent ab0b9aee33
commit 2f77d371e9
6 changed files with 44 additions and 19 deletions

View File

@ -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,7 +39,7 @@ function config($stateProvider, $urlRouterProvider) {
fileRoutes.forEach(function(route) {
$stateProvider.state(route.state, {
url: route.url,
template: `<${route.component} full-height></${route.component}>`,
template: `<${route.component} full-height ${getParams(route)}></${route.component}>`,
resolve: {
loader: loader(module)
}
@ -34,5 +48,7 @@ function config($stateProvider, $urlRouterProvider) {
}
}
config.$inject = ['$stateProvider', '$urlRouterProvider'];
core.module.config(config);

View File

@ -1,20 +1,20 @@
<form ng-submit="$ctrl.submit()" pad-large>
<vn-title>Datos básicos</vn-title>
<vn-horizontal>
<vn-textfield vn-one label="Alias" name="alias" model="$ctrl.model"></vn-textfield>
<vn-textfield vn-one label="NIF/CIF" name="fi" model="$ctrl.model"></vn-textfield>
<vn-textfield vn-one label="Alias" name="alias" model="$ctrl.client"></vn-textfield>
<vn-textfield vn-one label="NIF/CIF" name="fi" model="$ctrl.client"></vn-textfield>
</vn-horizontal>
<vn-horizontal>
<vn-textfield autofocus vn-one label="Razón social" name="socialName" model="$ctrl.model"></vn-textfield>
<vn-date-picker vn-one label="Fecha alta" name="dischargeDate" model="$ctrl.model"></vn-date-picker>
<vn-textfield autofocus vn-one label="Razón social" name="socialName" model="$ctrl.client"></vn-textfield>
<vn-date-picker vn-one label="Fecha alta" name="dischargeDate" model="$ctrl.client"></vn-date-picker>
</vn-horizontal>
<vn-horizontal>
<vn-textfield vn-one label="Contacto" name="contact" model="$ctrl.model"></vn-textfield>
<vn-textfield vn-one label="Teléfono" name="telefono" model="$ctrl.model"></vn-textfield>
<vn-textfield vn-one label="Contacto" name="contact" model="$ctrl.client"></vn-textfield>
<vn-textfield vn-one label="Teléfono" name="telefono" model="$ctrl.client"></vn-textfield>
</vn-horizontal>
<vn-horizontal>
<vn-textfield vn-one label="Calidad" name="quality" model="$ctrl.model"></vn-textfield>
<vn-combo vn-one label="Comercial" name="salesPerson" model="$ctrl.model">
<vn-textfield vn-one label="Calidad" name="quality" model="$ctrl.client"></vn-textfield>
<vn-combo vn-one label="Comercial" name="salesPerson" model="$ctrl.client">
<option value="1">Comercial 1</option>
<option value="2">Comercial 2</option>
</vn-combo>

View File

@ -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(

View File

@ -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'];

View File

@ -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"
},{