@operato/app 1.0.0-beta.7 → 1.0.0

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 (90) hide show
  1. package/CHANGELOG.md +377 -0
  2. package/demo/data-grist-test.html +1 -1
  3. package/dist/src/filters-form/filter-resource-select.d.ts +4 -0
  4. package/dist/src/filters-form/filter-resource-select.js +78 -0
  5. package/dist/src/filters-form/filter-resource-select.js.map +1 -0
  6. package/dist/src/filters-form/index.d.ts +1 -0
  7. package/dist/src/filters-form/index.js +5 -0
  8. package/dist/src/filters-form/index.js.map +1 -0
  9. package/dist/src/grist-editor/index.js +1 -9
  10. package/dist/src/grist-editor/index.js.map +1 -1
  11. package/dist/src/grist-editor/ox-grist-editor-resource-object.d.ts +0 -1
  12. package/dist/src/grist-editor/ox-grist-editor-resource-object.js +7 -12
  13. package/dist/src/grist-editor/ox-grist-editor-resource-object.js.map +1 -1
  14. package/dist/src/grist-editor/ox-grist-renderer-crontab.js +3 -3
  15. package/dist/src/grist-editor/ox-grist-renderer-crontab.js.map +1 -1
  16. package/dist/src/grist-editor/ox-grist-renderer-resource-id.js +5 -2
  17. package/dist/src/grist-editor/ox-grist-renderer-resource-id.js.map +1 -1
  18. package/dist/src/grist-editor/ox-popup-code-input.js +5 -4
  19. package/dist/src/grist-editor/ox-popup-code-input.js.map +1 -1
  20. package/dist/src/grist-editor/ox-selector-resource-id.js +4 -3
  21. package/dist/src/grist-editor/ox-selector-resource-id.js.map +1 -1
  22. package/dist/src/grist-editor/ox-selector-resource-object.js +5 -3
  23. package/dist/src/grist-editor/ox-selector-resource-object.js.map +1 -1
  24. package/dist/src/input/ox-input-background-pattern.d.ts +3 -0
  25. package/dist/src/input/ox-input-background-pattern.js +35 -7
  26. package/dist/src/input/ox-input-background-pattern.js.map +1 -1
  27. package/dist/src/input/ox-input-fill-style.d.ts +4 -2
  28. package/dist/src/input/ox-input-fill-style.js +13 -7
  29. package/dist/src/input/ox-input-fill-style.js.map +1 -1
  30. package/dist/src/input/ox-input-graphql.d.ts +1 -1
  31. package/dist/src/input/ox-input-graphql.js +7 -7
  32. package/dist/src/input/ox-input-graphql.js.map +1 -1
  33. package/dist/src/property-editor/index.d.ts +2 -1
  34. package/dist/src/property-editor/index.js +5 -2
  35. package/dist/src/property-editor/index.js.map +1 -1
  36. package/dist/src/property-editor/ox-property-editor-graphql.d.ts +2 -2
  37. package/dist/src/property-editor/ox-property-editor-graphql.js +4 -4
  38. package/dist/src/property-editor/ox-property-editor-graphql.js.map +1 -1
  39. package/dist/tsconfig.tsbuildinfo +1 -1
  40. package/package.json +24 -30
  41. package/src/filters-form/filter-resource-select.ts +94 -0
  42. package/src/filters-form/index.ts +6 -0
  43. package/src/grist-editor/index.ts +1 -9
  44. package/src/grist-editor/ox-grist-editor-resource-object.ts +17 -13
  45. package/src/grist-editor/ox-grist-renderer-crontab.ts +5 -4
  46. package/src/grist-editor/ox-grist-renderer-resource-id.ts +6 -2
  47. package/src/grist-editor/ox-popup-code-input.ts +5 -4
  48. package/src/grist-editor/ox-selector-resource-id.ts +4 -3
  49. package/src/grist-editor/ox-selector-resource-object.ts +5 -3
  50. package/src/input/ox-input-background-pattern.ts +37 -7
  51. package/src/input/ox-input-fill-style.ts +18 -8
  52. package/src/input/ox-input-graphql.ts +8 -8
  53. package/src/property-editor/index.ts +5 -2
  54. package/src/property-editor/ox-property-editor-graphql.ts +5 -4
  55. package/dist/src/grist-editor/ox-grist-editor-crontab.d.ts +0 -8
  56. package/dist/src/grist-editor/ox-grist-editor-crontab.js +0 -50
  57. package/dist/src/grist-editor/ox-grist-editor-crontab.js.map +0 -1
  58. package/dist/src/grist-editor/ox-grist-editor-parameters.d.ts +0 -12
  59. package/dist/src/grist-editor/ox-grist-editor-parameters.js +0 -84
  60. package/dist/src/grist-editor/ox-grist-editor-parameters.js.map +0 -1
  61. package/dist/src/grist-editor/ox-grist-editor-partition-keys.d.ts +0 -11
  62. package/dist/src/grist-editor/ox-grist-editor-partition-keys.js +0 -74
  63. package/dist/src/grist-editor/ox-grist-editor-partition-keys.js.map +0 -1
  64. package/dist/src/grist-editor/ox-grist-editor-value-map.d.ts +0 -11
  65. package/dist/src/grist-editor/ox-grist-editor-value-map.js +0 -74
  66. package/dist/src/grist-editor/ox-grist-editor-value-map.js.map +0 -1
  67. package/dist/src/grist-editor/ox-parameters-builder.d.ts +0 -4
  68. package/dist/src/grist-editor/ox-parameters-builder.js +0 -118
  69. package/dist/src/grist-editor/ox-parameters-builder.js.map +0 -1
  70. package/dist/src/grist-editor/ox-popup-crontab-input.d.ts +0 -11
  71. package/dist/src/grist-editor/ox-popup-crontab-input.js +0 -74
  72. package/dist/src/grist-editor/ox-popup-crontab-input.js.map +0 -1
  73. package/dist/src/grist-editor/ox-popup-parameters-builder.d.ts +0 -13
  74. package/dist/src/grist-editor/ox-popup-parameters-builder.js +0 -111
  75. package/dist/src/grist-editor/ox-popup-parameters-builder.js.map +0 -1
  76. package/dist/src/grist-editor/ox-popup-partition-keys-input.d.ts +0 -12
  77. package/dist/src/grist-editor/ox-popup-partition-keys-input.js +0 -98
  78. package/dist/src/grist-editor/ox-popup-partition-keys-input.js.map +0 -1
  79. package/dist/src/grist-editor/ox-popup-value-map-input.d.ts +0 -12
  80. package/dist/src/grist-editor/ox-popup-value-map-input.js +0 -104
  81. package/dist/src/grist-editor/ox-popup-value-map-input.js.map +0 -1
  82. package/src/grist-editor/ox-grist-editor-crontab.ts +0 -62
  83. package/src/grist-editor/ox-grist-editor-parameters.ts +0 -99
  84. package/src/grist-editor/ox-grist-editor-partition-keys.ts +0 -86
  85. package/src/grist-editor/ox-grist-editor-value-map.ts +0 -86
  86. package/src/grist-editor/ox-parameters-builder.ts +0 -128
  87. package/src/grist-editor/ox-popup-crontab-input.ts +0 -74
  88. package/src/grist-editor/ox-popup-parameters-builder.ts +0 -106
  89. package/src/grist-editor/ox-popup-partition-keys-input.ts +0 -95
  90. package/src/grist-editor/ox-popup-value-map-input.ts +0 -101
