@operato/app 8.0.0-beta.0 → 8.0.0-beta.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.
- package/CHANGELOG.md +9 -0
- package/package.json +14 -14
- package/.editorconfig +0 -29
- package/.storybook/main.js +0 -3
- package/.storybook/server.mjs +0 -8
- package/src/filter-renderer/filter-resource-select.ts +0 -133
- package/src/filter-renderer/index.ts +0 -6
- package/src/filters-form/filter-resource-code.ts +0 -11
- package/src/filters-form/filter-resource-object.ts +0 -11
- package/src/filters-form/filter-resource-select.ts +0 -130
- package/src/filters-form/index.ts +0 -14
- package/src/filters-form/ox-filter-resource-code.ts +0 -154
- package/src/filters-form/ox-filter-resource-object.ts +0 -224
- package/src/grist-editor/index.ts +0 -26
- package/src/grist-editor/ox-grist-editor-code.ts +0 -64
- package/src/grist-editor/ox-grist-editor-json.ts +0 -64
- package/src/grist-editor/ox-grist-editor-privilege.ts +0 -58
- package/src/grist-editor/ox-grist-editor-resource-code.ts +0 -30
- package/src/grist-editor/ox-grist-editor-resource-id.ts +0 -88
- package/src/grist-editor/ox-grist-editor-resource-object-legacy.ts +0 -131
- package/src/grist-editor/ox-grist-editor-resource-object.ts +0 -156
- package/src/grist-editor/ox-grist-renderer-crontab.ts +0 -18
- package/src/grist-editor/ox-grist-renderer-resource-code.ts +0 -85
- package/src/grist-editor/ox-grist-renderer-resource-id.ts +0 -17
- package/src/grist-editor/ox-grist-renderer-resource-object.ts +0 -26
- package/src/grist-editor/ox-popup-code-input.ts +0 -69
- package/src/grist-editor/ox-popup-privilege-input.ts +0 -93
- package/src/index.ts +0 -4
- package/src/input/index.ts +0 -3
- package/src/input/ox-input-background-pattern.ts +0 -196
- package/src/input/ox-input-fill-style.ts +0 -377
- package/src/input/ox-input-graphql.ts +0 -153
- package/src/property-editor/index.ts +0 -83
- package/src/property-editor/ox-property-editor-graphql.ts +0 -22
- package/src/property-editor/ox-property-editor-resource-object.ts +0 -148
- package/src/selector/ox-selector-resource-id.ts +0 -201
- package/src/selector/ox-selector-resource-object-legacy.ts +0 -367
- package/src/selector/ox-selector-resource-object.ts +0 -300
- package/stories/graphql-client.stories.ts +0 -73
- package/stories/ox-input-graphql.stories.ts +0 -70
- package/stories/ox-selector-resource-object.stories.ts +0 -98
- package/tsconfig.json +0 -24
- package/web-dev-server.config.mjs +0 -27
- package/web-test-runner.config.mjs +0 -41
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,15 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [8.0.0-beta.1](https://github.com/hatiolab/operato/compare/v8.0.0-beta.0...v8.0.0-beta.1) (2025-01-08)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### :bug: Bug Fix
|
|
10
|
+
|
|
11
|
+
* missing .npmignore ([be05985](https://github.com/hatiolab/operato/commit/be05985abfae4af53501f718dd52932099f7fbcb))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
6
15
|
## [8.0.0-beta.0](https://github.com/hatiolab/operato/compare/v8.0.0-alpha.56...v8.0.0-beta.0) (2025-01-07)
|
|
7
16
|
|
|
8
17
|
**Note:** Version bump only for package @operato/app
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@operato/app",
|
|
3
3
|
"description": "WebApplication production supporting components following open-wc recommendations",
|
|
4
4
|
"author": "heartyoh",
|
|
5
|
-
"version": "8.0.0-beta.
|
|
5
|
+
"version": "8.0.0-beta.1",
|
|
6
6
|
"main": "dist/src/index.js",
|
|
7
7
|
"module": "dist/src/index.js",
|
|
8
8
|
"exports": {
|
|
@@ -147,18 +147,18 @@
|
|
|
147
147
|
"@graphql-tools/delegate": "^10.0.1",
|
|
148
148
|
"@graphql-tools/wrap": "^8.5.0",
|
|
149
149
|
"@material/web": "^2.0.0",
|
|
150
|
-
"@operato/attachment": "^8.0.0-beta.
|
|
151
|
-
"@operato/data-grist": "^8.0.0-beta.
|
|
152
|
-
"@operato/font": "^8.0.0-beta.
|
|
153
|
-
"@operato/form": "^8.0.0-beta.
|
|
154
|
-
"@operato/graphql": "^8.0.0-beta.
|
|
155
|
-
"@operato/i18n": "^8.0.0-beta.
|
|
156
|
-
"@operato/input": "^8.0.0-beta.
|
|
157
|
-
"@operato/layout": "^8.0.0-beta.
|
|
158
|
-
"@operato/property-editor": "^8.0.0-beta.
|
|
159
|
-
"@operato/shell": "^8.0.0-beta.
|
|
160
|
-
"@operato/styles": "^8.0.0-beta.
|
|
161
|
-
"@operato/utils": "^8.0.0-beta.
|
|
150
|
+
"@operato/attachment": "^8.0.0-beta.1",
|
|
151
|
+
"@operato/data-grist": "^8.0.0-beta.1",
|
|
152
|
+
"@operato/font": "^8.0.0-beta.1",
|
|
153
|
+
"@operato/form": "^8.0.0-beta.1",
|
|
154
|
+
"@operato/graphql": "^8.0.0-beta.1",
|
|
155
|
+
"@operato/i18n": "^8.0.0-beta.1",
|
|
156
|
+
"@operato/input": "^8.0.0-beta.1",
|
|
157
|
+
"@operato/layout": "^8.0.0-beta.1",
|
|
158
|
+
"@operato/property-editor": "^8.0.0-beta.1",
|
|
159
|
+
"@operato/shell": "^8.0.0-beta.1",
|
|
160
|
+
"@operato/styles": "^8.0.0-beta.1",
|
|
161
|
+
"@operato/utils": "^8.0.0-beta.1",
|
|
162
162
|
"cm6-graphql": "^0.0.14",
|
|
163
163
|
"codemirror": "^6.0.1",
|
|
164
164
|
"cronstrue": "^2.2.0",
|
|
@@ -199,5 +199,5 @@
|
|
|
199
199
|
"prettier --write"
|
|
200
200
|
]
|
|
201
201
|
},
|
|
202
|
-
"gitHead": "
|
|
202
|
+
"gitHead": "d5b28a2e9deb632c0dc80132f6a7196dd6fe4220"
|
|
203
203
|
}
|
package/.editorconfig
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
# EditorConfig helps developers define and maintain consistent
|
|
2
|
-
# coding styles between different editors and IDEs
|
|
3
|
-
# editorconfig.org
|
|
4
|
-
|
|
5
|
-
root = true
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
[*]
|
|
9
|
-
|
|
10
|
-
# Change these settings to your own preference
|
|
11
|
-
indent_style = space
|
|
12
|
-
indent_size = 2
|
|
13
|
-
|
|
14
|
-
# We recommend you to keep these unchanged
|
|
15
|
-
end_of_line = lf
|
|
16
|
-
charset = utf-8
|
|
17
|
-
trim_trailing_whitespace = true
|
|
18
|
-
insert_final_newline = true
|
|
19
|
-
|
|
20
|
-
[*.md]
|
|
21
|
-
trim_trailing_whitespace = false
|
|
22
|
-
|
|
23
|
-
[*.json]
|
|
24
|
-
indent_size = 2
|
|
25
|
-
|
|
26
|
-
[*.{html,js,md}]
|
|
27
|
-
block_comment_start = /**
|
|
28
|
-
block_comment = *
|
|
29
|
-
block_comment_end = */
|
package/.storybook/main.js
DELETED
package/.storybook/server.mjs
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { storybookPlugin } from '@web/dev-server-storybook';
|
|
2
|
-
import baseConfig from '../web-dev-server.config.mjs';
|
|
3
|
-
|
|
4
|
-
export default /** @type {import('@web/dev-server').DevServerConfig} */ ({
|
|
5
|
-
...baseConfig,
|
|
6
|
-
open: '/',
|
|
7
|
-
plugins: [storybookPlugin({ type: 'web-components' }), ...baseConfig.plugins],
|
|
8
|
-
});
|
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
import '@operato/input/ox-checkbox.js'
|
|
2
|
-
import '../selector/ox-selector-resource-id'
|
|
3
|
-
|
|
4
|
-
import { html } from 'lit-html'
|
|
5
|
-
|
|
6
|
-
import { ColumnConfig, FilterConfigObject, FilterSelectRenderer } from '@operato/data-grist'
|
|
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(column: ColumnConfig, value: any, confirmCallback: SelectedCallback) {
|
|
13
|
-
const { queryName, select, list, basicArgs, valueField = 'id', title } = column.record.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-object
|
|
24
|
-
.value=${actualValue}
|
|
25
|
-
.confirmCallback=${confirmCallback}
|
|
26
|
-
.queryName=${queryName}
|
|
27
|
-
.columns=${select}
|
|
28
|
-
.list=${list}
|
|
29
|
-
.basicArgs=${basicArgs}
|
|
30
|
-
.valueField=${valueField}
|
|
31
|
-
></ox-selector-resource-object>
|
|
32
|
-
`
|
|
33
|
-
|
|
34
|
-
const popup = openPopup(template, {
|
|
35
|
-
backdrop: true,
|
|
36
|
-
size: 'large',
|
|
37
|
-
search: {
|
|
38
|
-
autofocus: true,
|
|
39
|
-
placeholder: title || i18next.t('title.select_item'),
|
|
40
|
-
handler: (instance: any, value: any) => {
|
|
41
|
-
/* instance: template instance */
|
|
42
|
-
instance.searchText(value)
|
|
43
|
-
}
|
|
44
|
-
},
|
|
45
|
-
filter: {
|
|
46
|
-
handler: (instance: any) => {
|
|
47
|
-
/* instance: template instance */
|
|
48
|
-
instance.toggleFilter()
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
})
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
export const FilterResourceSelect: FilterSelectRenderer = (column, value, owner: any) => {
|
|
55
|
-
const filter = column.filter as FilterConfigObject
|
|
56
|
-
const { operator = 'like' } = filter
|
|
57
|
-
var { idField = 'id', nameField = 'name', descriptionField = 'description' } = column.record.options || {}
|
|
58
|
-
const hideValue = value ? value[idField] : ''
|
|
59
|
-
const text = value ? value[nameField] : ''
|
|
60
|
-
|
|
61
|
-
return operator === 'like'
|
|
62
|
-
? html` <input
|
|
63
|
-
type="text"
|
|
64
|
-
name=${column.name}
|
|
65
|
-
.value=${text}
|
|
66
|
-
@change=${(e: CustomEvent) => {
|
|
67
|
-
const input = e.target as HTMLInputElement
|
|
68
|
-
input.dispatchEvent(
|
|
69
|
-
new CustomEvent('filter-change', {
|
|
70
|
-
bubbles: true,
|
|
71
|
-
composed: true,
|
|
72
|
-
detail: {
|
|
73
|
-
name: column.name,
|
|
74
|
-
operator,
|
|
75
|
-
value: input.value
|
|
76
|
-
}
|
|
77
|
-
})
|
|
78
|
-
)
|
|
79
|
-
}}
|
|
80
|
-
/>`
|
|
81
|
-
: operator == 'in'
|
|
82
|
-
? html``
|
|
83
|
-
: operator === 'eq'
|
|
84
|
-
? html`
|
|
85
|
-
<input name="${column.name}" .value=${hideValue} type="text" hidden />
|
|
86
|
-
<input
|
|
87
|
-
type="text"
|
|
88
|
-
name="${column.name}_disp"
|
|
89
|
-
.value=${text}
|
|
90
|
-
readonly
|
|
91
|
-
@click=${(e: Event) => {
|
|
92
|
-
e.stopPropagation()
|
|
93
|
-
|
|
94
|
-
const input = e.target as HTMLInputElement
|
|
95
|
-
|
|
96
|
-
const confirmCallback = (selected?: { [field: string]: any }) => {
|
|
97
|
-
let disp = selected ? selected[idField] : ''
|
|
98
|
-
|
|
99
|
-
if (selected && nameField) {
|
|
100
|
-
disp = selected[nameField]
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
input.value = disp
|
|
104
|
-
|
|
105
|
-
let codeInput =
|
|
106
|
-
owner.tagName.toLowerCase() == 'ox-grid-header'
|
|
107
|
-
? owner.renderRoot.querySelector(`[name="${column.name}"]`)
|
|
108
|
-
: owner.renderRoot.querySelector(`form [name="${column.name}"]`)
|
|
109
|
-
|
|
110
|
-
const objectValue = selected ? selected[idField] : ''
|
|
111
|
-
codeInput.value = objectValue
|
|
112
|
-
|
|
113
|
-
input.dispatchEvent(new Event('change', { bubbles: true }))
|
|
114
|
-
|
|
115
|
-
owner.dispatchEvent(
|
|
116
|
-
new CustomEvent('filter-change', {
|
|
117
|
-
bubbles: true,
|
|
118
|
-
composed: true,
|
|
119
|
-
detail: {
|
|
120
|
-
name: column.name,
|
|
121
|
-
operator,
|
|
122
|
-
value: objectValue
|
|
123
|
-
}
|
|
124
|
-
})
|
|
125
|
-
)
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
openResourceSelector(column, value, confirmCallback)
|
|
129
|
-
}}
|
|
130
|
-
/>
|
|
131
|
-
`
|
|
132
|
-
: html``
|
|
133
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import './ox-filter-resource-code.js'
|
|
2
|
-
|
|
3
|
-
import { html } from 'lit-html'
|
|
4
|
-
|
|
5
|
-
import { FilterSelectRenderer } from '@operato/data-grist'
|
|
6
|
-
|
|
7
|
-
export const FilterResourceCode: FilterSelectRenderer = (column, value, owner) => {
|
|
8
|
-
return html`
|
|
9
|
-
<ox-filter-resource-code name=${column?.name} .column=${column} .value=${value}></ox-filter-resource-code>
|
|
10
|
-
`
|
|
11
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import './ox-filter-resource-object.js'
|
|
2
|
-
|
|
3
|
-
import { html } from 'lit-html'
|
|
4
|
-
|
|
5
|
-
import { FilterSelectRenderer } from '@operato/data-grist'
|
|
6
|
-
|
|
7
|
-
export const FilterResourceObject: FilterSelectRenderer = (column, value, owner) => {
|
|
8
|
-
return html`
|
|
9
|
-
<ox-filter-resource-object name=${column?.name} .column=${column} .value=${value}></ox-filter-resource-object>
|
|
10
|
-
`
|
|
11
|
-
}
|
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
import '@operato/input/ox-checkbox.js'
|
|
2
|
-
import '../selector/ox-selector-resource-object'
|
|
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
|
-
import { GristRecord } from '@operato/data-grist'
|
|
10
|
-
|
|
11
|
-
type SelectedCallback = (value?: Partial<GristRecord>) => void
|
|
12
|
-
|
|
13
|
-
function openResourceSelector(filter: FilterConfig, value: any, confirmCallback: SelectedCallback) {
|
|
14
|
-
const { queryName, select, list, basicArgs, valueField = 'id', title } = filter.options || ({} as any)
|
|
15
|
-
|
|
16
|
-
var template = html`
|
|
17
|
-
<ox-selector-resource-object
|
|
18
|
-
.value=${value}
|
|
19
|
-
.confirmCallback=${confirmCallback}
|
|
20
|
-
.queryName=${queryName}
|
|
21
|
-
.columns=${select}
|
|
22
|
-
.list=${list}
|
|
23
|
-
.basicArgs=${basicArgs}
|
|
24
|
-
.valueField=${valueField}
|
|
25
|
-
></ox-selector-resource-object>
|
|
26
|
-
`
|
|
27
|
-
|
|
28
|
-
const popup = openPopup(template, {
|
|
29
|
-
backdrop: true,
|
|
30
|
-
size: 'large',
|
|
31
|
-
search: {
|
|
32
|
-
autofocus: true,
|
|
33
|
-
placeholder: title || i18next.t('title.select_item'),
|
|
34
|
-
handler: (instance: any, value: any) => {
|
|
35
|
-
/* instance: template instance */
|
|
36
|
-
instance.searchText(value)
|
|
37
|
-
}
|
|
38
|
-
},
|
|
39
|
-
filter: {
|
|
40
|
-
handler: (instance: any) => {
|
|
41
|
-
/* instance: template instance */
|
|
42
|
-
instance.toggleFilter()
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
})
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export const FilterResourceSelect: FilterSelectRenderer = (filter, value, owner: any) => {
|
|
49
|
-
const { name, operator = 'like' } = filter
|
|
50
|
-
var { idField = 'id', nameField = 'name', descriptionField = 'description' } = filter.options || ({} as any)
|
|
51
|
-
const hideValue = value ? value[idField] : ''
|
|
52
|
-
const text = value ? value[nameField] : ''
|
|
53
|
-
|
|
54
|
-
return operator === 'like'
|
|
55
|
-
? html` <input
|
|
56
|
-
type="text"
|
|
57
|
-
name=${name}
|
|
58
|
-
.value=${text}
|
|
59
|
-
@change=${(e: CustomEvent) => {
|
|
60
|
-
const input = e.target as HTMLInputElement
|
|
61
|
-
input.dispatchEvent(
|
|
62
|
-
new CustomEvent('filter-change', {
|
|
63
|
-
bubbles: true,
|
|
64
|
-
composed: true,
|
|
65
|
-
detail: {
|
|
66
|
-
name,
|
|
67
|
-
operator,
|
|
68
|
-
value: input.value
|
|
69
|
-
}
|
|
70
|
-
})
|
|
71
|
-
)
|
|
72
|
-
}}
|
|
73
|
-
/>`
|
|
74
|
-
: operator == 'in'
|
|
75
|
-
? html``
|
|
76
|
-
: operator === 'eq'
|
|
77
|
-
? html`
|
|
78
|
-
<input name="${name}" .value=${hideValue} type="text" hidden />
|
|
79
|
-
<input
|
|
80
|
-
type="text"
|
|
81
|
-
name="${name}_disp"
|
|
82
|
-
.value=${text}
|
|
83
|
-
readonly
|
|
84
|
-
@change=${() => false}
|
|
85
|
-
@click=${(e: Event) => {
|
|
86
|
-
e.stopPropagation()
|
|
87
|
-
|
|
88
|
-
const input = e.target as HTMLInputElement
|
|
89
|
-
const codeInput =
|
|
90
|
-
owner.tagName.toLowerCase() == 'ox-grid-header'
|
|
91
|
-
? owner.renderRoot.querySelector(`[name="${name}"]`)
|
|
92
|
-
: owner.renderRoot.querySelector(`form [name="${name}"]`)
|
|
93
|
-
|
|
94
|
-
const confirmCallback = (selected?: { [field: string]: any }) => {
|
|
95
|
-
let disp = selected ? selected[idField] : ''
|
|
96
|
-
|
|
97
|
-
if (selected && nameField) {
|
|
98
|
-
disp = selected[nameField]
|
|
99
|
-
}
|
|
100
|
-
input.value = disp
|
|
101
|
-
|
|
102
|
-
const value = selected ? selected[idField] : ''
|
|
103
|
-
codeInput.value = value
|
|
104
|
-
|
|
105
|
-
codeInput.dispatchEvent(
|
|
106
|
-
new Event('change', {
|
|
107
|
-
bubbles: true,
|
|
108
|
-
composed: true
|
|
109
|
-
})
|
|
110
|
-
)
|
|
111
|
-
|
|
112
|
-
owner.dispatchEvent(
|
|
113
|
-
new CustomEvent('filter-change', {
|
|
114
|
-
bubbles: true,
|
|
115
|
-
composed: true,
|
|
116
|
-
detail: {
|
|
117
|
-
name: name,
|
|
118
|
-
operator,
|
|
119
|
-
value
|
|
120
|
-
}
|
|
121
|
-
})
|
|
122
|
-
)
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
openResourceSelector(filter, codeInput.value, confirmCallback)
|
|
126
|
-
}}
|
|
127
|
-
/>
|
|
128
|
-
`
|
|
129
|
-
: html``
|
|
130
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { registerFilterRenderer } from '@operato/form'
|
|
2
|
-
import { registerFilterRenderer as dataGristFilterRenderer } from '@operato/data-grist'
|
|
3
|
-
|
|
4
|
-
import { FilterResourceSelect } from './filter-resource-select.js'
|
|
5
|
-
|
|
6
|
-
import { FilterResourceCode } from './filter-resource-code.js'
|
|
7
|
-
import { FilterResourceObject } from './filter-resource-object.js'
|
|
8
|
-
|
|
9
|
-
registerFilterRenderer('resource-object', [FilterResourceSelect])
|
|
10
|
-
registerFilterRenderer('resource-id', [FilterResourceSelect])
|
|
11
|
-
|
|
12
|
-
dataGristFilterRenderer('code', [FilterResourceCode])
|
|
13
|
-
dataGristFilterRenderer('object', [FilterResourceObject])
|
|
14
|
-
dataGristFilterRenderer('resource-object', [FilterResourceObject])
|
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
import '@operato/input/ox-select.js'
|
|
2
|
-
|
|
3
|
-
import gql from 'graphql-tag'
|
|
4
|
-
import { css, html } from 'lit'
|
|
5
|
-
import { customElement, property, state } from 'lit/decorators.js'
|
|
6
|
-
|
|
7
|
-
import { i18next } from '@operato/i18n'
|
|
8
|
-
import { FilterConfigObject } from '@operato/data-grist'
|
|
9
|
-
import { client, gqlContext } from '@operato/graphql'
|
|
10
|
-
import { OxFormField } from '@operato/input'
|
|
11
|
-
|
|
12
|
-
type CommonCodeDetail = {
|
|
13
|
-
name: string
|
|
14
|
-
description: string
|
|
15
|
-
rank: number
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const FETCH_COMMON_CODE_GQL = (codeName: string) => gql`
|
|
19
|
-
{
|
|
20
|
-
commonCode(name: "${codeName}") {
|
|
21
|
-
details {
|
|
22
|
-
name
|
|
23
|
-
description
|
|
24
|
-
rank
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
`
|
|
29
|
-
|
|
30
|
-
@customElement('ox-filter-resource-code')
|
|
31
|
-
export class OxFilterResourceCode extends OxFormField {
|
|
32
|
-
static styles = css`
|
|
33
|
-
:host {
|
|
34
|
-
min-width: 100px;
|
|
35
|
-
}
|
|
36
|
-
`
|
|
37
|
-
|
|
38
|
-
@property({ type: Object }) column: any
|
|
39
|
-
@property({ type: String }) value?: string
|
|
40
|
-
|
|
41
|
-
@state() codes?: CommonCodeDetail[]
|
|
42
|
-
|
|
43
|
-
render() {
|
|
44
|
-
const { name, filter } = this.column
|
|
45
|
-
const operator = (filter as FilterConfigObject).operator
|
|
46
|
-
const { selectDispOpt = 'code-name' } = this.column.record || {}
|
|
47
|
-
|
|
48
|
-
if (!this.codes) {
|
|
49
|
-
return html`<p>Loading...</p>`
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
return operator === 'in'
|
|
53
|
-
? html`
|
|
54
|
-
<ox-select
|
|
55
|
-
.value=${this.value}
|
|
56
|
-
@change=${(e: CustomEvent) => {
|
|
57
|
-
let val = e.detail
|
|
58
|
-
this.value = val?.length > 0 ? val : undefined
|
|
59
|
-
|
|
60
|
-
this?.dispatchEvent(
|
|
61
|
-
new CustomEvent('change', {
|
|
62
|
-
detail: {
|
|
63
|
-
name,
|
|
64
|
-
operator,
|
|
65
|
-
value: this.value
|
|
66
|
-
}
|
|
67
|
-
})
|
|
68
|
-
)
|
|
69
|
-
}}
|
|
70
|
-
>
|
|
71
|
-
<ox-popup-list multiple attr-selected="checked" with-search align-left>
|
|
72
|
-
<ox-checkbox
|
|
73
|
-
checkAll
|
|
74
|
-
@click=${(e: any) => {
|
|
75
|
-
const checked = e.target.checked
|
|
76
|
-
const val = checked ? this.codes!.map((code: CommonCodeDetail) => code.name) : []
|
|
77
|
-
|
|
78
|
-
e.target?.dispatchEvent(new CustomEvent('select', { bubbles: true, detail: val }))
|
|
79
|
-
}}
|
|
80
|
-
>${i18next.t('label.all')}</ox-checkbox
|
|
81
|
-
>
|
|
82
|
-
${this.codes
|
|
83
|
-
?.filter((code: CommonCodeDetail) => !!code.name)
|
|
84
|
-
.map(
|
|
85
|
-
(code: CommonCodeDetail) => html`
|
|
86
|
-
<ox-checkbox
|
|
87
|
-
option
|
|
88
|
-
value=${code.name}
|
|
89
|
-
@change=${(e: any) => {
|
|
90
|
-
const parent = e.target.parentElement
|
|
91
|
-
const checkCnt = e.target.checked ? 1 : -1
|
|
92
|
-
const checkedLen = parent.querySelectorAll('ox-checkbox[option][checked]').length + checkCnt
|
|
93
|
-
|
|
94
|
-
parent.querySelector('ox-checkbox[checkAll]').checked =
|
|
95
|
-
this.codes!.filter((code: CommonCodeDetail) => !!code.name).length === checkedLen
|
|
96
|
-
}}
|
|
97
|
-
>${selectDispOpt.replace('name', code.description).replace('code', code.name)}</ox-checkbox
|
|
98
|
-
>
|
|
99
|
-
`
|
|
100
|
-
)}
|
|
101
|
-
</ox-popup-list>
|
|
102
|
-
</ox-select>
|
|
103
|
-
`
|
|
104
|
-
: html`
|
|
105
|
-
<ox-select
|
|
106
|
-
.value=${this.value}
|
|
107
|
-
@change=${(e: CustomEvent) => {
|
|
108
|
-
this.value = e.detail
|
|
109
|
-
this.dispatchEvent(
|
|
110
|
-
new CustomEvent('change', {
|
|
111
|
-
detail: {
|
|
112
|
-
name,
|
|
113
|
-
operator,
|
|
114
|
-
value: this.value
|
|
115
|
-
}
|
|
116
|
-
})
|
|
117
|
-
)
|
|
118
|
-
}}
|
|
119
|
-
>
|
|
120
|
-
<ox-popup-list with-search>
|
|
121
|
-
<div option value=""> </div>
|
|
122
|
-
${this.codes?.map(
|
|
123
|
-
(code: CommonCodeDetail) => html`
|
|
124
|
-
<div option value=${code.name}>
|
|
125
|
-
${selectDispOpt.replace('name', code.description).replace('code', code.name)}
|
|
126
|
-
</div>
|
|
127
|
-
`
|
|
128
|
-
)}
|
|
129
|
-
</ox-popup-list>
|
|
130
|
-
</ox-select>
|
|
131
|
-
`
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
async fetchCodes() {
|
|
135
|
-
const { codeName } = this.column.record || {}
|
|
136
|
-
|
|
137
|
-
if (codeName) {
|
|
138
|
-
const response = await client.query({
|
|
139
|
-
query: FETCH_COMMON_CODE_GQL(codeName),
|
|
140
|
-
context: gqlContext()
|
|
141
|
-
})
|
|
142
|
-
|
|
143
|
-
this.codes = response?.data?.commonCode?.details || []
|
|
144
|
-
|
|
145
|
-
this.requestUpdate()
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
connectedCallback() {
|
|
150
|
-
super.connectedCallback()
|
|
151
|
-
|
|
152
|
-
this.fetchCodes()
|
|
153
|
-
}
|
|
154
|
-
}
|