@operato/app 1.2.52 → 1.3.2
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 +35 -0
- package/dist/src/filter-renderer/filter-resource-select.js +42 -11
- package/dist/src/filter-renderer/filter-resource-select.js.map +1 -1
- package/dist/src/filters-form/filter-resource-select.d.ts +1 -1
- package/dist/src/filters-form/filter-resource-select.js +44 -13
- package/dist/src/filters-form/filter-resource-select.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +17 -16
- package/src/filter-renderer/filter-resource-select.ts +49 -12
- package/src/filters-form/filter-resource-select.ts +49 -14
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": "1.2
|
|
5
|
+
"version": "1.3.2",
|
|
6
6
|
"main": "dist/src/index.js",
|
|
7
7
|
"module": "dist/src/index.js",
|
|
8
8
|
"exports": {
|
|
@@ -26,7 +26,8 @@
|
|
|
26
26
|
"./grist-editor/ox-grist-editor-resource-object.js": "./dist/src/grist-editor/ox-grist-editor-resource-object.js",
|
|
27
27
|
"./grist-editor/ox-grist-editor-resource-object-legacy.js": "./dist/src/grist-editor/ox-grist-editor-resource-object-legacy.js",
|
|
28
28
|
"./grist-editor/ox-grist-editor-resource-code.js": "./dist/src/grist-editor/ox-grist-editor-resource-code.js",
|
|
29
|
-
"./filter-renderer.js": "./dist/src/filter-renderer/index.js"
|
|
29
|
+
"./filter-renderer.js": "./dist/src/filter-renderer/index.js",
|
|
30
|
+
"./filters-form.js": "./dist/src/filters-form/index.js"
|
|
30
31
|
},
|
|
31
32
|
"typesVersions": {
|
|
32
33
|
"*": {
|
|
@@ -119,18 +120,18 @@
|
|
|
119
120
|
"@material/mwc-button": "^0.27.0",
|
|
120
121
|
"@material/mwc-icon": "^0.27.0",
|
|
121
122
|
"@material/mwc-icon-button": "^0.27.0",
|
|
122
|
-
"@operato/attachment": "^1.2
|
|
123
|
-
"@operato/data-grist": "^1.2
|
|
124
|
-
"@operato/font": "^1.2
|
|
125
|
-
"@operato/form": "^1.2
|
|
126
|
-
"@operato/graphql": "^1.2
|
|
127
|
-
"@operato/i18n": "^1.2
|
|
128
|
-
"@operato/input": "^1.2
|
|
129
|
-
"@operato/layout": "^1.2
|
|
130
|
-
"@operato/property-editor": "^1.2
|
|
131
|
-
"@operato/shell": "^1.2
|
|
132
|
-
"@operato/styles": "^1.2
|
|
133
|
-
"@operato/utils": "^1.2
|
|
123
|
+
"@operato/attachment": "^1.3.2",
|
|
124
|
+
"@operato/data-grist": "^1.3.2",
|
|
125
|
+
"@operato/font": "^1.3.2",
|
|
126
|
+
"@operato/form": "^1.3.2",
|
|
127
|
+
"@operato/graphql": "^1.3.2",
|
|
128
|
+
"@operato/i18n": "^1.3.2",
|
|
129
|
+
"@operato/input": "^1.3.2",
|
|
130
|
+
"@operato/layout": "^1.3.2",
|
|
131
|
+
"@operato/property-editor": "^1.3.2",
|
|
132
|
+
"@operato/shell": "^1.3.2",
|
|
133
|
+
"@operato/styles": "^1.3.2",
|
|
134
|
+
"@operato/utils": "^1.3.2",
|
|
134
135
|
"codemirror": "^5.64.0",
|
|
135
136
|
"codemirror-graphql": "^1.3.2",
|
|
136
137
|
"cronstrue": "^2.2.0",
|
|
@@ -156,7 +157,7 @@
|
|
|
156
157
|
"lint-staged": "^13.2.2",
|
|
157
158
|
"prettier": "^2.4.1",
|
|
158
159
|
"tslib": "^2.3.1",
|
|
159
|
-
"typescript": "
|
|
160
|
+
"typescript": "5.0.4"
|
|
160
161
|
},
|
|
161
162
|
"customElements": "custom-elements.json",
|
|
162
163
|
"prettier": "@hatiolab/prettier-config",
|
|
@@ -171,5 +172,5 @@
|
|
|
171
172
|
"prettier --write"
|
|
172
173
|
]
|
|
173
174
|
},
|
|
174
|
-
"gitHead": "
|
|
175
|
+
"gitHead": "956de896ec0e99f6673a694d11adf9879649dd68"
|
|
175
176
|
}
|
|
@@ -10,7 +10,7 @@ import { openPopup } from '@operato/layout'
|
|
|
10
10
|
type SelectedCallback = (value: { id: string; name: string; description: string }) => void
|
|
11
11
|
|
|
12
12
|
function openResourceSelector(column: ColumnConfig, value: any, confirmCallback: SelectedCallback) {
|
|
13
|
-
const { queryName, select, list, basicArgs, valueField = 'id' } = column.record.options
|
|
13
|
+
const { queryName, select, list, basicArgs, valueField = 'id', title } = column.record.options
|
|
14
14
|
|
|
15
15
|
var actualValue
|
|
16
16
|
if (typeof valueField === 'function') {
|
|
@@ -20,33 +20,49 @@ function openResourceSelector(column: ColumnConfig, value: any, confirmCallback:
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
var template = html`
|
|
23
|
-
<ox-selector-resource-
|
|
23
|
+
<ox-selector-resource-object
|
|
24
24
|
.value=${actualValue}
|
|
25
25
|
.confirmCallback=${confirmCallback}
|
|
26
26
|
.queryName=${queryName}
|
|
27
|
-
.
|
|
27
|
+
.columns=${select}
|
|
28
28
|
.list=${list}
|
|
29
29
|
.basicArgs=${basicArgs}
|
|
30
30
|
.valueField=${valueField}
|
|
31
|
-
></ox-selector-resource-
|
|
31
|
+
></ox-selector-resource-object>
|
|
32
32
|
`
|
|
33
33
|
|
|
34
34
|
const popup = openPopup(template, {
|
|
35
35
|
backdrop: true,
|
|
36
36
|
size: 'large',
|
|
37
|
-
|
|
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
|
+
}
|
|
38
51
|
})
|
|
39
52
|
}
|
|
40
53
|
|
|
41
|
-
export const FilterResourceSelect: FilterSelectRenderer = (column, value, owner) => {
|
|
54
|
+
export const FilterResourceSelect: FilterSelectRenderer = (column, value, owner: any) => {
|
|
42
55
|
const filter = column.filter as FilterConfigObject
|
|
43
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] : '';
|
|
44
60
|
|
|
45
61
|
return operator === 'like'
|
|
46
62
|
? html` <input
|
|
47
63
|
type="text"
|
|
48
64
|
name=${column.name}
|
|
49
|
-
.value=${
|
|
65
|
+
.value=${text}
|
|
50
66
|
@change=${(e: CustomEvent) => {
|
|
51
67
|
const input = e.target as HTMLInputElement
|
|
52
68
|
input.dispatchEvent(
|
|
@@ -66,23 +82,44 @@ export const FilterResourceSelect: FilterSelectRenderer = (column, value, owner)
|
|
|
66
82
|
? html``
|
|
67
83
|
: operator === 'eq'
|
|
68
84
|
? html`
|
|
85
|
+
<input name='${column.name}' .value=${hideValue} type="text" hidden></input>
|
|
69
86
|
<input
|
|
70
|
-
style="min-width: 100px; min-height: 24px"
|
|
71
87
|
type="text"
|
|
72
|
-
name
|
|
73
|
-
.value=${
|
|
88
|
+
name='${column.name}_disp'
|
|
89
|
+
.value=${text}
|
|
74
90
|
readonly
|
|
75
91
|
@click=${(e: Event) => {
|
|
76
92
|
e.stopPropagation()
|
|
77
93
|
|
|
94
|
+
const input = e.target as HTMLInputElement;
|
|
95
|
+
|
|
78
96
|
const confirmCallback = (selected?: { [field: string]: any }) => {
|
|
79
|
-
|
|
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 = owner.tagName.toLowerCase() == 'ox-grid-header'
|
|
106
|
+
? owner.renderRoot.querySelector(`[name="${column.name}"]`)
|
|
107
|
+
: owner.renderRoot.querySelector(`form [name="${column.name}"]`);
|
|
108
|
+
|
|
109
|
+
const objectValue = selected ? selected[idField] : '';
|
|
110
|
+
codeInput.value = objectValue;
|
|
111
|
+
|
|
112
|
+
input.dispatchEvent(new Event('change', { bubbles: true }))
|
|
80
113
|
|
|
81
114
|
owner.dispatchEvent(
|
|
82
115
|
new CustomEvent('filter-change', {
|
|
83
116
|
bubbles: true,
|
|
84
117
|
composed: true,
|
|
85
|
-
detail:
|
|
118
|
+
detail: {
|
|
119
|
+
name: column.name,
|
|
120
|
+
operator,
|
|
121
|
+
value: objectValue
|
|
122
|
+
}
|
|
86
123
|
})
|
|
87
124
|
)
|
|
88
125
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import '@operato/input/ox-checkbox.js'
|
|
2
|
-
import '../selector/ox-selector-resource-
|
|
2
|
+
import '../selector/ox-selector-resource-object'
|
|
3
3
|
|
|
4
4
|
import { html } from 'lit-html'
|
|
5
5
|
|
|
@@ -10,7 +10,7 @@ import { openPopup } from '@operato/layout'
|
|
|
10
10
|
type SelectedCallback = (value: { id: string; name: string; description: string }) => void
|
|
11
11
|
|
|
12
12
|
function openResourceSelector(filter: FilterConfig, value: any, confirmCallback: SelectedCallback) {
|
|
13
|
-
const { queryName, select, list, basicArgs, valueField = 'id' } = filter.options || {}
|
|
13
|
+
const { queryName, select, list, basicArgs, valueField = 'id', title } = filter.options || {}
|
|
14
14
|
|
|
15
15
|
var actualValue
|
|
16
16
|
if (typeof valueField === 'function') {
|
|
@@ -20,32 +20,48 @@ function openResourceSelector(filter: FilterConfig, value: any, confirmCallback:
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
var template = html`
|
|
23
|
-
<ox-selector-resource-
|
|
23
|
+
<ox-selector-resource-object
|
|
24
24
|
.value=${actualValue}
|
|
25
25
|
.confirmCallback=${confirmCallback}
|
|
26
26
|
.queryName=${queryName}
|
|
27
|
-
.
|
|
27
|
+
.columns=${select}
|
|
28
28
|
.list=${list}
|
|
29
29
|
.basicArgs=${basicArgs}
|
|
30
30
|
.valueField=${valueField}
|
|
31
|
-
></ox-selector-resource-
|
|
31
|
+
></ox-selector-resource-object>
|
|
32
32
|
`
|
|
33
33
|
|
|
34
34
|
const popup = openPopup(template, {
|
|
35
35
|
backdrop: true,
|
|
36
36
|
size: 'large',
|
|
37
|
-
|
|
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
|
+
}
|
|
38
51
|
})
|
|
39
52
|
}
|
|
40
53
|
|
|
41
|
-
export const FilterResourceSelect: FilterSelectRenderer = (filter, value, owner) => {
|
|
54
|
+
export const FilterResourceSelect: FilterSelectRenderer = (filter, value, owner: any) => {
|
|
42
55
|
const { name, operator = 'like' } = filter
|
|
56
|
+
var { idField = 'id', nameField = 'name', descriptionField = 'description' } = filter.options || {};
|
|
57
|
+
const hideValue = value ? value[idField] : '';
|
|
58
|
+
const text = value ? value[nameField] : '';
|
|
43
59
|
|
|
44
60
|
return operator === 'like'
|
|
45
61
|
? html` <input
|
|
46
62
|
type="text"
|
|
47
63
|
name=${name}
|
|
48
|
-
.value=${
|
|
64
|
+
.value=${text}
|
|
49
65
|
@change=${(e: CustomEvent) => {
|
|
50
66
|
const input = e.target as HTMLInputElement
|
|
51
67
|
input.dispatchEvent(
|
|
@@ -65,23 +81,42 @@ export const FilterResourceSelect: FilterSelectRenderer = (filter, value, owner)
|
|
|
65
81
|
? html``
|
|
66
82
|
: operator === 'eq'
|
|
67
83
|
? html`
|
|
68
|
-
<input
|
|
69
|
-
|
|
84
|
+
<input name='${name}' .value=${hideValue} type="text" hidden></input>
|
|
85
|
+
<input
|
|
70
86
|
type="text"
|
|
71
|
-
name
|
|
72
|
-
.value=${
|
|
87
|
+
name='${name}_disp'
|
|
88
|
+
.value=${text}
|
|
73
89
|
readonly
|
|
74
90
|
@click=${(e: Event) => {
|
|
75
91
|
e.stopPropagation()
|
|
92
|
+
const input = e.target as HTMLInputElement;
|
|
76
93
|
|
|
77
94
|
const confirmCallback = (selected?: { [field: string]: any }) => {
|
|
78
|
-
|
|
95
|
+
let disp = selected ? selected[idField] : '';
|
|
96
|
+
|
|
97
|
+
if(selected && nameField){
|
|
98
|
+
disp = selected[nameField];
|
|
99
|
+
}
|
|
100
|
+
input.value = disp;
|
|
101
|
+
|
|
102
|
+
let codeInput = owner.tagName.toLowerCase() == 'ox-grid-header'
|
|
103
|
+
? owner.renderRoot.querySelector(`[name="${name}"]`)
|
|
104
|
+
: owner.renderRoot.querySelector(`form [name="${name}"]`);
|
|
105
|
+
|
|
106
|
+
const objectValue = selected ? selected[idField] : '';
|
|
107
|
+
codeInput.value = objectValue;
|
|
108
|
+
|
|
109
|
+
input.dispatchEvent(new Event('change', { bubbles: true }))
|
|
79
110
|
|
|
80
111
|
owner.dispatchEvent(
|
|
81
112
|
new CustomEvent('filter-change', {
|
|
82
113
|
bubbles: true,
|
|
83
114
|
composed: true,
|
|
84
|
-
detail:
|
|
115
|
+
detail: {
|
|
116
|
+
name: name,
|
|
117
|
+
operator,
|
|
118
|
+
value: objectValue
|
|
119
|
+
}
|
|
85
120
|
})
|
|
86
121
|
)
|
|
87
122
|
}
|