@operato/app 1.0.0-beta.12 → 1.0.0-beta.13

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.
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "WebApplication production supporting components following open-wc recommendations",
4
4
  "license": "MIT",
5
5
  "author": "heartyoh",
6
- "version": "1.0.0-beta.12",
6
+ "version": "1.0.0-beta.13",
7
7
  "main": "dist/src/index.js",
8
8
  "module": "dist/src/index.js",
9
9
  "exports": {
@@ -59,18 +59,18 @@
59
59
  "@material/mwc-button": "^0.25.3",
60
60
  "@material/mwc-icon": "^0.25.3",
61
61
  "@material/mwc-icon-button": "^0.25.3",
62
- "@operato/attachment": "^1.0.0-beta.12",
63
- "@operato/data-grist": "^1.0.0-beta.12",
64
- "@operato/font": "^1.0.0-beta.12",
65
- "@operato/form": "^1.0.0-beta.12",
66
- "@operato/graphql": "^1.0.0-beta.12",
67
- "@operato/i18n": "^1.0.0-beta.12",
68
- "@operato/input": "^1.0.0-beta.12",
69
- "@operato/layout": "^1.0.0-beta.12",
70
- "@operato/property-editor": "^1.0.0-beta.12",
71
- "@operato/shell": "^1.0.0-beta.12",
72
- "@operato/styles": "^1.0.0-beta.12",
73
- "@operato/utils": "^1.0.0-beta.12",
62
+ "@operato/attachment": "^1.0.0-beta.13",
63
+ "@operato/data-grist": "^1.0.0-beta.13",
64
+ "@operato/font": "^1.0.0-beta.13",
65
+ "@operato/form": "^1.0.0-beta.13",
66
+ "@operato/graphql": "^1.0.0-beta.13",
67
+ "@operato/i18n": "^1.0.0-beta.13",
68
+ "@operato/input": "^1.0.0-beta.13",
69
+ "@operato/layout": "^1.0.0-beta.13",
70
+ "@operato/property-editor": "^1.0.0-beta.13",
71
+ "@operato/shell": "^1.0.0-beta.13",
72
+ "@operato/styles": "^1.0.0-beta.13",
73
+ "@operato/utils": "^1.0.0-beta.13",
74
74
  "codemirror": "^5.59.1",
75
75
  "codemirror-graphql": "^0.15.2",
76
76
  "cronstrue": "^2.2.0",
@@ -92,7 +92,7 @@
92
92
  "concurrently": "^5.3.0",
93
93
  "eslint": "^7.32.0",
94
94
  "eslint-config-prettier": "^8.3.0",
95
- "husky": "^4.3.8",
95
+ "husky": "^7.0.2",
96
96
  "lint-staged": "^10.5.4",
97
97
  "prettier": "^2.4.1",
98
98
  "tslib": "^2.3.1",
@@ -111,5 +111,5 @@
111
111
  "prettier --write"
112
112
  ]
113
113
  },
114
- "gitHead": "2fecdbd649f399d10287f67641b146add30351bd"
114
+ "gitHead": "e3fe7acd7edd9aa5dd6d0966435ae7f938b32d05"
115
115
  }
@@ -0,0 +1,94 @@
1
+ import '@operato/input/ox-checkbox.js'
2
+ import '../grist-editor/ox-selector-resource-id'
3
+
4
+ import { html } from 'lit-html'
5
+
6
+ import { FilterConfig, FilterSelectRenderer } from '@operato/form'
7
+ import { i18next } from '@operato/i18n'
8
+ import { openPopup } from '@operato/layout'
9
+
10
+ type SelectedCallback = (value: { id: string; name: string; description: string }) => void
11
+
12
+ function openResourceSelector(filter: FilterConfig, value: any, confirmCallback: SelectedCallback) {
13
+ const { queryName, select, list, basicArgs, valueField = 'id' } = filter.options || {}
14
+
15
+ var actualValue
16
+ if (typeof valueField === 'function') {
17
+ actualValue = valueField(value)
18
+ } else {
19
+ actualValue = value?.[valueField]
20
+ }
21
+
22
+ var template = html`
23
+ <ox-selector-resource-id
24
+ .value=${actualValue}
25
+ .confirmCallback=${confirmCallback}
26
+ .queryName=${queryName}
27
+ .select=${select}
28
+ .list=${list}
29
+ .basicArgs=${basicArgs}
30
+ .valueField=${valueField}
31
+ ></ox-selector-resource-id>
32
+ `
33
+
34
+ const popup = openPopup(template, {
35
+ backdrop: true,
36
+ size: 'large',
37
+ title: i18next.t('title.select_item')
38
+ })
39
+ }
40
+
41
+ export const FilterResourceSelect: FilterSelectRenderer = (filter, value, owner) => {
42
+ const { name, operator = 'like' } = filter
43
+
44
+ return operator === 'like'
45
+ ? html` <input
46
+ type="text"
47
+ name=${name}
48
+ .value=${value}
49
+ @change=${(e: CustomEvent) => {
50
+ const input = e.target as HTMLInputElement
51
+ input.dispatchEvent(
52
+ new CustomEvent('filter-change', {
53
+ bubbles: true,
54
+ composed: true,
55
+ detail: {
56
+ name,
57
+ operator,
58
+ value: input.value
59
+ }
60
+ })
61
+ )
62
+ }}
63
+ />`
64
+ : operator == 'in'
65
+ ? html``
66
+ : operator === 'eq'
67
+ ? html`
68
+ <input
69
+ style="min-width: 100px; min-height: 24px"
70
+ type="text"
71
+ name=${name}
72
+ .value=${value}
73
+ readonly
74
+ @click=${(e: Event) => {
75
+ e.stopPropagation()
76
+
77
+ const confirmCallback = (selected?: { [field: string]: any }) => {
78
+ var { idField = 'id', nameField = 'name', descriptionField = 'description' } = filter.options || {}
79
+
80
+ owner.dispatchEvent(
81
+ new CustomEvent('filter-change', {
82
+ bubbles: true,
83
+ composed: true,
84
+ detail: selected ? selected[idField] : ''
85
+ })
86
+ )
87
+ }
88
+
89
+ openResourceSelector(filter, value, confirmCallback)
90
+ }}
91
+ />
92
+ `
93
+ : html``
94
+ }
@@ -0,0 +1,6 @@
1
+ import { registerFilterRenderer } from '@operato/form'
2
+
3
+ import { FilterResourceSelect } from './filter-resource-select.js'
4
+
5
+ registerFilterRenderer('resource-object', [FilterResourceSelect])
6
+ registerFilterRenderer('resource-id', [FilterResourceSelect])