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", "module": "client",
"name": "Clients", "name": "Clients",
"icon": "person", "icon": "person",
"validations" : true,
"routes": [ "routes": [
{ {
"url": "/clients", "url": "/clients",

View File

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

View File

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

View File

@ -7,7 +7,7 @@ export function factory($translatePartialLoader, $http, $window, $ocLazyLoad, $q
constructor() { constructor() {
this._loadedModules = {}; this._loadedModules = {};
} }
load(moduleName) { load(moduleName, validations) {
if (this._loadedModules[moduleName]) if (this._loadedModules[moduleName])
return; return;
@ -20,6 +20,7 @@ export function factory($translatePartialLoader, $http, $window, $ocLazyLoad, $q
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]());
if (validations)
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),

View File

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

View File

@ -7,8 +7,7 @@
<vn-icon-button icon="textsms" ng-click="$ctrl.doAction('addComment')"></vn-icon-button> <vn-icon-button icon="textsms" ng-click="$ctrl.doAction('addComment')"></vn-icon-button>
</vn-none> </vn-none>
<vn-none margin-medium-right> <vn-none margin-medium-right>
<vn-icon-menu icon="person" url="/client/api/Employees" max-row="10" <vn-icon-menu icon="person" url="/client/api/Clients/employeeList" selected="$ctrl.actionWorker"></vn-icon-menu>
selected="$ctrl.actionWorker"></vn-icon-menu>
</vn-none> </vn-none>
<vn-none margin-medium-right> <vn-none margin-medium-right>
<vn-icon-menu icon="query_builder" items="$ctrl.hourItems" selected="$ctrl.actionHours"></vn-icon-menu> <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 ngModule from './module';
import {splitingRegister} from 'core'; import {splitingRegister} from 'core';
function loader(moduleName) { function loader(moduleName, validations) {
load.$inject = ['vnModuleLoader']; load.$inject = ['vnModuleLoader'];
function load(moduleLoader) { function load(moduleLoader) {
return moduleLoader.load(moduleName); return moduleLoader.load(moduleName, validations);
} }
return load; return load;
} }
@ -40,19 +40,22 @@ function config($stateProvider, $urlRouterProvider, aclServiceProvider) {
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;
let validations = routes[file].validations;
fileRoutes.forEach(function(route) { fileRoutes.forEach(function(route) {
if (aclService.routeHasPermission(route)) { if (aclService.routeHasPermission(route)) {
$stateProvider.state(route.state, { let routeOptions = {
url: route.url, url: route.url,
abstract: route.abstract || false, 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, validations)
}, },
data: { data: {
routes: fileRoutes routes: fileRoutes
} }
}); };
$stateProvider.state(route.state, routeOptions);
} }
}); });
} }