zone model and rest api

This commit is contained in:
dherrero 2017-10-11 12:47:02 +02:00
parent cf36d7d6be
commit 4dae59aa09
9 changed files with 92 additions and 34 deletions

View File

@ -19,6 +19,7 @@ class Autocomplete extends Component {
this.maxRow = 10;
this.showField = this.showField || 'name';
this.valueField = this.valueField || 'id';
this.order = this.order || 'name ASC';
this.items = this.data || [];
this.displayValueMultiCheck = [];
this._multiField = [];
@ -219,38 +220,45 @@ class Autocomplete extends Component {
}
getItems() {
let filter = {};
if (!this.finding) {
this.finding = true;
if (this.maxRow) {
if (this.items) {
filter.skip = this.items.length;
}
filter.limit = this.maxRow;
filter.order = 'name ASC';
}
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;
if (this.maxRow) {
if (this.items) {
filter.skip = this.items.length;
}
filter.limit = this.maxRow;
filter.order = this.order;
}
);
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() {
this.findMore = this.url && this.maxRow;
@ -308,7 +316,8 @@ module.component('vnAutocomplete', {
data: '<?',
field: '=',
label: '@',
multiple: '@?'
multiple: '@?',
order: '@?'
},
transclude: {
tplItem: '?tplItem'

View File

@ -1 +1,3 @@
{}
{
"Production" : "Production"
}

View File

@ -1,6 +1,6 @@
{
"module": "route",
"name": "Route",
"name": "Routes",
"icon" : "local_shipping",
"validations" : false,
"routes": [

View File

@ -0,0 +1,3 @@
{
"Routes" : "Routes"
}

View File

@ -1,3 +1,3 @@
{
"Routes" : "Rutas"
}

View File

@ -2,7 +2,13 @@
<form ng-submit="$ctrl.onSearch()">
<vn-horizontal>
<vn-date-picker vn-one label="Date" model="$ctrl.filter.date"></vn-date-picker>
<vn-textfield vn-one label="Zone" model="$ctrl.filter.zone"></vn-textfield>
<vn-autocomplete
vn-one
label="Zone"
field="$ctrl.filter.zone"
url="/route/api/Zones"
order="printingOrder ASC"
></vn-autocomplete>
</vn-horizontal>
<vn-horizontal>

View File

@ -9,5 +9,7 @@
"Can't contact with server": "No se pudo contactar con el servidor",
"Push on applications menu": "Para abrir un módulo pulsa en el menú de aplicaciones",
"Clients": "Clientes",
"Routes" : "Rutas",
"Production" : "Producción",
"Modules access" : "Acceso a módulos"
}

View File

@ -0,0 +1,33 @@
{
"name": "Zone",
"base": "MyModel",
"validateUpsert": true,
"properties": {
"id": {
"id": true,
"type": "Number",
"forceId": false
},
"name": {
"type": "String"
},
"printingOrder":{
"type": "Number"
}
},
"acls": [
{
"accessType": "*",
"principalType": "ROLE",
"principalId": "$everyone",
"permission": "DENY"
},
{
"accessType": "*",
"principalType": "ROLE",
"principalId": "root",
"permission": "ALLOW"
}
]
}

View File

@ -44,5 +44,8 @@
},
"Delivery": {
"dataSource": "vn"
},
"Zone": {
"dataSource": "vn"
}
}