From 06e9a22f405a824eca4a73e4bca1477f58f3b31d Mon Sep 17 00:00:00 2001 From: vicent Date: Thu, 12 May 2022 15:02:07 +0200 Subject: [PATCH] added search --- modules/zone/front/events/index.html | 49 +++++++++++++------------- modules/zone/front/events/index.js | 49 ++++++++++++++++++++++++-- modules/zone/front/location/index.js | 2 ++ modules/zone/front/location/style.scss | 30 ++++++++-------- modules/zone/front/routes.json | 7 ++-- 5 files changed, 93 insertions(+), 44 deletions(-) diff --git a/modules/zone/front/events/index.html b/modules/zone/front/events/index.html index 3a3eaf1b36..67657e665a 100644 --- a/modules/zone/front/events/index.html +++ b/modules/zone/front/events/index.html @@ -198,7 +198,6 @@ message="This item will be deleted" question="Are you sure you want to continue?"> - - + @@ -228,27 +227,27 @@ url="Zones/{{$ctrl.$params.id}}/getLeaves" filter="$ctrl.filter"> - - - - - - - - - - +
+ + +
+ + + + +
+
diff --git a/modules/zone/front/events/index.js b/modules/zone/front/events/index.js index ef0fad9e91..d7d54498c8 100644 --- a/modules/zone/front/events/index.js +++ b/modules/zone/front/events/index.js @@ -22,6 +22,17 @@ class Controller extends Section { return `Zones/${this.$params.id}/exclusions`; } + get checked() { + const geos = this.$.model.data || []; + const checkedLines = []; + for (let geo of geos) { + if (geo.checked) + checkedLines.push(geo); + } + + return checkedLines; + } + refresh() { this.$.data = null; this.$.$applyAsync(() => { @@ -200,8 +211,25 @@ class Controller extends Section { .then(() => this.refresh()); } - onSearch(params) { - if (this.selected.type == 'specificLocations') { + set excludeSearch(value) { + this._excludeSearch = value; + if (!value) this.onSearch(); + } + + get excludeSearch() { + return this._excludeSearch; + } + + onKeyDown(event) { + if (event.key == 'Enter') { + event.preventDefault(); + this.onSearch(); + } + } + + onSearch() { + const params = {search: this._excludeSearch}; + if (this.excludeType == 'specificLocations') { this.$.model.applyFilter({}, params).then(() => { const data = this.$.model.data; this.$.treeview.data = data; @@ -233,10 +261,25 @@ class Controller extends Section { return {name: {like: `%${value}%`}}; } } + + onSelection2(value, item) { + console.log(item, this.zone.id); + if (value == null) + value = undefined; + const params = {geoId: item.id, isIncluded: value}; + const path = `zones/${this.zone.id}/toggleIsIncluded`; + this.$http.post(path, params); + } } Controller.$inject = ['$element', '$scope', 'vnWeekDays']; ngModule.vnComponent('vnZoneEvents', { template: require('./index.html'), - controller: Controller + controller: Controller, + bindings: { + zone: '<' + }, + require: { + card: '^vnZoneCard' + } }); diff --git a/modules/zone/front/location/index.js b/modules/zone/front/location/index.js index 0f92f37def..8f3a24b65b 100644 --- a/modules/zone/front/location/index.js +++ b/modules/zone/front/location/index.js @@ -36,6 +36,8 @@ class Controller extends Section { } onSelection(value, item) { + console.log(item, this.zone.id); + if (value == null) value = undefined; const params = {geoId: item.id, isIncluded: value}; diff --git a/modules/zone/front/location/style.scss b/modules/zone/front/location/style.scss index 2316a26225..24d685a513 100644 --- a/modules/zone/front/location/style.scss +++ b/modules/zone/front/location/style.scss @@ -1,19 +1,21 @@ @import "variables"; -vn-treeview-child { - .content > .vn-check:not(.indeterminate):not(.checked) { - color: $color-alert; +vn-zone-location { + vn-treeview-child { + .content > .vn-check:not(.indeterminate):not(.checked) { + color: $color-alert; - & > .btn { - border-color: $color-alert; + & > .btn { + border-color: $color-alert; + } + } + .content > .vn-check.checked { + color: $color-notice; + + & > .btn { + background-color: $color-notice; + border-color: $color-notice + } } } - .content > .vn-check.checked { - color: $color-notice; - - & > .btn { - background-color: $color-notice; - border-color: $color-notice - } - } -} \ No newline at end of file +} diff --git a/modules/zone/front/routes.json b/modules/zone/front/routes.json index e08f973147..7f67260da1 100644 --- a/modules/zone/front/routes.json +++ b/modules/zone/front/routes.json @@ -85,10 +85,13 @@ "description": "Warehouses" }, { - "url": "/events", + "url": "/events?q", "state": "zone.card.events", "component": "vn-zone-events", - "description": "Calendar" + "description": "Calendar", + "params": { + "zone": "$ctrl.zone" + } }, { "url": "/location?q",