merge
This commit is contained in:
commit
7d5b421ace
|
@ -7,7 +7,8 @@
|
||||||
{
|
{
|
||||||
"url": "/clients",
|
"url": "/clients",
|
||||||
"state": "clients",
|
"state": "clients",
|
||||||
"component": "vn-client-index"
|
"component": "vn-client-index",
|
||||||
|
"acl": ["employee"]
|
||||||
}, {
|
}, {
|
||||||
"url": "/create",
|
"url": "/create",
|
||||||
"state": "create",
|
"state": "create",
|
||||||
|
|
|
@ -1,14 +1,16 @@
|
||||||
import {module} from '../module';
|
import {module} from '../module';
|
||||||
import Component from '../lib/component';
|
import Component from '../lib/component';
|
||||||
|
import copyObject from '../lib/copy';
|
||||||
import './style.scss';
|
import './style.scss';
|
||||||
|
|
||||||
class Autocomplete extends Component {
|
class Autocomplete extends Component {
|
||||||
constructor($element, $scope, $http, $timeout) {
|
constructor($element, $scope, $http, $timeout, $filter) {
|
||||||
super($element);
|
super($element);
|
||||||
this.$element = $element;
|
this.$element = $element;
|
||||||
this.$scope = $scope;
|
this.$scope = $scope;
|
||||||
this.$http = $http;
|
this.$http = $http;
|
||||||
this.$timeout = $timeout;
|
this.$timeout = $timeout;
|
||||||
|
this.$filter = $filter;
|
||||||
|
|
||||||
this._showDropDown = false;
|
this._showDropDown = false;
|
||||||
this.finding = false;
|
this.finding = false;
|
||||||
|
@ -20,7 +22,7 @@ class Autocomplete extends Component {
|
||||||
this.showField = this.showField || 'name';
|
this.showField = this.showField || 'name';
|
||||||
this.valueField = this.valueField || 'id';
|
this.valueField = this.valueField || 'id';
|
||||||
this.order = this.order || 'name ASC';
|
this.order = this.order || 'name ASC';
|
||||||
this.items = this.data || [];
|
this.items = copyObject(this.data) || [];
|
||||||
this.displayValueMultiCheck = [];
|
this.displayValueMultiCheck = [];
|
||||||
this._multiField = [];
|
this._multiField = [];
|
||||||
this.readonly = true;
|
this.readonly = true;
|
||||||
|
@ -187,10 +189,7 @@ class Autocomplete extends Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
findItems(search) {
|
findItems(search) {
|
||||||
if (!this.url)
|
if (this.url && search && !this.finding) {
|
||||||
return this.items ? this.items : [];
|
|
||||||
|
|
||||||
if (search && !this.finding) {
|
|
||||||
this.maxRow = false;
|
this.maxRow = false;
|
||||||
let filter = {where: {name: {regexp: search}}};
|
let filter = {where: {name: {regexp: search}}};
|
||||||
if (this.filter && this.filter.where) {
|
if (this.filter && this.filter.where) {
|
||||||
|
@ -215,6 +214,8 @@ class Autocomplete extends Component {
|
||||||
this.finding = false;
|
this.finding = false;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
} else if (search && !this.url && this.data) {
|
||||||
|
this.items = this.$filter('filter')(this.data, search);
|
||||||
} else if (!search && !this.finding) {
|
} else if (!search && !this.finding) {
|
||||||
this.maxRow = 10;
|
this.maxRow = 10;
|
||||||
this.items = [];
|
this.items = [];
|
||||||
|
@ -222,48 +223,54 @@ class Autocomplete extends Component {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
getItems() {
|
getItems() {
|
||||||
let filter = {};
|
if (this.url === undefined) {
|
||||||
if (!this.finding) {
|
this.items = copyObject(this.data);
|
||||||
this.finding = true;
|
this.maxRow = false;
|
||||||
|
this.removeLoadMore = true;
|
||||||
|
} else {
|
||||||
|
let filter = {};
|
||||||
|
if (!this.finding) {
|
||||||
|
this.finding = true;
|
||||||
|
|
||||||
if (this.maxRow) {
|
if (this.maxRow) {
|
||||||
if (this.items) {
|
if (this.items) {
|
||||||
filter.skip = this.items.length;
|
filter.skip = this.items.length;
|
||||||
}
|
|
||||||
filter.limit = this.maxRow;
|
|
||||||
filter.order = this.order;
|
|
||||||
}
|
|
||||||
if (this.filter) {
|
|
||||||
Object.assign(filter, this.filter);
|
|
||||||
}
|
|
||||||
|
|
||||||
let json = JSON.stringify(filter);
|
|
||||||
|
|
||||||
this.removeLoadMore = false;
|
|
||||||
|
|
||||||
this.$http.get(`${this.url}?filter=${json}`).then(
|
|
||||||
json => {
|
|
||||||
if (json.data.length) {
|
|
||||||
json.data.forEach(
|
|
||||||
el => {
|
|
||||||
if (this.multiple) {
|
|
||||||
el.checked = this.field.indexOf(el[this.valueField]) !== -1;
|
|
||||||
}
|
|
||||||
this.items.push(el);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
if (filter.skip === 0 && this.maxRow && json.data.length < this.maxRow) {
|
|
||||||
this.removeLoadMore = true;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
this.maxRow = false;
|
|
||||||
}
|
}
|
||||||
this.finding = false;
|
filter.limit = this.maxRow;
|
||||||
},
|
filter.order = this.order;
|
||||||
() => {
|
|
||||||
this.finding = false;
|
|
||||||
}
|
}
|
||||||
);
|
if (this.filter) {
|
||||||
|
Object.assign(filter, this.filter);
|
||||||
|
}
|
||||||
|
|
||||||
|
let json = JSON.stringify(filter);
|
||||||
|
|
||||||
|
this.removeLoadMore = false;
|
||||||
|
|
||||||
|
this.$http.get(`${this.url}?filter=${json}`).then(
|
||||||
|
json => {
|
||||||
|
if (json.data.length) {
|
||||||
|
json.data.forEach(
|
||||||
|
el => {
|
||||||
|
if (this.multiple) {
|
||||||
|
el.checked = this.field.indexOf(el[this.valueField]) !== -1;
|
||||||
|
}
|
||||||
|
this.items.push(el);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
if (filter.skip === 0 && this.maxRow && json.data.length < this.maxRow) {
|
||||||
|
this.removeLoadMore = true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.maxRow = false;
|
||||||
|
}
|
||||||
|
this.finding = false;
|
||||||
|
},
|
||||||
|
() => {
|
||||||
|
this.finding = false;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$onInit() {
|
$onInit() {
|
||||||
|
@ -305,9 +312,17 @@ class Autocomplete extends Component {
|
||||||
this.$element.unbind('focusout');
|
this.$element.unbind('focusout');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$onChanges(objectChange) {
|
||||||
|
if (objectChange.data && objectChange.data.currentValue && objectChange.data.currentValue.length) {
|
||||||
|
this.items = copyObject(objectChange.data.currentValue);
|
||||||
|
this.maxRow = false;
|
||||||
|
this.removeLoadMore = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Autocomplete.$inject = ['$element', '$scope', '$http', '$timeout'];
|
Autocomplete.$inject = ['$element', '$scope', '$http', '$timeout', '$filter'];
|
||||||
|
|
||||||
module.component('vnAutocomplete', {
|
module.component('vnAutocomplete', {
|
||||||
template: require('./autocomplete.html'),
|
template: require('./autocomplete.html'),
|
||||||
|
|
|
@ -7,7 +7,8 @@
|
||||||
{
|
{
|
||||||
"url": "/locator",
|
"url": "/locator",
|
||||||
"state": "locator",
|
"state": "locator",
|
||||||
"component": "vn-locator-index"
|
"component": "vn-locator-index",
|
||||||
|
"acl": ["developer"]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
|
@ -7,7 +7,8 @@
|
||||||
{
|
{
|
||||||
"url": "/production",
|
"url": "/production",
|
||||||
"state": "production",
|
"state": "production",
|
||||||
"component": "vn-production-index"
|
"component": "vn-production-index",
|
||||||
|
"acl": ["employee"]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
|
@ -4,7 +4,7 @@ export class ProductionTable {
|
||||||
constructor($filter) {
|
constructor($filter) {
|
||||||
this.$filter = $filter;
|
this.$filter = $filter;
|
||||||
this._tickets = [];
|
this._tickets = [];
|
||||||
this.itemsDisplayedInList = 16;
|
this.itemsDisplayedInList = 14;
|
||||||
this._checkAll = 0;
|
this._checkAll = 0;
|
||||||
this.pageTable = {
|
this.pageTable = {
|
||||||
filter: {
|
filter: {
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
"url": "/list",
|
"url": "/list",
|
||||||
"state": "routes.index",
|
"state": "routes.index",
|
||||||
"component": "vn-route-index",
|
"component": "vn-route-index",
|
||||||
"acl": ["employee"]
|
"acl": ["developer"]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"url": "/create",
|
"url": "/create",
|
||||||
|
@ -43,6 +43,7 @@
|
||||||
"url": "/logisticData",
|
"url": "/logisticData",
|
||||||
"state": "routes.card.logisticData",
|
"state": "routes.card.logisticData",
|
||||||
"component": "vn-route-logistic-data",
|
"component": "vn-route-logistic-data",
|
||||||
|
"acl": ["employee"],
|
||||||
"params": {
|
"params": {
|
||||||
"route": "$ctrl.route"
|
"route": "$ctrl.route"
|
||||||
},
|
},
|
||||||
|
|
|
@ -11,8 +11,8 @@ function loader(moduleName, validations) {
|
||||||
return load;
|
return load;
|
||||||
}
|
}
|
||||||
|
|
||||||
config.$inject = ['$stateProvider', '$urlRouterProvider', 'aclServiceProvider'];
|
config.$inject = ['$stateProvider', '$urlRouterProvider', 'aclServiceProvider', 'modulesFactoryProvider'];
|
||||||
function config($stateProvider, $urlRouterProvider, aclServiceProvider) {
|
function config($stateProvider, $urlRouterProvider, aclServiceProvider, modulesFactory) {
|
||||||
splitingRegister.registerGraph(deps);
|
splitingRegister.registerGraph(deps);
|
||||||
let aclService = aclServiceProvider.$get();
|
let aclService = aclServiceProvider.$get();
|
||||||
|
|
||||||
|
@ -37,25 +37,32 @@ function config($stateProvider, $urlRouterProvider, aclServiceProvider) {
|
||||||
template: '<vn-home></vn-home>'
|
template: '<vn-home></vn-home>'
|
||||||
});
|
});
|
||||||
|
|
||||||
for (let file in routes) {
|
for (let file in window.routes) {
|
||||||
let fileRoutes = routes[file].routes;
|
let fileRoutes = window.routes[file].routes;
|
||||||
let moduleName = routes[file].module;
|
let moduleName = window.routes[file].module;
|
||||||
let validations = routes[file].validations || false;
|
let validations = window.routes[file].validations || false;
|
||||||
fileRoutes.forEach(function(route) {
|
let mainModule = modulesFactory.$get().getMainRoute(fileRoutes);
|
||||||
if (aclService.routeHasPermission(route)) {
|
if (mainModule) {
|
||||||
$stateProvider.state(route.state, {
|
let count = fileRoutes.length;
|
||||||
url: route.url,
|
for (let i = 0; i < count; i++) {
|
||||||
abstract: route.abstract || false,
|
let route = fileRoutes[i];
|
||||||
template: `<${route.component} ${getParams(route)}></${route.component}>`,
|
if (aclService.routeHasPermission(route)) {
|
||||||
resolve: {
|
$stateProvider.state(route.state, {
|
||||||
loader: loader(moduleName, validations)
|
url: route.url,
|
||||||
},
|
abstract: route.abstract || false,
|
||||||
data: {
|
template: `<${route.component} ${getParams(route)}></${route.component}>`,
|
||||||
routes: fileRoutes
|
resolve: {
|
||||||
}
|
loader: loader(moduleName, validations)
|
||||||
});
|
},
|
||||||
|
data: {
|
||||||
|
routes: fileRoutes
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else if (route.state === mainModule.state) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ngModule.config(config);
|
ngModule.config(config);
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import ngModule from './module';
|
import ngModule from './module';
|
||||||
|
|
||||||
function modulesFactory(aclService) {
|
function modulesFactory(aclService) {
|
||||||
function _getMainRoute(routeCollection) {
|
function getMainRoute(routeCollection) {
|
||||||
let cant = routeCollection.length;
|
let cant = routeCollection.length;
|
||||||
for (let i = 0; i < cant; i++) {
|
for (let i = 0; i < cant; i++) {
|
||||||
if (!routeCollection[i].abstract) {
|
if (!routeCollection[i].abstract) {
|
||||||
|
@ -18,7 +18,7 @@ function modulesFactory(aclService) {
|
||||||
name: routes[file].name || routes[file].module,
|
name: routes[file].name || routes[file].module,
|
||||||
icon: routes[file].icon || ''
|
icon: routes[file].icon || ''
|
||||||
};
|
};
|
||||||
let mainRoute = _getMainRoute(window.routes[file].routes);
|
let mainRoute = getMainRoute(window.routes[file].routes);
|
||||||
if (mainRoute && aclService.routeHasPermission(mainRoute)) {
|
if (mainRoute && aclService.routeHasPermission(mainRoute)) {
|
||||||
card.route = mainRoute;
|
card.route = mainRoute;
|
||||||
modules.push(card);
|
modules.push(card);
|
||||||
|
@ -28,7 +28,8 @@ function modulesFactory(aclService) {
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
getModules: getModules
|
getModules: getModules,
|
||||||
|
getMainRoute: getMainRoute
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
modulesFactory.$inject = ['aclService'];
|
modulesFactory.$inject = ['aclService'];
|
||||||
|
|
Loading…
Reference in New Issue