@operato/dataset 1.0.0-alpha.23 → 1.0.0-alpha.26
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 +28 -0
- package/demo/index.html +1 -1
- package/demo/ox-grist-editor-data-item-spec.html +467 -0
- package/dist/src/grist-editor/index.d.ts +1 -1
- package/dist/src/grist-editor/index.js +3 -3
- package/dist/src/grist-editor/index.js.map +1 -1
- package/dist/src/grist-editor/ox-grist-editor-data-item-spec.d.ts +11 -0
- package/dist/src/grist-editor/{ox-data-item-spec-editor.js → ox-grist-editor-data-item-spec.js} +15 -36
- package/dist/src/grist-editor/ox-grist-editor-data-item-spec.js.map +1 -0
- package/dist/src/grist-editor/{ox-data-item-spec-editor-popup.d.ts → ox-popup-data-item-spec.d.ts} +1 -1
- package/dist/src/grist-editor/{ox-data-item-spec-editor-popup.js → ox-popup-data-item-spec.js} +10 -10
- package/dist/src/grist-editor/ox-popup-data-item-spec.js.map +1 -0
- package/dist/src/ox-data-item-spec.d.ts +1 -1
- package/dist/src/ox-data-item-spec.js +17 -3
- package/dist/src/ox-data-item-spec.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +12 -12
- package/src/grist-editor/index.ts +3 -3
- package/src/grist-editor/{ox-data-item-spec-editor.ts → ox-grist-editor-data-item-spec.ts} +12 -25
- package/src/grist-editor/{ox-data-item-spec-editor-popup.ts → ox-popup-data-item-spec.ts} +2 -2
- package/src/ox-data-item-spec.ts +19 -4
- package/demo/data-item-grist.html +0 -343
- package/dist/src/grist-editor/ox-data-item-spec-editor-popup.js.map +0 -1
- package/dist/src/grist-editor/ox-data-item-spec-editor.d.ts +0 -18
- package/dist/src/grist-editor/ox-data-item-spec-editor.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,34 @@
|
|
|
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
|
+
## [1.0.0-alpha.26](https://github.com/hatiolab/operato/compare/v1.0.0-alpha.25...v1.0.0-alpha.26) (2022-03-17)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @operato/dataset
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## [1.0.0-alpha.25](https://github.com/hatiolab/operato/compare/v1.0.0-alpha.24...v1.0.0-alpha.25) (2022-03-17)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package @operato/dataset
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
## [1.0.0-alpha.24](https://github.com/hatiolab/operato/compare/v1.0.0-alpha.23...v1.0.0-alpha.24) (2022-03-17)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### :bug: Bug Fix
|
|
26
|
+
|
|
27
|
+
* ccp, dataset, property-editor style ([92b2448](https://github.com/hatiolab/operato/commit/92b2448756604ee0b885949dd193241f319cf147))
|
|
28
|
+
* ox-data-item-spec style ([f963757](https://github.com/hatiolab/operato/commit/f963757ccef0144687ce49493281c25a82a259d3))
|
|
29
|
+
* refactoring grist-editor, property-editor and input ([bdc3197](https://github.com/hatiolab/operato/commit/bdc31977d148c80a3ac0bea4b33160bac277df1e))
|
|
30
|
+
* refactoring grist-editor, property-editor and input ([ea7431a](https://github.com/hatiolab/operato/commit/ea7431a5e2dfd96ef392c1905e9622df7c2ef88c))
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
6
34
|
## [1.0.0-alpha.23](https://github.com/hatiolab/operato/compare/v1.0.0-alpha.22...v1.0.0-alpha.23) (2022-03-17)
|
|
7
35
|
|
|
8
36
|
|
package/demo/index.html
CHANGED
|
@@ -21,6 +21,6 @@
|
|
|
21
21
|
<body>
|
|
22
22
|
<a href="./ox-data-entry-form.html">ox-data-entry-form</a>
|
|
23
23
|
<a href="./ox-data-item-spec.html">ox-data-item-spec</a>
|
|
24
|
-
<a href="./data-item-
|
|
24
|
+
<a href="./ox-grist-editor-data-item-spec.html">ox-grist-editor-data-item-spec</a>
|
|
25
25
|
</body>
|
|
26
26
|
</html>
|
|
@@ -0,0 +1,467 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en-GB">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8" />
|
|
5
|
+
<meta name="viewport" />
|
|
6
|
+
<style>
|
|
7
|
+
body {
|
|
8
|
+
/* box-sizing: border-box; */
|
|
9
|
+
margin: 0;
|
|
10
|
+
padding: 0;
|
|
11
|
+
overflow: hidden;
|
|
12
|
+
|
|
13
|
+
/* This is a font-stack that tries to use the system-default sans-serifs first */
|
|
14
|
+
font-family: Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';
|
|
15
|
+
line-height: 1.5;
|
|
16
|
+
-webkit-font-smoothing: antialiased;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
#app {
|
|
20
|
+
width: 100vw;
|
|
21
|
+
height: 100vh;
|
|
22
|
+
|
|
23
|
+
display: flex;
|
|
24
|
+
flex-direction: column;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
#demo {
|
|
28
|
+
flex: 1;
|
|
29
|
+
|
|
30
|
+
display: flex;
|
|
31
|
+
flex-direction: column;
|
|
32
|
+
overflow: hidden;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
grist-demo {
|
|
36
|
+
flex: 1;
|
|
37
|
+
overflow: auto;
|
|
38
|
+
}
|
|
39
|
+
</style>
|
|
40
|
+
<link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500" rel="stylesheet" />
|
|
41
|
+
<link href="https://fonts.googleapis.com/css?family=Material+Icons&display=block" rel="stylesheet" />
|
|
42
|
+
|
|
43
|
+
<link href="/themes/app-theme.css" rel="stylesheet" />
|
|
44
|
+
<link href="/themes/oops-theme.css" rel="stylesheet" />
|
|
45
|
+
<link href="/themes/grist-theme.css" rel="stylesheet" />
|
|
46
|
+
|
|
47
|
+
<script>
|
|
48
|
+
// HACK(keanulee): The Redux package assumes `process` exists - mock it here before
|
|
49
|
+
// the module is loaded.
|
|
50
|
+
window.process = {
|
|
51
|
+
env: {
|
|
52
|
+
NODE_ENV: 'production'
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
</script>
|
|
56
|
+
</head>
|
|
57
|
+
|
|
58
|
+
<body>
|
|
59
|
+
<script type="module">
|
|
60
|
+
window.operato = 1
|
|
61
|
+
|
|
62
|
+
import { LitElement, html, css, render } from 'lit'
|
|
63
|
+
|
|
64
|
+
import '@operato/property-editor/ox-property-editor-checkbox.js'
|
|
65
|
+
import '@operato/property-editor/ox-property-editor-number.js'
|
|
66
|
+
import '@operato/property-editor/ox-property-editor-string.js'
|
|
67
|
+
import '@operato/property-editor/ox-property-editor-options.js'
|
|
68
|
+
|
|
69
|
+
import '@operato/property-editor/ox-properties-dynamic-view.js'
|
|
70
|
+
|
|
71
|
+
import { OxPropertyEditor } from '@operato/property-editor'
|
|
72
|
+
|
|
73
|
+
OxPropertyEditor.register({
|
|
74
|
+
number: 'ox-property-editor-number',
|
|
75
|
+
string: 'ox-property-editor-string',
|
|
76
|
+
boolean: 'ox-property-editor-checkbox',
|
|
77
|
+
options: 'ox-property-editor-options'
|
|
78
|
+
})
|
|
79
|
+
|
|
80
|
+
import '@operato/data-grist'
|
|
81
|
+
import '@operato/data-grist/ox-filters-form.js'
|
|
82
|
+
import '@operato/data-grist/ox-sorters-control.js'
|
|
83
|
+
import '@material/mwc-icon'
|
|
84
|
+
import { CommonGristStyles } from '@operato/styles'
|
|
85
|
+
import { i18next } from '@operato/i18n'
|
|
86
|
+
import { OxGristEditorParameters } from '@operato/app/grist-editor/ox-grist-editor-parameters.js'
|
|
87
|
+
import { OxGristEditorCrontab } from '@operato/app/grist-editor/ox-grist-editor-crontab.js'
|
|
88
|
+
import { OxGristEditorValueMap } from '@operato/app/grist-editor/ox-grist-editor-value-map.js'
|
|
89
|
+
|
|
90
|
+
import { registerEditor } from '@operato/data-grist'
|
|
91
|
+
|
|
92
|
+
registerEditor('parameters', OxGristEditorParameters)
|
|
93
|
+
registerEditor('crontab', OxGristEditorCrontab)
|
|
94
|
+
registerEditor('value-map', OxGristEditorValueMap)
|
|
95
|
+
|
|
96
|
+
/* set grist-editors */
|
|
97
|
+
import '../dist/src/grist-editor/index.js'
|
|
98
|
+
|
|
99
|
+
import { OxDataItemSpec } from '../dist/src/ox-data-item-spec.js'
|
|
100
|
+
|
|
101
|
+
const ccpProvider = dataItem => {
|
|
102
|
+
return {
|
|
103
|
+
name: 'ccp',
|
|
104
|
+
description: 'ccp specs',
|
|
105
|
+
specs: [
|
|
106
|
+
{
|
|
107
|
+
type: 'number',
|
|
108
|
+
label: 'critical limits',
|
|
109
|
+
name: 'criticalLimits',
|
|
110
|
+
property: dataItem
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
type: 'string',
|
|
114
|
+
label: 'target limits',
|
|
115
|
+
name: 'targetLimits',
|
|
116
|
+
property: dataItem
|
|
117
|
+
}
|
|
118
|
+
]
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
const qcProvider = dataItem => {
|
|
123
|
+
return {
|
|
124
|
+
name: 'qc',
|
|
125
|
+
description: 'qc specs',
|
|
126
|
+
specs: [
|
|
127
|
+
{
|
|
128
|
+
type: 'number',
|
|
129
|
+
label: 'critical limits',
|
|
130
|
+
name: 'criticalLimits',
|
|
131
|
+
property: dataItem
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
type: 'boolean',
|
|
135
|
+
label: 'target limits',
|
|
136
|
+
name: 'targetLimits',
|
|
137
|
+
property: dataItem
|
|
138
|
+
}
|
|
139
|
+
]
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
OxDataItemSpec.registerProvider('ccp', ccpProvider)
|
|
144
|
+
OxDataItemSpec.registerProvider('qc', qcProvider)
|
|
145
|
+
|
|
146
|
+
const fetchHandler = async ({ page, limit, sorters = [] }) => {
|
|
147
|
+
var total = 10
|
|
148
|
+
var start = (page - 1) * limit
|
|
149
|
+
|
|
150
|
+
return {
|
|
151
|
+
total,
|
|
152
|
+
records: Array(limit * page > total ? total % limit : limit)
|
|
153
|
+
.fill()
|
|
154
|
+
.map((item, idx) => {
|
|
155
|
+
return {
|
|
156
|
+
id: idx,
|
|
157
|
+
name: `name-${start + idx + 1}`,
|
|
158
|
+
description: `description-${start + idx + 1}`,
|
|
159
|
+
sequence: idx + 1,
|
|
160
|
+
active: true,
|
|
161
|
+
tag: `tag-${idx + 1}`,
|
|
162
|
+
type: idx % 3 === 0 ? 'select' : idx % 3 === 1 ? 'number' : 'string',
|
|
163
|
+
spec: {
|
|
164
|
+
ccp: {
|
|
165
|
+
criticalLimits: 100,
|
|
166
|
+
targetLimits: 200
|
|
167
|
+
},
|
|
168
|
+
qc: {
|
|
169
|
+
criticalLimits: 300,
|
|
170
|
+
targetLimits: true
|
|
171
|
+
}
|
|
172
|
+
},
|
|
173
|
+
options:
|
|
174
|
+
idx % 2 === 0
|
|
175
|
+
? {
|
|
176
|
+
options: [
|
|
177
|
+
{
|
|
178
|
+
text: 'A',
|
|
179
|
+
value: 'a'
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
text: 'B',
|
|
183
|
+
value: 'b'
|
|
184
|
+
}
|
|
185
|
+
]
|
|
186
|
+
}
|
|
187
|
+
: undefined,
|
|
188
|
+
schedule: '* * * * * *',
|
|
189
|
+
keyvalue: {},
|
|
190
|
+
createdAt: Date.now(),
|
|
191
|
+
updatedAt: Date.now()
|
|
192
|
+
}
|
|
193
|
+
})
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
class GristDemo extends LitElement {
|
|
198
|
+
static styles = [
|
|
199
|
+
CommonGristStyles,
|
|
200
|
+
css`
|
|
201
|
+
:host {
|
|
202
|
+
display: flex;
|
|
203
|
+
flex-direction: column;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
#tailer {
|
|
207
|
+
display: flex;
|
|
208
|
+
flex-direction: row;
|
|
209
|
+
margin: 0 var(--margin-default);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
#tailer a {
|
|
213
|
+
padding: 0 var(--padding-default) 0 var(--padding-default);
|
|
214
|
+
margin: 0 var(--margin-narrow);
|
|
215
|
+
border-right: 1px solid rgba(0, 0, 0, 0.1);
|
|
216
|
+
font-size: var(--fontsize-default);
|
|
217
|
+
color: var(--primary-color);
|
|
218
|
+
}
|
|
219
|
+
`
|
|
220
|
+
]
|
|
221
|
+
|
|
222
|
+
static get properties() {
|
|
223
|
+
return {
|
|
224
|
+
mode: String
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
get grist() {
|
|
229
|
+
return this.renderRoot.querySelector('ox-grist')
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
config = {
|
|
233
|
+
list: { fields: ['name', 'description', 'active'] },
|
|
234
|
+
columns: [
|
|
235
|
+
{ type: 'gutter', gutterName: 'row-selector', multiple: true },
|
|
236
|
+
{
|
|
237
|
+
type: 'gutter',
|
|
238
|
+
gutterName: 'button',
|
|
239
|
+
icon: 'add',
|
|
240
|
+
handlers: {
|
|
241
|
+
click: 'record-copy'
|
|
242
|
+
}
|
|
243
|
+
},
|
|
244
|
+
{ type: 'gutter', gutterName: 'sequence' },
|
|
245
|
+
{
|
|
246
|
+
type: 'gutter',
|
|
247
|
+
gutterName: 'button',
|
|
248
|
+
icon: 'arrow_upward',
|
|
249
|
+
handlers: {
|
|
250
|
+
click: 'move-up'
|
|
251
|
+
}
|
|
252
|
+
},
|
|
253
|
+
{
|
|
254
|
+
type: 'gutter',
|
|
255
|
+
gutterName: 'button',
|
|
256
|
+
icon: 'arrow_downward',
|
|
257
|
+
handlers: {
|
|
258
|
+
click: 'move-down'
|
|
259
|
+
}
|
|
260
|
+
},
|
|
261
|
+
{
|
|
262
|
+
type: 'number',
|
|
263
|
+
name: 'sequence',
|
|
264
|
+
hidden: true
|
|
265
|
+
},
|
|
266
|
+
{
|
|
267
|
+
type: 'string',
|
|
268
|
+
name: 'id',
|
|
269
|
+
hidden: true
|
|
270
|
+
},
|
|
271
|
+
{
|
|
272
|
+
type: 'string',
|
|
273
|
+
name: 'name',
|
|
274
|
+
header: i18next.t('field.name'),
|
|
275
|
+
record: {
|
|
276
|
+
editable: true
|
|
277
|
+
},
|
|
278
|
+
width: 140
|
|
279
|
+
},
|
|
280
|
+
{
|
|
281
|
+
type: 'string',
|
|
282
|
+
name: 'description',
|
|
283
|
+
header: i18next.t('field.description'),
|
|
284
|
+
record: {
|
|
285
|
+
editable: true
|
|
286
|
+
},
|
|
287
|
+
width: 180
|
|
288
|
+
},
|
|
289
|
+
{
|
|
290
|
+
type: 'checkbox',
|
|
291
|
+
name: 'active',
|
|
292
|
+
label: true,
|
|
293
|
+
header: i18next.t('field.active'),
|
|
294
|
+
record: {
|
|
295
|
+
editable: true
|
|
296
|
+
},
|
|
297
|
+
sortable: true,
|
|
298
|
+
width: 60
|
|
299
|
+
},
|
|
300
|
+
{
|
|
301
|
+
type: 'string',
|
|
302
|
+
name: 'tag',
|
|
303
|
+
header: i18next.t('field.tag'),
|
|
304
|
+
record: {
|
|
305
|
+
editable: true
|
|
306
|
+
},
|
|
307
|
+
width: 180
|
|
308
|
+
},
|
|
309
|
+
{
|
|
310
|
+
type: 'select',
|
|
311
|
+
name: 'type',
|
|
312
|
+
header: i18next.t('field.type'),
|
|
313
|
+
record: {
|
|
314
|
+
options: ['', 'number', 'text', 'select', 'boolean', 'file'],
|
|
315
|
+
editable: true
|
|
316
|
+
},
|
|
317
|
+
width: 120
|
|
318
|
+
},
|
|
319
|
+
{
|
|
320
|
+
type: 'crontab',
|
|
321
|
+
name: 'schedule',
|
|
322
|
+
header: i18next.t('field.schedule'),
|
|
323
|
+
record: {
|
|
324
|
+
editable: true
|
|
325
|
+
},
|
|
326
|
+
width: 120
|
|
327
|
+
},
|
|
328
|
+
{
|
|
329
|
+
type: 'value-map',
|
|
330
|
+
name: 'keyvalue',
|
|
331
|
+
header: i18next.t('field.keyvalue'),
|
|
332
|
+
record: {
|
|
333
|
+
editable: true,
|
|
334
|
+
options: {
|
|
335
|
+
objectified: true,
|
|
336
|
+
valuetype: 'string'
|
|
337
|
+
}
|
|
338
|
+
},
|
|
339
|
+
width: 120
|
|
340
|
+
},
|
|
341
|
+
{
|
|
342
|
+
type: 'parameters',
|
|
343
|
+
name: 'options',
|
|
344
|
+
header: i18next.t('field.options'),
|
|
345
|
+
record: {
|
|
346
|
+
editable: true,
|
|
347
|
+
renderer: (value, column, record, rowIndex, field) => {
|
|
348
|
+
return typeof value === 'string' ? value : typeof value === 'object' ? JSON.stringify(value) : ''
|
|
349
|
+
},
|
|
350
|
+
options: async (value, column, record, row, field) => {
|
|
351
|
+
return {
|
|
352
|
+
name: record.type,
|
|
353
|
+
help: '',
|
|
354
|
+
spec:
|
|
355
|
+
record.type === 'select'
|
|
356
|
+
? [
|
|
357
|
+
{
|
|
358
|
+
type: 'options',
|
|
359
|
+
name: 'options',
|
|
360
|
+
label: 'options'
|
|
361
|
+
}
|
|
362
|
+
]
|
|
363
|
+
: [],
|
|
364
|
+
context: this.grist,
|
|
365
|
+
objectified: true /* tell parameters editor not to need to parse */
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
},
|
|
369
|
+
width: 120
|
|
370
|
+
},
|
|
371
|
+
{
|
|
372
|
+
type: 'string',
|
|
373
|
+
name: 'unit',
|
|
374
|
+
header: i18next.t('field.unit'),
|
|
375
|
+
record: {
|
|
376
|
+
editable: true
|
|
377
|
+
},
|
|
378
|
+
width: 120
|
|
379
|
+
},
|
|
380
|
+
{
|
|
381
|
+
type: 'number',
|
|
382
|
+
name: 'quota',
|
|
383
|
+
header: i18next.t('field.quota'),
|
|
384
|
+
record: {
|
|
385
|
+
editable: true
|
|
386
|
+
},
|
|
387
|
+
width: 60
|
|
388
|
+
},
|
|
389
|
+
{
|
|
390
|
+
type: 'data-item-spec',
|
|
391
|
+
name: 'spec',
|
|
392
|
+
header: i18next.t('field.spec'),
|
|
393
|
+
record: {
|
|
394
|
+
editable: true,
|
|
395
|
+
options: {
|
|
396
|
+
name,
|
|
397
|
+
objectified: true
|
|
398
|
+
}
|
|
399
|
+
},
|
|
400
|
+
width: 200
|
|
401
|
+
}
|
|
402
|
+
],
|
|
403
|
+
rows: {
|
|
404
|
+
selectable: {
|
|
405
|
+
multiple: true
|
|
406
|
+
}
|
|
407
|
+
},
|
|
408
|
+
pagination: {
|
|
409
|
+
infinite: true
|
|
410
|
+
},
|
|
411
|
+
sorters: [
|
|
412
|
+
{
|
|
413
|
+
name: 'sequence'
|
|
414
|
+
}
|
|
415
|
+
]
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
render() {
|
|
419
|
+
const mode = this.mode || 'CARD'
|
|
420
|
+
|
|
421
|
+
return html`
|
|
422
|
+
<ox-grist .config=${this.config} .mode=${mode} auto-fetch .fetchHandler=${fetchHandler}>
|
|
423
|
+
<div id="filters" slot="headroom">
|
|
424
|
+
<ox-filters-form @filters-change=${e => console.log('changed', e.detail)}></ox-filters-form>
|
|
425
|
+
</div>
|
|
426
|
+
|
|
427
|
+
<div slot="headroom" id="headroom">
|
|
428
|
+
<div id="sorters">
|
|
429
|
+
Sort
|
|
430
|
+
<mwc-icon
|
|
431
|
+
@click=${e => {
|
|
432
|
+
const target = e.currentTarget
|
|
433
|
+
this.renderRoot.querySelector('#sorter-control').open({
|
|
434
|
+
right: 0,
|
|
435
|
+
top: target.offsetTop + target.offsetHeight
|
|
436
|
+
})
|
|
437
|
+
}}
|
|
438
|
+
>expand_more</mwc-icon
|
|
439
|
+
>
|
|
440
|
+
<ox-popup id="sorter-control">
|
|
441
|
+
<ox-sorters-control> </ox-sorters-control>
|
|
442
|
+
</ox-popup>
|
|
443
|
+
</div>
|
|
444
|
+
|
|
445
|
+
<div id="modes">
|
|
446
|
+
<mwc-icon @click=${() => (this.mode = 'GRID')} ?active=${mode == 'GRID'}>view_list</mwc-icon>
|
|
447
|
+
<mwc-icon @click=${() => (this.mode = 'LIST')} ?active=${mode == 'LIST'}>menu</mwc-icon>
|
|
448
|
+
<mwc-icon @click=${() => (this.mode = 'CARD')} ?active=${mode == 'CARD'}>apps</mwc-icon>
|
|
449
|
+
</div>
|
|
450
|
+
</div>
|
|
451
|
+
</ox-grist>
|
|
452
|
+
`
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
customElements.define('ox-data-items', GristDemo)
|
|
457
|
+
|
|
458
|
+
setTimeout(() => {
|
|
459
|
+
render(html` <ox-data-items mode="LIST"></ox-data-items> `, document.querySelector('#demo'))
|
|
460
|
+
})
|
|
461
|
+
</script>
|
|
462
|
+
|
|
463
|
+
<div id="app">
|
|
464
|
+
<div id="demo"></div>
|
|
465
|
+
</div>
|
|
466
|
+
</body>
|
|
467
|
+
</html>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './ox-data-item-spec
|
|
1
|
+
export * from './ox-grist-editor-data-item-spec';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Json5Renderer, registerEditor, registerRenderer } from '@operato/data-grist';
|
|
2
|
-
import {
|
|
2
|
+
import { OxGristEditorDataItemSpec } from './ox-grist-editor-data-item-spec';
|
|
3
3
|
/* register grist renderer/editor for id */
|
|
4
|
-
registerEditor('data-item-spec',
|
|
4
|
+
registerEditor('data-item-spec', OxGristEditorDataItemSpec);
|
|
5
5
|
registerRenderer('data-item-spec', Json5Renderer);
|
|
6
|
-
export * from './ox-data-item-spec
|
|
6
|
+
export * from './ox-grist-editor-data-item-spec';
|
|
7
7
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/grist-editor/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AAErF,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/grist-editor/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AAErF,OAAO,EAAE,yBAAyB,EAAE,MAAM,kCAAkC,CAAA;AAE5E,2CAA2C;AAC3C,cAAc,CAAC,gBAAgB,EAAE,yBAAyB,CAAC,CAAA;AAE3D,gBAAgB,CAAC,gBAAgB,EAAE,aAAa,CAAC,CAAA;AAEjD,cAAc,kCAAkC,CAAA","sourcesContent":["import { Json5Renderer, registerEditor, registerRenderer } from '@operato/data-grist'\n\nimport { OxGristEditorDataItemSpec } from './ox-grist-editor-data-item-spec'\n\n/* register grist renderer/editor for id */\nregisterEditor('data-item-spec', OxGristEditorDataItemSpec)\n\nregisterRenderer('data-item-spec', Json5Renderer)\n\nexport * from './ox-grist-editor-data-item-spec'\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright © HatioLab Inc. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
import './ox-popup-data-item-spec.js';
|
|
5
|
+
import { InputEditor } from '@operato/data-grist';
|
|
6
|
+
export declare class OxGristEditorDataItemSpec extends InputEditor {
|
|
7
|
+
private popup?;
|
|
8
|
+
get editorTemplate(): import("lit-html").TemplateResult<1>;
|
|
9
|
+
firstUpdated(): Promise<void>;
|
|
10
|
+
openSelector(): Promise<void>;
|
|
11
|
+
}
|
package/dist/src/grist-editor/{ox-data-item-spec-editor.js → ox-grist-editor-data-item-spec.js}
RENAMED
|
@@ -2,13 +2,15 @@
|
|
|
2
2
|
* @license Copyright © HatioLab Inc. All rights reserved.
|
|
3
3
|
*/
|
|
4
4
|
import { __decorate } from "tslib";
|
|
5
|
-
import './ox-data-item-spec
|
|
6
|
-
import { LitElement, css, html } from 'lit';
|
|
5
|
+
import './ox-popup-data-item-spec.js';
|
|
7
6
|
import { openPopup } from '@operato/layout';
|
|
8
|
-
import {
|
|
7
|
+
import { InputEditor } from '@operato/data-grist';
|
|
8
|
+
import { cloneDeep } from 'lodash-es';
|
|
9
|
+
import { customElement } from 'lit/decorators.js';
|
|
10
|
+
import { html } from 'lit';
|
|
9
11
|
import { i18next } from '@operato/i18n';
|
|
10
|
-
let
|
|
11
|
-
|
|
12
|
+
let OxGristEditorDataItemSpec = class OxGristEditorDataItemSpec extends InputEditor {
|
|
13
|
+
get editorTemplate() {
|
|
12
14
|
const value = typeof this.value === 'object' ? JSON.stringify(this.value) : this.value;
|
|
13
15
|
return html ` ${value || ''} `;
|
|
14
16
|
}
|
|
@@ -43,7 +45,7 @@ let OxDataItemSpecEditor = class OxDataItemSpecEditor extends LitElement {
|
|
|
43
45
|
}));
|
|
44
46
|
};
|
|
45
47
|
try {
|
|
46
|
-
var value = !objectified && typeof this.value === 'string' ? JSON.parse(this.value) : this.value;
|
|
48
|
+
var value = !objectified && typeof this.value === 'string' ? JSON.parse(this.value) : cloneDeep(this.value || {});
|
|
47
49
|
}
|
|
48
50
|
catch (e) {
|
|
49
51
|
var value = {};
|
|
@@ -57,8 +59,8 @@ let OxDataItemSpecEditor = class OxDataItemSpecEditor extends LitElement {
|
|
|
57
59
|
따라서, 가급적 이들 속성의 레퍼런스를 변화시키지 않는 것이 좋다.
|
|
58
60
|
*/
|
|
59
61
|
var template = html `
|
|
60
|
-
<ox-data-item-spec
|
|
61
|
-
</ox-data-item-spec
|
|
62
|
+
<ox-popup-data-item-spec .value=${value} .dataItem=${this.record} .confirmCallback=${confirmCallback}>
|
|
63
|
+
</ox-popup-data-item-spec>
|
|
62
64
|
`;
|
|
63
65
|
this.popup = openPopup(template, {
|
|
64
66
|
backdrop: true,
|
|
@@ -68,31 +70,8 @@ let OxDataItemSpecEditor = class OxDataItemSpecEditor extends LitElement {
|
|
|
68
70
|
});
|
|
69
71
|
}
|
|
70
72
|
};
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
text-overflow: ellipsis;
|
|
77
|
-
}
|
|
78
|
-
`;
|
|
79
|
-
__decorate([
|
|
80
|
-
property({ type: Object })
|
|
81
|
-
], OxDataItemSpecEditor.prototype, "value", void 0);
|
|
82
|
-
__decorate([
|
|
83
|
-
property({ type: Object })
|
|
84
|
-
], OxDataItemSpecEditor.prototype, "column", void 0);
|
|
85
|
-
__decorate([
|
|
86
|
-
property({ type: Object })
|
|
87
|
-
], OxDataItemSpecEditor.prototype, "record", void 0);
|
|
88
|
-
__decorate([
|
|
89
|
-
property({ type: Number })
|
|
90
|
-
], OxDataItemSpecEditor.prototype, "row", void 0);
|
|
91
|
-
__decorate([
|
|
92
|
-
property({ type: Object })
|
|
93
|
-
], OxDataItemSpecEditor.prototype, "field", void 0);
|
|
94
|
-
OxDataItemSpecEditor = __decorate([
|
|
95
|
-
customElement('ox-data-item-spec-editor')
|
|
96
|
-
], OxDataItemSpecEditor);
|
|
97
|
-
export { OxDataItemSpecEditor };
|
|
98
|
-
//# sourceMappingURL=ox-data-item-spec-editor.js.map
|
|
73
|
+
OxGristEditorDataItemSpec = __decorate([
|
|
74
|
+
customElement('ox-grist-editor-data-item-spec')
|
|
75
|
+
], OxGristEditorDataItemSpec);
|
|
76
|
+
export { OxGristEditorDataItemSpec };
|
|
77
|
+
//# sourceMappingURL=ox-grist-editor-data-item-spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ox-grist-editor-data-item-spec.js","sourceRoot":"","sources":["../../../src/grist-editor/ox-grist-editor-data-item-spec.ts"],"names":[],"mappings":"AAAA;;GAEG;;AAEH,OAAO,8BAA8B,CAAA;AAErC,OAAO,EAAe,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAExD,OAAO,EAAE,WAAW,EAAE,MAAM,qB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,CAAA;IACJ,CAAC;CACF,CAAA;AA5EY,yBAAyB;IADrC,aAAa,CAAC,gCAAgC,CAAC;GACnC,yBAAyB,CA4ErC;SA5EY,yBAAyB","sourcesContent":["/**\n * @license Copyright © HatioLab Inc. All rights reserved.\n */\n\nimport './ox-popup-data-item-spec.js'\n\nimport { PopupHandle, openPopup } from '@operato/layout'\n\nimport { InputEditor } from '@operato/data-grist'\nimport { cloneDeep } from 'lodash-es'\nimport { customElement } from 'lit/decorators.js'\nimport { html } from 'lit'\nimport { i18next } from '@operato/i18n'\n\n@customElement('ox-grist-editor-data-item-spec')\nexport class OxGristEditorDataItemSpec extends InputEditor {\n private popup?: PopupHandle\n\n get editorTemplate() {\n const value = typeof this.value === 'object' ? JSON.stringify(this.value) : this.value\n return html` ${value || ''} `\n }\n\n async firstUpdated() {\n await this.updateComplete\n\n this.renderRoot.addEventListener('click', e => {\n e.stopPropagation()\n\n this.openSelector()\n })\n\n this.openSelector()\n }\n\n async openSelector() {\n if (this.popup) {\n delete this.popup\n }\n\n var { options } = this.column.record\n\n if (typeof options === 'function') {\n options = await options.call(this, this.value, this.column, this.record, this.row, this.field)\n }\n\n const { name, help, objectified = false } = options\n\n const confirmCallback = (newval: any) => {\n this.dispatchEvent(\n new CustomEvent('field-change', {\n bubbles: true,\n composed: true,\n detail: {\n before: this.value,\n after: !objectified ? JSON.stringify(newval) : newval,\n record: this.record,\n column: this.column,\n row: this.row\n }\n })\n )\n }\n\n try {\n var value: any =\n !objectified && typeof this.value === 'string' ? JSON.parse(this.value) : cloneDeep(this.value || {})\n } catch (e) {\n var value: any = {}\n }\n\n /* \n 주의 : 이 팝업 템플릿은 layout 모듈에 의해서 render 되므로, \n layout의 구성에 변화가 발생하면, 다시 render된다.\n 이 팝업이 떠 있는 상태에서, 또 다른 팝업이 뜨는 경우도 layout 구성의 변화를 야기한다. (overlay의 갯수의 증가)\n 이 경우 value, options, confirmCallback 등 클로져를 사용한 것들이 초기 바인딩된 값으로 다시 바인딩되게 되는데,\n 만약, 템플릿 내부에서 이들 속성의 레퍼런스가 변화했다면, 원래 상태로 되돌아가는 현상이 발생하게 된다.\n 따라서, 가급적 이들 속성의 레퍼런스를 변화시키지 않는 것이 좋다.\n */\n var template = html`\n <ox-popup-data-item-spec .value=${value} .dataItem=${this.record} .confirmCallback=${confirmCallback}>\n </ox-popup-data-item-spec>\n `\n\n this.popup = openPopup(template, {\n backdrop: true,\n size: 'large',\n title: `${name?.toUpperCase() || ''} ${i18next.t('field.spec')}`,\n help\n })\n }\n}\n"]}
|
package/dist/src/grist-editor/{ox-data-item-spec-editor-popup.d.ts → ox-popup-data-item-spec.d.ts}
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import '../ox-data-item-spec.js';
|
|
2
2
|
import { LitElement } from 'lit';
|
|
3
3
|
import { DataItem } from '../types.js';
|
|
4
|
-
export declare class
|
|
4
|
+
export declare class OxPopupDataItemSpec extends LitElement {
|
|
5
5
|
static styles: import("lit").CSSResult[];
|
|
6
6
|
value: any;
|
|
7
7
|
dataItem?: DataItem;
|