diff --git a/ayanova/src/api/relative-date-filter-calculator.js b/ayanova/src/api/relative-date-filter-calculator.js index 6fbc0808..ea19028c 100644 --- a/ayanova/src/api/relative-date-filter-calculator.js +++ b/ayanova/src/api/relative-date-filter-calculator.js @@ -5,7 +5,7 @@ { name: vm.lt("DateRangeTomorrow"), id: "**" }, { name: vm.lt("DateRangeLastWeek"), id: "**" }, - { name: vm.lt("DateRangeThisWeek"), id: "*thisweek*" }, + { name: vm.lt("DateRangeThisWeek"), id: "**" }, { name: vm.lt("DateRangeNextWeek"), id: "*nextweek*" }, { name: vm.lt("DateRangeLastMonth"), id: "*lastmonth*" }, { name: vm.lt("DateRangeThisMonth"), id: "*thismonth*" }, @@ -93,10 +93,40 @@ export default { //remove a second for boundary dtAfter = dtAfter.plus({ seconds: -1 }); //set return values from calculated values - // ret.after = dtAfter.toUTC().toString(); - // ret.before = dtBefore.toUTC().toString(); - ret.after = dtAfter.toString(); - ret.before = dtBefore.toString(); + ret.after = dtAfter.toUTC().toString(); + ret.before = dtBefore.toUTC().toString(); + break; + + case "*thisweek*": + //Between Sunday at midnight and Next sunday at midnight + + //Start with today + var dtAfter = dtToday; + //SET dtAfter to Monday start of this week + //go backwards to monday (In Luxon Monday is 1, Sunday is 7) + while (dtAfter.weekday != 1) { + dtAfter = dtAfter.plus({ days: -1 }); + } + //Now go back to sunday last second + dtAfter = dtAfter.plus({ seconds: -1 }); + + //Start with today + var dtBefore = dtToday; + + //SET dtBefore to next monday + //is it monday now? + if (dtBefore.weekday == 1) { + //Monday today? then go to next monday + dtBefore = dtBefore.plus({ days: 7 }); + } else { + //Find next monday... + while (dtBefore.weekday != 1) { + dtBefore = dtBefore.plus({ days: 1 }); + } + } + //set return values from calculated values + ret.after = dtAfter.toUTC().toString(); + ret.before = dtBefore.toUTC().toString(); break; } diff --git a/ayanova/src/components/gz-data-table.vue b/ayanova/src/components/gz-data-table.vue index 2d5a7b74..77fcf3d3 100644 --- a/ayanova/src/components/gz-data-table.vue +++ b/ayanova/src/components/gz-data-table.vue @@ -912,19 +912,20 @@ function loadFormSettings(vm) { //////////////////// // function untokenizeListView(lv) { + //it has one or more tokens + //iterate the array and build a new array with substituted tokens with the correct date and time in them + console.log(lv); + //console.log(JSON.parse(lv)); + console.log("test:thisweek"); + console.log(relativeDatefilterCalculator.tokenToDates("*thisweek*")); //[{"fld":"widgetname"},{"fld":"widgetstartdate","filter":{"items":[{"op":"=","value":"*past90days*","token":true}]}},{"fld":"widgetenddate"}] if (lv == null) { return lv; } //See if it has any date tokens if (lv.indexOf('"token":true') == -1) { - return; + return lv; } - //it has one or more tokens - //iterate the array and build a new array with substituted tokens with the correct date and time in them - console.log(lv); - //console.log(JSON.parse(lv)); - console.log("test:lastweek"); - console.log(relativeDatefilterCalculator.tokenToDates("*lastweek*")); + return lv; }