filtro de trabajadores y llamada a validaciones opcional

This commit is contained in:
Dani Herrero 2017-07-03 08:38:45 +02:00
parent 18ae915452
commit 06537bcf8d
7 changed files with 24 additions and 16 deletions

View File

@ -2,6 +2,7 @@
"module": "client",
"name": "Clients",
"icon": "person",
"validations" : true,
"routes": [
{
"url": "/clients",

View File

@ -1,6 +1,6 @@
<div class="icon-menu">
<vn-icon-button icon="{{::$ctrl.icon}}"></vn-icon-button>
<div ng-if="!$ctrl.url">
<div ng-if="!$ctrl.findMore">
<vn-drop-down
items="$ctrl.items"
show="$ctrl.showDropDown"
@ -8,7 +8,7 @@
filter="true"
></vn-drop-down>
</div>
<div ng-if="$ctrl.url">
<div ng-if="$ctrl.findMore">
<vn-drop-down
items="$ctrl.items"
show="$ctrl.showDropDown"

View File

@ -8,6 +8,7 @@ export default class IconMenu {
this.$timeout = $timeout;
this._showDropDown = false;
this.finding = false;
this.findMore = false;
}
get showDropDown() {
return this._showDropDown;
@ -69,6 +70,8 @@ export default class IconMenu {
this.getItems();
}
this.findMore = this.url && this.maxRow;
this.$element.bind('mouseover', e => {
this.$timeout(() => {
this.showDropDown = true;

View File

@ -7,7 +7,7 @@ export function factory($translatePartialLoader, $http, $window, $ocLazyLoad, $q
constructor() {
this._loadedModules = {};
}
load(moduleName) {
load(moduleName, validations) {
if (this._loadedModules[moduleName])
return;
@ -20,12 +20,13 @@ export function factory($translatePartialLoader, $http, $window, $ocLazyLoad, $q
for (let dep of deps) {
this._loadedModules[dep] = true;
promises.push(modules[dep]());
promises.push(new Promise(resolve => {
$http.get(`/${dep}/validations`).then(
json => this.onValidationsReady(json, resolve),
json => resolve()
);
}));
if (validations)
promises.push(new Promise(resolve => {
$http.get(`/${dep}/validations`).then(
json => this.onValidationsReady(json, resolve),
json => resolve()
);
}));
$translatePartialLoader.addPart(dep);
// FIXME: https://github.com/angular-translate/angular-translate/pull/1674

View File

@ -2,6 +2,7 @@
"module": "production",
"name": "Production",
"icon": "group_work",
"validations" : false,
"routes": [
{
"url": "/production",

View File

@ -7,8 +7,7 @@
<vn-icon-button icon="textsms" ng-click="$ctrl.doAction('addComment')"></vn-icon-button>
</vn-none>
<vn-none margin-medium-right>
<vn-icon-menu icon="person" url="/client/api/Employees" max-row="10"
selected="$ctrl.actionWorker"></vn-icon-menu>
<vn-icon-menu icon="person" url="/client/api/Clients/employeeList" selected="$ctrl.actionWorker"></vn-icon-menu>
</vn-none>
<vn-none margin-medium-right>
<vn-icon-menu icon="query_builder" items="$ctrl.hourItems" selected="$ctrl.actionHours"></vn-icon-menu>

View File

@ -3,10 +3,10 @@ import deps from 'spliting/modules.json';
import ngModule from './module';
import {splitingRegister} from 'core';
function loader(moduleName) {
function loader(moduleName, validations) {
load.$inject = ['vnModuleLoader'];
function load(moduleLoader) {
return moduleLoader.load(moduleName);
return moduleLoader.load(moduleName, validations);
}
return load;
}
@ -40,19 +40,22 @@ function config($stateProvider, $urlRouterProvider, aclServiceProvider) {
for (let file in routes) {
let fileRoutes = routes[file].routes;
let moduleName = routes[file].module;
let validations = routes[file].validations;
fileRoutes.forEach(function(route) {
if (aclService.routeHasPermission(route)) {
$stateProvider.state(route.state, {
let routeOptions = {
url: route.url,
abstract: route.abstract || false,
template: `<${route.component} ${getParams(route)}></${route.component}>`,
resolve: {
loader: loader(moduleName)
loader: loader(moduleName, validations)
},
data: {
routes: fileRoutes
}
});
};
$stateProvider.state(route.state, routeOptions);
}
});
}