From 301588e0ed7dce7f383b4eccaeae65544ca8597e Mon Sep 17 00:00:00 2001 From: nelo Date: Fri, 7 Oct 2016 12:51:31 +0200 Subject: [PATCH] Prueba concepto rutas --- @salix/app/src/fake.js | 26 +---------------------- @salix/app/src/routes.js | 34 +++++++++++++++++------------- @salix/app/src/spliting.js | 14 +++++++++++- @salix/crud/src/customer/routes.js | 8 +++++++ @salix/crud/src/spliting.js | 0 5 files changed, 41 insertions(+), 41 deletions(-) create mode 100644 @salix/crud/src/customer/routes.js create mode 100644 @salix/crud/src/spliting.js diff --git a/@salix/app/src/fake.js b/@salix/app/src/fake.js index 39683e7cc..06d01245e 100644 --- a/@salix/app/src/fake.js +++ b/@salix/app/src/fake.js @@ -4,31 +4,7 @@ export const graphRoutes = { url: '/index', state: 'index', template: '', - module: 'compras', - description: '', - image: '', - }, - { - url: '/add', - state: 'add', - template: '', - module: 'compras', - description: '', - image: '', - }, - { - url: '/edit', - state: 'edit', - template: '', - module: 'compras', - description: '', - image: '', - }, - { - url: '/delete', - state: 'delete', - template: '', - module: 'compras', + module: 'crud', description: '', image: '', } diff --git a/@salix/app/src/routes.js b/@salix/app/src/routes.js index 2fc5204f1..326f77c7a 100644 --- a/@salix/app/src/routes.js +++ b/@salix/app/src/routes.js @@ -1,22 +1,24 @@ import * as core from '@salix/core'; import * as spliting from './spliting'; +import * as routes from './fake'; -core.module.config(function ($stateProvider, $urlRouterProvider) { +function loader(route) { + + return function ($ocLazyLoad, $q) { + return $q((resolve) => { + core.splitingRegister.execute(route.module).then(function (dependencies) { + var array = dependencies.map((item) => { return { name: item } }); + resolve($ocLazyLoad.load(array)); + }); + + }); + }; + +} + +function config($stateProvider, $urlRouterProvider) { core.splitingRegister.registerGraph(routes.graphRoutes.graphDependendies); - function loader(route) { - return function loader($ocLazyLoad, $q) { - return $q((resolve) => { - core.splitingRegister.execute(route.module).then(function(dependencies){ - var array = dependencies.map((item) => { return { name: item } }); - resolve($ocLazyLoad.load(array)); - }); - - }); - }); - } - - $urlRouterProvider.otherwise("/"); routes.graphRoutes.routes.forEach(function (route) { $stateProvider.state(route.state, { @@ -27,5 +29,7 @@ core.module.config(function ($stateProvider, $urlRouterProvider) { } }) }); -}); +} + +core.module.config(config); diff --git a/@salix/app/src/spliting.js b/@salix/app/src/spliting.js index fb7680727..139d4dec5 100644 --- a/@salix/app/src/spliting.js +++ b/@salix/app/src/spliting.js @@ -25,4 +25,16 @@ export const pagos = () => { }, "salix.pagos"); }; -core.splitingRegister.register('pagos', pagos); \ No newline at end of file +core.splitingRegister.register('pagos', pagos); + + +export const crud = () => { + return new Promise(resolve => { + require.ensure([], () => { + require('@salix/crud'); + resolve('crud'); + }, "salix.crud"); + }); +}; + +core.splitingRegister.register('crud', crud); \ No newline at end of file diff --git a/@salix/crud/src/customer/routes.js b/@salix/crud/src/customer/routes.js new file mode 100644 index 000000000..d5158a39b --- /dev/null +++ b/@salix/crud/src/customer/routes.js @@ -0,0 +1,8 @@ +{ + url: '/index', + state: 'index', + template: '', + module: 'crud', + description: '', + image: '', +} diff --git a/@salix/crud/src/spliting.js b/@salix/crud/src/spliting.js new file mode 100644 index 000000000..e69de29bb