@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
package/package.json CHANGED
@@ -3,21 +3,32 @@
3
3
  "description": "WebApplication production supporting components following open-wc recommendations",
4
4
  "license": "MIT",
5
5
  "author": "heartyoh",
6
- "version": "1.0.0-alpha.9",
6
+ "version": "1.0.0-beta.2",
7
7
  "main": "dist/src/index.js",
8
8
  "module": "dist/src/index.js",
9
9
  "exports": {
10
10
  ".": "./dist/src/index.js",
11
- "./grist/id-input.js": "./dist/src/grist/id-input.js",
12
- "./grist/id-selector.js": "./dist/src/grist/id-selector.js",
13
- "./grist/id-renderer.js": "./dist/src/grist/id-renderer.js",
14
- "./grist/object-selector.js": "./dist/src/grist/object-selector.js",
15
- "./grist/object-editor.js": "./dist/src/grist/object-editor.js",
16
- "./grist/code-editor.js": "./dist/src/grist/code-editor.js",
17
- "./grist/parameters-editor.js": "./dist/src/grist/parameters-editor.js",
11
+ "./input.js": "./dist/src/input/index.js",
12
+ "./input/ox-input-graphql.js": "./dist/src/input/ox-input-graphql.js",
18
13
  "./input/ox-input-background-pattern.js": "./dist/src/input/ox-input-background-pattern.js",
19
- "./input/ox-input-color-gradient.js": "./dist/src/input/ox-input-color-gradient.js",
20
- "./input/ox-input-fill-style.js": "./dist/src/input/ox-input-fill-style.js"
14
+ "./input/ox-input-fill-style.js": "./dist/src/input/ox-input-fill-style.js",
15
+ "./property-editor.js": "./dist/src/property-editor/index.js",
16
+ "./property-editor/ox-property-editor-graphql.js": "./dist/src/property-editor/ox-property-editor-graphql.js",
17
+ "./grist-editor.js": "./dist/src/grist-editor/index.js",
18
+ "./grist-editor/ox-grist-editor-resource-id.js": "./dist/src/grist-editor/ox-grist-editor-resource-id.js",
19
+ "./grist-editor/ox-selector-resource-id.js": "./dist/src/grist-editor/ox-selector-resource-id.js",
20
+ "./grist-editor/ox-grist-renderer-resource-id.js": "./dist/src/grist-editor/ox-grist-renderer-resource-id.js",
21
+ "./grist-editor/ox-selector-resource-object.js": "./dist/src/grist-editor/ox-selector-resource-object.js",
22
+ "./grist-editor/ox-grist-renderer-resource-object.js": "./dist/src/grist-editor/ox-grist-renderer-resource-object.js",
23
+ "./grist-editor/ox-grist-editor-crontab.js": "./dist/src/grist-editor/ox-grist-editor-crontab.js",
24
+ "./grist-editor/ox-grist-renderer-crontab.js": "./dist/src/grist-editor/ox-grist-renderer-crontab.js",
25
+ "./grist-editor/ox-grist-editor-json.js": "./dist/src/grist-editor/ox-grist-editor-json.js",
26
+ "./grist-editor/ox-grist-editor-code.js": "./dist/src/grist-editor/ox-grist-editor-code.js",
27
+ "./grist-editor/ox-grist-editor-resource-object.js": "./dist/src/grist-editor/ox-grist-editor-resource-object.js",
28
+ "./grist-editor/ox-grist-editor-resource-code.js": "./dist/src/grist-editor/ox-grist-editor-resource-code.js",
29
+ "./grist-editor/ox-grist-editor-parameters.js": "./dist/src/grist-editor/ox-grist-editor-parameters.js",
30
+ "./grist-editor/ox-grist-editor-value-map.js": "./dist/src/grist-editor/ox-grist-editor-value-map.js",
31
+ "./grist-editor/ox-grist-editor-partition-keys.js": "./dist/src/grist-editor/ox-grist-editor-partition-keys.js"
21
32
  },
22
33
  "publishConfig": {
23
34
  "access": "public",
@@ -41,20 +52,31 @@
41
52
  "storybook:build": "tsc && npm run analyze -- --exclude dist && build-storybook"
42
53
  },
