@operato/app 8.0.0-alpha.9 → 8.0.0-beta.1
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/CHANGELOG.md +977 -2936
- package/dist/src/filters-form/filter-resource-code.d.ts +3 -0
- package/dist/src/filters-form/filter-resource-code.js +8 -0
- package/dist/src/filters-form/filter-resource-code.js.map +1 -0
- package/dist/src/filters-form/filter-resource-object.d.ts +3 -0
- package/dist/src/filters-form/filter-resource-object.js +8 -0
- package/dist/src/filters-form/filter-resource-object.js.map +1 -0
- package/dist/src/filters-form/index.js +6 -0
- package/dist/src/filters-form/index.js.map +1 -1
- package/dist/src/filters-form/ox-filter-resource-code.d.ts +17 -0
- package/dist/src/filters-form/ox-filter-resource-code.js +133 -0
- package/dist/src/filters-form/ox-filter-resource-code.js.map +1 -0
- package/dist/src/filters-form/ox-filter-resource-object.d.ts +13 -0
- package/dist/src/filters-form/ox-filter-resource-object.js +195 -0
- package/dist/src/filters-form/ox-filter-resource-object.js.map +1 -0
- package/dist/src/grist-editor/ox-grist-editor-resource-id.js +1 -1
- package/dist/src/grist-editor/ox-grist-editor-resource-id.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +33 -22
- package/.editorconfig +0 -29
- package/.storybook/main.js +0 -3
- package/.storybook/server.mjs +0 -8
- package/src/filter-renderer/filter-resource-select.ts +0 -133
- package/src/filter-renderer/index.ts +0 -6
- package/src/filters-form/filter-resource-select.ts +0 -130
- package/src/filters-form/index.ts +0 -6
- package/src/grist-editor/index.ts +0 -26
- package/src/grist-editor/ox-grist-editor-code.ts +0 -64
- package/src/grist-editor/ox-grist-editor-json.ts +0 -64
- package/src/grist-editor/ox-grist-editor-privilege.ts +0 -58
- package/src/grist-editor/ox-grist-editor-resource-code.ts +0 -30
- package/src/grist-editor/ox-grist-editor-resource-id.ts +0 -88
- package/src/grist-editor/ox-grist-editor-resource-object-legacy.ts +0 -131
- package/src/grist-editor/ox-grist-editor-resource-object.ts +0 -156
- package/src/grist-editor/ox-grist-renderer-crontab.ts +0 -18
- package/src/grist-editor/ox-grist-renderer-resource-code.ts +0 -85
- package/src/grist-editor/ox-grist-renderer-resource-id.ts +0 -17
- package/src/grist-editor/ox-grist-renderer-resource-object.ts +0 -26
- package/src/grist-editor/ox-popup-code-input.ts +0 -69
- package/src/grist-editor/ox-popup-privilege-input.ts +0 -93
- package/src/index.ts +0 -4
- package/src/input/index.ts +0 -3
- package/src/input/ox-input-background-pattern.ts +0 -196
- package/src/input/ox-input-fill-style.ts +0 -377
- package/src/input/ox-input-graphql.ts +0 -153
- package/src/property-editor/index.ts +0 -83
- package/src/property-editor/ox-property-editor-graphql.ts +0 -22
- package/src/property-editor/ox-property-editor-resource-object.ts +0 -148
- package/src/selector/ox-selector-resource-id.ts +0 -201
- package/src/selector/ox-selector-resource-object-legacy.ts +0 -367
- package/src/selector/ox-selector-resource-object.ts +0 -300
- package/stories/graphql-client.stories.ts +0 -73
- package/stories/ox-input-graphql.stories.ts +0 -70
- package/stories/ox-selector-resource-object.stories.ts +0 -98
- package/tsconfig.json +0 -24
- package/web-dev-server.config.mjs +0 -27
- package/web-test-runner.config.mjs +0 -41
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright © HatioLab Inc. All rights reserved.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { print } from 'graphql'
|
|
6
|
-
import { css, html, PropertyValues } from 'lit'
|
|
7
|
-
import { customElement, property, query } from 'lit/decorators.js'
|
|
8
|
-
import { graphql } from 'cm6-graphql'
|
|
9
|
-
|
|
10
|
-
import { history, historyKeymap, indentWithTab } from '@codemirror/commands'
|
|
11
|
-
import { autocompletion, closeBrackets } from '@codemirror/autocomplete'
|
|
12
|
-
import { bracketMatching, syntaxHighlighting } from '@codemirror/language'
|
|
13
|
-
import { oneDarkHighlightStyle, oneDark } from '@codemirror/theme-one-dark'
|
|
14
|
-
import { EditorView, highlightActiveLine, keymap, lineNumbers } from '@codemirror/view'
|
|
15
|
-
|
|
16
|
-
import { introspectSchema, wrapSchema } from '@graphql-tools/wrap'
|
|
17
|
-
import { GRAPHQL_URI } from '@operato/graphql'
|
|
18
|
-
import { OxFormField } from '@operato/input'
|
|
19
|
-
import { togglefullscreen } from '@operato/utils'
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
WEB Component for code-mirror graphql editor.
|
|
23
|
-
|
|
24
|
-
Example:
|
|
25
|
-
|
|
26
|
-
<ox-input-graphql value=${text} link=${link}>
|
|
27
|
-
</ox-input-graphql>
|
|
28
|
-
*/
|
|
29
|
-
@customElement('ox-input-graphql')
|
|
30
|
-
export default class OxInputGraphql extends OxFormField {
|
|
31
|
-
static styles = [
|
|
32
|
-
css`
|
|
33
|
-
:host {
|
|
34
|
-
display: flex;
|
|
35
|
-
flex-direction: column;
|
|
36
|
-
position: relative;
|
|
37
|
-
background: white;
|
|
38
|
-
overflow: auto;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
.cm-editor {
|
|
42
|
-
flex: 1;
|
|
43
|
-
}
|
|
44
|
-
`
|
|
45
|
-
]
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* `value`는 에디터에서 작성중인 contents이다.
|
|
49
|
-
*/
|
|
50
|
-
@property({ type: String }) value?: string
|
|
51
|
-
@property({ type: String }) link?: string
|
|
52
|
-
@property({ type: Boolean, attribute: 'show-line-numbers' }) showLineNumbers: boolean = false
|
|
53
|
-
|
|
54
|
-
private _self_changing: boolean = false
|
|
55
|
-
private _editor?: EditorView
|
|
56
|
-
private _changed: boolean = false
|
|
57
|
-
|
|
58
|
-
async updated(changes: PropertyValues<this>) {
|
|
59
|
-
const editor = await this.getEditor()
|
|
60
|
-
if (changes.has('value') && editor && !this._self_changing) {
|
|
61
|
-
const to = editor.state.doc.toString().length
|
|
62
|
-
editor.dispatch({
|
|
63
|
-
changes: { from: 0, to, insert: this.value === undefined ? '' : String(this.value) }
|
|
64
|
-
})
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
async getSchema() {
|
|
69
|
-
const executor = async ({ document, variables }: any) => {
|
|
70
|
-
const query = print(document)
|
|
71
|
-
const uri = this.link || GRAPHQL_URI
|
|
72
|
-
|
|
73
|
-
const fetchResult = await fetch(uri, {
|
|
74
|
-
method: 'POST',
|
|
75
|
-
headers: {
|
|
76
|
-
'Content-Type': 'application/json'
|
|
77
|
-
},
|
|
78
|
-
body: JSON.stringify({ query, variables })
|
|
79
|
-
})
|
|
80
|
-
return fetchResult.json()
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
return await wrapSchema({
|
|
84
|
-
schema: await introspectSchema(executor),
|
|
85
|
-
executor
|
|
86
|
-
})
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
async getEditor() {
|
|
90
|
-
if (!this._editor) {
|
|
91
|
-
var schema
|
|
92
|
-
try {
|
|
93
|
-
schema = await this.getSchema()
|
|
94
|
-
} catch (err) {
|
|
95
|
-
console.error(err)
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
this._editor = new EditorView({
|
|
99
|
-
doc: this.value,
|
|
100
|
-
extensions: [
|
|
101
|
-
...(this.showLineNumbers ? [lineNumbers()] : []),
|
|
102
|
-
bracketMatching(),
|
|
103
|
-
closeBrackets(),
|
|
104
|
-
history(),
|
|
105
|
-
autocompletion(),
|
|
106
|
-
oneDark,
|
|
107
|
-
syntaxHighlighting(oneDarkHighlightStyle),
|
|
108
|
-
graphql(schema, {
|
|
109
|
-
onShowInDocs(field, type, parentType) {
|
|
110
|
-
alert(`Showing in docs.: Field: ${field}, Type: ${type}, ParentType: ${parentType}`)
|
|
111
|
-
},
|
|
112
|
-
onFillAllFields(view, schema, _query, cursor, token) {
|
|
113
|
-
alert(`Filling all fields. Token: ${token}`)
|
|
114
|
-
}
|
|
115
|
-
}),
|
|
116
|
-
highlightActiveLine(),
|
|
117
|
-
history(),
|
|
118
|
-
keymap.of([...historyKeymap, indentWithTab]),
|
|
119
|
-
EditorView.updateListener.of(async v => {
|
|
120
|
-
if (v.docChanged) {
|
|
121
|
-
this._self_changing = true
|
|
122
|
-
this._changed = true
|
|
123
|
-
|
|
124
|
-
await this.updateComplete
|
|
125
|
-
|
|
126
|
-
this._self_changing = false
|
|
127
|
-
}
|
|
128
|
-
})
|
|
129
|
-
],
|
|
130
|
-
parent: this.renderRoot
|
|
131
|
-
})
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
this._editor.contentDOM.addEventListener('keydown', event => {
|
|
135
|
-
event.stopPropagation()
|
|
136
|
-
|
|
137
|
-
if (event.key === 'Escape') {
|
|
138
|
-
togglefullscreen(this._editor!.contentDOM)
|
|
139
|
-
}
|
|
140
|
-
})
|
|
141
|
-
|
|
142
|
-
this._editor.contentDOM.addEventListener('blur', e => {
|
|
143
|
-
if (!this._changed) {
|
|
144
|
-
return
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
this.value = this._editor!.state.doc.toString()
|
|
148
|
-
this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true, detail: this.value }))
|
|
149
|
-
})
|
|
150
|
-
|
|
151
|
-
return this._editor
|
|
152
|
-
}
|
|
153
|
-
}
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import '@operato/property-editor/ox-property-editor-3axis.js'
|
|
2
|
-
import '@operato/property-editor/ox-property-editor-3dish.js'
|
|
3
|
-
import '@operato/property-editor/ox-property-editor-legend.js'
|
|
4
|
-
import '@operato/property-editor/ox-property-editor-number.js'
|
|
5
|
-
import '@operato/property-editor/ox-property-editor-unit-number.js'
|
|
6
|
-
import '@operato/property-editor/ox-property-editor-password.js'
|
|
7
|
-
import '@operato/property-editor/ox-property-editor-action.js'
|
|
8
|
-
import '@operato/property-editor/ox-property-editor-angle.js'
|
|
9
|
-
import '@operato/property-editor/ox-property-editor-string.js'
|
|
10
|
-
import '@operato/property-editor/ox-property-editor-data.js'
|
|
11
|
-
import '@operato/property-editor/ox-property-editor-date.js'
|
|
12
|
-
import '@operato/property-editor/ox-property-editor-month.js'
|
|
13
|
-
import '@operato/property-editor/ox-property-editor-time.js'
|
|
14
|
-
import '@operato/property-editor/ox-property-editor-datetime.js'
|
|
15
|
-
import '@operato/property-editor/ox-property-editor-checkbox.js'
|
|
16
|
-
import '@operato/property-editor/ox-property-editor-options.js'
|
|
17
|
-
import '@operato/property-editor/ox-property-editor-select.js'
|
|
18
|
-
import '@operato/property-editor/ox-property-editor-scene-component-id.js'
|
|
19
|
-
import '@operato/property-editor/ox-property-editor-color.js'
|
|
20
|
-
import '@operato/property-editor/ox-property-editor-multiple-colors.js'
|
|
21
|
-
import '@operato/property-editor/ox-property-editor-solid-colorstops.js'
|
|
22
|
-
import '@operato/property-editor/ox-property-editor-gradient-colorstops.js'
|
|
23
|
-
import '@operato/property-editor/ox-property-editor-textarea.js'
|
|
24
|
-
import '@operato/property-editor/ox-property-editor-table.js'
|
|
25
|
-
import '@operato/property-editor/ox-property-editor-key-values.js'
|
|
26
|
-
import '@operato/property-editor/ox-property-editor-partition-keys.js'
|
|
27
|
-
import '@operato/property-editor/ox-property-editor-value-map.js'
|
|
28
|
-
import '@operato/property-editor/ox-property-editor-value-ranges.js'
|
|
29
|
-
import '@operato/property-editor/ox-property-editor-hashtags.js'
|
|
30
|
-
import '@operato/property-editor/ox-property-editor-image.js'
|
|
31
|
-
import '@operato/property-editor/ox-property-editor-file.js'
|
|
32
|
-
import '@operato/attachment/ox-property-editor-attachment-selector.js'
|
|
33
|
-
import '@operato/attachment/ox-property-editor-image-selector.js'
|
|
34
|
-
import '@operato/font/ox-property-editor-font-selector.js'
|
|
35
|
-
import './ox-property-editor-graphql.js'
|
|
36
|
-
import './ox-property-editor-resource-object.js'
|
|
37
|
-
|
|
38
|
-
import { OxPropertyEditor } from '@operato/property-editor'
|
|
39
|
-
|
|
40
|
-
OxPropertyEditor.register({
|
|
41
|
-
'3axis': 'ox-property-editor-3axis',
|
|
42
|
-
'3dish': 'ox-property-editor-3dish',
|
|
43
|
-
legend: 'ox-property-editor-legend',
|
|
44
|
-
number: 'ox-property-editor-number',
|
|
45
|
-
'unit-number': 'ox-property-editor-unit-number',
|
|
46
|
-
slider: 'ox-property-editor-range',
|
|
47
|
-
password: 'ox-property-editor-password',
|
|
48
|
-
action: 'ox-property-editor-action',
|
|
49
|
-
angle: 'ox-property-editor-angle',
|
|
50
|
-
string: 'ox-property-editor-string',
|
|
51
|
-
textarea: 'ox-property-editor-textarea',
|
|
52
|
-
javascript: 'ox-property-editor-textarea',
|
|
53
|
-
script: 'ox-property-editor-textarea',
|
|
54
|
-
checkbox: 'ox-property-editor-checkbox',
|
|
55
|
-
boolean: 'ox-property-editor-checkbox',
|
|
56
|
-
select: 'ox-property-editor-select',
|
|
57
|
-
date: 'ox-property-editor-date',
|
|
58
|
-
month: 'ox-property-editor-month',
|
|
59
|
-
datetime: 'ox-property-editor-datetime',
|
|
60
|
-
time: 'ox-property-editor-time',
|
|
61
|
-
options: 'ox-property-editor-options',
|
|
62
|
-
data: 'ox-property-editor-data',
|
|
63
|
-
file: 'ox-property-editor-file',
|
|
64
|
-
image: 'ox-property-editor-image',
|
|
65
|
-
'range-input': 'ox-property-editor-range',
|
|
66
|
-
'attachment-selector': 'ox-property-editor-attachment-selector',
|
|
67
|
-
'gltf-selector': 'ox-property-editor-attachment-selector',
|
|
68
|
-
'image-selector': 'ox-property-editor-image-selector',
|
|
69
|
-
color: 'ox-property-editor-color',
|
|
70
|
-
'solid-color-stops': 'ox-property-editor-solid-colorstops',
|
|
71
|
-
'gradient-color-stops': 'ox-property-editor-gradient-colorstops',
|
|
72
|
-
'multiple-color': 'ox-property-editor-multiple-colors',
|
|
73
|
-
map: 'ox-property-editor-value-map',
|
|
74
|
-
range: 'ox-property-editor-value-ranges',
|
|
75
|
-
graphql: 'ox-property-editor-graphql',
|
|
76
|
-
'editor-table': 'ox-property-editor-table',
|
|
77
|
-
'id-input': 'ox-property-editor-scene-component-id',
|
|
78
|
-
'font-selector': 'ox-property-editor-font-selector',
|
|
79
|
-
'partition-keys': 'ox-property-editor-partion-keys',
|
|
80
|
-
'key-values': 'ox-property-editor-key-values',
|
|
81
|
-
hashtags: 'ox-property-editor-hashtags',
|
|
82
|
-
'resource-object': 'ox-property-editor-resource-object'
|
|
83
|
-
})
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import '../input/ox-input-graphql.js'
|
|
2
|
-
|
|
3
|
-
import { css, html, TemplateResult } from 'lit'
|
|
4
|
-
import { customElement } from 'lit/decorators.js'
|
|
5
|
-
|
|
6
|
-
import { OxPropertyEditor, PropertySpec } from '@operato/property-editor'
|
|
7
|
-
|
|
8
|
-
@customElement('ox-property-editor-graphql')
|
|
9
|
-
export class OxPropertyEditorGraphQL extends OxPropertyEditor {
|
|
10
|
-
static styles = [
|
|
11
|
-
...OxPropertyEditor.styles,
|
|
12
|
-
css`
|
|
13
|
-
:host {
|
|
14
|
-
grid-template-rows: auto 1fr;
|
|
15
|
-
}
|
|
16
|
-
`
|
|
17
|
-
]
|
|
18
|
-
|
|
19
|
-
editorTemplate(value: any, spec: PropertySpec): TemplateResult {
|
|
20
|
-
return html` <ox-input-graphql class="multiline-input" id="editor" .value=${value} fullwidth> </ox-input-graphql> `
|
|
21
|
-
}
|
|
22
|
-
}
|
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
import '../selector/ox-selector-resource-object.js'
|
|
2
|
-
|
|
3
|
-
import { html, TemplateResult } from 'lit'
|
|
4
|
-
import { customElement } from 'lit/decorators.js'
|
|
5
|
-
|
|
6
|
-
import { i18next } from '@operato/i18n'
|
|
7
|
-
import { openPopup, PopupHandle } from '@operato/layout'
|
|
8
|
-
import { OxPropertyEditor, PropertySpec } from '@operato/property-editor'
|
|
9
|
-
|
|
10
|
-
@customElement('ox-property-editor-resource-object')
|
|
11
|
-
export class OxPropertyEditorResourceObject extends OxPropertyEditor {
|
|
12
|
-
static get styles() {
|
|
13
|
-
return [...OxPropertyEditor.styles]
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
private popup?: PopupHandle
|
|
17
|
-
|
|
18
|
-
editorTemplate(value: any, spec: PropertySpec): TemplateResult {
|
|
19
|
-
var { nameField = 'name', descriptionField = 'description' } = spec.property || {}
|
|
20
|
-
var name, description
|
|
21
|
-
|
|
22
|
-
if (typeof nameField === 'function') {
|
|
23
|
-
name = nameField(value)
|
|
24
|
-
} else {
|
|
25
|
-
name = value && value[nameField]
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
if (typeof descriptionField === 'function') {
|
|
29
|
-
description = descriptionField(value)
|
|
30
|
-
} else {
|
|
31
|
-
description = value && value[descriptionField] && `(${value[descriptionField]})`
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
return html`
|
|
35
|
-
${!value
|
|
36
|
-
? html`<span tabindex="0" @click=${this.onClick.bind(this)} @keydown=${this.onKeyDown.bind(this)}></span>`
|
|
37
|
-
: html`
|
|
38
|
-
<span tabindex="0" @click=${this.onClick.bind(this)} @keydown=${this.onKeyDown.bind(this)}
|
|
39
|
-
>${name || ''}${description || ''}</span
|
|
40
|
-
>
|
|
41
|
-
`}
|
|
42
|
-
`
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
onClick(e: Event): void {
|
|
46
|
-
e.stopPropagation()
|
|
47
|
-
this.openSelector()
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
onKeyDown(e: KeyboardEvent): void {
|
|
51
|
-
const key = e.key
|
|
52
|
-
if (key == 'Enter') {
|
|
53
|
-
e.stopPropagation()
|
|
54
|
-
this.openSelector()
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
openSelector() {
|
|
59
|
-
if (this.popup) {
|
|
60
|
-
delete this.popup
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
var {
|
|
64
|
-
title,
|
|
65
|
-
idField = 'id',
|
|
66
|
-
nameField = 'name',
|
|
67
|
-
descriptionField = 'description',
|
|
68
|
-
valueField = 'id',
|
|
69
|
-
queryName,
|
|
70
|
-
basicArgs,
|
|
71
|
-
select,
|
|
72
|
-
columns,
|
|
73
|
-
pagination,
|
|
74
|
-
list
|
|
75
|
-
} = this.property || {}
|
|
76
|
-
|
|
77
|
-
/* select options is only for compatability, it might be able to be deprecated. */
|
|
78
|
-
columns = columns || select
|
|
79
|
-
|
|
80
|
-
const confirmCallback = (selected?: { [field: string]: any }) => {
|
|
81
|
-
this.value = selected
|
|
82
|
-
? {
|
|
83
|
-
...(columns || [])
|
|
84
|
-
.map((field: any) => field.name)
|
|
85
|
-
.reduce(
|
|
86
|
-
(obj: { [field: string]: any }, fieldName: string) => {
|
|
87
|
-
return (obj = {
|
|
88
|
-
...obj,
|
|
89
|
-
[fieldName]: selected[fieldName]
|
|
90
|
-
})
|
|
91
|
-
},
|
|
92
|
-
{} as { [field: string]: any }
|
|
93
|
-
),
|
|
94
|
-
[idField]: selected[idField],
|
|
95
|
-
[nameField]: selected[nameField],
|
|
96
|
-
[descriptionField]: selected[descriptionField]
|
|
97
|
-
}
|
|
98
|
-
: null
|
|
99
|
-
|
|
100
|
-
this.dispatchEvent(
|
|
101
|
-
new CustomEvent('change', {
|
|
102
|
-
bubbles: true,
|
|
103
|
-
composed: true
|
|
104
|
-
})
|
|
105
|
-
)
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
var value = this.value || {}
|
|
109
|
-
var actualValue
|
|
110
|
-
if (typeof valueField === 'function') {
|
|
111
|
-
actualValue = valueField(value)
|
|
112
|
-
} else {
|
|
113
|
-
actualValue = value[valueField]
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
var template = html`
|
|
117
|
-
<ox-selector-resource-object
|
|
118
|
-
.value=${actualValue}
|
|
119
|
-
.confirmCallback=${confirmCallback.bind(this)}
|
|
120
|
-
.queryName=${queryName}
|
|
121
|
-
.columns=${columns}
|
|
122
|
-
.pagination=${pagination}
|
|
123
|
-
.list=${list}
|
|
124
|
-
.basicArgs=${basicArgs}
|
|
125
|
-
.valueField=${valueField}
|
|
126
|
-
></ox-selector-resource-object>
|
|
127
|
-
`
|
|
128
|
-
|
|
129
|
-
this.popup = openPopup(template, {
|
|
130
|
-
backdrop: true,
|
|
131
|
-
size: 'large',
|
|
132
|
-
search: {
|
|
133
|
-
autofocus: true,
|
|
134
|
-
placeholder: title || i18next.t('title.select_item'),
|
|
135
|
-
handler: (instance: any, value: any) => {
|
|
136
|
-
/* instance: template instance */
|
|
137
|
-
instance.searchText(value)
|
|
138
|
-
}
|
|
139
|
-
},
|
|
140
|
-
filter: {
|
|
141
|
-
handler: (instance: any) => {
|
|
142
|
-
/* instance: template instance */
|
|
143
|
-
instance.toggleFilter()
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
})
|
|
147
|
-
}
|
|
148
|
-
}
|
|
@@ -1,201 +0,0 @@
|
|
|
1
|
-
import '@material/web/icon/icon.js'
|
|
2
|
-
import '@operato/data-grist'
|
|
3
|
-
|
|
4
|
-
import gql from 'graphql-tag'
|
|
5
|
-
import { css, html, LitElement } from 'lit'
|
|
6
|
-
import { customElement, property, query } from 'lit/decorators.js'
|
|
7
|
-
|
|
8
|
-
import { DataGrist, FetchOption, GristData, GristRecord, InheritedValueType, ZERO_DATA } from '@operato/data-grist'
|
|
9
|
-
import { client } from '@operato/graphql'
|
|
10
|
-
import { i18next } from '@operato/i18n'
|
|
11
|
-
import { closePopup } from '@operato/popup'
|
|
12
|
-
import { isMobileDevice } from '@operato/utils'
|
|
13
|
-
import { CommonHeaderStyles } from '@operato/styles'
|
|
14
|
-
|
|
15
|
-
@customElement('ox-selector-resource-id')
|
|
16
|
-
export class OxSelectorResourceId extends LitElement {
|
|
17
|
-
static styles = [
|
|
18
|
-
CommonHeaderStyles,
|
|
19
|
-
css`
|
|
20
|
-
:host {
|
|
21
|
-
display: flex;
|
|
22
|
-
flex-direction: column;
|
|
23
|
-
|
|
24
|
-
background-color: var(--md-sys-color-surface);
|
|
25
|
-
|
|
26
|
-
width: var(--overlay-center-normal-width, 50%);
|
|
27
|
-
height: var(--overlay-center-normal-height, 50%);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
ox-grist {
|
|
31
|
-
flex: 1;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
#filters {
|
|
35
|
-
display: flex;
|
|
36
|
-
flex-direction: row;
|
|
37
|
-
justify-content: space-between;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
#filters > * {
|
|
41
|
-
padding: var(--padding-default) var(--spacing-large);
|
|
42
|
-
}
|
|
43
|
-
`
|
|
44
|
-
]
|
|
45
|
-
|
|
46
|
-
@property({ type: String }) value?: string
|
|
47
|
-
@property({ type: Object }) config: any
|
|
48
|
-
@property({ type: Object }) data: GristData = ZERO_DATA
|
|
49
|
-
@property({ type: String }) queryName!: string
|
|
50
|
-
@property({ type: Object }) basicArgs: any
|
|
51
|
-
@property({ type: String }) inherited?: InheritedValueType = InheritedValueType.Include
|
|
52
|
-
@property({ type: Object }) confirmCallback?: (record?: GristRecord) => void
|
|
53
|
-
@property({ type: Array }) selectedRecords: GristRecord[] = []
|
|
54
|
-
|
|
55
|
-
@query('ox-grist') grist!: DataGrist
|
|
56
|
-
|
|
57
|
-
render() {
|
|
58
|
-
return html`
|
|
59
|
-
<ox-grist
|
|
60
|
-
.mode=${isMobileDevice() ? 'LIST' : 'GRID'}
|
|
61
|
-
.config=${this.config}
|
|
62
|
-
.fetchHandler=${this.fetchHandler.bind(this)}
|
|
63
|
-
.selectedRecords=${this.selectedRecords}
|
|
64
|
-
>
|
|
65
|
-
<div id="filters" slot="headroom">
|
|
66
|
-
<ox-filters-form autofocus></ox-filters-form>
|
|
67
|
-
</div>
|
|
68
|
-
</ox-grist>
|
|
69
|
-
|
|
70
|
-
<div class="footer">
|
|
71
|
-
<button @click=${this.onEmpty.bind(this)}>
|
|
72
|
-
<md-icon>check_box_outline_blank</md-icon>${i18next.t('button.empty')}
|
|
73
|
-
</button>
|
|
74
|
-
<div filler></div>
|
|
75
|
-
<button @click=${this.onCancel.bind(this)}><md-icon>cancel</md-icon>${i18next.t('button.cancel')}</button>
|
|
76
|
-
<button @click=${this.onConfirm.bind(this)} done><md-icon>done</md-icon>${i18next.t('button.confirm')}</button>
|
|
77
|
-
</div>
|
|
78
|
-
`
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
onEmpty() {
|
|
82
|
-
this.confirmCallback && this.confirmCallback()
|
|
83
|
-
closePopup(this)
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
onCancel() {
|
|
87
|
-
closePopup(this)
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
onConfirm() {
|
|
91
|
-
this.confirmCallback && this.confirmCallback(this.selected)
|
|
92
|
-
closePopup(this)
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
async firstUpdated() {
|
|
96
|
-
this.config = {
|
|
97
|
-
columns: [
|
|
98
|
-
{
|
|
99
|
-
type: 'gutter',
|
|
100
|
-
gutterName: 'sequence'
|
|
101
|
-
},
|
|
102
|
-
{
|
|
103
|
-
type: 'gutter',
|
|
104
|
-
gutterName: 'row-selector',
|
|
105
|
-
multiple: false
|
|
106
|
-
},
|
|
107
|
-
{
|
|
108
|
-
type: 'string',
|
|
109
|
-
name: 'id',
|
|
110
|
-
header: i18next.t('field.id'),
|
|
111
|
-
hidden: true
|
|
112
|
-
},
|
|
113
|
-
{
|
|
114
|
-
type: 'string',
|
|
115
|
-
name: 'name',
|
|
116
|
-
header: i18next.t('field.name'),
|
|
117
|
-
record: {
|
|
118
|
-
align: 'left'
|
|
119
|
-
},
|
|
120
|
-
filter: 'search',
|
|
121
|
-
sortable: true,
|
|
122
|
-
width: 160
|
|
123
|
-
},
|
|
124
|
-
{
|
|
125
|
-
type: 'string',
|
|
126
|
-
name: 'description',
|
|
127
|
-
header: i18next.t('field.description'),
|
|
128
|
-
record: {
|
|
129
|
-
align: 'left'
|
|
130
|
-
},
|
|
131
|
-
filter: 'search',
|
|
132
|
-
sortable: true,
|
|
133
|
-
width: 300
|
|
134
|
-
}
|
|
135
|
-
],
|
|
136
|
-
rows: {
|
|
137
|
-
selectable: {
|
|
138
|
-
multiple: false
|
|
139
|
-
},
|
|
140
|
-
handlers: {
|
|
141
|
-
click: 'select-row'
|
|
142
|
-
}
|
|
143
|
-
},
|
|
144
|
-
pagination: {
|
|
145
|
-
infinite: true
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
await this.updateComplete
|
|
150
|
-
|
|
151
|
-
/* TODO config가 설정될 때, fetch() 가 동작하므로, fetch 완료 이벤트를 받아서, selected를 설정해주는 것이 좋겠다.
|
|
152
|
-
현재는 fetch() 가 두번 일어난다.
|
|
153
|
-
*/
|
|
154
|
-
await this.grist.fetch()
|
|
155
|
-
|
|
156
|
-
var selected = this.grist.data.records.find(item => this.value == item.id)
|
|
157
|
-
if (selected) {
|
|
158
|
-
this.selectedRecords = [selected]
|
|
159
|
-
}
|
|
160
|
-
/* TODO config가 설정될 때, fetch() 가 동작하므로, fetch 완료 이벤트를 받아서, selected를 설정해주는 것이 좋겠다. */
|
|
161
|
-
|
|
162
|
-
await this.updateComplete
|
|
163
|
-
this.grist.focus()
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
async fetchHandler({ page = 1, limit = 100, sorters = [], filters = [], inherited }: FetchOption) {
|
|
167
|
-
const response = await client.query({
|
|
168
|
-
query: gql`
|
|
169
|
-
query ($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!], $inherited) {
|
|
170
|
-
q: ${this.queryName}(filters: $filters, pagination: $pagination, sortings: $sortings, inhereted: $inherited) {
|
|
171
|
-
items {
|
|
172
|
-
id
|
|
173
|
-
name
|
|
174
|
-
description
|
|
175
|
-
}
|
|
176
|
-
total
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
`,
|
|
180
|
-
variables: {
|
|
181
|
-
filters,
|
|
182
|
-
pagination: { page, limit },
|
|
183
|
-
sortings: sorters,
|
|
184
|
-
inherited: inherited || this.inherited
|
|
185
|
-
}
|
|
186
|
-
})
|
|
187
|
-
|
|
188
|
-
return {
|
|
189
|
-
total: response.data.q.total || 0,
|
|
190
|
-
records: response.data.q.items || []
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
get selected() {
|
|
195
|
-
var grist = this.renderRoot.querySelector('ox-grist') as DataGrist
|
|
196
|
-
|
|
197
|
-
var selected = grist.selected
|
|
198
|
-
|
|
199
|
-
return selected && selected.length > 0 ? selected[0] : undefined
|
|
200
|
-
}
|
|
201
|
-
}
|