@things-factory/integration-ui 6.2.37 → 6.2.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/client/bootstrap.ts +1 -0
- package/client/editors/property-editor.ts +25 -0
- package/client/editors/things-editor-tag-scenarios.ts +244 -0
- package/dist-client/bootstrap.js +1 -0
- package/dist-client/bootstrap.js.map +1 -1
- package/dist-client/editors/property-editor.d.ts +5 -0
- package/dist-client/editors/property-editor.js +21 -0
- package/dist-client/editors/property-editor.js.map +1 -1
- package/dist-client/editors/things-editor-tag-scenarios.d.ts +32 -0
- package/dist-client/editors/things-editor-tag-scenarios.js +226 -0
- package/dist-client/editors/things-editor-tag-scenarios.js.map +1 -0
- package/dist-client/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
package/client/bootstrap.ts
CHANGED
|
@@ -34,6 +34,7 @@ export default function bootstrap() {
|
|
|
34
34
|
'http-body': 'property-editor-http-body',
|
|
35
35
|
'entity-selector': 'property-editor-entity-selector',
|
|
36
36
|
'scenario-step-input': 'property-editor-scenario-step-input',
|
|
37
|
+
'tag-scenarios': 'property-editor-tag-scenarios',
|
|
37
38
|
'procedure-parameters': 'property-editor-procedure-parameters'
|
|
38
39
|
})
|
|
39
40
|
}
|
|
@@ -5,6 +5,7 @@ import './things-editor-http-headers'
|
|
|
5
5
|
import './things-editor-http-parameters'
|
|
6
6
|
import './things-editor-http-body'
|
|
7
7
|
import './things-editor-oracle-procedure'
|
|
8
|
+
import './things-editor-tag-scenarios'
|
|
8
9
|
|
|
9
10
|
import { html } from 'lit'
|
|
10
11
|
|
|
@@ -98,3 +99,27 @@ export class PropertyEditorProcedureParameters extends OxPropertyEditor {
|
|
|
98
99
|
}
|
|
99
100
|
|
|
100
101
|
customElements.define('property-editor-procedure-parameters', PropertyEditorProcedureParameters)
|
|
102
|
+
|
|
103
|
+
export class PropertyEditorTagScenarios extends OxPropertyEditor {
|
|
104
|
+
static get styles() {
|
|
105
|
+
return [...OxPropertyEditor.styles]
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
editorTemplate(value, spec) {
|
|
109
|
+
/* context must be a datagrid(grist) instance, and host must be a record */
|
|
110
|
+
const { context: grid, host: record } = spec
|
|
111
|
+
const steps = grid?.dirtyData.records.filter(rec => rec.name !== record.name).map(rec => rec.name) || []
|
|
112
|
+
|
|
113
|
+
return html`
|
|
114
|
+
<things-editor-tag-scenarios
|
|
115
|
+
id="editor"
|
|
116
|
+
.value=${value}
|
|
117
|
+
.properties=${spec.property}
|
|
118
|
+
.steps=${steps}
|
|
119
|
+
fullwidth
|
|
120
|
+
></things-editor-tag-scenarios>
|
|
121
|
+
`
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
customElements.define('property-editor-tag-scenarios', PropertyEditorTagScenarios)
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright © HatioLab Inc. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import '@operato/input/ox-select.js'
|
|
6
|
+
|
|
7
|
+
import gql from 'graphql-tag'
|
|
8
|
+
import { css, html, LitElement } from 'lit'
|
|
9
|
+
import { customElement, property, state } from 'lit/decorators.js'
|
|
10
|
+
import { keyed } from 'lit/directives/keyed.js'
|
|
11
|
+
|
|
12
|
+
import { client } from '@operato/graphql'
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
tag-scenarios map editor element
|
|
16
|
+
|
|
17
|
+
Example:
|
|
18
|
+
|
|
19
|
+
<things-editor-tag-scenarios value=${map}>
|
|
20
|
+
</things-editor-tag-scenarios>
|
|
21
|
+
*/
|
|
22
|
+
@customElement('things-editor-tag-scenarios')
|
|
23
|
+
export default class ThingsEditorTagScenarios extends LitElement {
|
|
24
|
+
static styles = [
|
|
25
|
+
css`
|
|
26
|
+
:host {
|
|
27
|
+
display: flex;
|
|
28
|
+
flex-direction: column;
|
|
29
|
+
align-content: center;
|
|
30
|
+
|
|
31
|
+
width: 100%;
|
|
32
|
+
overflow: visible;
|
|
33
|
+
border: 1px solid #ccc;
|
|
34
|
+
margin: 5px 0;
|
|
35
|
+
|
|
36
|
+
background-color: #ddd;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
div[data-record],
|
|
40
|
+
div[data-record-new] {
|
|
41
|
+
display: flex;
|
|
42
|
+
flex-flow: row nowrap;
|
|
43
|
+
align-items: center;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
div[data-record] > *,
|
|
47
|
+
div[data-record-new] > * {
|
|
48
|
+
min-height: 20px;
|
|
49
|
+
margin: 2px;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
button {
|
|
53
|
+
text-align: center;
|
|
54
|
+
border-radius: 50%;
|
|
55
|
+
font-size: 1em;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
input,
|
|
59
|
+
ox-select {
|
|
60
|
+
flex: 1;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
input {
|
|
64
|
+
padding: 5px;
|
|
65
|
+
box-sizing: border-box;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
ox-select {
|
|
69
|
+
--input-padding: 4px;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
ox-popup-list {
|
|
73
|
+
max-height: 300px;
|
|
74
|
+
overflow: auto;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
select,
|
|
78
|
+
ox-select,
|
|
79
|
+
input:not([type='checkbox']) {
|
|
80
|
+
border: 1px solid rgba(0, 0, 0, 0.2);
|
|
81
|
+
border-radius: 4px;
|
|
82
|
+
background-color: white;
|
|
83
|
+
}
|
|
84
|
+
`
|
|
85
|
+
]
|
|
86
|
+
|
|
87
|
+
@property({ type: Object }) value: { [key: string]: string } = {}
|
|
88
|
+
|
|
89
|
+
_changingNow: boolean = false
|
|
90
|
+
|
|
91
|
+
@state() private scenarios: string[] = []
|
|
92
|
+
|
|
93
|
+
firstUpdated() {
|
|
94
|
+
this.renderRoot.addEventListener('change', this._onChange.bind(this))
|
|
95
|
+
this.fetchScenarios()
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
async fetchScenarios() {
|
|
99
|
+
const { data, errors } = await client.query({
|
|
100
|
+
query: gql`
|
|
101
|
+
query {
|
|
102
|
+
scenarios {
|
|
103
|
+
items {
|
|
104
|
+
id
|
|
105
|
+
name
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
`
|
|
110
|
+
})
|
|
111
|
+
|
|
112
|
+
if (data) {
|
|
113
|
+
this.scenarios = (data?.scenarios.items || []).map(item => item.name)
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
render() {
|
|
118
|
+
const spec = {
|
|
119
|
+
queryName: 'scenarios'
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
return html`
|
|
123
|
+
${this._toArray(this.value).map(
|
|
124
|
+
item => html`
|
|
125
|
+
<div data-record>
|
|
126
|
+
<input type="text" data-key placeholder="(set tag)" .value=${item.key} />
|
|
127
|
+
<ox-select data-value placeholder="(select scenario)" .value=${item.value}>
|
|
128
|
+
<ox-popup-list with-search>
|
|
129
|
+
<div option value=""> </div>
|
|
130
|
+
${this.scenarios.map(scenario => html` <div option value=${scenario}>${scenario}</div> `)}
|
|
131
|
+
</ox-popup-list>
|
|
132
|
+
</ox-select>
|
|
133
|
+
|
|
134
|
+
<button class="record-action" @click=${e => this._delete(e)} tabindex="-1">x</button>
|
|
135
|
+
</div>
|
|
136
|
+
`
|
|
137
|
+
)}
|
|
138
|
+
|
|
139
|
+
<div data-record-new>
|
|
140
|
+
<input type="text" data-key placeholder="(set tag)" value="" />
|
|
141
|
+
${keyed(
|
|
142
|
+
Date.now(),
|
|
143
|
+
html`
|
|
144
|
+
<ox-select data-value placeholder="(select scenario)" value="">
|
|
145
|
+
<ox-popup-list with-search>
|
|
146
|
+
<div option value=""> </div>
|
|
147
|
+
${this.scenarios.map(scenario => html` <div option value=${scenario}>${scenario}</div> `)}
|
|
148
|
+
</ox-popup-list>
|
|
149
|
+
</ox-select>
|
|
150
|
+
`
|
|
151
|
+
)}
|
|
152
|
+
|
|
153
|
+
<button class="record-action" @click=${e => this._add()} tabindex="-1">+</button>
|
|
154
|
+
</div>
|
|
155
|
+
`
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
_onChange(e) {
|
|
159
|
+
if (this._changingNow) {
|
|
160
|
+
return
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
this._changingNow = true
|
|
164
|
+
|
|
165
|
+
var input = e.target
|
|
166
|
+
var value = input.value
|
|
167
|
+
|
|
168
|
+
var div = input.parentElement
|
|
169
|
+
|
|
170
|
+
if (div.hasAttribute('data-record')) {
|
|
171
|
+
var dataList = div.querySelectorAll('[data-value]:not([hidden])')
|
|
172
|
+
for (var i = 0; i < dataList.length; i++) {
|
|
173
|
+
if (dataList[i] !== input) {
|
|
174
|
+
dataList[i].value = value || ''
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
if (div.hasAttribute('data-record')) {
|
|
180
|
+
this._build()
|
|
181
|
+
} else if (div.hasAttribute('data-record-new') && input.hasAttribute('data-value')) {
|
|
182
|
+
this._add()
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
this._changingNow = false
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
_build(includeNewRecord?) {
|
|
189
|
+
if (includeNewRecord) var records = this.renderRoot.querySelectorAll('[data-record],[data-record-new]')
|
|
190
|
+
else var records = this.renderRoot.querySelectorAll('[data-record]')
|
|
191
|
+
|
|
192
|
+
var newmap = {}
|
|
193
|
+
|
|
194
|
+
for (var i = 0; i < records.length; i++) {
|
|
195
|
+
var record = records[i]
|
|
196
|
+
|
|
197
|
+
var key = (record.querySelector('[data-key]') as HTMLInputElement).value
|
|
198
|
+
var inputs = record.querySelectorAll('[data-value]:not([style*="display: none"])')
|
|
199
|
+
if (!inputs || inputs.length == 0) continue
|
|
200
|
+
|
|
201
|
+
var input = inputs[inputs.length - 1] as HTMLInputElement
|
|
202
|
+
|
|
203
|
+
var value = input.value
|
|
204
|
+
|
|
205
|
+
if (key) newmap[key] = value || ''
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
this.value = newmap
|
|
209
|
+
this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true }))
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/* map아이템들을 template(dom-repeat)용 배열로 변환하는 함수 */
|
|
213
|
+
_toArray(map) {
|
|
214
|
+
var array: { key: any; value: any }[] = []
|
|
215
|
+
|
|
216
|
+
for (var key in map) {
|
|
217
|
+
array.push({
|
|
218
|
+
key: key,
|
|
219
|
+
value: map[key]
|
|
220
|
+
})
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
return array
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
_add() {
|
|
227
|
+
this._build(true)
|
|
228
|
+
|
|
229
|
+
var inputs = this.renderRoot.querySelectorAll('[data-record-new] input:not([style*="display: none"])')
|
|
230
|
+
|
|
231
|
+
for (var i = 0; i < inputs.length; i++) {
|
|
232
|
+
let input = inputs[i] as HTMLInputElement
|
|
233
|
+
input.value = ''
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
;(inputs[0] as HTMLInputElement).focus()
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
_delete(e) {
|
|
240
|
+
var record = e.target.parentElement
|
|
241
|
+
record.querySelector('[data-key]').value = ''
|
|
242
|
+
this._build()
|
|
243
|
+
}
|
|
244
|
+
}
|
package/dist-client/bootstrap.js
CHANGED
|
@@ -24,6 +24,7 @@ export default function bootstrap() {
|
|
|
24
24
|
'http-body': 'property-editor-http-body',
|
|
25
25
|
'entity-selector': 'property-editor-entity-selector',
|
|
26
26
|
'scenario-step-input': 'property-editor-scenario-step-input',
|
|
27
|
+
'tag-scenarios': 'property-editor-tag-scenarios',
|
|
27
28
|
'procedure-parameters': 'property-editor-procedure-parameters'
|
|
28
29
|
});
|
|
29
30
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bootstrap.js","sourceRoot":"","sources":["../client/bootstrap.ts"],"names":[],"mappings":"AAAA,OAAO,oBAAoB,CAAA;AAC3B,OAAO,yBAAyB,CAAA;AAChC,OAAO,2BAA2B,CAAA;AAElC,OAAO,EAAE,iBAAiB,EAAE,MAAM,mDAAmD,CAAA;AACrF,OAAO,EAAE,sBAAsB,EAAE,MAAM,wDAAwD,CAAA;AAC/F,OAAO,EACL,cAAc,IAAI,mBAAmB,EACrC,gBAAgB,IAAI,qBAAqB,EAE1C,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAE,oBAAoB,EAAE,MAAM,kDAAkD,CAAA;AAEvF,OAAO,EAAE,uBAAuB,EAAE,MAAM,qDAAqD,CAAA;AAC7F,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAA;AAE3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAA;AAChE,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAA;AAC9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAA;AAE7D,MAAM,CAAC,OAAO,UAAU,SAAS;IAC/B,mBAAmB,CAAC,WAAW,EAAE,gBAAgB,CAAC,CAAA;IAClD,mBAAmB,CAAC,WAAW,EAAE,iBAAiB,CAAC,CAAA;IACnD,mBAAmB,CAAC,YAAY,EAAE,kBAAkB,CAAC,CAAA;IACrD,mBAAmB,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAA;IAC9C,mBAAmB,CAAC,YAAY,EAAE,uBAAuB,CAAC,CAAA;IAC1D,mBAAmB,CAAC,SAAS,EAAE,oBAAoB,CAAC,CAAA;IAEpD,qBAAqB,CAAC,SAAS,EAAE,sBAAsB,CAAC,CAAA;IAExD,gBAAgB,CAAC,QAAQ,CAAC;QACxB,cAAc,EAAE,8BAA8B;QAC9C,iBAAiB,EAAE,iCAAiC;QACpD,WAAW,EAAE,2BAA2B;QACxC,iBAAiB,EAAE,iCAAiC;QACpD,qBAAqB,EAAE,qCAAqC;QAC5D,sBAAsB,EAAE,sCAAsC;KAC/D,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import '@material/mwc-icon'\nimport './editors/entity-editor'\nimport './editors/property-editor'\n\nimport { OxGristEditorJson } from '@operato/app/grist-editor/ox-grist-editor-json.js'\nimport { OxGristRendererCrontab } from '@operato/app/grist-editor/ox-grist-renderer-crontab.js'\nimport {\n registerEditor as registerGristEditor,\n registerRenderer as registerGristRenderer,\n OxGristRendererJson5\n} from '@operato/data-grist'\nimport { OxGristEditorCrontab } from '@operato/grist-editor/ox-grist-editor-crontab.js'\nimport { OxGristEditorPrivilege } from '@operato/app/grist-editor/ox-grist-editor-privilege.js'\nimport { OxGristEditorParameters } from '@operato/grist-editor/ox-grist-editor-parameters.js'\nimport { OxPropertyEditor } from '@operato/property-editor'\n\nimport { ConnectionSelector } from './grist/connection-selector'\nimport { ConnectorSelector } from './grist/connector-selector'\nimport { TaskTypeSelector } from './grist/task-type-selector'\n\nexport default function bootstrap() {\n registerGristEditor('task-type', TaskTypeSelector)\n registerGristEditor('connector', ConnectorSelector)\n registerGristEditor('connection', ConnectionSelector)\n registerGristEditor('json', OxGristEditorJson)\n registerGristEditor('parameters', OxGristEditorParameters)\n registerGristEditor('crontab', OxGristEditorCrontab)\n\n registerGristRenderer('crontab', OxGristRendererCrontab)\n\n OxPropertyEditor.register({\n 'http-headers': 'property-editor-http-headers',\n 'http-parameters': 'property-editor-http-parameters',\n 'http-body': 'property-editor-http-body',\n 'entity-selector': 'property-editor-entity-selector',\n 'scenario-step-input': 'property-editor-scenario-step-input',\n 'procedure-parameters': 'property-editor-procedure-parameters'\n })\n}\n"]}
|
|
1
|
+
{"version":3,"file":"bootstrap.js","sourceRoot":"","sources":["../client/bootstrap.ts"],"names":[],"mappings":"AAAA,OAAO,oBAA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KAC/D,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import '@material/mwc-icon'\nimport './editors/entity-editor'\nimport './editors/property-editor'\n\nimport { OxGristEditorJson } from '@operato/app/grist-editor/ox-grist-editor-json.js'\nimport { OxGristRendererCrontab } from '@operato/app/grist-editor/ox-grist-renderer-crontab.js'\nimport {\n registerEditor as registerGristEditor,\n registerRenderer as registerGristRenderer,\n OxGristRendererJson5\n} from '@operato/data-grist'\nimport { OxGristEditorCrontab } from '@operato/grist-editor/ox-grist-editor-crontab.js'\nimport { OxGristEditorPrivilege } from '@operato/app/grist-editor/ox-grist-editor-privilege.js'\nimport { OxGristEditorParameters } from '@operato/grist-editor/ox-grist-editor-parameters.js'\nimport { OxPropertyEditor } from '@operato/property-editor'\n\nimport { ConnectionSelector } from './grist/connection-selector'\nimport { ConnectorSelector } from './grist/connector-selector'\nimport { TaskTypeSelector } from './grist/task-type-selector'\n\nexport default function bootstrap() {\n registerGristEditor('task-type', TaskTypeSelector)\n registerGristEditor('connector', ConnectorSelector)\n registerGristEditor('connection', ConnectionSelector)\n registerGristEditor('json', OxGristEditorJson)\n registerGristEditor('parameters', OxGristEditorParameters)\n registerGristEditor('crontab', OxGristEditorCrontab)\n\n registerGristRenderer('crontab', OxGristRendererCrontab)\n\n OxPropertyEditor.register({\n 'http-headers': 'property-editor-http-headers',\n 'http-parameters': 'property-editor-http-parameters',\n 'http-body': 'property-editor-http-body',\n 'entity-selector': 'property-editor-entity-selector',\n 'scenario-step-input': 'property-editor-scenario-step-input',\n 'tag-scenarios': 'property-editor-tag-scenarios',\n 'procedure-parameters': 'property-editor-procedure-parameters'\n })\n}\n"]}
|
|
@@ -2,6 +2,7 @@ import './things-editor-http-headers';
|
|
|
2
2
|
import './things-editor-http-parameters';
|
|
3
3
|
import './things-editor-http-body';
|
|
4
4
|
import './things-editor-oracle-procedure';
|
|
5
|
+
import './things-editor-tag-scenarios';
|
|
5
6
|
import { OxPropertyEditor } from '@operato/property-editor';
|
|
6
7
|
export declare class PropertyEditorScenarioStepInput extends OxPropertyEditor {
|
|
7
8
|
static get styles(): import("lit").CSSResult[];
|
|
@@ -23,3 +24,7 @@ export declare class PropertyEditorProcedureParameters extends OxPropertyEditor
|
|
|
23
24
|
static get styles(): import("lit").CSSResult[];
|
|
24
25
|
editorTemplate(value: any, spec: any): import("lit-html").TemplateResult<1>;
|
|
25
26
|
}
|
|
27
|
+
export declare class PropertyEditorTagScenarios extends OxPropertyEditor {
|
|
28
|
+
static get styles(): import("lit").CSSResult[];
|
|
29
|
+
editorTemplate(value: any, spec: any): import("lit-html").TemplateResult<1>;
|
|
30
|
+
}
|
|
@@ -5,6 +5,7 @@ import './things-editor-http-headers';
|
|
|
5
5
|
import './things-editor-http-parameters';
|
|
6
6
|
import './things-editor-http-body';
|
|
7
7
|
import './things-editor-oracle-procedure';
|
|
8
|
+
import './things-editor-tag-scenarios';
|
|
8
9
|
import { html } from 'lit';
|
|
9
10
|
import { OxPropertyEditor } from '@operato/property-editor';
|
|
10
11
|
export class PropertyEditorScenarioStepInput extends OxPropertyEditor {
|
|
@@ -79,4 +80,24 @@ export class PropertyEditorProcedureParameters extends OxPropertyEditor {
|
|
|
79
80
|
}
|
|
80
81
|
}
|
|
81
82
|
customElements.define('property-editor-procedure-parameters', PropertyEditorProcedureParameters);
|
|
83
|
+
export class PropertyEditorTagScenarios extends OxPropertyEditor {
|
|
84
|
+
static get styles() {
|
|
85
|
+
return [...OxPropertyEditor.styles];
|
|
86
|
+
}
|
|
87
|
+
editorTemplate(value, spec) {
|
|
88
|
+
/* context must be a datagrid(grist) instance, and host must be a record */
|
|
89
|
+
const { context: grid, host: record } = spec;
|
|
90
|
+
const steps = (grid === null || grid === void 0 ? void 0 : grid.dirtyData.records.filter(rec => rec.name !== record.name).map(rec => rec.name)) || [];
|
|
91
|
+
return html `
|
|
92
|
+
<things-editor-tag-scenarios
|
|
93
|
+
id="editor"
|
|
94
|
+
.value=${value}
|
|
95
|
+
.properties=${spec.property}
|
|
96
|
+
.steps=${steps}
|
|
97
|
+
fullwidth
|
|
98
|
+
></things-editor-tag-scenarios>
|
|
99
|
+
`;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
customElements.define('property-editor-tag-scenarios', PropertyEditorTagScenarios);
|
|
82
103
|
//# sourceMappingURL=property-editor.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"property-editor.js","sourceRoot":"","sources":["../../client/editors/property-editor.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,8BAA8B,CAAA;AACrC,OAAO,iCAAiC,CAAA;AACxC,OAAO,2BAA2B,CAAA;AAClC,OAAO,kCAAkC,CAAA;
|
|
1
|
+
{"version":3,"file":"property-editor.js","sourceRoot":"","sources":["../../client/editors/property-editor.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,8BAA8B,CAAA;AACrC,OAAO,iCAAiC,CAAA;AACxC,OAAO,2BAA2B,CAAA;AAClC,OAAO,kCAAkC,CAAA;AACzC,OAAO,+BAA+B,CAAA;AAEtC,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAE1B,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAA;AAE3D,MAAM,OAAO,+BAAgC,SAAQ,gBAAgB;IACnE,MAAM,KAAK,MAAM;QACf,OAAO,CAAC,GAAG,gBAAgB,CAAC,MAAM,CAAC,CAAA;IACrC,CAAC;IAED,cAAc,CAAC,KAAK,EAAE,IAAI;QACxB,2EAA2E;QAC3E,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,IAAI,CAAA;QAC5C,MAAM,KAAK,GAAG,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,KAAK,MAAM,CAAC,IAAI,EAAE,GAAG,CAAC,GAAG,CAAC,EAAE,CAA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I,CAAC,KAAI,EAAE,CAAA;QAExG,OAAO,IAAI,CAAA;;;iBAGE,KAAK;sBACA,IAAI,CAAC,QAAQ;iBAClB,KAAK;;;KAGjB,CAAA;IACH,CAAC;CACF;AAED,cAAc,CAAC,MAAM,CAAC,+BAA+B,EAAE,0BAA0B,CAAC,CAAA","sourcesContent":["/*\n * Copyright © HatioLab Inc. All rights reserved.\n */\nimport './things-editor-http-headers'\nimport './things-editor-http-parameters'\nimport './things-editor-http-body'\nimport './things-editor-oracle-procedure'\nimport './things-editor-tag-scenarios'\n\nimport { html } from 'lit'\n\nimport { OxPropertyEditor } from '@operato/property-editor'\n\nexport class PropertyEditorScenarioStepInput extends OxPropertyEditor {\n static get styles() {\n return [...OxPropertyEditor.styles]\n }\n\n editorTemplate(value, spec) {\n /* context must be a datagrid(grist) instance, and host must be a record */\n const { context: grid, host: record } = spec\n const steps = grid?.dirtyData.records.filter(rec => rec.name !== record.name).map(rec => rec.name) || []\n\n return html`\n <input id=\"editor\" .value=${value || ''} list=\"step-list\" />\n <datalist id=\"step-list\">${steps.map(id => html` <option value=${id}></option> `)}</datalist>\n `\n }\n}\n\ncustomElements.define('property-editor-scenario-step-input', PropertyEditorScenarioStepInput)\n\nexport class PropertyEditorHttpHeaders extends OxPropertyEditor {\n static get styles() {\n return [...OxPropertyEditor.styles]\n }\n\n editorTemplate(value, spec) {\n return html`\n <things-editor-http-headers id=\"editor\" .value=${value} .properties=${spec.property}></things-editor-http-headers>\n `\n }\n}\n\ncustomElements.define('property-editor-http-headers', PropertyEditorHttpHeaders)\n\nexport class PropertyEditorHttpParameters extends OxPropertyEditor {\n static get styles() {\n return [...OxPropertyEditor.styles]\n }\n\n editorTemplate(value, spec) {\n return html`\n <things-editor-http-parameters\n id=\"editor\"\n .value=${value}\n .properties=${spec.property}\n ></things-editor-http-parameters>\n `\n }\n}\n\ncustomElements.define('property-editor-http-parameters', PropertyEditorHttpParameters)\n\nexport class PropertyEditorHttpBody extends OxPropertyEditor {\n static get styles() {\n return [...OxPropertyEditor.styles]\n }\n\n editorTemplate(value, spec) {\n return html`\n <things-editor-http-body id=\"editor\" .value=${value} .properties=${spec.property}></things-editor-http-body>\n `\n }\n}\n\ncustomElements.define('property-editor-http-body', PropertyEditorHttpBody)\n\nexport class PropertyEditorProcedureParameters extends OxPropertyEditor {\n static get styles() {\n return [...OxPropertyEditor.styles]\n }\n\n editorTemplate(value, spec) {\n /* context must be a datagrid(grist) instance, and host must be a record */\n const { context: grid, host: record } = spec\n const steps = grid?.dirtyData.records.filter(rec => rec.name !== record.name).map(rec => rec.name) || []\n\n return html`\n <things-editor-oracle-procedure\n id=\"editor\"\n .value=${value}\n .properties=${spec.property}\n .steps=${steps}\n fullwidth\n ></things-editor-oracle-procedure>\n `\n }\n}\n\ncustomElements.define('property-editor-procedure-parameters', PropertyEditorProcedureParameters)\n\nexport class PropertyEditorTagScenarios extends OxPropertyEditor {\n static get styles() {\n return [...OxPropertyEditor.styles]\n }\n\n editorTemplate(value, spec) {\n /* context must be a datagrid(grist) instance, and host must be a record */\n const { context: grid, host: record } = spec\n const steps = grid?.dirtyData.records.filter(rec => rec.name !== record.name).map(rec => rec.name) || []\n\n return html`\n <things-editor-tag-scenarios\n id=\"editor\"\n .value=${value}\n .properties=${spec.property}\n .steps=${steps}\n fullwidth\n ></things-editor-tag-scenarios>\n `\n }\n}\n\ncustomElements.define('property-editor-tag-scenarios', PropertyEditorTagScenarios)\n"]}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright © HatioLab Inc. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
import '@operato/input/ox-select.js';
|
|
5
|
+
import { LitElement } from 'lit';
|
|
6
|
+
/**
|
|
7
|
+
tag-scenarios map editor element
|
|
8
|
+
|
|
9
|
+
Example:
|
|
10
|
+
|
|
11
|
+
<things-editor-tag-scenarios value=${map}>
|
|
12
|
+
</things-editor-tag-scenarios>
|
|
13
|
+
*/
|
|
14
|
+
export default class ThingsEditorTagScenarios extends LitElement {
|
|
15
|
+
static styles: import("lit").CSSResult[];
|
|
16
|
+
value: {
|
|
17
|
+
[key: string]: string;
|
|
18
|
+
};
|
|
19
|
+
_changingNow: boolean;
|
|
20
|
+
private scenarios;
|
|
21
|
+
firstUpdated(): void;
|
|
22
|
+
fetchScenarios(): Promise<void>;
|
|
23
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
24
|
+
_onChange(e: any): void;
|
|
25
|
+
_build(includeNewRecord?: any): void;
|
|
26
|
+
_toArray(map: any): {
|
|
27
|
+
key: any;
|
|
28
|
+
value: any;
|
|
29
|
+
}[];
|
|
30
|
+
_add(): void;
|
|
31
|
+
_delete(e: any): void;
|
|
32
|
+
}
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright © HatioLab Inc. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
import { __decorate, __metadata } from "tslib";
|
|
5
|
+
import '@operato/input/ox-select.js';
|
|
6
|
+
import gql from 'graphql-tag';
|
|
7
|
+
import { css, html, LitElement } from 'lit';
|
|
8
|
+
import { customElement, property, state } from 'lit/decorators.js';
|
|
9
|
+
import { keyed } from 'lit/directives/keyed.js';
|
|
10
|
+
import { client } from '@operato/graphql';
|
|
11
|
+
/**
|
|
12
|
+
tag-scenarios map editor element
|
|
13
|
+
|
|
14
|
+
Example:
|
|
15
|
+
|
|
16
|
+
<things-editor-tag-scenarios value=${map}>
|
|
17
|
+
</things-editor-tag-scenarios>
|
|
18
|
+
*/
|
|
19
|
+
let ThingsEditorTagScenarios = class ThingsEditorTagScenarios extends LitElement {
|
|
20
|
+
constructor() {
|
|
21
|
+
super(...arguments);
|
|
22
|
+
this.value = {};
|
|
23
|
+
this._changingNow = false;
|
|
24
|
+
this.scenarios = [];
|
|
25
|
+
}
|
|
26
|
+
firstUpdated() {
|
|
27
|
+
this.renderRoot.addEventListener('change', this._onChange.bind(this));
|
|
28
|
+
this.fetchScenarios();
|
|
29
|
+
}
|
|
30
|
+
async fetchScenarios() {
|
|
31
|
+
const { data, errors } = await client.query({
|
|
32
|
+
query: gql `
|
|
33
|
+
query {
|
|
34
|
+
scenarios {
|
|
35
|
+
items {
|
|
36
|
+
id
|
|
37
|
+
name
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
`
|
|
42
|
+
});
|
|
43
|
+
if (data) {
|
|
44
|
+
this.scenarios = ((data === null || data === void 0 ? void 0 : data.scenarios.items) || []).map(item => item.name);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
render() {
|
|
48
|
+
const spec = {
|
|
49
|
+
queryName: 'scenarios'
|
|
50
|
+
};
|
|
51
|
+
return html `
|
|
52
|
+
${this._toArray(this.value).map(item => html `
|
|
53
|
+
<div data-record>
|
|
54
|
+
<input type="text" data-key placeholder="(set tag)" .value=${item.key} />
|
|
55
|
+
<ox-select data-value placeholder="(select scenario)" .value=${item.value}>
|
|
56
|
+
<ox-popup-list with-search>
|
|
57
|
+
<div option value=""> </div>
|
|
58
|
+
${this.scenarios.map(scenario => html ` <div option value=${scenario}>${scenario}</div> `)}
|
|
59
|
+
</ox-popup-list>
|
|
60
|
+
</ox-select>
|
|
61
|
+
|
|
62
|
+
<button class="record-action" @click=${e => this._delete(e)} tabindex="-1">x</button>
|
|
63
|
+
</div>
|
|
64
|
+
`)}
|
|
65
|
+
|
|
66
|
+
<div data-record-new>
|
|
67
|
+
<input type="text" data-key placeholder="(set tag)" value="" />
|
|
68
|
+
${keyed(Date.now(), html `
|
|
69
|
+
<ox-select data-value placeholder="(select scenario)" value="">
|
|
70
|
+
<ox-popup-list with-search>
|
|
71
|
+
<div option value=""> </div>
|
|
72
|
+
${this.scenarios.map(scenario => html ` <div option value=${scenario}>${scenario}</div> `)}
|
|
73
|
+
</ox-popup-list>
|
|
74
|
+
</ox-select>
|
|
75
|
+
`)}
|
|
76
|
+
|
|
77
|
+
<button class="record-action" @click=${e => this._add()} tabindex="-1">+</button>
|
|
78
|
+
</div>
|
|
79
|
+
`;
|
|
80
|
+
}
|
|
81
|
+
_onChange(e) {
|
|
82
|
+
if (this._changingNow) {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
this._changingNow = true;
|
|
86
|
+
var input = e.target;
|
|
87
|
+
var value = input.value;
|
|
88
|
+
var div = input.parentElement;
|
|
89
|
+
if (div.hasAttribute('data-record')) {
|
|
90
|
+
var dataList = div.querySelectorAll('[data-value]:not([hidden])');
|
|
91
|
+
for (var i = 0; i < dataList.length; i++) {
|
|
92
|
+
if (dataList[i] !== input) {
|
|
93
|
+
dataList[i].value = value || '';
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
if (div.hasAttribute('data-record')) {
|
|
98
|
+
this._build();
|
|
99
|
+
}
|
|
100
|
+
else if (div.hasAttribute('data-record-new') && input.hasAttribute('data-value')) {
|
|
101
|
+
this._add();
|
|
102
|
+
}
|
|
103
|
+
this._changingNow = false;
|
|
104
|
+
}
|
|
105
|
+
_build(includeNewRecord) {
|
|
106
|
+
if (includeNewRecord)
|
|
107
|
+
var records = this.renderRoot.querySelectorAll('[data-record],[data-record-new]');
|
|
108
|
+
else
|
|
109
|
+
var records = this.renderRoot.querySelectorAll('[data-record]');
|
|
110
|
+
var newmap = {};
|
|
111
|
+
for (var i = 0; i < records.length; i++) {
|
|
112
|
+
var record = records[i];
|
|
113
|
+
var key = record.querySelector('[data-key]').value;
|
|
114
|
+
var inputs = record.querySelectorAll('[data-value]:not([style*="display: none"])');
|
|
115
|
+
if (!inputs || inputs.length == 0)
|
|
116
|
+
continue;
|
|
117
|
+
var input = inputs[inputs.length - 1];
|
|
118
|
+
var value = input.value;
|
|
119
|
+
if (key)
|
|
120
|
+
newmap[key] = value || '';
|
|
121
|
+
}
|
|
122
|
+
this.value = newmap;
|
|
123
|
+
this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true }));
|
|
124
|
+
}
|
|
125
|
+
/* map아이템들을 template(dom-repeat)용 배열로 변환하는 함수 */
|
|
126
|
+
_toArray(map) {
|
|
127
|
+
var array = [];
|
|
128
|
+
for (var key in map) {
|
|
129
|
+
array.push({
|
|
130
|
+
key: key,
|
|
131
|
+
value: map[key]
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
return array;
|
|
135
|
+
}
|
|
136
|
+
_add() {
|
|
137
|
+
this._build(true);
|
|
138
|
+
var inputs = this.renderRoot.querySelectorAll('[data-record-new] input:not([style*="display: none"])');
|
|
139
|
+
for (var i = 0; i < inputs.length; i++) {
|
|
140
|
+
let input = inputs[i];
|
|
141
|
+
input.value = '';
|
|
142
|
+
}
|
|
143
|
+
;
|
|
144
|
+
inputs[0].focus();
|
|
145
|
+
}
|
|
146
|
+
_delete(e) {
|
|
147
|
+
var record = e.target.parentElement;
|
|
148
|
+
record.querySelector('[data-key]').value = '';
|
|
149
|
+
this._build();
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
ThingsEditorTagScenarios.styles = [
|
|
153
|
+
css `
|
|
154
|
+
:host {
|
|
155
|
+
display: flex;
|
|
156
|
+
flex-direction: column;
|
|
157
|
+
align-content: center;
|
|
158
|
+
|
|
159
|
+
width: 100%;
|
|
160
|
+
overflow: visible;
|
|
161
|
+
border: 1px solid #ccc;
|
|
162
|
+
margin: 5px 0;
|
|
163
|
+
|
|
164
|
+
background-color: #ddd;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
div[data-record],
|
|
168
|
+
div[data-record-new] {
|
|
169
|
+
display: flex;
|
|
170
|
+
flex-flow: row nowrap;
|
|
171
|
+
align-items: center;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
div[data-record] > *,
|
|
175
|
+
div[data-record-new] > * {
|
|
176
|
+
min-height: 20px;
|
|
177
|
+
margin: 2px;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
button {
|
|
181
|
+
text-align: center;
|
|
182
|
+
border-radius: 50%;
|
|
183
|
+
font-size: 1em;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
input,
|
|
187
|
+
ox-select {
|
|
188
|
+
flex: 1;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
input {
|
|
192
|
+
padding: 5px;
|
|
193
|
+
box-sizing: border-box;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
ox-select {
|
|
197
|
+
--input-padding: 4px;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
ox-popup-list {
|
|
201
|
+
max-height: 300px;
|
|
202
|
+
overflow: auto;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
select,
|
|
206
|
+
ox-select,
|
|
207
|
+
input:not([type='checkbox']) {
|
|
208
|
+
border: 1px solid rgba(0, 0, 0, 0.2);
|
|
209
|
+
border-radius: 4px;
|
|
210
|
+
background-color: white;
|
|
211
|
+
}
|
|
212
|
+
`
|
|
213
|
+
];
|
|
214
|
+
__decorate([
|
|
215
|
+
property({ type: Object }),
|
|
216
|
+
__metadata("design:type", Object)
|
|
217
|
+
], ThingsEditorTagScenarios.prototype, "value", void 0);
|
|
218
|
+
__decorate([
|
|
219
|
+
state(),
|
|
220
|
+
__metadata("design:type", Array)
|
|
221
|
+
], ThingsEditorTagScenarios.prototype, "scenarios", void 0);
|
|
222
|
+
ThingsEditorTagScenarios = __decorate([
|
|
223
|
+
customElement('things-editor-tag-scenarios')
|
|
224
|
+
], ThingsEditorTagScenarios);
|
|
225
|
+
export default ThingsEditorTagScenarios;
|
|
226
|
+
//# sourceMappingURL=things-editor-tag-scenarios.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"things-editor-tag-scenarios.js","sourceRoot":"","sources":["../../client/editors/things-editor-tag-scenarios.ts"],"names":[],"mappings":"AAAA;;GAEG;;AAEH,OAAO,6BAA6B,CAAA;AAEpC,OAAO,GAAG,MAAM,aAAa,CAAA;AAC7B,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM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@operato/input/ox-select.js'\n\nimport gql from 'graphql-tag'\nimport { css, html, LitElement } from 'lit'\nimport { customElement, property, state } from 'lit/decorators.js'\nimport { keyed } from 'lit/directives/keyed.js'\n\nimport { client } from '@operato/graphql'\n\n/**\ntag-scenarios map editor element\n\nExample:\n\n <things-editor-tag-scenarios value=${map}>\n </things-editor-tag-scenarios>\n*/\n@customElement('things-editor-tag-scenarios')\nexport default class ThingsEditorTagScenarios extends LitElement {\n static styles = [\n css`\n :host {\n display: flex;\n flex-direction: column;\n align-content: center;\n\n width: 100%;\n overflow: visible;\n border: 1px solid #ccc;\n margin: 5px 0;\n\n background-color: #ddd;\n }\n\n div[data-record],\n div[data-record-new] {\n display: flex;\n flex-flow: row nowrap;\n align-items: center;\n }\n\n div[data-record] > *,\n div[data-record-new] > * {\n min-height: 20px;\n margin: 2px;\n }\n\n button {\n text-align: center;\n border-radius: 50%;\n font-size: 1em;\n }\n\n input,\n ox-select {\n flex: 1;\n }\n\n input {\n padding: 5px;\n box-sizing: border-box;\n }\n\n ox-select {\n --input-padding: 4px;\n }\n\n ox-popup-list {\n max-height: 300px;\n overflow: auto;\n }\n\n select,\n ox-select,\n input:not([type='checkbox']) {\n border: 1px solid rgba(0, 0, 0, 0.2);\n border-radius: 4px;\n background-color: white;\n }\n `\n ]\n\n @property({ type: Object }) value: { [key: string]: string } = {}\n\n _changingNow: boolean = false\n\n @state() private scenarios: string[] = []\n\n firstUpdated() {\n this.renderRoot.addEventListener('change', this._onChange.bind(this))\n this.fetchScenarios()\n }\n\n async fetchScenarios() {\n const { data, errors } = await client.query({\n query: gql`\n query {\n scenarios {\n items {\n id\n name\n }\n }\n }\n `\n })\n\n if (data) {\n this.scenarios = (data?.scenarios.items || []).map(item => item.name)\n }\n }\n\n render() {\n const spec = {\n queryName: 'scenarios'\n }\n\n return html`\n ${this._toArray(this.value).map(\n item => html`\n <div data-record>\n <input type=\"text\" data-key placeholder=\"(set tag)\" .value=${item.key} />\n <ox-select data-value placeholder=\"(select scenario)\" .value=${item.value}>\n <ox-popup-list with-search>\n <div option value=\"\"> </div>\n ${this.scenarios.map(scenario => html` <div option value=${scenario}>${scenario}</div> `)}\n </ox-popup-list>\n </ox-select>\n\n <button class=\"record-action\" @click=${e => this._delete(e)} tabindex=\"-1\">x</button>\n </div>\n `\n )}\n\n <div data-record-new>\n <input type=\"text\" data-key placeholder=\"(set tag)\" value=\"\" />\n ${keyed(\n Date.now(),\n html`\n <ox-select data-value placeholder=\"(select scenario)\" value=\"\">\n <ox-popup-list with-search>\n <div option value=\"\"> </div>\n ${this.scenarios.map(scenario => html` <div option value=${scenario}>${scenario}</div> `)}\n </ox-popup-list>\n </ox-select>\n `\n )}\n\n <button class=\"record-action\" @click=${e => this._add()} tabindex=\"-1\">+</button>\n </div>\n `\n }\n\n _onChange(e) {\n if (this._changingNow) {\n return\n }\n\n this._changingNow = true\n\n var input = e.target\n var value = input.value\n\n var div = input.parentElement\n\n if (div.hasAttribute('data-record')) {\n var dataList = div.querySelectorAll('[data-value]:not([hidden])')\n for (var i = 0; i < dataList.length; i++) {\n if (dataList[i] !== input) {\n dataList[i].value = value || ''\n }\n }\n }\n\n if (div.hasAttribute('data-record')) {\n this._build()\n } else if (div.hasAttribute('data-record-new') && input.hasAttribute('data-value')) {\n this._add()\n }\n\n this._changingNow = false\n }\n\n _build(includeNewRecord?) {\n if (includeNewRecord) var records = this.renderRoot.querySelectorAll('[data-record],[data-record-new]')\n else var records = this.renderRoot.querySelectorAll('[data-record]')\n\n var newmap = {}\n\n for (var i = 0; i < records.length; i++) {\n var record = records[i]\n\n var key = (record.querySelector('[data-key]') as HTMLInputElement).value\n var inputs = record.querySelectorAll('[data-value]:not([style*=\"display: none\"])')\n if (!inputs || inputs.length == 0) continue\n\n var input = inputs[inputs.length - 1] as HTMLInputElement\n\n var value = input.value\n\n if (key) newmap[key] = value || ''\n }\n\n this.value = newmap\n this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true }))\n }\n\n /* map아이템들을 template(dom-repeat)용 배열로 변환하는 함수 */\n _toArray(map) {\n var array: { key: any; value: any }[] = []\n\n for (var key in map) {\n array.push({\n key: key,\n value: map[key]\n })\n }\n\n return array\n }\n\n _add() {\n this._build(true)\n\n var inputs = this.renderRoot.querySelectorAll('[data-record-new] input:not([style*=\"display: none\"])')\n\n for (var i = 0; i < inputs.length; i++) {\n let input = inputs[i] as HTMLInputElement\n input.value = ''\n }\n\n ;(inputs[0] as HTMLInputElement).focus()\n }\n\n _delete(e) {\n var record = e.target.parentElement\n record.querySelector('[data-key]').value = ''\n this._build()\n }\n}\n"]}
|