cambio en routes e interfaz localizador al 5%

This commit is contained in:
Dani Herrero 2017-06-06 13:06:47 +02:00
parent 622884d31c
commit 9fcdb28d14
15 changed files with 124 additions and 52 deletions

View File

@ -8,7 +8,7 @@ export function factory($translatePartialLoader, $http, $window, $ocLazyLoad, $q
this._loadedModules = {}; this._loadedModules = {};
} }
load(moduleName) { load(moduleName) {
if(this._loadedModules[moduleName]) if (this._loadedModules[moduleName])
return; return;
this._loadedModules[moduleName] = true; this._loadedModules[moduleName] = true;
@ -17,18 +17,19 @@ export function factory($translatePartialLoader, $http, $window, $ocLazyLoad, $q
let modules = splitingRegister.modules; let modules = splitingRegister.modules;
let promises = []; let promises = [];
for(let dep of deps) { for (let dep of deps) {
this._loadedModules[dep] = true; this._loadedModules[dep] = true;
promises.push(modules[dep]()); promises.push(modules[dep]());
promises.push(new Promise(resolve => { promises.push(new Promise(resolve => {
$http.get(`/${dep}/validations`).then( $http.get(`/${dep}/validations`).then(
json => this.onValidationsReady(json, resolve) json => this.onValidationsReady(json, resolve),
json => resolve()
); );
})); }));
$translatePartialLoader.addPart(dep); $translatePartialLoader.addPart(dep);
// FIXME: https://github.com/angular-translate/angular-translate/pull/1674 // FIXME: https://github.com/angular-translate/angular-translate/pull/1674
//promises.push($translate.refresh()); // promises.push($translate.refresh());
setTimeout (() => $translate.refresh(), 500); setTimeout (() => $translate.refresh(), 500);
} }
@ -41,7 +42,7 @@ export function factory($translatePartialLoader, $http, $window, $ocLazyLoad, $q
}); });
} }
parseValidation(val) { parseValidation(val) {
switch(val.validation) { switch (val.validation) {
case 'custom': case 'custom':
// TODO: Reemplazar eval // TODO: Reemplazar eval
val.customValidator = eval(`(${val.customValidator})`); val.customValidator = eval(`(${val.customValidator})`);
@ -53,11 +54,11 @@ export function factory($translatePartialLoader, $http, $window, $ocLazyLoad, $q
} }
onValidationsReady(json, resolve) { onValidationsReady(json, resolve) {
let entities = json.data; let entities = json.data;
for(let entity in entities) { for (let entity in entities) {
let fields = entities[entity].validations; let fields = entities[entity].validations;
for(let field in fields) { for (let field in fields) {
let validations = fields[field]; let validations = fields[field];
for(let validation of validations) for (let validation of validations)
this.parseValidation(validation); this.parseValidation(validation);
} }
} }

View File

@ -0,0 +1 @@
export * from './src/production';

View File

@ -0,0 +1,12 @@
{
"module": "production",
"name": "Production",
"icon": "group_work",
"routes": [
{
"url": "/production",
"state": "production",
"component": "vn-production-index"
}
]
}

View File

@ -0,0 +1,29 @@
<vn-card margin-large>
<vn-vertical pad-medium>
<vn-horizontal vn-one>
<vn-one>
<vn-title><span translate>Localizador</span></vn-title>
</vn-one>
<vn-one>
<vn-textfield vn-one label="Search" model="$ctrl.filter"></vn-textfield>
</vn-one>
<vn-one>
<vn-horizontal>
<vn-one></vn-one>
<vn-one>
<vn-textfield vn-one label="Search" model="$ctrl.Search"></vn-textfield>
</vn-one>
<vn-none>
<vn-icon-button icon="refresh"></vn-icon-button>
</vn-none>
</vn-horizontal>
</vn-one>
</vn-horizontal>
<vn-horizontal vn-one>
<vn-one>
</vn-one>
<vn-two></vn-two>
</vn-horizontal>
</vn-vertical>
</vn-card>

View File

@ -0,0 +1,13 @@
import ngModule from '../module';
export default class ProductionIndex {
search(index) {
index.filter.search = this.model.search;
index.accept();
}
}
ngModule.component('vnProductionIndex', {
template: require('./index.html'),
controller: ProductionIndex
});

View File

@ -0,0 +1 @@
{}

View File

@ -0,0 +1 @@
{}

View File

@ -0,0 +1,5 @@
import {ng} from 'vendor';
import 'core';
const ngModule = ng.module('production', []);
export default ngModule;

View File

@ -0,0 +1,5 @@
export * from './module';
// import components
import './index/index';

View File

@ -2,7 +2,7 @@
<vn-horizontal> <vn-horizontal>
<h6 vn-one translate="Modules access"></h6> <h6 vn-one translate="Modules access"></h6>
</vn-horizontal> </vn-horizontal>
<vn-horizontal vn-one> <vn-module-container>
<a ng-repeat="mod in $ctrl.modules" ui-sref="{{::mod.route.state}}" class="{{::mod.name}} vn-module mdl-shadow--4dp"> <a ng-repeat="mod in $ctrl.modules" ui-sref="{{::mod.route.state}}" class="{{::mod.name}} vn-module mdl-shadow--4dp">
<vn-vertical> <vn-vertical>
<vn-one> <vn-one>

View File

@ -10,32 +10,45 @@ vn-home {
a:link{ a:link{
text-decoration: none; text-decoration: none;
} }
.vn-module{ vn-module-container{
display: flex; display: flex;
flex: none; flex: 1;
padding: 2em; flex-direction: row;
border-radius: 4px; justify-content: center;
box-sizing: border-box;
transition: opacity 0.7s ease;
h4{
text-transform: capitalize;
}
vn-one{
text-align: center;
}
i{ .vn-module{
font-size: 50px !important; display: flex;
margin: 0 auto; flex: none;
padding: 2em;
margin: 10px;
border-radius: 4px;
box-sizing: border-box;
transition: opacity 0.7s ease;
h4{
text-transform: capitalize;
font-size: 16pt;
}
vn-one{
text-align: center;
}
i{
font-size: 50px !important;
margin: 0 auto;
}
&:hover{
opacity: 0.7;
}
&.Clients{
background-color: #ffa410;
color: #ffffff;
}
&.Production{
background-color: #95d600;
color: #ffffff;
}
} }
&:hover{
opacity: 0.7;
}
&.Clients{
background-color: #ffa410;
color: #ffffff;
}
} }
} }

View File

@ -9,9 +9,9 @@ export default class LeftMenu {
this.init(); this.init();
} }
init() { init() {
let station = this.$state.current.data.station || 'default'; let routes = this.$state.current.data.routes || [];
if (routes[station]) { if (routes.length) {
routes[station].routes.forEach(i => { routes.forEach(i => {
if (i.menu && this.aclService.routeHasPermission(i)) if (i.menu && this.aclService.routeHasPermission(i))
this.items.push({ this.items.push({
description: i.menu.description, description: i.menu.description,

View File

@ -50,7 +50,7 @@ function config($stateProvider, $urlRouterProvider, aclServiceProvider) {
loader: loader(moduleName) loader: loader(moduleName)
}, },
data: { data: {
station: file routes: fileRoutes
} }
}); });
} }

View File

@ -114,7 +114,7 @@ gulp.task('webpack-dev-server', ['spliting'], function() {
// Locale // Locale
var localeFiles = `./${srcDir}/**/locale/*.json`; var localeFiles = `${srcDir}/**/locale/*.json`;
gulp.task('locales', function() { gulp.task('locales', function() {
var streams = []; var streams = [];
@ -132,22 +132,12 @@ gulp.task('locales', function() {
// Routes // Routes
var routeFiles = `./${srcDir}/**/routes.json`; var routeFiles = `${srcDir}/**/routes.json`;
gulp.task('routes', function() { gulp.task('routes', function() {
function cb(file) {
var relative = file.relative.replace(/\\/g, '/');
var dirname = relative.match(/^(.*)\/routes\.json$/)[1];
return {
dirname: dirname,
json: file.contents
};
}
return gulp.src(routeFiles) return gulp.src(routeFiles)
.pipe(wrap('\n"<%=dirname%>": <%=json%>', cb))
.pipe(concat('routes.js', {newLine: ','})) .pipe(concat('routes.js', {newLine: ','}))
.pipe(wrap('var routes = {<%=contents%>\n};')) .pipe(wrap('var routes = [<%=contents%>\n];'))
.pipe(gulp.dest(buildDir)); .pipe(gulp.dest(buildDir));
}); });

View File

@ -1,6 +1,7 @@
{ {
"salix": ["client"], "salix": ["client", "production"],
"auth": [], "auth": [],
"core": [], "core": [],
"client": [] "client": [],
"production": []
} }