43
54
  "dependencies": {
55
+ "@graphql-tools/load": "^7.3.2",
56
+ "@graphql-tools/url-loader": "^7.2.0",
57
+ "@graphql-tools/wrap": "^8.1.1",
44
58
  "@material/mwc-button": "^0.25.3",
45
59
  "@material/mwc-icon": "^0.25.3",
46
60
  "@material/mwc-icon-button": "^0.25.3",
47
- "@operato/attachment": "^1.0.0-alpha.9",
48
- "@operato/data-grist": "^1.0.0-alpha.9",
49
- "@operato/form": "^1.0.0-alpha.9",
50
- "@operato/graphql": "^1.0.0-alpha.9",
51
- "@operato/i18n": "^1.0.0-alpha.9",
52
- "@operato/layout": "^1.0.0-alpha.9",
53
- "@operato/property-editor": "^1.0.0-alpha.9",
54
- "@operato/shell": "^1.0.0-alpha.9",
55
- "@operato/styles": "^1.0.0-alpha.9",
56
- "@operato/utils": "^1.0.0-alpha.9",
57
- "lit": "^2.2.0"
61
+ "@operato/attachment": "^1.0.0-beta.2",
62
+ "@operato/data-grist": "^1.0.0-beta.2",
63
+ "@operato/font": "^1.0.0-beta.2",
64
+ "@operato/form": "^1.0.0-beta.2",
65
+ "@operato/graphql": "^1.0.0-beta.2",
66
+ "@operato/i18n": "^1.0.0-beta.2",
67
+ "@operato/input": "^1.0.0-beta.2",
68
+ "@operato/layout": "^1.0.0-beta.2",
69
+ "@operato/property-editor": "^1.0.0-beta.2",
70
+ "@operato/shell": "^1.0.0-beta.2",
71
+ "@operato/styles": "^1.0.0-beta.2",
72
+ "@operato/utils": "^1.0.0-beta.2",
73
+ "codemirror": "^5.59.1",
74
+ "codemirror-graphql": "^0.15.2",
75
+ "cronstrue": "^2.2.0",
76
+ "cross-fetch": "^3.1.5",
77
+ "graphql": "^15.7.2",
78
+ "graphql-tag": "^2.12.6",
79
+ "lit": "^2.2.1"
58
80
  },
59
81
  "devDependencies": {
60
82
  "@custom-elements-manifest/analyzer": "^0.4.17",
@@ -88,5 +110,5 @@
88
110
  "prettier --write"
89
111
  ]
90
112
  },
91
- "gitHead": "fb82c87ab8b869139076c4e74c46309460b67d35"
113
+ "gitHead": "514a836d3f5e959695701ba41913aee18a1efe66"
92
114
  }
