added search
gitea/salix/pipeline/head There was a failure building this commit Details

This commit is contained in:
Vicent Llopis 2022-05-12 15:02:07 +02:00
parent b96d9ea4c2
commit 06e9a22f40
5 changed files with 93 additions and 44 deletions

View File

@ -198,7 +198,6 @@
message="This item will be deleted"
question="Are you sure you want to continue?">
</vn-confirm>
<vn-dialog
vn-id="excludeDialog"
on-response="$ctrl.onExcludeResponse($response)"
@ -208,16 +207,16 @@
label="Day"
ng-model="$ctrl.selected.dated">
</vn-date-picker>
<vn-vertical>
<vn-vertical style="width: 600px;">
<vn-vertical class="vn-pb-md">
<vn-radio
ng-model="$ctrl.selected.type"
ng-model="$ctrl.excludeType"
label="All"
on-change="$ctrl.test()"
val="all">
</vn-radio>
<vn-radio
ng-model="$ctrl.selected.type"
ng-model="$ctrl.excludeType"
label="Specific locations"
on-change="$ctrl.onSearch($params)"
val="specificLocations">
@ -228,27 +227,27 @@
url="Zones/{{$ctrl.$params.id}}/getLeaves"
filter="$ctrl.filter">
</vn-crud-model>
<vn-portal slot="topbar">
<vn-searchbar
on-search="$ctrl.onSearch($params)"
auto-state="false">
</vn-searchbar>
</vn-portal>
<div ng-if="$ctrl.excludeType == 'specificLocations'">
<vn-textfield
label="Search"
ng-keydown="$ctrl.onKeyDown($event)"
ng-model="$ctrl.excludeSearch">
</vn-textfield>
<div style="max-height: 300px; overflow: auto;">
<vn-treeview
ng-if="$ctrl.selected.type == 'specificLocations'"
vn-id="treeview"
root-label="Locations where it is not distributed"
fetch-func="$ctrl.onFetch($item)"
sort-func="$ctrl.onSort($a, $b)">
<vn-check acl-role="deliveryBoss"
ng-model="$ctrl.item.selected"
triple-state="true"
<vn-check
ng-model="geo.checked"
on-change="$ctrl.onSelection2(value, item)"
ng-click="$event.preventDefault()"
label="{{::item.name}}">
<!-- on-change="$ctrl.onSelection2(value, item)" -->
</vn-check>
</vn-treeview>
</div>
</div>
</vn-vertical>
</tpl-body>
<tpl-buttons>

View File

@ -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'
}
});

View File

@ -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};

View File

@ -1,6 +1,7 @@
@import "variables";
vn-treeview-child {
vn-zone-location {
vn-treeview-child {
.content > .vn-check:not(.indeterminate):not(.checked) {
color: $color-alert;
@ -16,4 +17,5 @@ vn-treeview-child {
border-color: $color-notice
}
}
}
}

View File

@ -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",