All files / src/kernel ServerSideSearcherConfig.ts

83.33% Statements 15/18
0% Branches 0/2
0% Functions 0/1
83.33% Lines 15/18

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58          66x                                                     66x             66x 66x 66x 66x 66x 66x 66x 66x 66x 66x 66x 66x   66x          
import { MatchMode } from "@props/RecordProps";
 
/**
 * 匹配规则与后台通信时的 value 及前台显示给用户的显示值的对应关系
 */
export const MatcherDisplay: { [key in MatchMode]: string } = {
  "=": "Equal to",
  "!=": "Not equal to",
  ">": "Greater than",
  "<": "Smaller than",
  ">=": "Greater than or equal",
  "<=": "Smaller than or equal",
  "endsWith": "Ends with",
  "startsWith": "Starts with",
  "contains": "Contains",
  "notContains": "not Contains",
  "containsAll": "Contains all of",
  "containsAny": "Contains some of ",
  "notContainsAny": "Contains none of",
  "between": "between",
  "before": "Before",
  "after": "After",
  "beforeOrEqual": "Before or equal to",
  "afterOrEqual": "After or equal to",
  "isOneOf": "Is one of",
  "isNotAnyOf": "Is not any of",
  "isEmpty": "Is empty",
  "isNotEmpty": "Is not empty",
  "hasNoRelated": "Has no relate data",
  "hasRelated": "Has relate data",
};
 
export const isMultiple = (matcher?: MatchMode): boolean => {
  if (!matcher) {
    return false;
  }
  return ["containsAll", "containsAny", "notContainsAny", "contains", "notContains", "isOneOf", "isNotAnyOf"].includes(matcher);
};
 
export const TextMatchers: Array<MatchMode> = ["contains", "=", "notContains", "startsWith", "endsWith", "isEmpty", "isNotEmpty"];
export const NumberMatchers: Array<MatchMode> = ["=", "!=", ">", "<", ">=", "<=", "between", "isEmpty", "isNotEmpty"];
export const DateMatchers: Array<MatchMode> = ["before", "after", "beforeOrEqual", "afterOrEqual", "=", "!=", "between", "isEmpty", "isNotEmpty"];
export const BooleanMatchers: Array<MatchMode> = ["=", "!=", "isEmpty", "isNotEmpty"];
export const SingleSelectionMatchers: Array<MatchMode> = ["=", "!=", "isOneOf", "isNotAnyOf", "isEmpty", "isNotEmpty"];
export const ObjectMatchers: Array<MatchMode> = ["=", "!=", "isOneOf", "isNotAnyOf", "isEmpty", "isNotEmpty"];
export const MultipleSelectMatchers: Array<MatchMode> = ["containsAny", "containsAll", "notContainsAny", "isEmpty", "isNotEmpty"];
export const ConfigAttributeMatchers: Array<MatchMode> = ["contains", "notContains", "isEmpty", "isNotEmpty"];
export const ArrayMatchers: Array<MatchMode> = ["hasRelated", "hasNoRelated"];
export const SingleModeMatcher: Array<MatchMode> = ["=", "!="];
export const MultipleModeMatcher: Array<MatchMode> = ["isOneOf", "isNotAnyOf", "containsAll", "containsAny", "notContainsAny", "contains", "notContains"];
export const NoValueModeMatcher: Array<MatchMode> = ["isEmpty", "isNotEmpty", "hasRelated", "hasNoRelated"];
 
export const FilterStatus: { [propName: string]: string } = {
  outOfSync: "outOfSync",
  applied: "applied",
  init: "init",
};