@operato/dataset 1.0.0-alpha.3 → 1.0.0-alpha.32

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