terrier-engine 4.35.0 → 4.36.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -30,19 +30,25 @@ type BaseFilter = {
30
30
  edit_label?: string
31
31
  }
32
32
 
33
- const directOperators = ['eq', 'ne', 'ilike', 'lt', 'gt', 'lte', 'gte'] as const
33
+ const directOperators = ['eq', 'ne', 'ilike', 'lt', 'gt', 'lte', 'gte', 'contains', 'excludes'] as const
34
34
  export type DirectOperator = typeof directOperators[number]
35
35
 
36
36
  /**
37
37
  * Computes the operator options for the given column type.
38
38
  * @param type
39
39
  */
40
- function operatorOptions(type: string): SelectOptions {
40
+ function operatorOptions(colDef?: ColumnDef): SelectOptions {
41
+ const type = colDef?.type || 'text'
41
42
  let operators: DirectOperator[] = ['eq', 'ne'] // equality is the only thing we can assume for any type
42
43
  switch (type) {
43
44
  case 'text':
44
45
  case 'string':
45
- operators = ['eq', 'ne', 'ilike']
46
+ if (colDef?.array) {
47
+ operators = ['contains', 'excludes']
48
+ }
49
+ else {
50
+ operators = ['eq', 'ne', 'ilike']
51
+ }
46
52
  break
47
53
  case 'float':
48
54
  case 'integer':
@@ -111,7 +117,7 @@ function operatorDisplay(op: DirectOperator): string {
111
117
  case 'gte':
112
118
  return '≥'
113
119
  default:
114
- return '?'
120
+ return op
115
121
  }
116
122
  }
117
123
 
@@ -402,7 +408,7 @@ class DirectFilterEditor extends FilterFields<DirectFilter> {
402
408
  col.div('.tt-readonly-field', {text: this.data.column})
403
409
  })
404
410
  parent.div('.operator', col => {
405
- const opts = operatorOptions(this.columnDef?.type || 'text')
411
+ const opts = operatorOptions(this.columnDef)
406
412
  this.select(col, 'operator', opts)
407
413
  })
408
414
  parent.div('.filter', col => {
@@ -630,7 +636,8 @@ class AddFilterDropdown extends Dropdown<{modelDef: ModelDef, callback: AddFilte
630
636
  return this.state.callback({id, filter_type: 'date_range', column, range: {period: 'year', relative: 0}})
631
637
  default: // direct
632
638
  const colType = colDef.type == 'number' || colDef.type == 'cents' ? colDef.type : 'text'
633
- return this.state.callback({id, filter_type: 'direct', column, column_type: colType, operator: 'eq', value: '0'})
639
+ const defaultValue = colType == 'text' ? '' : '0'
640
+ return this.state.callback({id, filter_type: 'direct', column, column_type: colType, operator: 'eq', value: defaultValue})
634
641
  }
635
642
  }
636
643
  else {
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "files": [
5
5
  "*"
6
6
  ],
7
- "version": "4.35.0",
7
+ "version": "4.36.0",
8
8
  "repository": {
9
9
  "type": "git",
10
10
  "url": "https://github.com/Terrier-Tech/terrier-engine"