@@ -0,0 +1,30 @@
1
+ import { OxGristRendererJson5, registerEditor, registerRenderer } from '@operato/data-grist'
2
+
3
+ import { OxGristEditorCrontab } from './ox-grist-editor-crontab.js'
4
+ import { OxGristEditorJson } from './ox-grist-editor-json.js'
5
+ import { OxGristEditorParameters } from './ox-grist-editor-parameters.js'
6
+ import { OxGristEditorPartitionKeys } from './ox-grist-editor-partition-keys.js'
7
+ import { OxGristEditorResourceCode } from './ox-grist-editor-resource-code.js'
8
+ import { OxGristEditorResourceId } from './ox-grist-editor-resource-id.js'
9
+ import { OxGristEditorResourceObject } from './ox-grist-editor-resource-object.js'
10
+ import { OxGristEditorValueMap } from './ox-grist-editor-value-map.js'
11
+ import { OxGristRendererCrontab } from './ox-grist-renderer-crontab.js'
12
+ import { OxGristRendererResourceId } from './ox-grist-renderer-resource-id.js'
13
+ import { OxGristRendererResourceObject } from './ox-grist-renderer-resource-object.js'
14
+
15
+ /* register grist renderer/editor for id */
16
+ registerEditor('resource-id', OxGristEditorResourceId)
17
+ registerEditor('resource-object', OxGristEditorResourceObject)
18
+ registerEditor('resource-code', OxGristEditorResourceCode)
19
+ registerEditor('parameters', OxGristEditorParameters)
20
+ registerEditor('value-map', OxGristEditorValueMap)
21
+ registerEditor('partition-keys', OxGristEditorPartitionKeys)
22
+ registerEditor('crontab', OxGristEditorCrontab)
23
+ registerEditor('json', OxGristEditorJson)
24
+
25
+ registerRenderer('resource-id', OxGristRendererResourceId)
26
+ registerRenderer('resource-object', OxGristRendererResourceObject)
27
+ registerRenderer('parameters', OxGristRendererJson5)
28
+ registerRenderer('value-map', OxGristRendererJson5)
29
+ registerRenderer('partition-keys', OxGristRendererJson5)
30
+ registerRenderer('crontab', OxGristRendererCrontab)
@@ -0,0 +1,62 @@
1
+ import './ox-popup-code-input.js'
2
+
3
+ import { html } from 'lit'
4
+ import { customElement } from 'lit/decorators.js'
5
+
6
+ import { OxGristEditor } from '@operato/data-grist'
7
+ import { i18next } from '@operato/i18n'
8
+ import { openPopup } from '@operato/layout'
9
+
10
+ @customElement('ox-grist-editor-code')
11
+ export class OxGristEditorCode extends OxGristEditor {
12
+ get editorTemplate() {
13
+ return html` <input type="text" .value=${this.value || ''} /> `
14
+ }
15
+
16
+ async firstUpdated() {
17
+ await this.updateComplete
18
+
19
+ this.renderRoot.addEventListener('click', e => {
20
+ e.stopPropagation()
21
+
22
+ this.showEditorPopup()
23
+ })
24
+
25
+ this.showEditorPopup()
26
+ }
27
+
28
+ showEditorPopup() {
29
+ var { mode } = this.column.record?.options || {}
30
+
31
+ var change = (value: string) => {
32
+ this.dispatchEvent(
33
+ new CustomEvent('field-change', {
34
+ bubbles: true,
35
+ composed: true,
36
+ detail: {
37
+ before: this.value,
38
+ after: value,
39
+ column: this.column,
40
+ record: this.record,
41
+ row: this.row
42
+ }
43
+ })
44
+ )
45
+ }
46
+
47
+ var popup = openPopup(
48
+ html`
49
+ <ox-popup-code-input
50
+ .value=${this.value}
51
+ mode=${mode}
52
+ .confirmCallback=${change.bind(this)}
53
+ ></ox-popup-code-input>
54
+ `,
55
+ {
56
+ backdrop: true,
57
+ title: i18next.t('title.edit code'),
58
+ help: 'data-grist/grist-editor/code'
59
+ }
60
+ )
61
+ }
62
+ }
@@ -0,0 +1,62 @@
1
+ import './ox-popup-crontab-input.js'
2
+
3
+ import { html } from 'lit'
4
+ import { customElement } from 'lit/decorators.js'
5
+
6
+ import { OxGristEditor } from '@operato/data-grist'
7
+ import { i18next } from '@operato/i18n'
8
+ import { openPopup, PopupHandle } from '@operato/layout'
9
+
10
+ @customElement('ox-grist-editor-crontab')
11
+ export class OxGristEditorCrontab extends OxGristEditor {
12
+ private popup?: PopupHandle
13
+
14
+ get editorTemplate() {
15
+ return html` <input type="text" .value=${this.value || ''} /> `
16
+ }
17
+
18
+ async firstUpdated() {
19
+ await this.updateComplete
20
+
21
+ this.renderRoot.addEventListener('click', e => {
22
+ e.stopPropagation()
23
+
24
+ this.showEditorPopup()
25
+ })
26
+
27
+ this.showEditorPopup()
28
+ }
29
+
30
+ showEditorPopup() {
31
+ if (this.popup) {
32
+ delete this.popup
33
+ }
34
+
35
+ const confirmCallback = (newval: any) => {
36
+ this.dispatchEvent(
37
+ new CustomEvent('field-change', {
38
+ bubbles: true,
39
+ composed: true,
40
+ detail: {
41
+ before: this.value,
42
+ after: newval,
43
+ record: this.record,
44
+ column: this.column,
45
+ row: this.row
46
+ }
47
+ })
48
+ )
49
+ }
50
+
51
+ this.popup = openPopup(
52
+ html`
53
+ <ox-popup-crontab-input .value=${this.value} .confirmCallback=${confirmCallback}></ox-popup-crontab-input>
54
+ `,
55
+ {
56
+ backdrop: true,
57
+ title: i18next.t('title.setting schedule'),
58
+ help: 'data-grist/grist-editor/crontab'
59
+ }
60
+ )
61
+ }
62
+ }
@@ -0,0 +1,62 @@
1
+ import './ox-popup-code-input.js'
2
+
3
+ import { OxGristEditor } from '@operato/data-grist'
4
+ import { customElement } from 'lit/decorators.js'
5
+ import { html } from 'lit'
6
+ import { i18next } from '@operato/i18n'
7
+ import { openPopup } from '@operato/layout'
8
+
9
+ @customElement('ox-grist-editor-json')
10
+ export class OxGristEditorJson extends OxGristEditor {
11
+ get editorTemplate() {
12
+ return html` <input type="text" .value=${this.value || ''} /> `
13
+ }
14
+
15
+ async firstUpdated() {
16
+ await this.updateComplete
17
+
18
+ this.renderRoot.addEventListener('click', e => {
19
+ e.stopPropagation()
20
+
21
+ this.showEditorPopup()
22
+ })
23
+
24
+ this.showEditorPopup()
25
+ }
26
+
27
+ showEditorPopup() {
28
+ var change = (value: string) => {
29
+ this.dispatchEvent(
30
+ new CustomEvent('change', {
31
+ bubbles: true,
32
+ composed: true,
33
+ detail: {
34
+ before: this.value,
35
+ after: value,
36
+ column: this.column,
37
+ record: this.record,
38
+ row: this.row
39
+ }
40
+ })
41
+ )
42
+ }
43
+
44
+ var popup = openPopup(
45
+ html`
46
+ <ox-popup-code-input
47
+ .value=${this.value}
48
+ mode="javascript"
49
+ @change=${(e: CustomEvent) => {
50
+ change(e.detail.value)
51
+ popup.close()
52
+ }}
53
+ ></ox-popup-code-input>
54
+ `,
55
+ {
56
+ backdrop: true,
57
+ title: i18next.t('title.setting schedule'),
58
+ help: 'data-grist/grist-editor/code'
59
+ }
60
+ )
61
+ }
62
+ }
@@ -2,36 +2,22 @@
2
2
  * @license Copyright © HatioLab Inc. All rights reserved.
3
3
  */
4
4
 
5
- import './parameters-editor-builder.js'
6
- import './parameters-editor-popup.js'
5
+ import './ox-parameters-builder.js'
6
+ import './ox-popup-parameters-builder.js'
7
7
 
8
- import { ColumnConfig, GristRecord } from '@operato/data-grist'
9
- import { LitElement, css, html } from 'lit'
8
+ import { ColumnConfig, GristRecord, OxGristEditor } from '@operato/data-grist'
10
9
  import { PopupHandle, openPopup } from '@operato/layout'
11
- import { customElement, property } from 'lit/decorators.js'
10
+ import { css, html } from 'lit'
12
11
 
12
+ import { cloneDeep } from 'lodash-es'
13
+ import { customElement } from 'lit/decorators.js'
13
14
  import { i18next } from '@operato/i18n'
14
15
 
15
- @customElement('ox-parameters-editor')
16
- export class ParametersEditor extends LitElement {
17
- static styles = css`
18
- :host {
19
- color: black;
20
-
21
- overflow: hidden;
22
- text-overflow: ellipsis;
23
- }
24
- `
25
-
26
- @property({ type: Object }) value: any
27
- @property({ type: Object }) column!: ColumnConfig
28
- @property({ type: Object }) record!: GristRecord
29
- @property({ type: Number }) row!: number
30
- @property({ type: Object }) field!: any
31
-
16
+ @customElement('ox-grist-editor-parameters')
17
+ export class OxGristEditorParameters extends OxGristEditor {
32
18
  private popup?: PopupHandle
33
19
 
34
- render() {
20
+ get editorTemplate() {
35
21
  const value = typeof this.value === 'object' ? JSON.stringify(this.value) : this.value
36
22
  return html` ${value || ''} `
37
23
  }
@@ -78,7 +64,8 @@ export class ParametersEditor extends LitElement {
78
64
  }
79
65
 
80
66
  try {
81
- var value: any = !objectified && typeof this.value === 'string' ? JSON.parse(this.value) : this.value
67
+ var value: any =
68
+ !objectified && typeof this.value === 'string' ? JSON.parse(this.value) : cloneDeep(this.value || {})
82
69
  } catch (e) {
83
70
  var value: any = {}
84
71
  }
@@ -92,14 +79,14 @@ export class ParametersEditor extends LitElement {
92
79
  따라서, 가급적 이들 속성의 레퍼런스를 변화시키지 않는 것이 좋다.
93
80
  */
94
81
  var template = html`
95
- <ox-parameters-editor-popup
82
+ <ox-popup-parameters-builder
96
83
  .value=${value}
97
84
  .props=${spec}
98
85
  .host=${this.record}
99
86
  .context=${context}
100
87
  .confirmCallback=${confirmCallback}
101
88
  >
102
- </ox-parameters-editor-popup>
89
+ </ox-popup-parameters-builder>
103
90
  `
104
91
 
105
92
  this.popup = openPopup(template, {
@@ -0,0 +1,86 @@
1
+ /**
2
+ * @license Copyright © HatioLab Inc. All rights reserved.
3
+ */
4
+
5
+ import './ox-popup-partition-keys-input.js'
6
+
7
+ import { html } from 'lit'
8
+ import { customElement } from 'lit/decorators.js'
9
+ import { cloneDeep } from 'lodash-es'
10
+
11
+ import { OxGristEditor } from '@operato/data-grist'
12
+ import { i18next } from '@operato/i18n'
13
+ import { openPopup, PopupHandle } from '@operato/layout'
14
+
15
+ @customElement('ox-grist-editor-partition-keys')
16
+ export class OxGristEditorPartitionKeys 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, 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-partition-keys-input .value=${value} .confirmCallback=${confirmCallback}>
76
+ </ox-popup-partition-keys-input>
77
+ `
78
+
79
+ this.popup = openPopup(template, {
80
+ backdrop: true,
81
+ size: 'large',
82
+ title: `${name?.toUpperCase() || i18next.t('field.partition-keys')} `,
83
+ help
84
+ })
85
+ }
86
+ }
@@ -1,9 +1,9 @@
1
1
  import '@material/mwc-icon'
2
- import {} from '@operato/shell'
3
2
 
4
- import { InputEditor, RecordConfig } from '@operato/data-grist'
3
+ import { OxGristEditor, RecordConfig } from '@operato/data-grist'
5
4
  import { client, gqlContext } from '@operato/graphql'
6
5
 
6
+ import { customElement } from 'lit/decorators.js'
7
7
  import gql from 'graphql-tag'
8
8
  import { html } from 'lit'
9
9
 
@@ -31,7 +31,8 @@ const FETCH_COMMON_CODE_GQL = (codeName: string) => gql`
31
31
  }
32
32
  `
33
33
 
34
- export class CodeEditor extends InputEditor {
34
+ @customElement('ox-grist-editor-resource-code')
35
+ export class OxGristEditorResourceCode extends OxGristEditor {
35
36
  async firstUpdated() {
36
37
  super.firstUpdated()
37
38
 
@@ -74,5 +75,3 @@ export class CodeEditor extends InputEditor {
74
75
  `
75
76
  }
76
77
  }
77
-
78
- customElements.define('code-editor', CodeEditor)
@@ -0,0 +1,85 @@
1
+ import '@material/mwc-icon'
2
+ import './ox-selector-resource-id.js'
3
+
4
+ import { html } from 'lit'
5
+ import { customElement } from 'lit/decorators.js'
6
+
7
+ import { GristRecord, OxGristEditor } from '@operato/data-grist'
8
+ import { openPopup, PopupHandle } from '@operato/layout'
9
+
10
+ @customElement('ox-input-resource-id')
11
+ export class OxGristEditorResourceId extends OxGristEditor {
12
+ private popup?: PopupHandle
13
+
14
+ render() {
15
+ var { nameField = 'name', descriptionField = 'description' } = this.column.record.options || {}
16
+ var value = this.value
17
+
18
+ return html`
19
+ ${!value ? html`` : html` <span>${value[nameField]} (${value[descriptionField]})</span> `}
20
+ <mwc-icon>arrow_drop_down</mwc-icon>
21
+ `
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
+ openSelector() {
37
+ if (this.popup) {
38
+ delete this.popup
39
+ }
40
+
41
+ const confirmCallback: (record?: GristRecord) => void = selected => {
42
+ if (!selected) {
43
+ return
44
+ }
45
+
46
+ var { idField = 'id', nameField = 'name', descriptionField = 'description' } = this.column.record.options || {}
47
+
48
+ this.dispatchEvent(
49
+ new CustomEvent('field-change', {
50
+ bubbles: true,
51
+ composed: true,
52
+ detail: {
53
+ before: this.value,
54
+ after: selected
55
+ ? {
56
+ [idField]: selected[idField],
57
+ [nameField]: selected[nameField],
58
+ [descriptionField]: selected[descriptionField]
59
+ }
60
+ : null,
61
+ record: this.record,
62
+ column: this.column,
63
+ row: this.row
64
+ }
65
+ })
66
+ )
67
+ }
68
+
69
+ var value = this.value || {}
70
+ var template = html`
71
+ <ox-selector-resource-id
72
+ .value=${value.id}
73
+ .confirmCallback=${confirmCallback.bind(this)}
74
+ .queryName=${this.column.record.options.queryName}
75
+ .basicArgs=${this.column.record.options.basicArgs}
76
+ ></ox-selector-resource-id>
77
+ `
78
+
79
+ this.popup = openPopup(template, {
80
+ backdrop: true,
81
+ size: 'large',
82
+ title: 'select item'
83
+ })
84
+ }
85
+ }