This commit is contained in:
@@ -911,21 +911,87 @@ function loadFormSettings(vm) {
|
|||||||
// items.Add(fitem); */
|
// items.Add(fitem); */
|
||||||
////////////////////
|
////////////////////
|
||||||
//
|
//
|
||||||
function untokenizeListView(lv) {
|
function untokenizeListView(lvJson) {
|
||||||
//it has one or more tokens
|
//if 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
|
//iterate the array and build a new array with substituted tokens with the correct date and time in them
|
||||||
//console.log(lv);
|
console.log(lvJson);
|
||||||
//console.log(JSON.parse(lv));
|
|
||||||
console.log("test:past90days");
|
//format of a date token filter
|
||||||
console.log(relativeDatefilterCalculator.tokenToDates("*past90days*"));
|
|
||||||
//[{"fld":"widgetname"},{"fld":"widgetstartdate","filter":{"items":[{"op":"=","value":"*past90days*","token":true}]}},{"fld":"widgetenddate"}]
|
//[{"fld":"widgetname"},{"fld":"widgetstartdate","filter":{"items":[{"op":"=","value":"*past90days*","token":true}]}},{"fld":"widgetenddate"}]
|
||||||
if (lv == null) {
|
if (lvJson == null) {
|
||||||
return lv;
|
return lvJson;
|
||||||
}
|
}
|
||||||
//See if it has any date tokens
|
//See if it has any date tokens
|
||||||
if (lv.indexOf('"token":true') == -1) {
|
if (lvJson.indexOf('"token":true') == -1) {
|
||||||
return lv;
|
return lvJson;
|
||||||
}
|
}
|
||||||
return lv;
|
|
||||||
}
|
console.log("WE HAVE TOKENS...PROCESSING...");
|
||||||
|
//we have one or more tokens, substitute them in the filter array
|
||||||
|
var ret = [];
|
||||||
|
var lv = JSON.parse(lvJson);
|
||||||
|
|
||||||
|
//iterate the incoming and copy to the outgoing directly
|
||||||
|
//except if a date token filter then substitute our own filter object in place
|
||||||
|
for (var ilv = 0; ilv < lv.length; ilv++) {
|
||||||
|
//listview object
|
||||||
|
var lvo = lv[ilv];
|
||||||
|
//instantiate return object
|
||||||
|
var reto = {};
|
||||||
|
//copy over field name to return object
|
||||||
|
reto.fld = lvo.fld;
|
||||||
|
//does it have a filter?
|
||||||
|
if (lvo.filter) {
|
||||||
|
//yes, so copy / transform as required
|
||||||
|
|
||||||
|
//create an empty filter items array on return object
|
||||||
|
reto.filter = { items: [] };
|
||||||
|
|
||||||
|
//"any" property set?
|
||||||
|
if (lvo.filter.any) {
|
||||||
|
reto.filter.any = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
//iterate the filter items in the source lvo object
|
||||||
|
for (var j = 0; j < lvo.filter.items.length; j++) {
|
||||||
|
//get this filter item
|
||||||
|
var fi = lvo.filter.items[j];
|
||||||
|
//no token shortcut
|
||||||
|
if (!fi.token) {
|
||||||
|
//just copy it out
|
||||||
|
reto.filter.items.push(fi);
|
||||||
|
} else {
|
||||||
|
//it has a date token so let's build it out
|
||||||
|
//filter item value contains the token, op is always equals
|
||||||
|
var filterDates = relativeDatefilterCalculator.tokenToDates(fi.value);
|
||||||
|
//create and add a new filter item for each not undefined value
|
||||||
|
//{ after: undefined, before: undefined }
|
||||||
|
//AFTER DATE?
|
||||||
|
if (filterDates.after) {
|
||||||
|
reto.filter.items.push({
|
||||||
|
op: ">=", //GreaterThanOrEqualTo
|
||||||
|
value: filterDates.after
|
||||||
|
});
|
||||||
|
}
|
||||||
|
//BEFORE DATE?
|
||||||
|
if (filterDates.before) {
|
||||||
|
reto.filter.items.push({
|
||||||
|
op: "<=", //LessThanOrEqualTo
|
||||||
|
value: filterDates.before
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//end of has filter if condition
|
||||||
|
}
|
||||||
|
|
||||||
|
//push the return object into the return array
|
||||||
|
ret.push(reto);
|
||||||
|
//end of iterate lv loop
|
||||||
|
}
|
||||||
|
console.log("After processing:");
|
||||||
|
console.log(JSON.stringify(ret));
|
||||||
|
return JSON.stringify(ret);
|
||||||
|
} //[{"fld":"widgetname"},{"fld":"widgetstartdate","filter":{"items":[{"op":"=","value":"*past90days*","token":true}]}},{"fld":"widgetenddate"}]
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user