• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

teableio / teable / 8536869866

03 Apr 2024 10:05AM CUT coverage: 21.234% (-0.3%) from 21.535%
8536869866

Pull #514

github

web-flow
Merge 91a25d710 into 45ee7ebb3
Pull Request #514: refactor: user and link selector

1394 of 2532 branches covered (55.06%)

27 of 1620 new or added lines in 60 files covered. (1.67%)

4 existing lines in 2 files now uncovered.

14588 of 68702 relevant lines covered (21.23%)

2.02 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/packages/sdk/src/components/filter/utils.ts
1
import type { IFilter } from '@teable/core';
×
2
import { FieldType } from '@teable/core';
×
3
import { cloneDeep } from 'lodash';
×
4
import type { IFieldInstance } from '../../model';
×
NEW
5
import { operatorLabelMapping, fieldNumberLabelMap, EMPTY_OPERATORS } from './constant';
×
6
import { isFilterItem } from './types';
×
7

×
8
export const getFieldOperatorMapping = (type?: FieldType) => {
×
9
  let mergedMapping = cloneDeep(operatorLabelMapping);
×
10
  if (type === FieldType.Number) {
×
11
    mergedMapping = { ...operatorLabelMapping, ...fieldNumberLabelMap };
×
12
  }
×
13
  return mergedMapping;
×
14
};
×
15

×
16
export const getFilterFieldIds = (
×
17
  filter: NonNullable<IFilter>['filterSet'],
×
18
  fieldMap: Record<string, IFieldInstance>
×
19
): Set<string> => {
×
20
  const filterIds = new Set<string>();
×
21

×
22
  filter.forEach((item) => {
×
23
    if (isFilterItem(item)) {
×
24
      // checkbox's default value is null, but it does work
×
25
      if (
×
26
        item.value === 0 ||
×
27
        item.value ||
×
NEW
28
        EMPTY_OPERATORS.includes(item.operator) ||
×
29
        fieldMap[item.fieldId]?.type === FieldType.Checkbox
×
30
      ) {
×
31
        filterIds.add(item.fieldId);
×
32
      }
×
33
    } else {
×
34
      const childFilterIds = getFilterFieldIds(item.filterSet, fieldMap);
×
35
      childFilterIds.forEach((id) => filterIds.add(id));
×
36
    }
×
37
  });
×
38

×
39
  return filterIds;
×
40
};
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc