@operato/app 1.0.0-alpha.9 → 1.0.0-beta.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.
Files changed (145) hide show
  1. package/@types/global/index.d.ts +2 -0
  2. package/CHANGELOG.md +335 -17
  3. package/demo/data-grist-test.html +15 -10
  4. package/demo/index.html +1 -10
  5. package/dist/src/{grist → grist-editor}/index.d.ts +0 -0
  6. package/dist/src/grist-editor/index.js +28 -0
  7. package/dist/src/grist-editor/index.js.map +1 -0
  8. package/dist/src/grist-editor/ox-grist-editor-code.d.ts +7 -0
  9. package/dist/src/grist-editor/ox-grist-editor-code.js +53 -0
  10. package/dist/src/grist-editor/ox-grist-editor-code.js.map +1 -0
  11. package/dist/src/grist-editor/ox-grist-editor-crontab.d.ts +8 -0
  12. package/dist/src/grist-editor/ox-grist-editor-crontab.js +50 -0
  13. package/dist/src/grist-editor/ox-grist-editor-crontab.js.map +1 -0
  14. package/dist/src/grist-editor/ox-grist-editor-json.d.ts +7 -0
  15. package/dist/src/grist-editor/ox-grist-editor-json.js +54 -0
  16. package/dist/src/grist-editor/ox-grist-editor-json.js.map +1 -0
  17. package/dist/src/grist-editor/ox-grist-editor-parameters.d.ts +12 -0
  18. package/dist/src/{grist/parameters-editor.js → grist-editor/ox-grist-editor-parameters.js} +16 -37
  19. package/dist/src/grist-editor/ox-grist-editor-parameters.js.map +1 -0
  20. package/dist/src/grist-editor/ox-grist-editor-partition-keys.d.ts +11 -0
  21. package/dist/src/grist-editor/ox-grist-editor-partition-keys.js +74 -0
  22. package/dist/src/grist-editor/ox-grist-editor-partition-keys.js.map +1 -0
  23. package/dist/src/{grist/code-editor.d.ts → grist-editor/ox-grist-editor-resource-code.d.ts} +2 -2
  24. package/dist/src/{grist/code-editor.js → grist-editor/ox-grist-editor-resource-code.js} +10 -5
  25. package/dist/src/grist-editor/ox-grist-editor-resource-code.js.map +1 -0
  26. package/dist/src/grist-editor/ox-grist-editor-resource-id.d.ts +9 -0
  27. package/dist/src/grist-editor/ox-grist-editor-resource-id.js +72 -0
  28. package/dist/src/grist-editor/ox-grist-editor-resource-id.js.map +1 -0
  29. package/dist/src/grist-editor/ox-grist-editor-resource-object.d.ts +11 -0
  30. package/dist/src/{grist/object-editor.js → grist-editor/ox-grist-editor-resource-object.js} +30 -78
  31. package/dist/src/grist-editor/ox-grist-editor-resource-object.js.map +1 -0
  32. package/dist/src/grist-editor/ox-grist-editor-value-map.d.ts +11 -0
  33. package/dist/src/grist-editor/ox-grist-editor-value-map.js +74 -0
  34. package/dist/src/grist-editor/ox-grist-editor-value-map.js.map +1 -0
  35. package/dist/src/grist-editor/ox-grist-renderer-crontab.d.ts +2 -0
  36. package/dist/src/grist-editor/ox-grist-renderer-crontab.js +26 -0
  37. package/dist/src/grist-editor/ox-grist-renderer-crontab.js.map +1 -0
  38. package/dist/src/grist-editor/ox-grist-renderer-resource-id.d.ts +2 -0
  39. package/dist/src/grist-editor/ox-grist-renderer-resource-id.js +9 -0
  40. package/dist/src/grist-editor/ox-grist-renderer-resource-id.js.map +1 -0
  41. package/dist/src/grist-editor/ox-grist-renderer-resource-object.d.ts +2 -0
  42. package/dist/src/grist-editor/ox-grist-renderer-resource-object.js +22 -0
  43. package/dist/src/grist-editor/ox-grist-renderer-resource-object.js.map +1 -0
  44. package/dist/src/{grist/parameters-editor-builder.d.ts → grist-editor/ox-parameters-builder.d.ts} +1 -1
  45. package/dist/src/{grist/parameters-editor-builder.js → grist-editor/ox-parameters-builder.js} +10 -11
  46. package/dist/src/grist-editor/ox-parameters-builder.js.map +1 -0
  47. package/dist/src/grist-editor/ox-popup-code-input.d.ts +12 -0
  48. package/dist/src/grist-editor/ox-popup-code-input.js +71 -0
  49. package/dist/src/grist-editor/ox-popup-code-input.js.map +1 -0
  50. package/dist/src/grist-editor/ox-popup-crontab-input.d.ts +11 -0
  51. package/dist/src/grist-editor/ox-popup-crontab-input.js +74 -0
  52. package/dist/src/grist-editor/ox-popup-crontab-input.js.map +1 -0
  53. package/dist/src/{grist/parameters-editor-popup.d.ts → grist-editor/ox-popup-parameters-builder.d.ts} +1 -1
  54. package/dist/src/{grist/parameters-editor-popup.js → grist-editor/ox-popup-parameters-builder.js} +15 -15
  55. package/dist/src/grist-editor/ox-popup-parameters-builder.js.map +1 -0
  56. package/dist/src/grist-editor/ox-popup-partition-keys-input.d.ts +12 -0
  57. package/dist/src/grist-editor/ox-popup-partition-keys-input.js +98 -0
  58. package/dist/src/grist-editor/ox-popup-partition-keys-input.js.map +1 -0
  59. package/dist/src/grist-editor/ox-popup-value-map-input.d.ts +12 -0
  60. package/dist/src/grist-editor/ox-popup-value-map-input.js +104 -0
  61. package/dist/src/grist-editor/ox-popup-value-map-input.js.map +1 -0
  62. package/dist/src/{grist/id-selector.d.ts → grist-editor/ox-selector-resource-id.d.ts} +4 -3
  63. package/dist/src/{grist/id-selector.js → grist-editor/ox-selector-resource-id.js} +23 -18
  64. package/dist/src/grist-editor/ox-selector-resource-id.js.map +1 -0
  65. package/dist/src/{grist/object-selector.d.ts → grist-editor/ox-selector-resource-object.d.ts} +4 -3
  66. package/dist/src/{grist/object-selector.js → grist-editor/ox-selector-resource-object.js} +30 -25
  67. package/dist/src/grist-editor/ox-selector-resource-object.js.map +1 -0
  68. package/dist/src/index.d.ts +3 -1
  69. package/dist/src/index.js +3 -1
  70. package/dist/src/index.js.map +1 -1
  71. package/dist/src/input/index.d.ts +3 -0
  72. package/dist/src/input/index.js +4 -0
  73. package/dist/src/input/index.js.map +1 -0
  74. package/dist/src/input/ox-input-background-pattern.d.ts +1 -1
  75. package/dist/src/input/ox-input-background-pattern.js +6 -3
  76. package/dist/src/input/ox-input-background-pattern.js.map +1 -1
  77. package/dist/src/input/ox-input-fill-style.d.ts +2 -3
  78. package/dist/src/input/ox-input-fill-style.js +2 -2
  79. package/dist/src/input/ox-input-fill-style.js.map +1 -1
  80. package/dist/src/input/ox-input-graphql.d.ts +36 -0
  81. package/dist/src/input/ox-input-graphql.js +161 -0
  82. package/dist/src/input/ox-input-graphql.js.map +1 -0
  83. package/dist/src/property-editor/index.d.ts +24 -0
  84. package/dist/src/property-editor/index.js +58 -0
  85. package/dist/src/property-editor/index.js.map +1 -0
  86. package/dist/src/property-editor/ox-property-editor-graphql.d.ts +5 -0
  87. package/dist/src/property-editor/ox-property-editor-graphql.js +15 -0
  88. package/dist/src/property-editor/ox-property-editor-graphql.js.map +1 -0
  89. package/dist/tsconfig.tsbuildinfo +1 -1
  90. package/package.json +44 -22
  91. package/src/grist-editor/index.ts +30 -0
  92. package/src/grist-editor/ox-grist-editor-code.ts +62 -0
  93. package/src/grist-editor/ox-grist-editor-crontab.ts +62 -0
  94. package/src/grist-editor/ox-grist-editor-json.ts +62 -0
  95. package/src/{grist/parameters-editor.ts → grist-editor/ox-grist-editor-parameters.ts} +13 -26
  96. package/src/grist-editor/ox-grist-editor-partition-keys.ts +86 -0
  97. package/src/{grist/code-editor.ts → grist-editor/ox-grist-editor-resource-code.ts} +4 -5
  98. package/src/grist-editor/ox-grist-editor-resource-id.ts +85 -0
  99. package/src/{grist/object-editor.ts → grist-editor/ox-grist-editor-resource-object.ts} +28 -63
  100. package/src/grist-editor/ox-grist-editor-value-map.ts +86 -0
  101. package/src/grist-editor/ox-grist-renderer-crontab.ts +30 -0
  102. package/src/{grist/id-renderer.ts → grist-editor/ox-grist-renderer-resource-id.ts} +4 -3
  103. package/src/grist-editor/ox-grist-renderer-resource-object.ts +26 -0
  104. package/src/{grist/parameters-editor-builder.ts → grist-editor/ox-parameters-builder.ts} +4 -6
  105. package/src/grist-editor/ox-popup-code-input.ts +65 -0
  106. package/src/grist-editor/ox-popup-crontab-input.ts +74 -0
  107. package/src/{grist/parameters-editor-popup.ts → grist-editor/ox-popup-parameters-builder.ts} +5 -5
  108. package/src/grist-editor/ox-popup-partition-keys-input.ts +95 -0
  109. package/src/grist-editor/ox-popup-value-map-input.ts +101 -0
  110. package/src/{grist/id-selector.ts → grist-editor/ox-selector-resource-id.ts} +12 -6
  111. package/src/{grist/object-selector.ts → grist-editor/ox-selector-resource-object.ts} +15 -9
  112. package/src/index.ts +3 -1
  113. package/src/input/index.ts +3 -0
  114. package/src/input/ox-input-background-pattern.ts +6 -3
  115. package/src/input/ox-input-fill-style.ts +3 -4
  116. package/src/input/ox-input-graphql.ts +169 -0
  117. package/src/property-editor/index.ts +59 -0
  118. package/src/property-editor/ox-property-editor-graphql.ts +12 -0
  119. package/themes/app-theme.css +142 -0
  120. package/themes/grist-theme.css +194 -0
  121. package/themes/oops-theme.css +26 -0
  122. package/themes/report-theme.css +47 -0
  123. package/dist/src/grist/code-editor.js.map +0 -1
  124. package/dist/src/grist/id-input.d.ts +0 -19
  125. package/dist/src/grist/id-input.js +0 -119
  126. package/dist/src/grist/id-input.js.map +0 -1
  127. package/dist/src/grist/id-renderer.d.ts +0 -2
  128. package/dist/src/grist/id-renderer.js +0 -9
  129. package/dist/src/grist/id-renderer.js.map +0 -1
  130. package/dist/src/grist/id-selector.js.map +0 -1
  131. package/dist/src/grist/index.js +0 -11
  132. package/dist/src/grist/index.js.map +0 -1
  133. package/dist/src/grist/object-editor.d.ts +0 -18
  134. package/dist/src/grist/object-editor.js.map +0 -1
  135. package/dist/src/grist/object-selector.js.map +0 -1
  136. package/dist/src/grist/parameters-editor-builder.js.map +0 -1
  137. package/dist/src/grist/parameters-editor-popup.js.map +0 -1
  138. package/dist/src/grist/parameters-editor.d.ts +0 -19
  139. package/dist/src/grist/parameters-editor.js.map +0 -1
  140. package/dist/src/input/ox-input-color-gradient.d.ts +0 -25
  141. package/dist/src/input/ox-input-color-gradient.js +0 -318
  142. package/dist/src/input/ox-input-color-gradient.js.map +0 -1
  143. package/src/grist/id-input.ts +0 -135
  144. package/src/grist/index.ts +0 -13
  145. package/src/input/ox-input-color-gradient.ts +0 -341
@@ -1,57 +1,19 @@
1
1
  import '@material/mwc-icon'
2
- import './object-selector.js'
2
+ import './ox-selector-resource-object.js'
3
3
 
4
- import { ColumnConfig, GristData, GristRecord, ZERO_COLUMN, ZERO_CONFIG, ZERO_RECORD } from '@operato/data-grist'
5
- import { LitElement, TemplateResult, css, html } from 'lit'
6
- import { PopupHandle, openPopup } from '@operato/layout'
7
- import { customElement, property } from 'lit/decorators.js'
4
+ import { html, TemplateResult } from 'lit'
5
+ import { customElement } from 'lit/decorators.js'
8
6
 
7
+ import { OxGristEditor } from '@operato/data-grist'
9
8
  import { i18next } from '@operato/i18n'
9
+ import { openPopup, PopupHandle } from '@operato/layout'
10
10
 
11
- @customElement('ox-object-editor')
12
- export class ObjectEditor extends LitElement {
13
- static styles = css`
14
- :host {
15
- display: flex;
16
- flex-flow: row nowrap;
17
-
18
- padding: 7px 0px;
19
- box-sizing: border-box;
20
-
21
- width: 100%;
22
- height: 100%;
23
-
24
- border: 0;
25
- background-color: transparent;
26
-
27
- font: var(--grist-object-editor-font);
28
- color: var(--grist-object-editor-color);
29
- justify-content: inherit;
30
- }
31
-
32
- span {
33
- display: flex;
34
- flex: auto;
35
-
36
- justify-content: inherit;
37
- }
38
-
39
- mwc-icon {
40
- width: 20px;
41
- font-size: 1.5em;
42
- margin-left: auto;
43
- }
44
- `
45
-
46
- @property({ type: Object }) value: { [prop: string]: any } = {}
47
- @property({ type: Object }) column: ColumnConfig = ZERO_COLUMN
48
- @property({ type: Object }) record: GristRecord = ZERO_RECORD
49
- @property({ type: Number }) row?: number
50
-
11
+ @customElement('ox-grist-editor-resource-object')
12
+ export class OxGristEditorResourceObject extends OxGristEditor {
51
13
  private popup?: PopupHandle
52
14
  private template?: TemplateResult
53
15
 
54
- render() {
16
+ get editorTemplate() {
55
17
  var value = this.value || {}
56
18
 
57
19
  var { nameField = 'name', descriptionField = 'description' } = this.column.record.options || {}
@@ -75,7 +37,6 @@ export class ObjectEditor extends LitElement {
75
37
  }
76
38
 
77
39
  async firstUpdated() {
78
- this.value = this.record[this.column.name]
79
40
  this.template = ((this.column.record || {}).options || {}).template
80
41
 
81
42
  await this.updateComplete
@@ -85,6 +46,8 @@ export class ObjectEditor extends LitElement {
85
46
 
86
47
  this.openSelector()
87
48
  })
49
+
50
+ this.openSelector()
88
51
  }
89
52
 
90
53
  openSelector() {
@@ -92,7 +55,7 @@ export class ObjectEditor extends LitElement {
92
55
  delete this.popup
93
56
  }
94
57
 
95
- const confirmCallback = (selected: { [field: string]: any }) => {
58
+ const confirmCallback = (selected?: { [field: string]: any }) => {
96
59
  var { idField = 'id', nameField = 'name', descriptionField = 'description' } = this.column.record.options || {}
97
60
 
98
61
  this.dispatchEvent(
@@ -101,19 +64,21 @@ export class ObjectEditor extends LitElement {
101
64
  composed: true,
102
65
  detail: {
103
66
  before: this.value,
104
- after: {
105
- ...(this.column.record.options.select || [])
106
- .map((field: any) => field.name)
107
- .reduce((obj: { [field: string]: any }, fieldName: string) => {
108
- return (obj = {
109
- ...obj,
110
- [fieldName]: selected[fieldName]
111
- })
112
- }, {} as { [field: string]: any }),
113
- [idField]: selected[idField],
114
- [nameField]: selected[nameField],
115
- [descriptionField]: selected[descriptionField]
116
- },
67
+ after: selected
68
+ ? {
69
+ ...(this.column.record.options.select || [])
70
+ .map((field: any) => field.name)
71
+ .reduce((obj: { [field: string]: any }, fieldName: string) => {
72
+ return (obj = {
73
+ ...obj,
74
+ [fieldName]: selected[fieldName]
75
+ })
76
+ }, {} as { [field: string]: any }),
77
+ [idField]: selected[idField],
78
+ [nameField]: selected[nameField],
79
+ [descriptionField]: selected[descriptionField]
80
+ }
81
+ : null,
117
82
  record: this.record,
118
83
  column: this.column,
119
84
  row: this.row
@@ -134,7 +99,7 @@ export class ObjectEditor extends LitElement {
134
99
  var template =
135
100
  this.template ||
136
101
  html`
137
- <object-selector
102
+ <ox-selector-resource-object
138
103
  .value=${actualValue}
139
104
  .confirmCallback=${confirmCallback.bind(this)}
140
105
  .queryName=${this.column.record.options.queryName}
@@ -142,7 +107,7 @@ export class ObjectEditor extends LitElement {
142
107
  .list=${this.column.record.options.list}
143
108
  .basicArgs=${this.column.record.options.basicArgs}
144
109
  .valueField=${this.column.record.options.valueField}
145
- ></object-selector>
110
+ ></ox-selector-resource-object>
146
111
  `
147
112
 
148
113
  this.popup = openPopup(template, {
@@ -0,0 +1,86 @@
1
+ /**
2
+ * @license Copyright © HatioLab Inc. All rights reserved.
3
+ */
4
+
5
+ import './ox-popup-value-map-input.js'
6
+
7
+ import { ColumnConfig, GristRecord, OxGristEditor } from '@operato/data-grist'
8
+ import { PopupHandle, openPopup } from '@operato/layout'
9
+ import { css, html } from 'lit'
10
+ import { customElement, property } from 'lit/decorators.js'
11
+
12
+ import { cloneDeep } from 'lodash-es'
13
+ import { i18next } from '@operato/i18n'
14
+
15
+ @customElement('ox-grist-editor-value-map')
16
+ export class OxGristEditorValueMap extends OxGristEditor {
17
+ private popup?: PopupHandle
18
+
19
+ get editorTemplate() {
20
+ const value = typeof this.value === 'object' ? JSON.stringify(this.value) : this.value
21
+ return html` ${value || ''} `
22
+ }
23
+
24
+ async firstUpdated() {
25
+ await this.updateComplete
26
+
27
+ this.renderRoot.addEventListener('click', e => {
28
+ e.stopPropagation()
29
+
30
+ this.openSelector()
31
+ })
32
+
33
+ this.openSelector()
34
+ }
35
+
36
+ async openSelector() {
37
+ if (this.popup) {
38
+ delete this.popup
39
+ }
40
+
41
+ const { name, help, valuetype = 'string', objectified = false } = this.column.record?.options || {}
42
+
43
+ const confirmCallback = (newval: any) => {
44
+ this.dispatchEvent(
45
+ new CustomEvent('field-change', {
46
+ bubbles: true,
47
+ composed: true,
48
+ detail: {
49
+ before: this.value,
50
+ after: !objectified ? JSON.stringify(newval) : newval,
51
+ record: this.record,
52
+ column: this.column,
53
+ row: this.row
54
+ }
55
+ })
56
+ )
57
+ }
58
+
59
+ try {
60
+ var value: any =
61
+ !objectified && typeof this.value === 'string' ? JSON.parse(this.value) : cloneDeep(this.value || {})
62
+ } catch (e) {
63
+ var value: any = {}
64
+ }
65
+
66
+ /*
67
+ 주의 : 이 팝업 템플릿은 layout 모듈에 의해서 render 되므로,
68
+ layout의 구성에 변화가 발생하면, 다시 render된다.
69
+ 이 팝업이 떠 있는 상태에서, 또 다른 팝업이 뜨는 경우도 layout 구성의 변화를 야기한다. (overlay의 갯수의 증가)
70
+ 이 경우 value, options, confirmCallback 등 클로져를 사용한 것들이 초기 바인딩된 값으로 다시 바인딩되게 되는데,
71
+ 만약, 템플릿 내부에서 이들 속성의 레퍼런스가 변화했다면, 원래 상태로 되돌아가는 현상이 발생하게 된다.
72
+ 따라서, 가급적 이들 속성의 레퍼런스를 변화시키지 않는 것이 좋다.
73
+ */
74
+ var template = html`
75
+ <ox-popup-value-map-input .value=${value} .valuetype=${valuetype} .confirmCallback=${confirmCallback}>
76
+ </ox-popup-value-map-input>
77
+ `
78
+
79
+ this.popup = openPopup(template, {
80
+ backdrop: true,
81
+ size: 'large',
82
+ title: `${name?.toUpperCase() || i18next.t('field.value-map')} `,
83
+ help
84
+ })
85
+ }
86
+ }
@@ -0,0 +1,30 @@
1
+ import { FieldRenderer } from '@operato/data-grist'
2
+ import cronstrue from 'cronstrue/i18n'
3
+ import { detectOverflow } from '@operato/utils'
4
+ import { html } from 'lit'
5
+ import i18next from 'i18next'
6
+
7
+ function onmouseover(e: Event) {
8
+ const element = e.target as HTMLSpanElement
9
+ if (detectOverflow(element)) {
10
+ element.setAttribute('data-tooltip', element.textContent!)
11
+ }
12
+ }
13
+
14
+ function onmouseout(e: Event) {
15
+ const element = e.target as HTMLSpanElement
16
+ element.removeAttribute('data-tooltip')
17
+ }
18
+
19
+ export const OxGristRendererCrontab: FieldRenderer = (value, column, record, rowIndex, field) => {
20
+ let text = ''
21
+
22
+ try {
23
+ const language = (i18next.language || 'en').substring(0, 2)
24
+ text = value === undefined ? '' : cronstrue.toString(value, { locale: language || 'en' })
25
+ } catch (e) {
26
+ console.error(e)
27
+ }
28
+
29
+ return html`<span @mouseover=${onmouseover} @mouseout=${onmouseout}>${text}</span>`
30
+ }
@@ -1,12 +1,13 @@
1
- import { FieldRenderer } from '@operato/data-grist'
2
1
  import { html } from 'lit'
3
2
 
4
- export const IdRenderer: FieldRenderer = (value, column, record, rowIndex, field) => {
3
+ import { FieldRenderer } from '@operato/data-grist'
4
+
5
+ export const OxGristRendererResourceId: FieldRenderer = (value, column, record, rowIndex, field) => {
5
6
  if (!value) {
6
7
  return ''
7
8
  }
8
9
 
9
10
  var { nameField = 'name', descriptionField = 'description' } = column.record.options || {}
10
11
 
11
- return html` ${value[nameField] || ''}(${value[descriptionField] || ''}) `
12
+ return html`<span>${value[nameField] || ''}(${value[descriptionField] || ''})</span> `
12
13
  }
@@ -0,0 +1,26 @@
1
+ import { html } from 'lit-html'
2
+
3
+ import { FieldRenderer } from '@operato/data-grist'
4
+
5
+ export const OxGristRendererResourceObject: FieldRenderer = (value, column, record, rowIndex, field) => {
6
+ if (!value) {
7
+ return ''
8
+ }
9
+
10
+ var { nameField = 'name', descriptionField = 'description' } = column.record.options || {}
11
+ var name, description
12
+
13
+ if (typeof nameField === 'function') {
14
+ name = nameField(value)
15
+ } else {
16
+ name = value[nameField]
17
+ }
18
+
19
+ if (typeof descriptionField === 'function') {
20
+ description = descriptionField(value)
21
+ } else {
22
+ description = value[descriptionField] && `(${value[descriptionField]})`
23
+ }
24
+
25
+ return html`<span>${name || ''}${description || ''}</span> `
26
+ }
@@ -2,8 +2,6 @@
2
2
  * @license Copyright © HatioLab Inc. All rights reserved.
3
3
  */
4
4
 
5
- import '@things-factory/modeller-ui'
6
-
7
5
  import { LitElement, PropertyValues, html } from 'lit'
8
6
  import { OxPropertyEditor, PropertySpec } from '@operato/property-editor'
9
7
  import { customElement, property } from 'lit/decorators.js'
@@ -16,12 +14,12 @@ import { store } from '@operato/shell'
16
14
 
17
15
  Example:
18
16
 
19
- <ox-parameters-editor-builder value="{{value}}">
17
+ <ox-parameters-builder value="{{value}}">
20
18
  <label>Center X</label>
21
19
  <input type="number" .value="${value.cx}">
22
20
  <label>Width</label>
23
21
  <input type="number" .value="${value.width}">
24
- </ox-parameters-editor-builder>
22
+ </ox-parameters-builder>
25
23
  */
26
24
 
27
25
  const DEFAULT_VALUE = {
@@ -45,8 +43,8 @@ const DEFAULT_VALUE = {
45
43
  date: null
46
44
  } as any
47
45
 
48
- @customElement('ox-parameters-editor-builder')
49
- class ParametersEditorBuilder extends connect(store)(LitElement) {
46
+ @customElement('ox-parameters-builder')
47
+ class OxParametersBuilder extends connect(store)(LitElement) {
50
48
  @property({ type: Object }) value: any
51
49
  @property({ type: Array }) props?: PropertySpec[]
52
50
  @property({ type: Object }) host: any
@@ -0,0 +1,65 @@
1
+ import '@operato/input/ox-input-code.js'
2
+
3
+ import { LitElement, css, html } from 'lit'
4
+ import { customElement, property } from 'lit/decorators.js'
5
+
6
+ import { ScrollbarStyles } from '@operato/styles'
7
+ import { i18next } from '@operato/i18n'
8
+
9
+ @customElement('ox-popup-code-input')
10
+ export class OxPopupCodeInput extends LitElement {
11
+ static styles = [
12
+ ScrollbarStyles,
13
+ css`
14
+ :host {
15
+ display: flex;
16
+ flex-direction: column;
17
+
18
+ background-color: #fff;
19
+
20
+ width: var(--overlay-center-normal-width, 50%);
21
+ height: var(--overlay-center-normal-height, 50%);
22
+ }
23
+
24
+ ox-input-code {
25
+ flex: 1;
26
+ overflow-y: auto;
27
+ }
28
+
29
+ .button-container {
30
+ display: flex;
31
+ margin-left: auto;
32
+ }
33
+ `
34
+ ]
35
+
36
+ @property({ type: Object }) value: any
37
+ @property({ type: String }) mode: string = 'javascript'
38
+ @property({ type: Object }) confirmCallback!: (newval: any) => void
39
+
40
+ render() {
41
+ return html`
42
+ <ox-input-code .value=${this.value} .mode=${this.mode} @change=${this.onChange.bind(this)}> </ox-input-code>
43
+
44
+ <div class="button-container">
45
+ <mwc-button @click=${this.onCancel.bind(this)}>${i18next.t('button.cancel')}</mwc-button>
46
+ <mwc-button @click=${this.onConfirm.bind(this)}>${i18next.t('button.confirm')}</mwc-button>
47
+ </div>
48
+ `
49
+ }
50
+
51
+ private onChange(e: CustomEvent) {
52
+ e.stopPropagation()
53
+
54
+ this.value = e.detail
55
+ }
56
+
57
+ private onCancel(e: Event) {
58
+ history.back()
59
+ }
60
+
61
+ private onConfirm(e: Event) {
62
+ this.confirmCallback && this.confirmCallback(this.value)
63
+ history.back()
64
+ }
65
+ }
@@ -0,0 +1,74 @@
1
+ import '@operato/input/ox-input-crontab.js'
2
+
3
+ import { LitElement, css, html } from 'lit'
4
+ import { customElement, property } from 'lit/decorators.js'
5
+
6
+ import { ScrollbarStyles } from '@operato/styles'
7
+ import { i18next } from '@operato/i18n'
8
+
9
+ @customElement('ox-popup-crontab-input')
10
+ export class OxPopupCrontabInput extends LitElement {
11
+ static styles = [
12
+ ScrollbarStyles,
13
+ css`
14
+ :host {
15
+ display: flex;
16
+ flex-direction: column;
17
+
18
+ background-color: #fff;
19
+
20
+ width: var(--overlay-center-normal-width, 50%);
21
+ height: var(--overlay-center-normal-height, 50%);
22
+ }
23
+
24
+ ox-input-crontab {
25
+ flex: 1;
26
+ overflow-y: auto;
27
+ }
28
+
29
+ span {
30
+ flex: 1;
31
+
32
+ display: flex;
33
+ align-items: center;
34
+ justify-content: center;
35
+
36
+ color: var(--primary-color);
37
+ }
38
+
39
+ .button-container {
40
+ display: flex;
41
+ margin-left: auto;
42
+ }
43
+ `
44
+ ]
45
+
46
+ @property({ type: Object }) value: any
47
+ @property({ type: Object }) confirmCallback!: (newval: any) => void
48
+
49
+ render() {
50
+ return html`
51
+ <ox-input-crontab .value=${this.value} @change=${this.onChange.bind(this)}> </ox-input-crontab>
52
+
53
+ <div class="button-container">
54
+ <mwc-button @click=${this.onCancel.bind(this)}>${i18next.t('button.cancel')}</mwc-button>
55
+ <mwc-button @click=${this.onConfirm.bind(this)}>${i18next.t('button.confirm')}</mwc-button>
56
+ </div>
57
+ `
58
+ }
59
+
60
+ private onChange(e: CustomEvent) {
61
+ e.stopPropagation()
62
+
63
+ this.value = e.detail
64
+ }
65
+
66
+ private onCancel(e: Event) {
67
+ history.back()
68
+ }
69
+
70
+ private onConfirm(e: Event) {
71
+ this.confirmCallback && this.confirmCallback(this.value)
72
+ history.back()
73
+ }
74
+ }
@@ -4,8 +4,8 @@ import { customElement, property } from 'lit/decorators.js'
4
4
  import { ScrollbarStyles } from '@operato/styles'
5
5
  import { i18next } from '@operato/i18n'
6
6
 
7
- @customElement('ox-parameters-editor-popup')
8
- export class ParametersEditorPopup extends LitElement {
7
+ @customElement('ox-popup-parameters-builder')
8
+ export class OxPopupParametersBuilder extends LitElement {
9
9
  static styles = [
10
10
  ScrollbarStyles,
11
11
  css`
@@ -19,7 +19,7 @@ export class ParametersEditorPopup extends LitElement {
19
19
  height: var(--overlay-center-normal-height, 50%);
20
20
  }
21
21
 
22
- ox-parameters-editor-builder {
22
+ ox-parameters-builder {
23
23
  flex: 1;
24
24
  overflow-y: auto;
25
25
  }
@@ -53,14 +53,14 @@ export class ParametersEditorPopup extends LitElement {
53
53
  return html`
54
54
  ${props.length > 0
55
55
  ? html`
56
- <ox-parameters-editor-builder
56
+ <ox-parameters-builder
57
57
  .value=${this.value}
58
58
  .props=${props}
59
59
  .host=${this.host}
60
60
  .context=${this.context}
61
61
  @property-change=${this.onChange.bind(this)}
62
62
  >
63
- </ox-parameters-editor-builder>
63
+ </ox-parameters-builder>
64
64
  `
65
65
  : html` <span><i18n-msg msgid="text.no properties to set"></i18n-msg></span> `}
66
66
 
@@ -0,0 +1,95 @@
1
+ import '@operato/input/ox-input-partition-keys.js'
2
+
3
+ import { LitElement, css, html } from 'lit'
4
+ import { customElement, property } from 'lit/decorators.js'
5
+
6
+ import { ScrollbarStyles } from '@operato/styles'
7
+ import { i18next } from '@operato/i18n'
8
+
9
+ @customElement('ox-popup-partition-keys-input')
10
+ export class OxPopupPartitionKeysInput extends LitElement {
11
+ static styles = [
12
+ ScrollbarStyles,
13
+ css`
14
+ :host {
15
+ display: flex;
16
+ flex-direction: column;
17
+
18
+ background-color: #fff;
19
+
20
+ width: var(--overlay-center-normal-width, 50%);
21
+ height: var(--overlay-center-normal-height, 50%);
22
+ }
23
+
24
+ ox-input-partition-keys {
25
+ flex: 1;
26
+ overflow-y: auto;
27
+ }
28
+
29
+ span {
30
+ flex: 1;
31
+
32
+ display: flex;
33
+ align-items: center;
34
+ justify-content: center;
35
+
36
+ color: var(--primary-color);
37
+ }
38
+
39
+ .button-container {
40
+ display: flex;
41
+ margin-left: auto;
42
+ }
43
+ `
44
+ ]
45
+
46
+ @property({ type: Object }) value: any
47
+ @property({ type: String }) valuetype: string = 'string'
48
+ @property({ type: Object }) confirmCallback!: (newval: any) => void
49
+
50
+ render() {
51
+ return html`
52
+ <ox-input-partition-keys .value=${this.value} @change=${this.onChange.bind(this)}> </ox-input-partition-keys>
53
+
54
+ <div class="button-container">
55
+ <mwc-button @click=${this.onCancel.bind(this)}>${i18next.t('button.cancel')}</mwc-button>
56
+ <mwc-button @click=${this.onConfirm.bind(this)}>${i18next.t('button.confirm')}</mwc-button>
57
+ </div>
58
+ `
59
+ }
60
+
61
+ private onChange(e: CustomEvent) {
62
+ e.stopPropagation()
63
+
64
+ /*
65
+ 주의 : 이 팝업 템플릿은 layout 모듈에 의해서 render 되므로,
66
+ layout의 구성에 변화가 발생하면, 다시 render된다.
67
+ 이 팝업이 떠 있는 상태에서, 또 다른 팝업이 뜨는 경우도 layout 구성의 변화를 야기한다. (overlay의 갯수의 증가)
68
+ 이 경우 value, options, confirmCallback 등 클로져를 사용한 것들이 초기 바인딩된 값으로 다시 바인딩되게 되는데,
69
+ 만약, 템플릿 내부에서 이들 속성의 레퍼런스가 변화했다면, 원래 상태로 되돌아가는 현상이 발생하게 된다.
70
+ 따라서, 가급적 이들 속성의 레퍼런스를 변화시키지 않는 것이 좋다.
71
+ (이 팝업 클래스를 템플릿으로 사용한 곳의 코드를 참조하세요.)
72
+ =>
73
+ 이런 이유로, Object.assign(...)을 사용하였다.
74
+ */
75
+
76
+ if (!this.value || typeof this.value !== 'object') {
77
+ this.value = {}
78
+ }
79
+
80
+ for (let key in this.value) {
81
+ delete this.value[key]
82
+ }
83
+
84
+ Object.assign(this.value, e.detail)
85
+ }
86
+
87
+ private onCancel(e: Event) {
88
+ history.back()
89
+ }
90
+
91
+ private onConfirm(e: Event) {
92
+ this.confirmCallback && this.confirmCallback(this.value)
93
+ history.back()
94
+ }
95
+ }