feat: add dialog
gitea/salix/pipeline/head There was a failure building this commit
Details
gitea/salix/pipeline/head There was a failure building this commit
Details
This commit is contained in:
parent
06e9a22f40
commit
ab13c16948
|
@ -81,11 +81,14 @@ BEGIN
|
|||
SELECT e.zoneFk, e.`type`, e.dated, e.`started`, e.`ended`, e.weekDays
|
||||
FROM tZone t
|
||||
JOIN zoneEvent e ON e.zoneFk = t.id;
|
||||
|
||||
SELECT e.zoneFk, e.dated
|
||||
FROM tZone t
|
||||
JOIN zoneExclusion e ON e.zoneFk = t.id
|
||||
LEFT JOIN zoneExclusionGeo eg ON eg.zoneExclusionFk = e.id
|
||||
WHERE eg.zoneExclusionFk IS NULL;
|
||||
JOIN zoneGeo zg1 ON zg1.id = eg.geoFk
|
||||
JOIN zoneGeo zg2 ON zg2.id = vGeoFk
|
||||
WHERE eg.zoneExclusionFk IS NULL OR zg2.`path` LIKE CONCAT(zg1.`path`,'%');
|
||||
|
||||
DROP TEMPORARY TABLE tZone;
|
||||
END$$
|
||||
|
|
|
@ -0,0 +1,48 @@
|
|||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethod('exclusionGeo', {
|
||||
description: 'Exclude a zoneGeo for a zone',
|
||||
accepts: [
|
||||
{
|
||||
arg: 'zoneFk',
|
||||
type: 'number',
|
||||
description: 'The zone id'
|
||||
},
|
||||
{
|
||||
arg: 'date',
|
||||
type: 'date',
|
||||
description: 'The date to exclude'
|
||||
},
|
||||
{
|
||||
arg: 'geoIds',
|
||||
type: 'any',
|
||||
description: 'The geos id'
|
||||
}
|
||||
|
||||
],
|
||||
returns: {
|
||||
type: 'object',
|
||||
root: true
|
||||
},
|
||||
http: {
|
||||
path: `/exclusionGeo`,
|
||||
verb: 'POST'
|
||||
}
|
||||
});
|
||||
|
||||
Self.exclusionGeo = async(zoneFk, date, geoIds, options) => {
|
||||
const models = Self.app.models;
|
||||
|
||||
const newZoneExclusion = await models.ZoneExclusion.create({
|
||||
zoneFk: zoneFk,
|
||||
dated: date
|
||||
});
|
||||
|
||||
for (let geoId of geoIds) {
|
||||
await models.ZoneExclusionGeo.create({
|
||||
zoneExclusionFk: newZoneExclusion.id,
|
||||
geoFk: geoId.id
|
||||
});
|
||||
}
|
||||
};
|
||||
};
|
|
@ -53,11 +53,22 @@ module.exports = Self => {
|
|||
|
||||
query = `
|
||||
SELECT *
|
||||
FROM vn.zoneExclusion
|
||||
FROM vn.zoneExclusion e
|
||||
LEFT JOIN vn.zoneExclusionGeo eg ON eg.zoneExclusionFk = e.id
|
||||
WHERE zoneFk = ?
|
||||
AND dated BETWEEN ? AND ?;`;
|
||||
AND dated BETWEEN ? AND ?
|
||||
AND eg.zoneExclusionFk IS NULL;`;
|
||||
const exclusions = await Self.rawSql(query, [zoneFk, started, ended], myOptions);
|
||||
|
||||
return {events, exclusions};
|
||||
query = `
|
||||
SELECT *
|
||||
FROM vn.zoneExclusion e
|
||||
LEFT JOIN vn.zoneExclusionGeo eg ON eg.zoneExclusionFk = e.id
|
||||
WHERE zoneFk = ?
|
||||
AND dated BETWEEN ? AND ?
|
||||
AND eg.zoneExclusionFk IS NOT NULL;`;
|
||||
const geoExclusions = await Self.rawSql(query, [zoneFk, started, ended], myOptions);
|
||||
|
||||
return {events, exclusions, geoExclusions};
|
||||
};
|
||||
};
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
"required": true
|
||||
},
|
||||
"geoFk": {
|
||||
"type": "date",
|
||||
"type": "number",
|
||||
"required": true
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ module.exports = Self => {
|
|||
require('../methods/zone/deleteZone')(Self);
|
||||
require('../methods/zone/includingExpired')(Self);
|
||||
require('../methods/zone/getZoneClosing')(Self);
|
||||
require('../methods/zone/exclusionGeo')(Self);
|
||||
|
||||
Self.validatesPresenceOf('agencyModeFk', {
|
||||
message: `Agency cannot be blank`
|
||||
|
|
|
@ -75,6 +75,17 @@ class Controller extends Component {
|
|||
}
|
||||
}
|
||||
|
||||
this.geoExclusions = {};
|
||||
let geoExclusions = value.geoExclusions;
|
||||
|
||||
if (geoExclusions) {
|
||||
for (let geoExclusion of geoExclusions) {
|
||||
let stamp = toStamp(geoExclusion.dated);
|
||||
if (!this.geoExclusions[stamp]) this.geoExclusions[stamp] = [];
|
||||
this.geoExclusions[stamp].push(geoExclusion);
|
||||
}
|
||||
}
|
||||
|
||||
let events = value.events;
|
||||
|
||||
if (events) {
|
||||
|
@ -154,13 +165,16 @@ class Controller extends Component {
|
|||
|
||||
hasEvents(day) {
|
||||
let stamp = day.getTime();
|
||||
return this.days[stamp] || this.exclusions[stamp];
|
||||
return this.days[stamp] || this.exclusions[stamp] || this.geoExclusions[stamp];
|
||||
}
|
||||
|
||||
getClass(day) {
|
||||
let stamp = day.getTime();
|
||||
return this.exclusions[stamp] && !this.days[stamp]
|
||||
? 'excluded' : '';
|
||||
if (this.geoExclusions[stamp] && !this.days[stamp])
|
||||
return 'geoExcluded';
|
||||
else if (this.exclusions[stamp] && !this.days[stamp])
|
||||
return 'excluded';
|
||||
else return '';
|
||||
}
|
||||
}
|
||||
Controller.$inject = ['$element', '$scope', 'vnWeekDays'];
|
||||
|
|
|
@ -33,6 +33,9 @@ vn-zone-calendar {
|
|||
&.excluded .day-number {
|
||||
background-color: $color-alert;
|
||||
}
|
||||
&.geoExcluded .day-number {
|
||||
background-color: #33CAFF;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -205,18 +205,18 @@
|
|||
<tpl-body>
|
||||
<vn-date-picker
|
||||
label="Day"
|
||||
ng-model="$ctrl.selected.dated">
|
||||
ng-model="$ctrl.excludeSelected.dated">
|
||||
</vn-date-picker>
|
||||
<vn-vertical style="width: 600px;">
|
||||
<vn-vertical class="width">
|
||||
<vn-vertical class="vn-pb-md">
|
||||
<vn-radio
|
||||
ng-model="$ctrl.excludeType"
|
||||
ng-model="$ctrl.excludeSelected.type"
|
||||
label="All"
|
||||
on-change="$ctrl.test()"
|
||||
val="all">
|
||||
</vn-radio>
|
||||
<vn-radio
|
||||
ng-model="$ctrl.excludeType"
|
||||
ng-model="$ctrl.excludeSelected.type"
|
||||
label="Specific locations"
|
||||
on-change="$ctrl.onSearch($params)"
|
||||
val="specificLocations">
|
||||
|
@ -227,20 +227,23 @@
|
|||
url="Zones/{{$ctrl.$params.id}}/getLeaves"
|
||||
filter="$ctrl.filter">
|
||||
</vn-crud-model>
|
||||
<div ng-if="$ctrl.excludeType == 'specificLocations'">
|
||||
<div ng-if="$ctrl.excludeSelected.type == 'specificLocations'">
|
||||
<vn-textfield
|
||||
label="Search"
|
||||
ng-keydown="$ctrl.onKeyDown($event)"
|
||||
ng-model="$ctrl.excludeSearch">
|
||||
<prepend>
|
||||
<vn-icon icon="search"></vn-icon>
|
||||
</prepend>
|
||||
</vn-textfield>
|
||||
<div style="max-height: 300px; overflow: auto;">
|
||||
<div class="treeview">
|
||||
<vn-treeview
|
||||
vn-id="treeview"
|
||||
root-label="Locations where it is not distributed"
|
||||
fetch-func="$ctrl.onFetch($item)"
|
||||
sort-func="$ctrl.onSort($a, $b)">
|
||||
<vn-check
|
||||
ng-model="geo.checked"
|
||||
ng-model="item.checked"
|
||||
on-change="$ctrl.onSelection2(value, item)"
|
||||
ng-click="$event.preventDefault()"
|
||||
label="{{::item.name}}">
|
||||
|
@ -254,13 +257,15 @@
|
|||
<input
|
||||
type="button"
|
||||
response="cancel"
|
||||
translate-attr="{value: 'Cancel'}">
|
||||
translate-attr="{value: 'Cancel'}"
|
||||
tabindex="0">
|
||||
</input>
|
||||
<input
|
||||
type="button"
|
||||
ng-if="!$ctrl.isNew"
|
||||
response="delete"
|
||||
translate-attr="{value: 'Delete'}">
|
||||
translate-attr="{value: 'Delete'}"
|
||||
tabindex="0">
|
||||
</input>
|
||||
<button response="accept">
|
||||
<span ng-if="$ctrl.isNew" translate>Add</span>
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import ngModule from '../module';
|
||||
import Section from 'salix/components/section';
|
||||
import './style.scss';
|
||||
|
||||
class Controller extends Section {
|
||||
constructor($element, $, vnWeekDays) {
|
||||
|
@ -29,7 +30,6 @@ class Controller extends Section {
|
|||
if (geo.checked)
|
||||
checkedLines.push(geo);
|
||||
}
|
||||
|
||||
return checkedLines;
|
||||
}
|
||||
|
||||
|
@ -68,7 +68,7 @@ class Controller extends Section {
|
|||
else
|
||||
this.create(type, days, weekday);
|
||||
} else {
|
||||
this.selected = {
|
||||
this.excludeSelected = {
|
||||
type: 'all',
|
||||
dated: days[0]
|
||||
};
|
||||
|
@ -152,20 +152,26 @@ class Controller extends Section {
|
|||
onExcludeResponse(response) {
|
||||
switch (response) {
|
||||
case 'accept': {
|
||||
let selected = this.selected;
|
||||
let type = selected.type;
|
||||
let excludeSelected = this.excludeSelected;
|
||||
let type = excludeSelected.type;
|
||||
if (type == 'all')
|
||||
this.exclusionCreate(this.days);
|
||||
return this.exclusionCreate(this.days);
|
||||
else {
|
||||
const params = [{
|
||||
zoneExclusionFk: 1,
|
||||
geoFk: 1
|
||||
}];
|
||||
this.$http.post(`ZoneExclusionGeos`, params).then(() => this.refresh());
|
||||
}
|
||||
// inserta en zoneExclusionGeo el zoneGeo seleccionado
|
||||
const geoIds = [];
|
||||
for (let zoneGeo of this.checked) {
|
||||
geoIds.push({
|
||||
id: zoneGeo.id
|
||||
});
|
||||
}
|
||||
|
||||
return 1;
|
||||
const params = {
|
||||
zoneFk: parseInt(this.$params.id),
|
||||
date: this.days[0],
|
||||
geoIds: geoIds
|
||||
};
|
||||
return this.$http.post(`Zones/exclusionGeo`, params)
|
||||
.then(() => this.refresh());
|
||||
}
|
||||
}
|
||||
case 'delete':
|
||||
return this.exclusionDelete(this.exclusions);
|
||||
|
@ -229,7 +235,7 @@ class Controller extends Section {
|
|||
|
||||
onSearch() {
|
||||
const params = {search: this._excludeSearch};
|
||||
if (this.excludeType == 'specificLocations') {
|
||||
if (this.excludeSelected.type == 'specificLocations') {
|
||||
this.$.model.applyFilter({}, params).then(() => {
|
||||
const data = this.$.model.data;
|
||||
this.$.treeview.data = data;
|
||||
|
@ -263,7 +269,6 @@ class Controller extends Section {
|
|||
}
|
||||
|
||||
onSelection2(value, item) {
|
||||
console.log(item, this.zone.id);
|
||||
if (value == null)
|
||||
value = undefined;
|
||||
const params = {geoId: item.id, isIncluded: value};
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
@import "variables";
|
||||
|
||||
.width{
|
||||
width: 600px
|
||||
}
|
||||
|
||||
.treeview{
|
||||
max-height: 300px;
|
||||
overflow: auto;
|
||||
}
|
||||
|
|
@ -36,8 +36,6 @@ 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};
|
||||
|
|
Loading…
Reference in New Issue