@@ -1,86 +0,0 @@
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
- }
@@ -1,128 +0,0 @@
1
- /**
2
- * @license Copyright © HatioLab Inc. All rights reserved.
3
- */
4
-
5
- import { LitElement, PropertyValues, html } from 'lit'
6
- import { OxPropertyEditor, PropertySpec } from '@operato/property-editor'
7
- import { customElement, property } from 'lit/decorators.js'
8
-
9
- import { connect } from 'pwa-helpers/connect-mixin'
10
- import { store } from '@operato/shell'
11
-
12
- /**
13
- 모든 에디터들은 change 이벤트를 지원해야 한다. 또한, 모든 에디터들은 value속성에 값을 가져야 한다.
14
-
15
- Example:
16
-
17
- <ox-parameters-builder value="{{value}}">
18
- <label>Center X</label>
19
- <input type="number" .value="${value.cx}">
20
- <label>Width</label>
21
- <input type="number" .value="${value.width}">
22
- </ox-parameters-builder>
23
- */
24
-
25
- const DEFAULT_VALUE = {
26
- legend: '',
27
- number: 0,
28
- angle: 0,
29
- string: '',
30
- text: '',
31
- textarea: '',
32
- checkbox: false,
33
- select: '',
34
- color: '#000000',
35
- 'solidcolor-stops': null,
36
- 'gradientcolor-stops': null,
37
- 'gltf-selector': '',
38
- 'image-selector': '',
39
- multiplecolor: null,
40
- editortable: null,
41
- imageselector: '',
42
- options: null,
43
- date: null
44
- } as any
45
-
46
- @customElement('ox-parameters-builder')
47
- class OxParametersBuilder extends connect(store)(LitElement) {
48
- @property({ type: Object }) value: any
49
- @property({ type: Array }) props?: PropertySpec[]
50
- @property({ type: Object }) host: any
51
-
52
- render() {
53
- return html`<slot></slot>`
54
- }
55
-
56
- firstUpdated() {
57
- this.addEventListener('change', this._onValueChanged.bind(this))
58
- }
59
-
60
- updated(changes: PropertyValues<this>) {
61
- changes.has('props') && this._onPropsChanged(this.props)
62
- changes.has('value') && this._setValues()
63
- }
64
-
65
- _onPropsChanged(props: PropertySpec[] | undefined) {
66
- this.textContent = ''
67
- ;(props || []).forEach(prop => {
68
- let elementType = OxPropertyEditor.getEditor(prop.type)
69
- if (!elementType) {
70
- console.warn('Property Editor not defined', prop.type)
71
- return
72
- }
73
- let element = document.createElement(elementType) as OxPropertyEditor
74
-
75
- element.label = prop.label
76
- element.type = prop.type
77
- element.placeholder = prop.placeholder
78
- element.host = this.host
79
- // element.context = this.context
80
- element.setAttribute('name', prop.name)
81
-
82
- if (prop.observe) {
83
- element.observe = prop.observe
84
- }
85
- element.property = prop.property
86
- element.setAttribute('property-editor', '')
87
-
88
- this.appendChild(element)
89
- })
90
- }
91
-
92
- _setValues() {
93
- var value = this.value || {}
94
- Array.from(this.querySelectorAll('[name]')).forEach(propertyEditor => {
95
- const editor = propertyEditor as OxPropertyEditor
96
- let name = editor.getAttribute('name')
97
- editor.value = value[name!] === undefined ? DEFAULT_VALUE[editor.type] : value[name!]
98
- })
99
- }
100
-
101
- _getValues() {
102
- var value = {} as any
103
- Array.from(this.querySelectorAll('[name]')).forEach(propertyEditor => {
104
- const editor = propertyEditor as OxPropertyEditor
105
- let name = editor.getAttribute('name')
106
- value[name!] = editor.value === undefined ? DEFAULT_VALUE[editor.type] : editor.value
107
- })
108
-
109
- return value
110
- }
111
-
112
- _onValueChanged(e: Event) {
113
- e.stopPropagation()
114
- var prop = e.target as HTMLElement
115
-
116
- if (!prop || !prop.hasAttribute('property-editor')) {
117
- return
118
- }
119
-
120
- this.dispatchEvent(
121
- new CustomEvent('property-change', {
122
- bubbles: true,
123
- composed: true,
124
- detail: this._getValues()
125
- })
126
- )
127
- }
128
- }
@@ -1,74 +0,0 @@
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
- }
@@ -1,106 +0,0 @@
1
- import { LitElement, css, html } from 'lit'
2
- import { customElement, property } from 'lit/decorators.js'
3
-
4
- import { ScrollbarStyles } from '@operato/styles'
5
- import { i18next } from '@operato/i18n'
6
-
7
- @customElement('ox-popup-parameters-builder')
8
- export class OxPopupParametersBuilder extends LitElement {
9
- static styles = [
10
- ScrollbarStyles,
11
- css`
12
- :host {
13
- display: flex;
14
- flex-direction: column;
15
-
16
- background-color: #fff;
17
-
18
- width: var(--overlay-center-normal-width, 50%);
19
- height: var(--overlay-center-normal-height, 50%);
20
- }
21
-
22
- ox-parameters-builder {
23
- flex: 1;
24
- overflow-y: auto;
25
- }
26
-
27
- span {
28
- flex: 1;
29
-
30
- display: flex;
31
- align-items: center;
32
- justify-content: center;
33
-
34
- color: var(--primary-color);
35
- }
36
-
37
- .button-container {
38
- display: flex;
39
- margin-left: auto;
40
- }
41
- `
42
- ]
43
-
44
- @property({ type: Object }) value: any
45
- @property({ type: Object }) props: any
46
- @property({ type: Object }) host: any
47
- @property({ type: Object }) context: any
48
- @property({ type: Object }) confirmCallback!: (newval: any) => void
49
-
50
- render() {
51
- var props = this.props instanceof Array ? this.props : []
52
-
53
- return html`
54
- ${props.length > 0
55
- ? html`
56
- <ox-parameters-builder
57
- .value=${this.value}
58
- .props=${props}
59
- .host=${this.host}
60
- .context=${this.context}
61
- @property-change=${this.onChange.bind(this)}
62
- >
63
- </ox-parameters-builder>
64
- `
65
- : html` <span><i18n-msg msgid="text.no properties to set"></i18n-msg></span> `}
66
-
67
- <div class="button-container">
68
- <mwc-button @click=${this.onCancel.bind(this)}>${i18next.t('button.cancel')}</mwc-button>
69
- <mwc-button @click=${this.onConfirm.bind(this)}>${i18next.t('button.confirm')}</mwc-button>
70
- </div>
71
- `
72
- }
73
-
74
- private onChange(e: CustomEvent) {
75
- e.stopPropagation()
76
-
77
- /*
78
- 주의 : 이 팝업 템플릿은 layout 모듈에 의해서 render 되므로,
79
- layout의 구성에 변화가 발생하면, 다시 render된다.
80
- 이 팝업이 떠 있는 상태에서, 또 다른 팝업이 뜨는 경우도 layout 구성의 변화를 야기한다. (overlay의 갯수의 증가)
81
- 이 경우 value, options, confirmCallback 등 클로져를 사용한 것들이 초기 바인딩된 값으로 다시 바인딩되게 되는데,
82
- 만약, 템플릿 내부에서 이들 속성의 레퍼런스가 변화했다면, 원래 상태로 되돌아가는 현상이 발생하게 된다.
83
- 따라서, 가급적 이들 속성의 레퍼런스를 변화시키지 않는 것이 좋다.
84
- (이 팝업 클래스를 템플릿으로 사용한 곳의 코드를 참조하세요.)
85
- =>
86
- 이런 이유로, Object.assign(...)을 사용하였다.
87
- */
88
- if (!this.value) {
89
- this.value = {}
90
- }
91
-
92
- for (let key in this.value) {
93
- delete this.value[key]
94
- }
95
- Object.assign(this.value, e.detail)
96
- }
97
-
98
- private onCancel(e: Event) {
99
- history.back()
100
- }
101
-
102
- private onConfirm(e: Event) {
103
- this.confirmCallback && this.confirmCallback(this.value)
104
- history.back()
105
- }
106
- }
@@ -1,95 +0,0 @@
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
- }
@@ -1,101 +0,0 @@
1
- import '@operato/input/ox-input-value-map.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-value-map-input')
10
- export class OxPopupValueMapInput 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-value-map {
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-value-map
53
- .value=${this.value}
54
- keytype="string"
55
- .valuetype=${this.valuetype}
56
- @change=${this.onChange.bind(this)}
57
- >
58
- </ox-input-value-map>
59
-
60
- <div class="button-container">
61
- <mwc-button @click=${this.onCancel.bind(this)}>${i18next.t('button.cancel')}</mwc-button>
62
- <mwc-button @click=${this.onConfirm.bind(this)}>${i18next.t('button.confirm')}</mwc-button>
63
- </div>
64
- `
65
- }
66
-
67
- private onChange(e: CustomEvent) {
68
- e.stopPropagation()
69
-
70
- /*
71
- 주의 : 이 팝업 템플릿은 layout 모듈에 의해서 render 되므로,
72
- layout의 구성에 변화가 발생하면, 다시 render된다.
73
- 이 팝업이 떠 있는 상태에서, 또 다른 팝업이 뜨는 경우도 layout 구성의 변화를 야기한다. (overlay의 갯수의 증가)
74
- 이 경우 value, options, confirmCallback 등 클로져를 사용한 것들이 초기 바인딩된 값으로 다시 바인딩되게 되는데,
75
- 만약, 템플릿 내부에서 이들 속성의 레퍼런스가 변화했다면, 원래 상태로 되돌아가는 현상이 발생하게 된다.
76
- 따라서, 가급적 이들 속성의 레퍼런스를 변화시키지 않는 것이 좋다.
77
- (이 팝업 클래스를 템플릿으로 사용한 곳의 코드를 참조하세요.)
78
- =>
79
- 이런 이유로, Object.assign(...)을 사용하였다.
80
- */
81
-
82
- if (!this.value) {
83
- this.value = {}
84
- }
85
-
86
- for (let key in this.value) {
87
- delete this.value[key]
88
- }
89
-
90
- Object.assign(this.value, e.detail)
91
- }
92
-
93
- private onCancel(e: Event) {
94
- history.back()
95
- }
96
-
97
- private onConfirm(e: Event) {
98
- this.confirmCallback && this.confirmCallback(this.value)
99
- history.back()
100
- }
101
- }