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",
"state": "clientCard",
"abstract": true,
"component": "vn-client-card"
}, {
"url": "/basic-data",

View File

@ -1,4 +1,5 @@
<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-descriptor client="card.client" active="card.client.active" class="display-block" ></vn-descriptor>
<vn-left-menu items="card.items"></vn-left-menu>

View File

@ -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);

View File

@ -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)}></${route.component}>`,
resolve: {
loader: loader(moduleName)

View File

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