feat(zone): filter calendar
gitea/salix/pipeline/head There was a failure building this commit Details

This commit is contained in:
Alex Moreno 2021-11-02 07:55:35 +01:00
parent f7e2182722
commit b2dd9e6076
3 changed files with 37 additions and 15 deletions

View File

@ -0,0 +1,21 @@
module.exports = Self => {
Self.remoteMethodCtx('getEventsFiltered', {
description: 'Get events filtered for zone and date',
accessType: 'READ',
returns: {
type: 'object',
root: true
},
http: {
path: `/getEventsFiltered`,
verb: 'GET'
}
});
Self.getEventsFiltered = async(zoneFk, started, ended) => {
query = `CALL vn.zone_getEventsFiltered(?,?,?)`;
const [events, exclusions] = await Self.rawSql(query, [zoneFk, started, ended]);
console.log(events);
return {events, exclusions};
};
};

View File

@ -2,6 +2,7 @@ module.exports = Self => {
require('../methods/zone/clone')(Self);
require('../methods/zone/getLeaves')(Self);
require('../methods/zone/getEvents')(Self);
require('../methods/zone/getEventsFiltered')(Self);
require('../methods/zone/toggleIsIncluded')(Self);
require('../methods/zone/getUpcomingDeliveries')(Self);
require('../methods/zone/deleteZone')(Self);

View File

@ -12,22 +12,22 @@ class Controller extends Section {
this.refresh();
}
get path() {
return `Zones/${this.$params.id}/events`;
}
get exclusionsPath() {
return `Zones/${this.$params.id}/exclusions`;
}
refresh() {
let data = {};
this.$q.all([
this.$http.get(this.path)
.then(res => data.events = res.data),
this.$http.get(this.exclusionsPath)
.then(res => data.exclusions = res.data)
]).finally(() => {
this.$.data = null;
let params = {
ended: '2022-01-31',
started: '2021-10-01',
zoneFk: 10
};
let ended = '2022-01-31';
let started = '2021-10-01';
let zoneFk = 10;
// let filter = encodeURIComponent(JSON.stringify(params));
let path = `Zones/getEventsFiltered?zoneFk=${zoneFk}&started=${started}&ended=${ended}`;
console.log(path);
this.$http.get(path).then(res => {
console.log(res.data);
let data = res.data;
this.$.data = data;
});
}