1781-zoneHoliday #994
|
@ -81,11 +81,14 @@ BEGIN
|
||||||
SELECT e.zoneFk, e.`type`, e.dated, e.`started`, e.`ended`, e.weekDays
|
SELECT e.zoneFk, e.`type`, e.dated, e.`started`, e.`ended`, e.weekDays
|
||||||
FROM tZone t
|
FROM tZone t
|
||||||
JOIN zoneEvent e ON e.zoneFk = t.id;
|
JOIN zoneEvent e ON e.zoneFk = t.id;
|
||||||
|
|
||||||
SELECT e.zoneFk, e.dated
|
SELECT e.zoneFk, e.dated
|
||||||
FROM tZone t
|
FROM tZone t
|
||||||
JOIN zoneExclusion e ON e.zoneFk = t.id
|
JOIN zoneExclusion e ON e.zoneFk = t.id
|
||||||
LEFT JOIN zoneExclusionGeo eg ON eg.zoneExclusionFk = e.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;
|
DROP TEMPORARY TABLE tZone;
|
||||||
END$$
|
END$$
|
||||||
|
|
|
@ -0,0 +1,48 @@
|
||||||
|
|
||||||
|
module.exports = Self => {
|
||||||
|
Self.remoteMethod('exclusionGeo', {
|
||||||
|
description: 'Exclude a zoneGeo for a zone',
|
||||||
vicent marked this conversation as resolved
|
|||||||
|
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'
|
||||||
|
}
|
||||||
vicent marked this conversation as resolved
Outdated
carlosjr
commented
geoIds a mi entender son Identificadores de geo por ejemplo: [1, 2, 3, 4] pero poner un nombre que reprensentaria una coleccion de ids y darle de tipo "any" no es buena practica resultando en un manejo de datos confuso. refactoriza los argumentos para que reciba lo que necesita que aparentemente son ids a secas en una array. geoIds a mi entender son Identificadores de geo por ejemplo: [1, 2, 3, 4]
pero poner un nombre que reprensentaria una coleccion de ids y darle de tipo "any" no es buena practica resultando en un manejo de datos confuso.
refactoriza los argumentos para que reciba lo que necesita que aparentemente son ids a secas en una array.
|
|||||||
|
|
||||||
|
],
|
||||||
|
returns: {
|
||||||
|
type: 'object',
|
||||||
|
root: true
|
||||||
|
},
|
||||||
|
http: {
|
||||||
|
path: `/exclusionGeo`,
|
||||||
|
verb: 'POST'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
vicent marked this conversation as resolved
carlosjr
commented
where are my tests and my transaction? where are my tests and my transaction?
|
|||||||
|
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 = `
|
query = `
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM vn.zoneExclusion
|
FROM vn.zoneExclusion e
|
||||||
|
LEFT JOIN vn.zoneExclusionGeo eg ON eg.zoneExclusionFk = e.id
|
||||||
WHERE zoneFk = ?
|
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);
|
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
|
"required": true
|
||||||
},
|
},
|
||||||
"geoFk": {
|
"geoFk": {
|
||||||
"type": "date",
|
"type": "number",
|
||||||
"required": true
|
"required": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@ module.exports = Self => {
|
||||||
require('../methods/zone/deleteZone')(Self);
|
require('../methods/zone/deleteZone')(Self);
|
||||||
require('../methods/zone/includingExpired')(Self);
|
require('../methods/zone/includingExpired')(Self);
|
||||||
require('../methods/zone/getZoneClosing')(Self);
|
require('../methods/zone/getZoneClosing')(Self);
|
||||||
|
require('../methods/zone/exclusionGeo')(Self);
|
||||||
|
|
||||||
Self.validatesPresenceOf('agencyModeFk', {
|
Self.validatesPresenceOf('agencyModeFk', {
|
||||||
message: `Agency cannot be blank`
|
message: `Agency cannot be blank`
|
||||||
|
|
|
@ -75,6 +75,17 @@ class Controller extends Component {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.geoExclusions = {};
|
||||||
|
let geoExclusions = value.geoExclusions;
|
||||||
|
|
||||||
|
if (geoExclusions) {
|
||||||
vicent marked this conversation as resolved
carlosjr
commented
is this testes? is this testes?
|
|||||||
|
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;
|
let events = value.events;
|
||||||
|
|
||||||
if (events) {
|
if (events) {
|
||||||
|
@ -154,13 +165,16 @@ class Controller extends Component {
|
||||||
|
|
||||||
hasEvents(day) {
|
hasEvents(day) {
|
||||||
let stamp = day.getTime();
|
let stamp = day.getTime();
|
||||||
return this.days[stamp] || this.exclusions[stamp];
|
return this.days[stamp] || this.exclusions[stamp] || this.geoExclusions[stamp];
|
||||||
}
|
}
|
||||||
|
|
||||||
getClass(day) {
|
getClass(day) {
|
||||||
let stamp = day.getTime();
|
let stamp = day.getTime();
|
||||||
return this.exclusions[stamp] && !this.days[stamp]
|
if (this.geoExclusions[stamp] && !this.days[stamp])
|
||||||
? 'excluded' : '';
|
return 'geoExcluded';
|
||||||
|
else if (this.exclusions[stamp] && !this.days[stamp])
|
||||||
|
return 'excluded';
|
||||||
|
else return '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Controller.$inject = ['$element', '$scope', 'vnWeekDays'];
|
Controller.$inject = ['$element', '$scope', 'vnWeekDays'];
|
||||||
|
|
|
@ -33,6 +33,9 @@ vn-zone-calendar {
|
||||||
&.excluded .day-number {
|
&.excluded .day-number {
|
||||||
background-color: $color-alert;
|
background-color: $color-alert;
|
||||||
}
|
}
|
||||||
|
&.geoExcluded .day-number {
|
||||||
|
background-color: #33CAFF;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -205,18 +205,18 @@
|
||||||
<tpl-body>
|
<tpl-body>
|
||||||
<vn-date-picker
|
<vn-date-picker
|
||||||
label="Day"
|
label="Day"
|
||||||
ng-model="$ctrl.selected.dated">
|
ng-model="$ctrl.excludeSelected.dated">
|
||||||
</vn-date-picker>
|
</vn-date-picker>
|
||||||
<vn-vertical style="width: 600px;">
|
<vn-vertical class="width">
|
||||||
<vn-vertical class="vn-pb-md">
|
<vn-vertical class="vn-pb-md">
|
||||||
<vn-radio
|
<vn-radio
|
||||||
ng-model="$ctrl.excludeType"
|
ng-model="$ctrl.excludeSelected.type"
|
||||||
label="All"
|
label="All"
|
||||||
on-change="$ctrl.test()"
|
on-change="$ctrl.test()"
|
||||||
val="all">
|
val="all">
|
||||||
</vn-radio>
|
</vn-radio>
|
||||||
<vn-radio
|
<vn-radio
|
||||||
ng-model="$ctrl.excludeType"
|
ng-model="$ctrl.excludeSelected.type"
|
||||||
label="Specific locations"
|
label="Specific locations"
|
||||||
on-change="$ctrl.onSearch($params)"
|
on-change="$ctrl.onSearch($params)"
|
||||||
val="specificLocations">
|
val="specificLocations">
|
||||||
|
@ -227,20 +227,23 @@
|
||||||
url="Zones/{{$ctrl.$params.id}}/getLeaves"
|
url="Zones/{{$ctrl.$params.id}}/getLeaves"
|
||||||
filter="$ctrl.filter">
|
filter="$ctrl.filter">
|
||||||
</vn-crud-model>
|
</vn-crud-model>
|
||||||
<div ng-if="$ctrl.excludeType == 'specificLocations'">
|
<div ng-if="$ctrl.excludeSelected.type == 'specificLocations'">
|
||||||
<vn-textfield
|
<vn-textfield
|
||||||
label="Search"
|
label="Search"
|
||||||
ng-keydown="$ctrl.onKeyDown($event)"
|
ng-keydown="$ctrl.onKeyDown($event)"
|
||||||
ng-model="$ctrl.excludeSearch">
|
ng-model="$ctrl.excludeSearch">
|
||||||
|
<prepend>
|
||||||
|
<vn-icon icon="search"></vn-icon>
|
||||||
|
</prepend>
|
||||||
</vn-textfield>
|
</vn-textfield>
|
||||||
<div style="max-height: 300px; overflow: auto;">
|
<div class="treeview">
|
||||||
<vn-treeview
|
<vn-treeview
|
||||||
vn-id="treeview"
|
vn-id="treeview"
|
||||||
root-label="Locations where it is not distributed"
|
root-label="Locations where it is not distributed"
|
||||||
fetch-func="$ctrl.onFetch($item)"
|
fetch-func="$ctrl.onFetch($item)"
|
||||||
sort-func="$ctrl.onSort($a, $b)">
|
sort-func="$ctrl.onSort($a, $b)">
|
||||||
<vn-check
|
<vn-check
|
||||||
ng-model="geo.checked"
|
ng-model="item.checked"
|
||||||
on-change="$ctrl.onSelection2(value, item)"
|
on-change="$ctrl.onSelection2(value, item)"
|
||||||
ng-click="$event.preventDefault()"
|
ng-click="$event.preventDefault()"
|
||||||
label="{{::item.name}}">
|
label="{{::item.name}}">
|
||||||
|
@ -254,13 +257,15 @@
|
||||||
<input
|
<input
|
||||||
type="button"
|
type="button"
|
||||||
response="cancel"
|
response="cancel"
|
||||||
translate-attr="{value: 'Cancel'}">
|
translate-attr="{value: 'Cancel'}"
|
||||||
|
tabindex="0">
|
||||||
</input>
|
</input>
|
||||||
<input
|
<input
|
||||||
type="button"
|
type="button"
|
||||||
ng-if="!$ctrl.isNew"
|
ng-if="!$ctrl.isNew"
|
||||||
response="delete"
|
response="delete"
|
||||||
translate-attr="{value: 'Delete'}">
|
translate-attr="{value: 'Delete'}"
|
||||||
|
tabindex="0">
|
||||||
</input>
|
</input>
|
||||||
<button response="accept">
|
<button response="accept">
|
||||||
<span ng-if="$ctrl.isNew" translate>Add</span>
|
<span ng-if="$ctrl.isNew" translate>Add</span>
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import ngModule from '../module';
|
import ngModule from '../module';
|
||||||
import Section from 'salix/components/section';
|
import Section from 'salix/components/section';
|
||||||
|
import './style.scss';
|
||||||
|
|
||||||
class Controller extends Section {
|
class Controller extends Section {
|
||||||
constructor($element, $, vnWeekDays) {
|
constructor($element, $, vnWeekDays) {
|
||||||
|
@ -29,7 +30,6 @@ class Controller extends Section {
|
||||||
if (geo.checked)
|
if (geo.checked)
|
||||||
checkedLines.push(geo);
|
checkedLines.push(geo);
|
||||||
}
|
}
|
||||||
|
|
||||||
return checkedLines;
|
return checkedLines;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ class Controller extends Section {
|
||||||
else
|
else
|
||||||
this.create(type, days, weekday);
|
this.create(type, days, weekday);
|
||||||
} else {
|
} else {
|
||||||
this.selected = {
|
this.excludeSelected = {
|
||||||
type: 'all',
|
type: 'all',
|
||||||
dated: days[0]
|
dated: days[0]
|
||||||
};
|
};
|
||||||
|
@ -152,20 +152,26 @@ class Controller extends Section {
|
||||||
onExcludeResponse(response) {
|
onExcludeResponse(response) {
|
||||||
switch (response) {
|
switch (response) {
|
||||||
case 'accept': {
|
case 'accept': {
|
||||||
let selected = this.selected;
|
let excludeSelected = this.excludeSelected;
|
||||||
let type = selected.type;
|
let type = excludeSelected.type;
|
||||||
if (type == 'all')
|
if (type == 'all')
|
||||||
this.exclusionCreate(this.days);
|
return this.exclusionCreate(this.days);
|
||||||
else {
|
else {
|
||||||
const params = [{
|
const geoIds = [];
|
||||||
zoneExclusionFk: 1,
|
for (let zoneGeo of this.checked) {
|
||||||
geoFk: 1
|
geoIds.push({
|
||||||
}];
|
id: zoneGeo.id
|
||||||
this.$http.post(`ZoneExclusionGeos`, params).then(() => this.refresh());
|
});
|
||||||
}
|
}
|
||||||
// inserta en zoneExclusionGeo el zoneGeo seleccionado
|
|
||||||
|
|
||||||
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':
|
case 'delete':
|
||||||
return this.exclusionDelete(this.exclusions);
|
return this.exclusionDelete(this.exclusions);
|
||||||
|
@ -229,7 +235,7 @@ class Controller extends Section {
|
||||||
|
|
||||||
onSearch() {
|
onSearch() {
|
||||||
const params = {search: this._excludeSearch};
|
const params = {search: this._excludeSearch};
|
||||||
if (this.excludeType == 'specificLocations') {
|
if (this.excludeSelected.type == 'specificLocations') {
|
||||||
this.$.model.applyFilter({}, params).then(() => {
|
this.$.model.applyFilter({}, params).then(() => {
|
||||||
const data = this.$.model.data;
|
const data = this.$.model.data;
|
||||||
this.$.treeview.data = data;
|
this.$.treeview.data = data;
|
||||||
|
@ -263,7 +269,6 @@ class Controller extends Section {
|
||||||
}
|
}
|
||||||
|
|
||||||
onSelection2(value, item) {
|
onSelection2(value, item) {
|
||||||
console.log(item, this.zone.id);
|
|
||||||
if (value == null)
|
if (value == null)
|
||||||
value = undefined;
|
value = undefined;
|
||||||
const params = {geoId: item.id, isIncluded: value};
|
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) {
|
onSelection(value, item) {
|
||||||
console.log(item, this.zone.id);
|
|
||||||
|
|
||||||
if (value == null)
|
if (value == null)
|
||||||
value = undefined;
|
value = undefined;
|
||||||
const params = {geoId: item.id, isIncluded: value};
|
const params = {geoId: item.id, isIncluded: value};
|
||||||
|
|
Loading…
Reference in New Issue
from