Client card, uso de mgCrud. Routes: añadido estado abstract

This commit is contained in:
Dani Herrero 2017-05-23 09:20:21 +02:00
parent c1acd51d96
commit bda48488fc
5 changed files with 21 additions and 16 deletions

View File

@ -8,6 +8,7 @@
}, { }, {
"url": "/clients/:id", "url": "/clients/:id",
"state": "clientCard", "state": "clientCard",
"abstract": true,
"component": "vn-client-card" "component": "vn-client-card"
}, { }, {
"url": "/basic-data", "url": "/basic-data",

View File

@ -1,4 +1,5 @@
<vn-horizontal> <vn-horizontal>
<mg-ajax path="/client/api/Clients/{{edit.params.id}}/card" options="mgEdit" actions="card.client=edit.model;"></mg-ajax>
<vn-empty style="min-width: 18em; padding-left: 1em; padding-bottom: 1em;"> <vn-empty style="min-width: 18em; padding-left: 1em; padding-bottom: 1em;">
<vn-descriptor client="card.client" active="card.client.active" class="display-block" ></vn-descriptor> <vn-descriptor client="card.client" active="card.client.active" class="display-block" ></vn-descriptor>
<vn-left-menu items="card.items"></vn-left-menu> <vn-left-menu items="card.items"></vn-left-menu>

View File

@ -5,22 +5,22 @@ export const NAME = 'vnClientCard';
export const COMPONENT = { export const COMPONENT = {
template: require('./index.html'), template: require('./index.html'),
controllerAs: 'card', controllerAs: 'card',
controller: function($http, $stateParams) { controller: function() {
this.client = null; var self = this;
$http.get(`/client/api/Clients/${$stateParams.id}/card`).then( self.client = null;
json => this.client = json.data self.items = [];
);
this.items = []; self.$onInit = function() {
routes.client.routes.forEach(i => { routes.client.routes.forEach(i => {
if (i.description) if (i.description)
this.items.push({ self.items.push({
description: i.description, description: i.description,
icon: i.icon, icon: i.icon,
href: i.state href: i.state
}); });
}); });
};
} }
}; };
COMPONENT.controller.$inject = ['$http', '$stateParams'];
module.component(NAME, COMPONENT); module.component(NAME, COMPONENT);

View File

@ -29,6 +29,8 @@ function config($stateProvider, $urlRouterProvider) {
return temporalParams.join(' '); return temporalParams.join(' ');
} }
$urlRouterProvider.otherwise('/');
for (let file in routes) { for (let file in routes) {
let fileRoutes = routes[file].routes; let fileRoutes = routes[file].routes;
let moduleName = routes[file].module; let moduleName = routes[file].module;
@ -36,6 +38,7 @@ function config($stateProvider, $urlRouterProvider) {
fileRoutes.forEach(function(route) { fileRoutes.forEach(function(route) {
$stateProvider.state(route.state, { $stateProvider.state(route.state, {
url: route.url, url: route.url,
abstract: route.abstract || false,
template: `<${route.component} ${getParams(route)}></${route.component}>`, template: `<${route.component} ${getParams(route)}></${route.component}>`,
resolve: { resolve: {
loader: loader(moduleName) loader: loader(moduleName)

View File

@ -23,7 +23,7 @@
"devDependencies": { "devDependencies": {
"babel": "^6.5.2", "babel": "^6.5.2",
"babel-core": "^6.22.1", "babel-core": "^6.22.1",
"babel-loader": "^6.2.10", "babel-loader": "^6.4.1",
"babel-preset-es2015": "^6.22.0", "babel-preset-es2015": "^6.22.0",
"cors": "^2.8.1", "cors": "^2.8.1",
"css-loader": "^0.25.0", "css-loader": "^0.25.0",