diff --git a/ayanova/src/api/relative-date-filter-calculator.js b/ayanova/src/api/relative-date-filter-calculator.js index 153ab22d..11a7f6fe 100644 --- a/ayanova/src/api/relative-date-filter-calculator.js +++ b/ayanova/src/api/relative-date-filter-calculator.js @@ -1,81 +1,59 @@ // //TODO: Replace all this server code with equivalent client code +/* Xeslint-disable */ + +/* { name: vm.lt("DateRangeYesterday"), id: "*yesterday*" }, + { name: vm.lt("DateRangeToday"), id: "*today*" }, + { name: vm.lt("DateRangeTomorrow"), id: "*tomorrow*" }, + { name: vm.lt("DateRangeLastWeek"), id: "*lastweek*" }, + { name: vm.lt("DateRangeThisWeek"), id: "*thisweek*" }, + { name: vm.lt("DateRangeNextWeek"), id: "*nextweek*" }, + { name: vm.lt("DateRangeLastMonth"), id: "*lastmonth*" }, + { name: vm.lt("DateRangeThisMonth"), id: "*thismonth*" }, + { name: vm.lt("DateRangeNextMonth"), id: "*nextmonth*" }, + { name: vm.lt("DateRange14DayWindow"), id: "*14daywindow*" }, + { name: vm.lt("DateRangePast"), id: "*past*" }, + { name: vm.lt("DateRangeFuture"), id: "*future*" }, + { name: vm.lt("DateRangeLastYear"), id: "*lastyear*" }, //prior year from jan to dec + { name: vm.lt("DateRangeThisYear"), id: "*thisyear*" }, + { + name: vm.lt("DateRangeInTheLastThreeMonths"), + id: "*last3months*" + }, + { + name: vm.lt("DateRangeInTheLastSixMonths"), + id: "*last6months*" + }, + { name: vm.lt("DateRangePastYear"), id: "*pastyear*" }, //last 365 days + + { name: vm.lt("DateRangePast90Days"), id: "*past90days*" }, + { name: vm.lt("DateRangePast30Days"), id: "*past30days*" }, + { name: vm.lt("DateRangePast24Hours"), id: "*past24hours*" } */ +///////////////////////////////// +// Convert a date token to local +// date range suitable for query +// +export default { + /////////////////////////////// + // token to date range + // + tokenToDates: function(token) { + if (token == null || token.length == 0) { + throw "relative-date-filter-calculator: date token is null or empty"; + } + var dtStart = new Date(); + var dtEnd = new Date(); + switch (token) { + case "*yesterday*": + break; + } + + return { after: dtStart, before: dtEnd }; + } + + //new functions above here +}; -//EXAMPLE FROM INTEGRATION TEST OF BETWEEN TWO DATES -// dynamic fitem = new JObject(); -// fitem.op = Util.OpGreaterThanOrEqualTo; -// fitem.value = new DateTime(2019, 3, 12, 10, 0, 0).ToOffsetAdjustedUniversalTime(); -// items.Add(fitem); - -// fitem = new JObject(); -// fitem.op = Util.OpLessThanOrEqualTo; -// fitem.value = new DateTime(2019, 3, 12, 11, 0, 0).ToOffsetAdjustedUniversalTime(); -// items.Add(fitem); - - -// namespace AyaNova.DataList -// { -// public static class DataListFilterSpecialToken -// { -// public const string Null = "*NULL*"; -// public const string Yesterday = "{[yesterday]}"; -// public const string Today = "{[today]}"; -// public const string Tomorrow = "{[tomorrow]}"; -// public const string LastWeek = "{[lastweek]}"; -// public const string ThisWeek = "{[thisweek]}"; -// public const string NextWeek = "{[nextweek]}"; -// public const string LastMonth = "{[lastmonth]}"; -// public const string ThisMonth = "{[thismonth]}"; -// public const string NextMonth = "{[nextmonth]}"; -// public const string FourteenDayWindow = "{[14daywindow]}"; -// public const string Past = "{[past]}"; -// public const string Future = "{[future]}"; -// public const string LastYear = "{[lastyear]}"; -// public const string ThisYear = "{[thisyear]}"; -// public const string InTheLast3Months = "{[last3months]}"; -// public const string InTheLast6Months = "{[last6months]}"; -// public const string InTheLastYear = "{[lastcalendaryear]}"; - -// //Months THIS year -// public const string January = "{[january]}"; -// public const string February = "{[february]}"; -// public const string March = "{[march]}"; -// public const string April = "{[april]}"; -// public const string May = "{[may]}"; -// public const string June = "{[june]}"; -// public const string July = "{[july]}"; -// public const string August = "{[august]}"; -// public const string September = "{[september]}"; -// public const string October = "{[october]}"; -// public const string November = "{[november]}"; -// public const string December = "{[december]}"; - -// //These TEXT filter tokens were more for paging purposes than anything else -// //however paging is done by numeric range now so will not implement for now -// // public const string AH = "{[ah]}"; -// // public const string IP = "{[ip]}"; -// // public const string QZ = "{[qz]}"; -// // public const string ZeroToThree = "{[03]}"; -// // public const string FourToSix = "{[46]}"; -// // public const string SevenToNine = "{[79]}"; - -// //Don't think I need these -// //public const string LessThanZero = "{[<0]}"; -// // public const string Zero = "{[0]}"; -// //public const string GreaterThanZero = "{[>0]}"; - -// //https://www.klipfolio.com/resources/articles/kpi-timeframe-comparison-metrics - -// //More business time frames - -// public const string YearToDate = "{[yeartodate]}"; - -// public const string Past90Days = "{[past90days]}"; -// public const string Past30Days = "{[past30days]}"; -// public const string Past24Hours = "{[past24hours]}"; - -// } -// } // //############################################################### OLD SERVER FILTERING CODE ########################## diff --git a/ayanova/src/components/gz-data-table.vue b/ayanova/src/components/gz-data-table.vue index 7eec16c8..b07f60e4 100644 --- a/ayanova/src/components/gz-data-table.vue +++ b/ayanova/src/components/gz-data-table.vue @@ -320,6 +320,8 @@ ///////////////////////////////////////////////////////////////////////////////////////////////////////////// /* Xeslint-disable */ //////////////////////////////////////////////////////////////////////////////////////////////////////////// +import relativeDatefilterCalculator from "../api/relative-date-filter-calculator.js"; + export default { data() { return { @@ -897,6 +899,16 @@ function loadFormSettings(vm) { } } +/*//EXAMPLE FROM INTEGRATION TEST OF BETWEEN TWO DATES +// dynamic fitem = new JObject(); +// fitem.op = Util.OpGreaterThanOrEqualTo; +// fitem.value = new DateTime(2019, 3, 12, 10, 0, 0).ToOffsetAdjustedUniversalTime(); +// items.Add(fitem); + +// fitem = new JObject(); +// fitem.op = Util.OpLessThanOrEqualTo; +// fitem.value = new DateTime(2019, 3, 12, 11, 0, 0).ToOffsetAdjustedUniversalTime(); +// items.Add(fitem); */ //////////////////// // function untokenizeListView(lv) { @@ -911,6 +923,8 @@ 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(JSON.parse(lv)); + console.log("test:yesterday"); + console.log(relativeDatefilterCalculator.tokenToDates("*yesterday*")); }