diff --git a/src/CONST/index.ts b/src/CONST/index.ts index fc18e9a11613..4b9943598c95 100755 --- a/src/CONST/index.ts +++ b/src/CONST/index.ts @@ -6165,6 +6165,10 @@ const CONST = { TRIP: 'trip', CHAT: 'chat', }, + ACTION_FILTERS: { + PAY: 'pay', + EXPORT: 'export', + }, ACTION_TYPES: { VIEW: 'view', REVIEW: 'review', @@ -6305,6 +6309,7 @@ const CONST = { REIMBURSABLE: 'reimbursable', BILLABLE: 'billable', POLICY_ID: 'policyID', + ACTION: 'action', }, TAG_EMPTY_VALUE: 'none', CATEGORY_EMPTY_VALUE: 'none,Uncategorized', @@ -6347,6 +6352,7 @@ const CONST = { ASSIGNEE: 'assignee', REIMBURSABLE: 'reimbursable', BILLABLE: 'billable', + ACTION: 'action', }, DATE_MODIFIERS: { BEFORE: 'Before', diff --git a/src/components/Search/SearchAutocompleteList.tsx b/src/components/Search/SearchAutocompleteList.tsx index cbc61c4be97e..880a615c7344 100644 --- a/src/components/Search/SearchAutocompleteList.tsx +++ b/src/components/Search/SearchAutocompleteList.tsx @@ -449,6 +449,12 @@ function SearchAutocompleteList( mapKey: CONST.SEARCH.SYNTAX_FILTER_KEYS.POLICY_ID, })); } + case CONST.SEARCH.SYNTAX_FILTER_KEYS.ACTION: { + return Object.values(CONST.SEARCH.ACTION_FILTERS).map((status) => ({ + filterKey: CONST.SEARCH.SEARCH_USER_FRIENDLY_KEYS.ACTION, + text: status, + })); + } default: { return []; } diff --git a/src/libs/SearchAutocompleteUtils.ts b/src/libs/SearchAutocompleteUtils.ts index 51adfd47b543..513038d225c3 100644 --- a/src/libs/SearchAutocompleteUtils.ts +++ b/src/libs/SearchAutocompleteUtils.ts @@ -133,6 +133,7 @@ function filterOutRangesWithCorrectValue( }) as string[]; const groupByList = Object.values(CONST.SEARCH.GROUP_BY) as string[]; const booleanList = Object.values(CONST.SEARCH.BOOLEAN) as string[]; + const actionList = Object.values(CONST.SEARCH.ACTION_FILTERS) as string[]; switch (range.key) { case CONST.SEARCH.SYNTAX_FILTER_KEYS.IN: @@ -157,6 +158,8 @@ function filterOutRangesWithCorrectValue( return expenseTypeList.includes(range.value); case CONST.SEARCH.SYNTAX_ROOT_KEYS.STATUS: return statusList.includes(range.value); + case CONST.SEARCH.SYNTAX_FILTER_KEYS.ACTION: + return actionList.includes(range.value); case CONST.SEARCH.SYNTAX_FILTER_KEYS.CATEGORY: return categoryList.get().includes(range.value); case CONST.SEARCH.SYNTAX_FILTER_KEYS.TAG: diff --git a/src/libs/SearchParser/autocompleteParser.js b/src/libs/SearchParser/autocompleteParser.js index 85b792aa5ae2..02c312524ced 100644 --- a/src/libs/SearchParser/autocompleteParser.js +++ b/src/libs/SearchParser/autocompleteParser.js @@ -226,14 +226,15 @@ function peg$parse(input, options) { var peg$c40 = "assignee"; var peg$c41 = "createdby"; var peg$c42 = "created-by"; - var peg$c43 = "!="; - var peg$c44 = ">="; - var peg$c45 = ">"; - var peg$c46 = "<="; - var peg$c47 = "<"; - var peg$c48 = "\u201C"; - var peg$c49 = "\u201D"; - var peg$c50 = "\""; + var peg$c43 = "action"; + var peg$c44 = "!="; + var peg$c45 = ">="; + var peg$c46 = ">"; + var peg$c47 = "<="; + var peg$c48 = "<"; + var peg$c49 = "\u201C"; + var peg$c50 = "\u201D"; + var peg$c51 = "\""; var peg$r0 = /^[:=]/; var peg$r1 = /^[^ ,\t\n\r\xA0]/; @@ -291,30 +292,31 @@ function peg$parse(input, options) { var peg$e41 = peg$literalExpectation("assignee", true); var peg$e42 = peg$literalExpectation("createdBy", true); var peg$e43 = peg$literalExpectation("created-by", true); - var peg$e44 = peg$otherExpectation("operator"); - var peg$e45 = peg$classExpectation([":", "="], false, false); - var peg$e46 = peg$literalExpectation("!=", false); - var peg$e47 = peg$literalExpectation(">=", false); - var peg$e48 = peg$literalExpectation(">", false); - var peg$e49 = peg$literalExpectation("<=", false); - var peg$e50 = peg$literalExpectation("<", false); - var peg$e51 = peg$otherExpectation("word"); - var peg$e52 = peg$classExpectation([" ", ",", "\t", "\n", "\r", "\xA0"], true, false); - var peg$e53 = peg$otherExpectation("whitespace"); - var peg$e54 = peg$classExpectation([" ", "\t", "\r", "\n", "\xA0"], false, false); - var peg$e55 = peg$otherExpectation("quote"); - var peg$e56 = peg$classExpectation([" ", ",", "\"", "\u201D", "\u201C", "\t", "\n", "\r", "\xA0"], true, false); - var peg$e57 = peg$classExpectation(["\"", ["\u201C", "\u201D"]], false, false); - var peg$e58 = peg$classExpectation(["\"", "\u201D", "\u201C", "\r", "\n"], true, false); - var peg$e59 = peg$literalExpectation("\u201C", false); - var peg$e60 = peg$literalExpectation("\u201D", false); - var peg$e61 = peg$literalExpectation("\"", false); - var peg$e62 = peg$classExpectation([" ", "\t", "\n", "\r", "\xA0", ["a", "z"], ["A", "Z"], ["0", "9"]], false, false); - var peg$e63 = peg$classExpectation([["a", "z"], ["A", "Z"], ["0", "9"]], false, false); - var peg$e64 = peg$classExpectation([" ", "\t", "\n", "\r", "\xA0"], false, false); - var peg$e65 = peg$classExpectation([" ", "\t", "\n", "\r", "\xA0", ["a", "z"], ["A", "Z"]], false, false); - var peg$e66 = peg$anyExpectation(); - var peg$e67 = peg$classExpectation([","], false, false); + var peg$e44 = peg$literalExpectation("action", true); + var peg$e45 = peg$otherExpectation("operator"); + var peg$e46 = peg$classExpectation([":", "="], false, false); + var peg$e47 = peg$literalExpectation("!=", false); + var peg$e48 = peg$literalExpectation(">=", false); + var peg$e49 = peg$literalExpectation(">", false); + var peg$e50 = peg$literalExpectation("<=", false); + var peg$e51 = peg$literalExpectation("<", false); + var peg$e52 = peg$otherExpectation("word"); + var peg$e53 = peg$classExpectation([" ", ",", "\t", "\n", "\r", "\xA0"], true, false); + var peg$e54 = peg$otherExpectation("whitespace"); + var peg$e55 = peg$classExpectation([" ", "\t", "\r", "\n", "\xA0"], false, false); + var peg$e56 = peg$otherExpectation("quote"); + var peg$e57 = peg$classExpectation([" ", ",", "\"", "\u201D", "\u201C", "\t", "\n", "\r", "\xA0"], true, false); + var peg$e58 = peg$classExpectation(["\"", ["\u201C", "\u201D"]], false, false); + var peg$e59 = peg$classExpectation(["\"", "\u201D", "\u201C", "\r", "\n"], true, false); + var peg$e60 = peg$literalExpectation("\u201C", false); + var peg$e61 = peg$literalExpectation("\u201D", false); + var peg$e62 = peg$literalExpectation("\"", false); + var peg$e63 = peg$classExpectation([" ", "\t", "\n", "\r", "\xA0", ["a", "z"], ["A", "Z"], ["0", "9"]], false, false); + var peg$e64 = peg$classExpectation([["a", "z"], ["A", "Z"], ["0", "9"]], false, false); + var peg$e65 = peg$classExpectation([" ", "\t", "\n", "\r", "\xA0"], false, false); + var peg$e66 = peg$classExpectation([" ", "\t", "\n", "\r", "\xA0", ["a", "z"], ["A", "Z"]], false, false); + var peg$e67 = peg$anyExpectation(); + var peg$e68 = peg$classExpectation([","], false, false); var peg$f0 = function(ranges) { return { autocomplete, ranges }; }; var peg$f1 = function(filters) { return filters.filter(Boolean).flat(); }; @@ -403,28 +405,29 @@ function peg$parse(input, options) { var peg$f37 = function() { return "title"; }; var peg$f38 = function() { return "assignee"; }; var peg$f39 = function() { return "createdBy"; }; - var peg$f40 = function() { return "eq"; }; - var peg$f41 = function() { return "neq"; }; - var peg$f42 = function() { return "gte"; }; - var peg$f43 = function() { return "gt"; }; - var peg$f44 = function() { return "lte"; }; - var peg$f45 = function() { return "lt"; }; - var peg$f46 = function(o) { + var peg$f40 = function() { return "action"; }; + var peg$f41 = function() { return "eq"; }; + var peg$f42 = function() { return "neq"; }; + var peg$f43 = function() { return "gte"; }; + var peg$f44 = function() { return "gt"; }; + var peg$f45 = function() { return "lte"; }; + var peg$f46 = function() { return "lt"; }; + var peg$f47 = function(o) { if (nameOperator) { expectingNestedQuote = (o === "eq"); // Use simple parser if no valid operator is found } return o; }; - var peg$f47 = function(chars) { return chars.join("").trim(); }; - var peg$f48 = function() { return "and"; }; - var peg$f49 = function() { return expectingNestedQuote; }; - var peg$f50 = function(start, inner, end) { //handle no-breaking space + var peg$f48 = function(chars) { return chars.join("").trim(); }; + var peg$f49 = function() { return "and"; }; + var peg$f50 = function() { return expectingNestedQuote; }; + var peg$f51 = function(start, inner, end) { //handle no-breaking space return [...start, '"', ...inner, '"', ...end].join(""); }; - var peg$f51 = function(start) {return "“"}; - var peg$f52 = function(start) {return "”"}; - var peg$f53 = function(start) {return "\""}; - var peg$f54 = function(start, inner, end) { + var peg$f52 = function(start) {return "“"}; + var peg$f53 = function(start) {return "”"}; + var peg$f54 = function(start) {return "\""}; + var peg$f55 = function(start, inner, end) { return [...start, '"', ...inner, '"'].join(""); }; var peg$currPos = options.peg$currPos | 0; @@ -745,6 +748,9 @@ function peg$parse(input, options) { s1 = peg$parsebillable(); if (s1 === peg$FAILED) { s1 = peg$parsepolicyID(); + if (s1 === peg$FAILED) { + s1 = peg$parseaction(); + } } } } @@ -1607,6 +1613,26 @@ function peg$parse(input, options) { return s0; } + function peg$parseaction() { + var s0, s1; + + s0 = peg$currPos; + s1 = input.substr(peg$currPos, 6); + if (s1.toLowerCase() === peg$c43) { + peg$currPos += 6; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e44); } + } + if (s1 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$f40(); + } + s0 = s1; + + return s0; + } + function peg$parseoperator() { var s0, s1; @@ -1617,81 +1643,81 @@ function peg$parse(input, options) { peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e45); } + if (peg$silentFails === 0) { peg$fail(peg$e46); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f40(); + s1 = peg$f41(); } s0 = s1; if (s0 === peg$FAILED) { s0 = peg$currPos; - if (input.substr(peg$currPos, 2) === peg$c43) { - s1 = peg$c43; + if (input.substr(peg$currPos, 2) === peg$c44) { + s1 = peg$c44; peg$currPos += 2; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e46); } + if (peg$silentFails === 0) { peg$fail(peg$e47); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f41(); + s1 = peg$f42(); } s0 = s1; if (s0 === peg$FAILED) { s0 = peg$currPos; - if (input.substr(peg$currPos, 2) === peg$c44) { - s1 = peg$c44; + if (input.substr(peg$currPos, 2) === peg$c45) { + s1 = peg$c45; peg$currPos += 2; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e47); } + if (peg$silentFails === 0) { peg$fail(peg$e48); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f42(); + s1 = peg$f43(); } s0 = s1; if (s0 === peg$FAILED) { s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 62) { - s1 = peg$c45; + s1 = peg$c46; peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e48); } + if (peg$silentFails === 0) { peg$fail(peg$e49); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f43(); + s1 = peg$f44(); } s0 = s1; if (s0 === peg$FAILED) { s0 = peg$currPos; - if (input.substr(peg$currPos, 2) === peg$c46) { - s1 = peg$c46; + if (input.substr(peg$currPos, 2) === peg$c47) { + s1 = peg$c47; peg$currPos += 2; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e49); } + if (peg$silentFails === 0) { peg$fail(peg$e50); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f44(); + s1 = peg$f45(); } s0 = s1; if (s0 === peg$FAILED) { s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 60) { - s1 = peg$c47; + s1 = peg$c48; peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e50); } + if (peg$silentFails === 0) { peg$fail(peg$e51); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f45(); + s1 = peg$f46(); } s0 = s1; } @@ -1702,7 +1728,7 @@ function peg$parse(input, options) { peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e44); } + if (peg$silentFails === 0) { peg$fail(peg$e45); } } return s0; @@ -1715,7 +1741,7 @@ function peg$parse(input, options) { s1 = peg$parseoperator(); if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f46(s1); + s1 = peg$f47(s1); } s0 = s1; @@ -1733,7 +1759,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e52); } + if (peg$silentFails === 0) { peg$fail(peg$e53); } } if (s2 !== peg$FAILED) { while (s2 !== peg$FAILED) { @@ -1743,7 +1769,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e52); } + if (peg$silentFails === 0) { peg$fail(peg$e53); } } } } else { @@ -1751,13 +1777,13 @@ function peg$parse(input, options) { } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f47(s1); + s1 = peg$f48(s1); } s0 = s1; peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e51); } + if (peg$silentFails === 0) { peg$fail(peg$e52); } } return s0; @@ -1769,7 +1795,7 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = peg$parse_(); peg$savedPos = s0; - s1 = peg$f48(); + s1 = peg$f49(); s0 = s1; return s0; @@ -1785,7 +1811,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e54); } + if (peg$silentFails === 0) { peg$fail(peg$e55); } } while (s1 !== peg$FAILED) { s0.push(s1); @@ -1794,12 +1820,12 @@ function peg$parse(input, options) { peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e54); } + if (peg$silentFails === 0) { peg$fail(peg$e55); } } } peg$silentFails--; s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e53); } + if (peg$silentFails === 0) { peg$fail(peg$e54); } return s0; } @@ -1809,7 +1835,7 @@ function peg$parse(input, options) { s0 = peg$currPos; peg$savedPos = peg$currPos; - s1 = peg$f49(); + s1 = peg$f50(); if (s1) { s1 = undefined; } else { @@ -1846,7 +1872,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e56); } + if (peg$silentFails === 0) { peg$fail(peg$e57); } } while (s2 !== peg$FAILED) { s1.push(s2); @@ -1855,7 +1881,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e56); } + if (peg$silentFails === 0) { peg$fail(peg$e57); } } } s2 = input.charAt(peg$currPos); @@ -1863,7 +1889,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e57); } + if (peg$silentFails === 0) { peg$fail(peg$e58); } } if (s2 !== peg$FAILED) { s3 = []; @@ -1872,7 +1898,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e58); } + if (peg$silentFails === 0) { peg$fail(peg$e59); } } while (s4 !== peg$FAILED) { s3.push(s4); @@ -1881,7 +1907,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e58); } + if (peg$silentFails === 0) { peg$fail(peg$e59); } } } s4 = input.charAt(peg$currPos); @@ -1889,7 +1915,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e57); } + if (peg$silentFails === 0) { peg$fail(peg$e58); } } if (s4 !== peg$FAILED) { s5 = []; @@ -1898,7 +1924,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e52); } + if (peg$silentFails === 0) { peg$fail(peg$e53); } } while (s6 !== peg$FAILED) { s5.push(s6); @@ -1907,11 +1933,11 @@ function peg$parse(input, options) { peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e52); } + if (peg$silentFails === 0) { peg$fail(peg$e53); } } } peg$savedPos = s0; - s0 = peg$f50(s1, s3, s5); + s0 = peg$f51(s1, s3, s5); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -1923,7 +1949,7 @@ function peg$parse(input, options) { peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e55); } + if (peg$silentFails === 0) { peg$fail(peg$e56); } } return s0; @@ -1940,7 +1966,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e56); } + if (peg$silentFails === 0) { peg$fail(peg$e57); } } while (s2 !== peg$FAILED) { s1.push(s2); @@ -1949,7 +1975,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e56); } + if (peg$silentFails === 0) { peg$fail(peg$e57); } } } s2 = input.charAt(peg$currPos); @@ -1957,7 +1983,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e57); } + if (peg$silentFails === 0) { peg$fail(peg$e58); } } if (s2 !== peg$FAILED) { s3 = []; @@ -1966,7 +1992,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e58); } + if (peg$silentFails === 0) { peg$fail(peg$e59); } } if (s4 === peg$FAILED) { s4 = peg$currPos; @@ -1982,15 +2008,15 @@ function peg$parse(input, options) { } if (s5 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 8220) { - s6 = peg$c48; + s6 = peg$c49; peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e59); } + if (peg$silentFails === 0) { peg$fail(peg$e60); } } if (s6 !== peg$FAILED) { peg$savedPos = s4; - s4 = peg$f51(s1); + s4 = peg$f52(s1); } else { peg$currPos = s4; s4 = peg$FAILED; @@ -2013,15 +2039,15 @@ function peg$parse(input, options) { } if (s5 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 8221) { - s6 = peg$c49; + s6 = peg$c50; peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e60); } + if (peg$silentFails === 0) { peg$fail(peg$e61); } } if (s6 !== peg$FAILED) { peg$savedPos = s4; - s4 = peg$f52(s1); + s4 = peg$f53(s1); } else { peg$currPos = s4; s4 = peg$FAILED; @@ -2044,15 +2070,15 @@ function peg$parse(input, options) { } if (s5 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 34) { - s6 = peg$c50; + s6 = peg$c51; peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e61); } + if (peg$silentFails === 0) { peg$fail(peg$e62); } } if (s6 !== peg$FAILED) { peg$savedPos = s4; - s4 = peg$f53(s1); + s4 = peg$f54(s1); } else { peg$currPos = s4; s4 = peg$FAILED; @@ -2071,7 +2097,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e58); } + if (peg$silentFails === 0) { peg$fail(peg$e59); } } if (s4 === peg$FAILED) { s4 = peg$currPos; @@ -2087,15 +2113,15 @@ function peg$parse(input, options) { } if (s5 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 8220) { - s6 = peg$c48; + s6 = peg$c49; peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e59); } + if (peg$silentFails === 0) { peg$fail(peg$e60); } } if (s6 !== peg$FAILED) { peg$savedPos = s4; - s4 = peg$f51(s1); + s4 = peg$f52(s1); } else { peg$currPos = s4; s4 = peg$FAILED; @@ -2118,15 +2144,15 @@ function peg$parse(input, options) { } if (s5 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 8221) { - s6 = peg$c49; + s6 = peg$c50; peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e60); } + if (peg$silentFails === 0) { peg$fail(peg$e61); } } if (s6 !== peg$FAILED) { peg$savedPos = s4; - s4 = peg$f52(s1); + s4 = peg$f53(s1); } else { peg$currPos = s4; s4 = peg$FAILED; @@ -2149,15 +2175,15 @@ function peg$parse(input, options) { } if (s5 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 34) { - s6 = peg$c50; + s6 = peg$c51; peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e61); } + if (peg$silentFails === 0) { peg$fail(peg$e62); } } if (s6 !== peg$FAILED) { peg$savedPos = s4; - s4 = peg$f53(s1); + s4 = peg$f54(s1); } else { peg$currPos = s4; s4 = peg$FAILED; @@ -2173,7 +2199,7 @@ function peg$parse(input, options) { s4 = peg$parseclosingQuote(); if (s4 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f54(s1, s3, s4); + s0 = peg$f55(s1, s3, s4); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -2185,7 +2211,7 @@ function peg$parse(input, options) { peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e55); } + if (peg$silentFails === 0) { peg$fail(peg$e56); } } return s0; @@ -2200,7 +2226,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e57); } + if (peg$silentFails === 0) { peg$fail(peg$e58); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -2238,7 +2264,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e62); } + if (peg$silentFails === 0) { peg$fail(peg$e63); } } while (s2 !== peg$FAILED) { s1.push(s2); @@ -2247,7 +2273,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e62); } + if (peg$silentFails === 0) { peg$fail(peg$e63); } } } s2 = []; @@ -2256,7 +2282,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e63); } + if (peg$silentFails === 0) { peg$fail(peg$e64); } } while (s3 !== peg$FAILED) { s2.push(s3); @@ -2265,7 +2291,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e63); } + if (peg$silentFails === 0) { peg$fail(peg$e64); } } } s3 = []; @@ -2274,7 +2300,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e64); } + if (peg$silentFails === 0) { peg$fail(peg$e65); } } while (s4 !== peg$FAILED) { s3.push(s4); @@ -2283,7 +2309,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e64); } + if (peg$silentFails === 0) { peg$fail(peg$e65); } } } s4 = peg$parseoperator(); @@ -2302,7 +2328,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e65); } + if (peg$silentFails === 0) { peg$fail(peg$e66); } } while (s2 !== peg$FAILED) { s1.push(s2); @@ -2311,7 +2337,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e65); } + if (peg$silentFails === 0) { peg$fail(peg$e66); } } } s2 = peg$currPos; @@ -2332,7 +2358,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e66); } + if (peg$silentFails === 0) { peg$fail(peg$e67); } } peg$silentFails--; if (s4 === peg$FAILED) { @@ -2358,7 +2384,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e67); } + if (peg$silentFails === 0) { peg$fail(peg$e68); } } } } diff --git a/src/libs/SearchParser/autocompleteParser.peggy b/src/libs/SearchParser/autocompleteParser.peggy index 22201362f5f3..4da2a0785ca1 100644 --- a/src/libs/SearchParser/autocompleteParser.peggy +++ b/src/libs/SearchParser/autocompleteParser.peggy @@ -77,6 +77,7 @@ autocompleteKey "key" / reimbursable / billable / policyID + / action ) filterKey diff --git a/src/libs/SearchParser/baseRules.peggy b/src/libs/SearchParser/baseRules.peggy index fbb25e1ba803..fe4b8afd047f 100644 --- a/src/libs/SearchParser/baseRules.peggy +++ b/src/libs/SearchParser/baseRules.peggy @@ -61,6 +61,7 @@ feed = "feed"i { return "feed"; } title = "title"i { return "title"; } assignee = "assignee"i { return "assignee"; } createdBy = "createdBy"i / "created-by"i { return "createdBy"; } +action = "action"i { return "action"; } operator "operator" = (":" / "=") { return "eq"; } diff --git a/src/libs/SearchParser/searchParser.js b/src/libs/SearchParser/searchParser.js index 490fc4bb98e3..ceb3235e5fcc 100644 --- a/src/libs/SearchParser/searchParser.js +++ b/src/libs/SearchParser/searchParser.js @@ -227,14 +227,15 @@ function peg$parse(input, options) { var peg$c40 = "assignee"; var peg$c41 = "createdby"; var peg$c42 = "created-by"; - var peg$c43 = "!="; - var peg$c44 = ">="; - var peg$c45 = ">"; - var peg$c46 = "<="; - var peg$c47 = "<"; - var peg$c48 = "\u201C"; - var peg$c49 = "\u201D"; - var peg$c50 = "\""; + var peg$c43 = "action"; + var peg$c44 = "!="; + var peg$c45 = ">="; + var peg$c46 = ">"; + var peg$c47 = "<="; + var peg$c48 = "<"; + var peg$c49 = "\u201C"; + var peg$c50 = "\u201D"; + var peg$c51 = "\""; var peg$r0 = /^[^ \t\r\n\xA0]/; var peg$r1 = /^[:=]/; @@ -295,30 +296,31 @@ function peg$parse(input, options) { var peg$e43 = peg$literalExpectation("assignee", true); var peg$e44 = peg$literalExpectation("createdBy", true); var peg$e45 = peg$literalExpectation("created-by", true); - var peg$e46 = peg$otherExpectation("operator"); - var peg$e47 = peg$classExpectation([":", "="], false, false); - var peg$e48 = peg$literalExpectation("!=", false); - var peg$e49 = peg$literalExpectation(">=", false); - var peg$e50 = peg$literalExpectation(">", false); - var peg$e51 = peg$literalExpectation("<=", false); - var peg$e52 = peg$literalExpectation("<", false); - var peg$e53 = peg$otherExpectation("word"); - var peg$e54 = peg$classExpectation([" ", ",", "\t", "\n", "\r", "\xA0"], true, false); - var peg$e55 = peg$otherExpectation("whitespace"); - var peg$e56 = peg$classExpectation([" ", "\t", "\r", "\n", "\xA0"], false, false); - var peg$e57 = peg$otherExpectation("quote"); - var peg$e58 = peg$classExpectation([" ", ",", "\"", "\u201D", "\u201C", "\t", "\n", "\r", "\xA0"], true, false); - var peg$e59 = peg$classExpectation(["\"", ["\u201C", "\u201D"]], false, false); - var peg$e60 = peg$classExpectation(["\"", "\u201D", "\u201C", "\r", "\n"], true, false); - var peg$e61 = peg$literalExpectation("\u201C", false); - var peg$e62 = peg$literalExpectation("\u201D", false); - var peg$e63 = peg$literalExpectation("\"", false); - var peg$e64 = peg$classExpectation([" ", "\t", "\n", "\r", "\xA0", ["a", "z"], ["A", "Z"], ["0", "9"]], false, false); - var peg$e65 = peg$classExpectation([["a", "z"], ["A", "Z"], ["0", "9"]], false, false); - var peg$e66 = peg$classExpectation([" ", "\t", "\n", "\r", "\xA0"], false, false); - var peg$e67 = peg$classExpectation([" ", "\t", "\n", "\r", "\xA0", ["a", "z"], ["A", "Z"]], false, false); - var peg$e68 = peg$anyExpectation(); - var peg$e69 = peg$classExpectation([","], false, false); + var peg$e46 = peg$literalExpectation("action", true); + var peg$e47 = peg$otherExpectation("operator"); + var peg$e48 = peg$classExpectation([":", "="], false, false); + var peg$e49 = peg$literalExpectation("!=", false); + var peg$e50 = peg$literalExpectation(">=", false); + var peg$e51 = peg$literalExpectation(">", false); + var peg$e52 = peg$literalExpectation("<=", false); + var peg$e53 = peg$literalExpectation("<", false); + var peg$e54 = peg$otherExpectation("word"); + var peg$e55 = peg$classExpectation([" ", ",", "\t", "\n", "\r", "\xA0"], true, false); + var peg$e56 = peg$otherExpectation("whitespace"); + var peg$e57 = peg$classExpectation([" ", "\t", "\r", "\n", "\xA0"], false, false); + var peg$e58 = peg$otherExpectation("quote"); + var peg$e59 = peg$classExpectation([" ", ",", "\"", "\u201D", "\u201C", "\t", "\n", "\r", "\xA0"], true, false); + var peg$e60 = peg$classExpectation(["\"", ["\u201C", "\u201D"]], false, false); + var peg$e61 = peg$classExpectation(["\"", "\u201D", "\u201C", "\r", "\n"], true, false); + var peg$e62 = peg$literalExpectation("\u201C", false); + var peg$e63 = peg$literalExpectation("\u201D", false); + var peg$e64 = peg$literalExpectation("\"", false); + var peg$e65 = peg$classExpectation([" ", "\t", "\n", "\r", "\xA0", ["a", "z"], ["A", "Z"], ["0", "9"]], false, false); + var peg$e66 = peg$classExpectation([["a", "z"], ["A", "Z"], ["0", "9"]], false, false); + var peg$e67 = peg$classExpectation([" ", "\t", "\n", "\r", "\xA0"], false, false); + var peg$e68 = peg$classExpectation([" ", "\t", "\n", "\r", "\xA0", ["a", "z"], ["A", "Z"]], false, false); + var peg$e69 = peg$anyExpectation(); + var peg$e70 = peg$classExpectation([","], false, false); var peg$f0 = function(filters) { return applyDefaults(filters); }; var peg$f1 = function(head, tail) { @@ -419,28 +421,29 @@ function peg$parse(input, options) { var peg$f38 = function() { return "title"; }; var peg$f39 = function() { return "assignee"; }; var peg$f40 = function() { return "createdBy"; }; - var peg$f41 = function() { return "eq"; }; - var peg$f42 = function() { return "neq"; }; - var peg$f43 = function() { return "gte"; }; - var peg$f44 = function() { return "gt"; }; - var peg$f45 = function() { return "lte"; }; - var peg$f46 = function() { return "lt"; }; - var peg$f47 = function(o) { + var peg$f41 = function() { return "action"; }; + var peg$f42 = function() { return "eq"; }; + var peg$f43 = function() { return "neq"; }; + var peg$f44 = function() { return "gte"; }; + var peg$f45 = function() { return "gt"; }; + var peg$f46 = function() { return "lte"; }; + var peg$f47 = function() { return "lt"; }; + var peg$f48 = function(o) { if (nameOperator) { expectingNestedQuote = (o === "eq"); // Use simple parser if no valid operator is found } return o; }; - var peg$f48 = function(chars) { return chars.join("").trim(); }; - var peg$f49 = function() { return "and"; }; - var peg$f50 = function() { return expectingNestedQuote; }; - var peg$f51 = function(start, inner, end) { //handle no-breaking space + var peg$f49 = function(chars) { return chars.join("").trim(); }; + var peg$f50 = function() { return "and"; }; + var peg$f51 = function() { return expectingNestedQuote; }; + var peg$f52 = function(start, inner, end) { //handle no-breaking space return [...start, '"', ...inner, '"', ...end].join(""); }; - var peg$f52 = function(start) {return "“"}; - var peg$f53 = function(start) {return "”"}; - var peg$f54 = function(start) {return "\""}; - var peg$f55 = function(start, inner, end) { + var peg$f53 = function(start) {return "“"}; + var peg$f54 = function(start) {return "”"}; + var peg$f55 = function(start) {return "\""}; + var peg$f56 = function(start, inner, end) { return [...start, '"', ...inner, '"'].join(""); }; var peg$currPos = options.peg$currPos | 0; @@ -846,6 +849,9 @@ function peg$parse(input, options) { s1 = peg$parsereimbursable(); if (s1 === peg$FAILED) { s1 = peg$parsebillable(); + if (s1 === peg$FAILED) { + s1 = peg$parseaction(); + } } } } @@ -1807,6 +1813,26 @@ function peg$parse(input, options) { return s0; } + function peg$parseaction() { + var s0, s1; + + s0 = peg$currPos; + s1 = input.substr(peg$currPos, 6); + if (s1.toLowerCase() === peg$c43) { + peg$currPos += 6; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e46); } + } + if (s1 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$f41(); + } + s0 = s1; + + return s0; + } + function peg$parseoperator() { var s0, s1; @@ -1817,81 +1843,81 @@ function peg$parse(input, options) { peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e47); } + if (peg$silentFails === 0) { peg$fail(peg$e48); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f41(); + s1 = peg$f42(); } s0 = s1; if (s0 === peg$FAILED) { s0 = peg$currPos; - if (input.substr(peg$currPos, 2) === peg$c43) { - s1 = peg$c43; + if (input.substr(peg$currPos, 2) === peg$c44) { + s1 = peg$c44; peg$currPos += 2; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e48); } + if (peg$silentFails === 0) { peg$fail(peg$e49); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f42(); + s1 = peg$f43(); } s0 = s1; if (s0 === peg$FAILED) { s0 = peg$currPos; - if (input.substr(peg$currPos, 2) === peg$c44) { - s1 = peg$c44; + if (input.substr(peg$currPos, 2) === peg$c45) { + s1 = peg$c45; peg$currPos += 2; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e49); } + if (peg$silentFails === 0) { peg$fail(peg$e50); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f43(); + s1 = peg$f44(); } s0 = s1; if (s0 === peg$FAILED) { s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 62) { - s1 = peg$c45; + s1 = peg$c46; peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e50); } + if (peg$silentFails === 0) { peg$fail(peg$e51); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f44(); + s1 = peg$f45(); } s0 = s1; if (s0 === peg$FAILED) { s0 = peg$currPos; - if (input.substr(peg$currPos, 2) === peg$c46) { - s1 = peg$c46; + if (input.substr(peg$currPos, 2) === peg$c47) { + s1 = peg$c47; peg$currPos += 2; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e51); } + if (peg$silentFails === 0) { peg$fail(peg$e52); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f45(); + s1 = peg$f46(); } s0 = s1; if (s0 === peg$FAILED) { s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 60) { - s1 = peg$c47; + s1 = peg$c48; peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e52); } + if (peg$silentFails === 0) { peg$fail(peg$e53); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f46(); + s1 = peg$f47(); } s0 = s1; } @@ -1902,7 +1928,7 @@ function peg$parse(input, options) { peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e46); } + if (peg$silentFails === 0) { peg$fail(peg$e47); } } return s0; @@ -1915,7 +1941,7 @@ function peg$parse(input, options) { s1 = peg$parseoperator(); if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f47(s1); + s1 = peg$f48(s1); } s0 = s1; @@ -1933,7 +1959,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e54); } + if (peg$silentFails === 0) { peg$fail(peg$e55); } } if (s2 !== peg$FAILED) { while (s2 !== peg$FAILED) { @@ -1943,7 +1969,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e54); } + if (peg$silentFails === 0) { peg$fail(peg$e55); } } } } else { @@ -1951,13 +1977,13 @@ function peg$parse(input, options) { } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f48(s1); + s1 = peg$f49(s1); } s0 = s1; peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e53); } + if (peg$silentFails === 0) { peg$fail(peg$e54); } } return s0; @@ -1969,7 +1995,7 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = peg$parse_(); peg$savedPos = s0; - s1 = peg$f49(); + s1 = peg$f50(); s0 = s1; return s0; @@ -1985,7 +2011,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e56); } + if (peg$silentFails === 0) { peg$fail(peg$e57); } } while (s1 !== peg$FAILED) { s0.push(s1); @@ -1994,12 +2020,12 @@ function peg$parse(input, options) { peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e56); } + if (peg$silentFails === 0) { peg$fail(peg$e57); } } } peg$silentFails--; s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e55); } + if (peg$silentFails === 0) { peg$fail(peg$e56); } return s0; } @@ -2009,7 +2035,7 @@ function peg$parse(input, options) { s0 = peg$currPos; peg$savedPos = peg$currPos; - s1 = peg$f50(); + s1 = peg$f51(); if (s1) { s1 = undefined; } else { @@ -2046,7 +2072,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e58); } + if (peg$silentFails === 0) { peg$fail(peg$e59); } } while (s2 !== peg$FAILED) { s1.push(s2); @@ -2055,7 +2081,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e58); } + if (peg$silentFails === 0) { peg$fail(peg$e59); } } } s2 = input.charAt(peg$currPos); @@ -2063,7 +2089,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e59); } + if (peg$silentFails === 0) { peg$fail(peg$e60); } } if (s2 !== peg$FAILED) { s3 = []; @@ -2072,7 +2098,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e60); } + if (peg$silentFails === 0) { peg$fail(peg$e61); } } while (s4 !== peg$FAILED) { s3.push(s4); @@ -2081,7 +2107,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e60); } + if (peg$silentFails === 0) { peg$fail(peg$e61); } } } s4 = input.charAt(peg$currPos); @@ -2089,7 +2115,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e59); } + if (peg$silentFails === 0) { peg$fail(peg$e60); } } if (s4 !== peg$FAILED) { s5 = []; @@ -2098,7 +2124,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e54); } + if (peg$silentFails === 0) { peg$fail(peg$e55); } } while (s6 !== peg$FAILED) { s5.push(s6); @@ -2107,11 +2133,11 @@ function peg$parse(input, options) { peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e54); } + if (peg$silentFails === 0) { peg$fail(peg$e55); } } } peg$savedPos = s0; - s0 = peg$f51(s1, s3, s5); + s0 = peg$f52(s1, s3, s5); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -2123,7 +2149,7 @@ function peg$parse(input, options) { peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e57); } + if (peg$silentFails === 0) { peg$fail(peg$e58); } } return s0; @@ -2140,7 +2166,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e58); } + if (peg$silentFails === 0) { peg$fail(peg$e59); } } while (s2 !== peg$FAILED) { s1.push(s2); @@ -2149,7 +2175,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e58); } + if (peg$silentFails === 0) { peg$fail(peg$e59); } } } s2 = input.charAt(peg$currPos); @@ -2157,7 +2183,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e59); } + if (peg$silentFails === 0) { peg$fail(peg$e60); } } if (s2 !== peg$FAILED) { s3 = []; @@ -2166,7 +2192,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e60); } + if (peg$silentFails === 0) { peg$fail(peg$e61); } } if (s4 === peg$FAILED) { s4 = peg$currPos; @@ -2182,15 +2208,15 @@ function peg$parse(input, options) { } if (s5 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 8220) { - s6 = peg$c48; + s6 = peg$c49; peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e61); } + if (peg$silentFails === 0) { peg$fail(peg$e62); } } if (s6 !== peg$FAILED) { peg$savedPos = s4; - s4 = peg$f52(s1); + s4 = peg$f53(s1); } else { peg$currPos = s4; s4 = peg$FAILED; @@ -2213,15 +2239,15 @@ function peg$parse(input, options) { } if (s5 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 8221) { - s6 = peg$c49; + s6 = peg$c50; peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e62); } + if (peg$silentFails === 0) { peg$fail(peg$e63); } } if (s6 !== peg$FAILED) { peg$savedPos = s4; - s4 = peg$f53(s1); + s4 = peg$f54(s1); } else { peg$currPos = s4; s4 = peg$FAILED; @@ -2244,15 +2270,15 @@ function peg$parse(input, options) { } if (s5 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 34) { - s6 = peg$c50; + s6 = peg$c51; peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e63); } + if (peg$silentFails === 0) { peg$fail(peg$e64); } } if (s6 !== peg$FAILED) { peg$savedPos = s4; - s4 = peg$f54(s1); + s4 = peg$f55(s1); } else { peg$currPos = s4; s4 = peg$FAILED; @@ -2271,7 +2297,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e60); } + if (peg$silentFails === 0) { peg$fail(peg$e61); } } if (s4 === peg$FAILED) { s4 = peg$currPos; @@ -2287,15 +2313,15 @@ function peg$parse(input, options) { } if (s5 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 8220) { - s6 = peg$c48; + s6 = peg$c49; peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e61); } + if (peg$silentFails === 0) { peg$fail(peg$e62); } } if (s6 !== peg$FAILED) { peg$savedPos = s4; - s4 = peg$f52(s1); + s4 = peg$f53(s1); } else { peg$currPos = s4; s4 = peg$FAILED; @@ -2318,15 +2344,15 @@ function peg$parse(input, options) { } if (s5 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 8221) { - s6 = peg$c49; + s6 = peg$c50; peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e62); } + if (peg$silentFails === 0) { peg$fail(peg$e63); } } if (s6 !== peg$FAILED) { peg$savedPos = s4; - s4 = peg$f53(s1); + s4 = peg$f54(s1); } else { peg$currPos = s4; s4 = peg$FAILED; @@ -2349,15 +2375,15 @@ function peg$parse(input, options) { } if (s5 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 34) { - s6 = peg$c50; + s6 = peg$c51; peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e63); } + if (peg$silentFails === 0) { peg$fail(peg$e64); } } if (s6 !== peg$FAILED) { peg$savedPos = s4; - s4 = peg$f54(s1); + s4 = peg$f55(s1); } else { peg$currPos = s4; s4 = peg$FAILED; @@ -2373,7 +2399,7 @@ function peg$parse(input, options) { s4 = peg$parseclosingQuote(); if (s4 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f55(s1, s3, s4); + s0 = peg$f56(s1, s3, s4); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -2385,7 +2411,7 @@ function peg$parse(input, options) { peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e57); } + if (peg$silentFails === 0) { peg$fail(peg$e58); } } return s0; @@ -2400,7 +2426,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e59); } + if (peg$silentFails === 0) { peg$fail(peg$e60); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -2438,7 +2464,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e64); } + if (peg$silentFails === 0) { peg$fail(peg$e65); } } while (s2 !== peg$FAILED) { s1.push(s2); @@ -2447,7 +2473,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e64); } + if (peg$silentFails === 0) { peg$fail(peg$e65); } } } s2 = []; @@ -2456,7 +2482,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e65); } + if (peg$silentFails === 0) { peg$fail(peg$e66); } } while (s3 !== peg$FAILED) { s2.push(s3); @@ -2465,7 +2491,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e65); } + if (peg$silentFails === 0) { peg$fail(peg$e66); } } } s3 = []; @@ -2474,7 +2500,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e66); } + if (peg$silentFails === 0) { peg$fail(peg$e67); } } while (s4 !== peg$FAILED) { s3.push(s4); @@ -2483,7 +2509,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e66); } + if (peg$silentFails === 0) { peg$fail(peg$e67); } } } s4 = peg$parseoperator(); @@ -2502,7 +2528,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e67); } + if (peg$silentFails === 0) { peg$fail(peg$e68); } } while (s2 !== peg$FAILED) { s1.push(s2); @@ -2511,7 +2537,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e67); } + if (peg$silentFails === 0) { peg$fail(peg$e68); } } } s2 = peg$currPos; @@ -2532,7 +2558,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e68); } + if (peg$silentFails === 0) { peg$fail(peg$e69); } } peg$silentFails--; if (s4 === peg$FAILED) { @@ -2558,7 +2584,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e69); } + if (peg$silentFails === 0) { peg$fail(peg$e70); } } } } diff --git a/src/libs/SearchParser/searchParser.peggy b/src/libs/SearchParser/searchParser.peggy index f43a77f96eaa..3a9e47d3af97 100644 --- a/src/libs/SearchParser/searchParser.peggy +++ b/src/libs/SearchParser/searchParser.peggy @@ -137,6 +137,7 @@ key "key" / createdBy / reimbursable / billable + / action ) filterKey diff --git a/src/libs/SearchQueryUtils.ts b/src/libs/SearchQueryUtils.ts index 26e505757f1a..f4c043baadd6 100644 --- a/src/libs/SearchQueryUtils.ts +++ b/src/libs/SearchQueryUtils.ts @@ -89,6 +89,7 @@ const UserFriendlyKeyMap: Record CONST.SEARCH.SYNTAX_FILTER_KEYS[key] === filterKey); @@ -536,7 +538,8 @@ function buildFilterFormValuesFromQuery( filterKey === CONST.SEARCH.SYNTAX_FILTER_KEYS.REPORT_ID || filterKey === CONST.SEARCH.SYNTAX_FILTER_KEYS.MERCHANT || filterKey === CONST.SEARCH.SYNTAX_FILTER_KEYS.DESCRIPTION || - filterKey === CONST.SEARCH.SYNTAX_FILTER_KEYS.TITLE + filterKey === CONST.SEARCH.SYNTAX_FILTER_KEYS.TITLE || + filterKey === CONST.SEARCH.SYNTAX_FILTER_KEYS.ACTION ) { filtersForm[filterKey] = filterValues.at(0); } diff --git a/src/libs/SearchUIUtils.ts b/src/libs/SearchUIUtils.ts index c342f4c2b37f..5048c5b41612 100644 --- a/src/libs/SearchUIUtils.ts +++ b/src/libs/SearchUIUtils.ts @@ -1296,46 +1296,48 @@ function createTypeMenuSections(session: OnyxTypes.Session | undefined, hasCardF // Begin adding conditional sections, based on the policies the user has access to const showSubmitSuggestion = Object.values(policies).filter((p) => isPaidGroupPolicy(p)).length > 0; - const showApproveSuggestion = - Object.values(policies).filter((policy): policy is OnyxTypes.Policy => { - if (!policy || !email || !isPaidGroupPolicy(policy)) { - return false; - } - - const isPolicyApprover = policy.approver === email; - const isSubmittedTo = Object.values(policy.employeeList ?? {}).some((employee) => { - return employee.submitsTo === email || employee.forwardsTo === email; - }); + const showPaySuggestion = Object.values(policies).some((policy): policy is OnyxTypes.Policy => { + if (!policy || !isPaidGroupPolicy(policy)) { + return false; + } - return isPolicyApprover || isSubmittedTo; - }).length > 0; + const reimburser = policy.reimburser; + const isReimburser = reimburser === email; + const isAdmin = policy.role === CONST.POLICY.ROLE.ADMIN; - const showPaySuggestion = - Object.values(policies).filter((policy): policy is OnyxTypes.Policy => { - if (!policy || !isPaidGroupPolicy(policy)) { - return false; - } + if (policy.reimbursementChoice === CONST.POLICY.REIMBURSEMENT_CHOICES.REIMBURSEMENT_YES) { + return reimburser ? isReimburser : isAdmin; + } - const reimburser = policy.reimburser; - const isReimburser = reimburser === email; - const isAdmin = policy.role === CONST.POLICY.ROLE.ADMIN; + if (policy.reimbursementChoice === CONST.POLICY.REIMBURSEMENT_CHOICES.REIMBURSEMENT_MANUAL) { + return isAdmin; + } - if (policy.reimbursementChoice === CONST.POLICY.REIMBURSEMENT_CHOICES.REIMBURSEMENT_YES) { - return reimburser ? isReimburser : isAdmin; - } + return false; + }); - if (policy.reimbursementChoice === CONST.POLICY.REIMBURSEMENT_CHOICES.REIMBURSEMENT_MANUAL) { - return isAdmin; - } + const showApproveSuggestion = Object.values(policies).some((policy): policy is OnyxTypes.Policy => { + if (!policy || !email || !isPaidGroupPolicy(policy)) { + return false; + } + if (policy.approvalMode === CONST.POLICY.APPROVAL_MODE.OPTIONAL) { return false; - }).length > 0; + } + + const isPolicyApprover = policy.approver === email; + const isSubmittedTo = Object.values(policy.employeeList ?? {}).some((employee) => { + return employee.submitsTo === email || employee.forwardsTo === email; + }); + + return isPolicyApprover || isSubmittedTo; + }); // TODO: This option will be enabled soon (removing the && false). We are waiting on changes to support this // feature fully, but lets keep the code here for simplicity // https://github.com/Expensify/Expensify/issues/505933 const showExportSuggestion = - Object.values(policies).filter((policy): policy is OnyxTypes.Policy => { + Object.values(policies).some((policy): policy is OnyxTypes.Policy => { if (!policy || !email) { return false; } @@ -1347,7 +1349,7 @@ function createTypeMenuSections(session: OnyxTypes.Session | undefined, hasCardF const isXeroExporter = policy.connections?.xero?.config?.export?.exporter === email; return isIntacctExporter || isNetSuiteExporter || isQuickbooksDesktopExporter || isQuickbooksOnlineExporter || isXeroExporter; - }).length > 0 && false; + }) && false; // We suggest specific filters for users based on their access in specific policies. Show the todo section // only if any of these items are available @@ -1450,7 +1452,8 @@ function createTypeMenuSections(session: OnyxTypes.Session | undefined, hasCardF const queryString = buildQueryStringFromFilterFormValues({ type: CONST.SEARCH.DATA_TYPES.EXPENSE, groupBy: CONST.SEARCH.GROUP_BY.REPORTS, - status: [CONST.SEARCH.STATUS.EXPENSE.APPROVED, CONST.SEARCH.STATUS.EXPENSE.DONE], + action: CONST.SEARCH.ACTION_FILTERS.PAY, + reimbursable: CONST.SEARCH.BOOLEAN.YES, payer: session.accountID?.toString(), }); return queryString; @@ -1471,8 +1474,8 @@ function createTypeMenuSections(session: OnyxTypes.Session | undefined, hasCardF getSearchQuery: () => { const queryString = buildQueryStringFromFilterFormValues({ groupBy: CONST.SEARCH.GROUP_BY.REPORTS, + action: CONST.SEARCH.ACTION_FILTERS.EXPORT, exporter: [`${session.accountID}`], - status: [CONST.SEARCH.STATUS.EXPENSE.APPROVED, CONST.SEARCH.STATUS.EXPENSE.PAID, CONST.SEARCH.STATUS.EXPENSE.DONE], exportedOn: CONST.SEARCH.DATE_PRESETS.NEVER, }); return queryString; diff --git a/src/types/form/SearchAdvancedFiltersForm.ts b/src/types/form/SearchAdvancedFiltersForm.ts index eda21fa9730c..0a14fb8bc5f2 100644 --- a/src/types/form/SearchAdvancedFiltersForm.ts +++ b/src/types/form/SearchAdvancedFiltersForm.ts @@ -58,6 +58,7 @@ const FILTER_KEYS = { ASSIGNEE: 'assignee', REIMBURSABLE: 'reimbursable', BILLABLE: 'billable', + ACTION: 'action', } as const; const ALLOWED_TYPE_FILTERS = { @@ -100,6 +101,7 @@ const ALLOWED_TYPE_FILTERS = { FILTER_KEYS.EXPORTED_AFTER, FILTER_KEYS.EXPORTED_BEFORE, FILTER_KEYS.EXPORTED_ON, + FILTER_KEYS.ACTION, ], [CONST.SEARCH.DATA_TYPES.INVOICE]: [ FILTER_KEYS.TYPE, @@ -137,6 +139,7 @@ const ALLOWED_TYPE_FILTERS = { FILTER_KEYS.EXPORTED_AFTER, FILTER_KEYS.EXPORTED_BEFORE, FILTER_KEYS.EXPORTED_ON, + FILTER_KEYS.ACTION, ], [CONST.SEARCH.DATA_TYPES.TRIP]: [ FILTER_KEYS.TYPE, @@ -174,6 +177,7 @@ const ALLOWED_TYPE_FILTERS = { FILTER_KEYS.EXPORTED_AFTER, FILTER_KEYS.EXPORTED_BEFORE, FILTER_KEYS.EXPORTED_ON, + FILTER_KEYS.ACTION, ], [CONST.SEARCH.DATA_TYPES.CHAT]: [ FILTER_KEYS.TYPE, @@ -250,6 +254,7 @@ type SearchAdvancedFiltersForm = Form< [FILTER_KEYS.ASSIGNEE]: string[]; [FILTER_KEYS.REIMBURSABLE]: string; [FILTER_KEYS.BILLABLE]: string; + [FILTER_KEYS.ACTION]: string; } >;