From 4dae59aa09ed0399c7fb70141dd7e72c00f2ba58 Mon Sep 17 00:00:00 2001 From: dherrero Date: Wed, 11 Oct 2017 12:47:02 +0200 Subject: [PATCH] zone model and rest api --- client/core/src/autocomplete/autocomplete.js | 69 +++++++++++-------- client/production/src/locale/en.json | 4 +- client/route/routes.json | 2 +- client/route/src/locale/en.json | 3 + client/route/src/locale/es.json | 2 +- .../route/src/search-panel/search-panel.html | 8 ++- client/salix/src/locale/es.json | 2 + services/route/common/models/zone.json | 33 +++++++++ services/route/server/model-config.json | 3 + 9 files changed, 92 insertions(+), 34 deletions(-) create mode 100644 client/route/src/locale/en.json create mode 100644 services/route/common/models/zone.json diff --git a/client/core/src/autocomplete/autocomplete.js b/client/core/src/autocomplete/autocomplete.js index f0e6eb304..a4e04a9be 100644 --- a/client/core/src/autocomplete/autocomplete.js +++ b/client/core/src/autocomplete/autocomplete.js @@ -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: ' - + diff --git a/client/salix/src/locale/es.json b/client/salix/src/locale/es.json index f2bc551fc..fc0932817 100644 --- a/client/salix/src/locale/es.json +++ b/client/salix/src/locale/es.json @@ -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" } \ No newline at end of file diff --git a/services/route/common/models/zone.json b/services/route/common/models/zone.json new file mode 100644 index 000000000..a7a45bd27 --- /dev/null +++ b/services/route/common/models/zone.json @@ -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" + } + ] + } + \ No newline at end of file diff --git a/services/route/server/model-config.json b/services/route/server/model-config.json index 904b02b80..da305afb0 100644 --- a/services/route/server/model-config.json +++ b/services/route/server/model-config.json @@ -44,5 +44,8 @@ }, "Delivery": { "dataSource": "vn" + }, + "Zone": { + "dataSource": "vn" } }