@globalbrain/sefirot 4.35.4 → 4.36.1

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.
@@ -1,3 +1,5 @@
1
+ import { xor } from 'lodash-es'
2
+ import { type DropdownSection } from '../../../composables/Dropdown'
1
3
  import { type TableCell } from '../../../composables/Table'
2
4
  import { type RelatedManyFieldData } from '../FieldData'
3
5
  import { type FilterOperator } from '../FilterOperator'
@@ -14,6 +16,34 @@ export class RelatedManyField extends Field<RelatedManyFieldData> {
14
16
  this.fetcher = fetcher
15
17
  }
16
18
 
19
+ override async tableFilterMenu(filters: any[], onFilterUpdated: (filters: any[]) => void): Promise<DropdownSection | null> {
20
+ const method = this.data.resourceEndpointMethod
21
+ const url = this.data.resourceEndpointPath
22
+ const key = this.data.resourceEndpointDataKey
23
+
24
+ if (!url) {
25
+ return null
26
+ }
27
+
28
+ const selected = this.inFilterValueFor(this.data.key, filters)
29
+
30
+ const res = await this.fetcher(method, url)
31
+ const data = key ? res[key] : res
32
+
33
+ const options = data.map((item: any) => ({
34
+ label: item[this.data.resourceTitle],
35
+ value: item[this.data.filterKey]
36
+ }))
37
+
38
+ return {
39
+ type: 'filter',
40
+ search: true,
41
+ selected,
42
+ options,
43
+ onClick: (v) => { onFilterUpdated?.([this.data.key, 'in', xor(selected, [v])]) }
44
+ }
45
+ }
46
+
17
47
  override tableCell(v: any, _r: any): TableCell {
18
48
  return {
19
49
  type: 'pills',
@@ -39,6 +39,9 @@ export class SelectFilterInput extends FilterInput {
39
39
  }
40
40
 
41
41
  protected castValueMany(value: any): any {
42
+ if (value == null) {
43
+ return []
44
+ }
42
45
  if (Array.isArray(value)) {
43
46
  return value
44
47
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@globalbrain/sefirot",
3
- "version": "4.35.4",
3
+ "version": "4.36.1",
4
4
  "description": "Vue Components for Global Brain Design System.",
5
5
  "keywords": [
6
6
  "components",