|
|
@ -1,83 +1,64 @@
|
|
|
|
class globalFunc {
|
|
|
|
class globalFunc {
|
|
|
|
|
|
|
|
DataCheck(arg1, arg2) {
|
|
|
|
|
|
|
|
|
|
|
|
DataCheck(/*luxon, */arg1, arg2) {
|
|
|
|
var iarg1 = arg1
|
|
|
|
|
|
|
|
if (moment(iarg1).isValid()) {iarg1 = arg1.toString()}
|
|
|
|
|
|
|
|
var iarg2 = arg2
|
|
|
|
|
|
|
|
if (moment(iarg2).isValid()) {iarg2 = arg2.toString()}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!Array.isArray(iarg2) && !Array.isArray(iarg1)) {
|
|
|
|
|
|
|
|
var resultdc = this.compareData(iarg1, iarg2)
|
|
|
|
|
|
|
|
} else if (!Array.isArray(iarg1)) {
|
|
|
|
let tempresult = false
|
|
|
|
let tempresult = false
|
|
|
|
let iarg1 = arg1
|
|
|
|
|
|
|
|
let iarg2 = arg2
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
switch(true) {
|
|
|
|
|
|
|
|
case Boolean(arg1.isValid):
|
|
|
|
|
|
|
|
case Boolean(arg2.isValid):
|
|
|
|
|
|
|
|
case (!Boolean(iarg2 instanceof Object) && !Boolean(iarg1 instanceof Object)):
|
|
|
|
|
|
|
|
tempresult = this.compareData(/*luxon, */iarg1, iarg2)
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case (!Boolean(iarg1 instanceof Object)):
|
|
|
|
|
|
|
|
for (let i = 0; i < iarg2.length; i++) {
|
|
|
|
for (let i = 0; i < iarg2.length; i++) {
|
|
|
|
tempresult = tempresult || this.compareData(/*luxon, */iarg1, iarg2[i])
|
|
|
|
tempresult = tempresult || this.compareData(iarg1, iarg2[i])
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
var resultdc = tempresult
|
|
|
|
case (!Boolean(iarg2 instanceof Object)):
|
|
|
|
} else if (!Array.isArray(iarg2)) {
|
|
|
|
|
|
|
|
let tempresult = false
|
|
|
|
for (let i = 0; i < iarg1.length; i++) {
|
|
|
|
for (let i = 0; i < iarg1.length; i++) {
|
|
|
|
tempresult = tempresult || this.compareData(/*luxon, */iarg1[i], iarg2)
|
|
|
|
tempresult = tempresult || this.compareData(iarg1[i], iarg2)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
var resultdc = tempresult
|
|
|
|
default:
|
|
|
|
} else {
|
|
|
|
for (let i = 0; i < iarg2.length; i++) {
|
|
|
|
let tempresult = false
|
|
|
|
for (let j = 0; j < iarg1.length; j++) {
|
|
|
|
for (let i = 0; i < arg2.length; i++) {
|
|
|
|
tempresult = tempresult || this.compareData(/*luxon, */iarg1[j], iarg2[i])
|
|
|
|
for (let j = 0; j < arg1.length; j++) {
|
|
|
|
|
|
|
|
tempresult = tempresult || this.compareData(iarg1[j], iarg2[i])
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
var resultdc = tempresult
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return tempresult
|
|
|
|
return resultdc
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
compareData(/*luxon, */arg1, arg2) {
|
|
|
|
compareData(arg1, arg2) {
|
|
|
|
|
|
|
|
|
|
|
|
let tempresult = false;
|
|
|
|
let tempresult = false;
|
|
|
|
let targ1 = arg1
|
|
|
|
|
|
|
|
let toperator = ""
|
|
|
|
|
|
|
|
let targ2 = arg2
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (this.hasOperator(arg2.toString())) {
|
|
|
|
if (arg2.length > 1 && this.hasOperator(arg2)) {
|
|
|
|
toperator = this.getOperator(arg2)
|
|
|
|
switch(this.getOperator(arg2)) {
|
|
|
|
targ2 = arg2.replace(toperator, "")
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
switch(true) {
|
|
|
|
|
|
|
|
case Boolean(arg1.isValid):
|
|
|
|
|
|
|
|
targ1 = arg1.toString() //startOf("day")
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case Boolean(arg2.isValid):
|
|
|
|
|
|
|
|
targ2 = arg2.toString() // startOf("day") //(arg2.isValid) ? arg2.startOf("day") : (luxon.DateTime.fromISO(`${targ2}`)).startOf("day")
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case (arg1.length == 0):
|
|
|
|
|
|
|
|
targ1 = ''
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
switch(toperator) {
|
|
|
|
|
|
|
|
case '<':
|
|
|
|
case '<':
|
|
|
|
tempresult = (targ1 < targ2)
|
|
|
|
tempresult = (parseFloat(arg1) < parseFloat(arg2.replace(this.getOperator(arg2), "")))
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case '<=':
|
|
|
|
case '<=':
|
|
|
|
tempresult = (targ1 <= targ2)
|
|
|
|
tempresult = (parseFloat(arg1) <= parseFloat(arg2.replace(this.getOperator(arg2), "")))
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case '>':
|
|
|
|
case '>':
|
|
|
|
tempresult = (targ1 > targ2)
|
|
|
|
tempresult = (parseFloat(arg1) > parseFloat(arg2.replace(this.getOperator(arg2), "")))
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case '>=':
|
|
|
|
case '>=':
|
|
|
|
tempresult = (targ1 >= targ2)
|
|
|
|
tempresult = (parseFloat(arg1) >= parseFloat(arg2.replace(this.getOperator(arg2), "")))
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case '!':
|
|
|
|
case '!':
|
|
|
|
tempresult = (typeof targ1 === 'string' || targ1 instanceof String) ? !(targ1.search(new RegExp(targ2, "i")) > -1) : (targ1 != targ2)
|
|
|
|
if (isNaN(arg2.replace("!", ""))) {
|
|
|
|
break;
|
|
|
|
tempresult = !(arg1.search(new RegExp(arg2, "i")) > -1)
|
|
|
|
default:
|
|
|
|
} else {tempresult = (parseFloat(arg1) != parseFloat(arg2.replace(this.getOperator(arg2), "")))}
|
|
|
|
tempresult = (typeof targ1 === 'string' || targ1 instanceof String) ? (targ1.search(new RegExp(targ2, "i")) > -1) : (targ1 == targ2)
|
|
|
|
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {tempresult = (arg1.search(new RegExp(arg2, "i")) > -1)}
|
|
|
|
|
|
|
|
|
|
|
|
return tempresult
|
|
|
|
return tempresult
|
|
|
|
|
|
|
|
|
|
|
@ -89,7 +70,6 @@ class globalFunc {
|
|
|
|
case '<':
|
|
|
|
case '<':
|
|
|
|
case '>':
|
|
|
|
case '>':
|
|
|
|
case '!':
|
|
|
|
case '!':
|
|
|
|
case '=':
|
|
|
|
|
|
|
|
tempresult = true
|
|
|
|
tempresult = true
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -97,8 +77,11 @@ class globalFunc {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
getOperator(arg1) {
|
|
|
|
getOperator(arg1) {
|
|
|
|
|
|
|
|
let tempresult = arg1.charAt(0);
|
|
|
|
return (this.hasOperator(arg1.charAt(1))) ? arg1.charAt(0) + arg1.charAt(1) : arg1.charAt(0);
|
|
|
|
if (this.hasOperator(arg1.charAt(1))) {
|
|
|
|
|
|
|
|
tempresult = tempresult + arg1.charAt(1)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return tempresult
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
BuildList(arg1, construct) {
|
|
|
|
BuildList(arg1, construct) {
|
|
|
@ -121,7 +104,7 @@ class globalFunc {
|
|
|
|
|
|
|
|
|
|
|
|
let TempS = ""
|
|
|
|
let TempS = ""
|
|
|
|
|
|
|
|
|
|
|
|
if (arg2 instanceof Object) {
|
|
|
|
if (Array.isArray(arg2)) {
|
|
|
|
for (let i = 0; i < arg1.length; i++) {
|
|
|
|
for (let i = 0; i < arg1.length; i++) {
|
|
|
|
if (Boolean(arg1[i])) {
|
|
|
|
if (Boolean(arg1[i])) {
|
|
|
|
if (TempS == "") {
|
|
|
|
if (TempS == "") {
|
|
|
@ -151,8 +134,11 @@ class globalFunc {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Get1stArg(arg3) {
|
|
|
|
Get1stArg(arg3) {
|
|
|
|
|
|
|
|
if (!Array.isArray(arg3)) {
|
|
|
|
return ((arg3 instanceof Object) || (arg3 instanceof Array)) ? arg3[0] : arg3
|
|
|
|
return arg3
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
return arg3[0]
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
topLevelFilter(pobj, DocType, subType) {
|
|
|
|
topLevelFilter(pobj, DocType, subType) {
|
|
|
@ -169,7 +155,7 @@ class globalFunc {
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
IsInSearch(/*luxon, */pobj, DocType, darray, iarray) {
|
|
|
|
IsInSearch(pobj, DocType, darray, iarray) {
|
|
|
|
|
|
|
|
|
|
|
|
let ilength = iarray.length;
|
|
|
|
let ilength = iarray.length;
|
|
|
|
let result = true
|
|
|
|
let result = true
|
|
|
@ -183,7 +169,7 @@ class globalFunc {
|
|
|
|
if (Boolean(iarray[i])) {
|
|
|
|
if (Boolean(iarray[i])) {
|
|
|
|
let pProp = this.GetpProp(pobj, DocType, darray[i])
|
|
|
|
let pProp = this.GetpProp(pobj, DocType, darray[i])
|
|
|
|
if (!Boolean(pProp)) { result = result && false } else {
|
|
|
|
if (!Boolean(pProp)) { result = result && false } else {
|
|
|
|
result = result && this.DataCheck(/*luxon, */pProp, iarray[i])
|
|
|
|
result = result && this.DataCheck(pProp, iarray[i])
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {result = result && true}
|
|
|
|
} else {result = result && true}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -192,7 +178,7 @@ class globalFunc {
|
|
|
|
if (Boolean(iarray[i])) {
|
|
|
|
if (Boolean(iarray[i])) {
|
|
|
|
let pProp = this.GetpProp(pobj, DocType, darray[i])
|
|
|
|
let pProp = this.GetpProp(pobj, DocType, darray[i])
|
|
|
|
if (!Boolean(pProp)) { result = result && false } else {
|
|
|
|
if (!Boolean(pProp)) { result = result && false } else {
|
|
|
|
result = result && this.DataCheck(/*luxon, */pProp, iarray[i])
|
|
|
|
result = result && this.DataCheck(pProp, iarray[i])
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {result = result && true}
|
|
|
|
} else {result = result && true}
|
|
|
|
break;
|
|
|
|
break;
|
|
|
@ -202,14 +188,14 @@ class globalFunc {
|
|
|
|
return result
|
|
|
|
return result
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
getTable(dv, /*luxon, */DocType, darray, iarray, tabletype) {
|
|
|
|
getTable(dv, DocType, darray, iarray, tabletype) {
|
|
|
|
|
|
|
|
|
|
|
|
let page = dv.pages()
|
|
|
|
let page = dv.pages()
|
|
|
|
.filter(p => p && this.topLevelFilter(p, DocType, 0))
|
|
|
|
.filter(p => p && this.topLevelFilter(p, DocType, 0))
|
|
|
|
.where(p => p && this.IsInSearch(/*luxon, */p, DocType, darray, iarray))
|
|
|
|
.where(p => p && this.IsInSearch(p, DocType, darray, iarray))
|
|
|
|
|
|
|
|
|
|
|
|
if (page.length == 0) {
|
|
|
|
if (typeof page == 'undefined' || typeof page == 'null' || page.length === 0) {
|
|
|
|
return this.EmptyQueryMessage(dv)
|
|
|
|
return this.EmptyQueryMessage()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
dv.table(this.GetTableHeaders(DocType, tabletype), page
|
|
|
|
dv.table(this.GetTableHeaders(DocType, tabletype), page
|
|
|
@ -218,7 +204,7 @@ class globalFunc {
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
EmptyQueryMessage(dv) {
|
|
|
|
EmptyQueryMessage() {
|
|
|
|
return dv.el('b', '⚠️ Warning:\nNo result matching your query!')
|
|
|
|
return dv.el('b', '⚠️ Warning:\nNo result matching your query!')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -443,9 +429,7 @@ class globalFunc {
|
|
|
|
toEmoji(label) {
|
|
|
|
toEmoji(label) {
|
|
|
|
let tempresult = ""
|
|
|
|
let tempresult = ""
|
|
|
|
|
|
|
|
|
|
|
|
//other test for below: typeof label == 'object'
|
|
|
|
if (Array.isArray(label)) {
|
|
|
|
//return Object.entries(label)
|
|
|
|
|
|
|
|
if (label instanceof Object) {
|
|
|
|
|
|
|
|
for (let i = 0; i < label.length; i++) {
|
|
|
|
for (let i = 0; i < label.length; i++) {
|
|
|
|
if (tempresult == '') {
|
|
|
|
if (tempresult == '') {
|
|
|
|
tempresult = this.getEmoji(label[i]);
|
|
|
|
tempresult = this.getEmoji(label[i]);
|
|
|
@ -534,10 +518,6 @@ class globalFunc {
|
|
|
|
case 'Colombia':
|
|
|
|
case 'Colombia':
|
|
|
|
tempresult = "🇨🇴"
|
|
|
|
tempresult = "🇨🇴"
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case 'El Salvador':
|
|
|
|
|
|
|
|
case 'ElSalvador':
|
|
|
|
|
|
|
|
tempresult = "🇸🇻"
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'Pub':
|
|
|
|
case 'Pub':
|
|
|
|
tempresult = "🍺"
|
|
|
|
tempresult = "🍺"
|
|
|
|
break;
|
|
|
|
break;
|
|
|
@ -1030,7 +1010,6 @@ class globalFunc {
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return result
|
|
|
|
return result
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|