@operato/grist-editor 1.0.0-alpha.23 → 1.0.0-beta.40
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/.storybook/main.js +2 -2
- package/.storybook/server.mjs +4 -4
- package/CHANGELOG.md +4 -116
- package/LICENSE +2 -2
- package/README.md +29 -9
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.js +15 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/ox-grist-editor-crontab.d.ts +8 -0
- package/dist/src/ox-grist-editor-crontab.js +50 -0
- package/dist/src/ox-grist-editor-crontab.js.map +1 -0
- package/dist/src/ox-grist-editor-duration.d.ts +8 -0
- package/dist/src/ox-grist-editor-duration.js +50 -0
- package/dist/src/ox-grist-editor-duration.js.map +1 -0
- package/dist/src/ox-grist-editor-parameters.d.ts +12 -0
- package/dist/src/{parameters/parameters-editor.js → ox-grist-editor-parameters.js} +17 -39
- package/dist/src/ox-grist-editor-parameters.js.map +1 -0
- package/dist/src/ox-grist-editor-partition-keys.d.ts +11 -0
- package/dist/src/ox-grist-editor-partition-keys.js +74 -0
- package/dist/src/ox-grist-editor-partition-keys.js.map +1 -0
- package/dist/src/ox-grist-editor-value-map.d.ts +11 -0
- package/dist/src/ox-grist-editor-value-map.js +74 -0
- package/dist/src/ox-grist-editor-value-map.js.map +1 -0
- package/dist/src/ox-grist-renderer-crontab.d.ts +2 -0
- package/dist/src/ox-grist-renderer-crontab.js +26 -0
- package/dist/src/ox-grist-renderer-crontab.js.map +1 -0
- package/dist/src/{parameters/parameters-editor-builder.d.ts → ox-parameters-builder.d.ts} +0 -0
- package/dist/src/{parameters/parameters-editor-builder.js → ox-parameters-builder.js} +12 -14
- package/dist/src/ox-parameters-builder.js.map +1 -0
- package/dist/src/ox-popup-crontab-input.d.ts +11 -0
- package/dist/src/ox-popup-crontab-input.js +75 -0
- package/dist/src/ox-popup-crontab-input.js.map +1 -0
- package/dist/src/ox-popup-duration-input.d.ts +11 -0
- package/dist/src/ox-popup-duration-input.js +75 -0
- package/dist/src/ox-popup-duration-input.js.map +1 -0
- package/dist/src/{parameters/parameters-editor-popup.d.ts → ox-popup-parameters-builder.d.ts} +1 -1
- package/dist/src/{parameters/parameters-editor-popup.js → ox-popup-parameters-builder.js} +20 -19
- package/dist/src/ox-popup-parameters-builder.js.map +1 -0
- package/dist/src/ox-popup-partition-keys-input.d.ts +12 -0
- package/dist/src/ox-popup-partition-keys-input.js +100 -0
- package/dist/src/ox-popup-partition-keys-input.js.map +1 -0
- package/dist/src/ox-popup-value-map-input.d.ts +12 -0
- package/dist/src/ox-popup-value-map-input.js +105 -0
- package/dist/src/ox-popup-value-map-input.js.map +1 -0
- package/dist/stories/ox-grist-editor-crontab.stories.d.ts +24 -0
- package/dist/stories/ox-grist-editor-crontab.stories.js +406 -0
- package/dist/stories/ox-grist-editor-crontab.stories.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +36 -24
- package/src/index.ts +18 -0
- package/src/ox-grist-editor-crontab.ts +62 -0
- package/src/ox-grist-editor-duration.ts +62 -0
- package/src/{parameters/parameters-editor.ts → ox-grist-editor-parameters.ts} +14 -27
- package/src/ox-grist-editor-partition-keys.ts +86 -0
- package/src/ox-grist-editor-value-map.ts +86 -0
- package/src/ox-grist-renderer-crontab.ts +31 -0
- package/src/{parameters/parameters-editor-builder.ts → ox-parameters-builder.ts} +6 -8
- package/src/ox-popup-crontab-input.ts +75 -0
- package/src/ox-popup-duration-input.ts +75 -0
- package/src/{parameters/parameters-editor-popup.ts → ox-popup-parameters-builder.ts} +10 -9
- package/src/ox-popup-partition-keys-input.ts +97 -0
- package/src/ox-popup-value-map-input.ts +102 -0
- package/stories/ox-grist-editor-crontab.stories.ts +429 -0
- package/themes/app-theme.css +142 -0
- package/themes/form-theme.css +75 -0
- package/themes/grist-theme.css +194 -0
- package/themes/oops-theme.css +26 -0
- package/themes/report-theme.css +47 -0
- package/translations/en.json +3 -0
- package/translations/ko.json +3 -0
- package/translations/ms.json +3 -0
- package/translations/zh.json +3 -0
- package/web-dev-server.config.mjs +9 -8
- package/web-test-runner.config.mjs +7 -19
- package/.editorconfig +0 -29
- package/demo/data-grist-test.html +0 -456
- package/demo/index.html +0 -33
- package/dist/src/code/code-editor.d.ts +0 -6
- package/dist/src/code/code-editor.js +0 -50
- package/dist/src/code/code-editor.js.map +0 -1
- package/dist/src/code/index.d.ts +0 -1
- package/dist/src/code/index.js +0 -5
- package/dist/src/code/index.js.map +0 -1
- package/dist/src/id/id-input.d.ts +0 -19
- package/dist/src/id/id-input.js +0 -119
- package/dist/src/id/id-input.js.map +0 -1
- package/dist/src/id/id-renderer.d.ts +0 -2
- package/dist/src/id/id-renderer.js +0 -9
- package/dist/src/id/id-renderer.js.map +0 -1
- package/dist/src/id/id-selector.d.ts +0 -23
- package/dist/src/id/id-selector.js +0 -197
- package/dist/src/id/id-selector.js.map +0 -1
- package/dist/src/id/index.d.ts +0 -1
- package/dist/src/id/index.js +0 -7
- package/dist/src/id/index.js.map +0 -1
- package/dist/src/object/index.d.ts +0 -1
- package/dist/src/object/index.js +0 -6
- package/dist/src/object/index.js.map +0 -1
- package/dist/src/object/object-editor.d.ts +0 -18
- package/dist/src/object/object-editor.js +0 -152
- package/dist/src/object/object-editor.js.map +0 -1
- package/dist/src/object/object-selector.d.ts +0 -38
- package/dist/src/object/object-selector.js +0 -338
- package/dist/src/object/object-selector.js.map +0 -1
- package/dist/src/parameters/index.d.ts +0 -1
- package/dist/src/parameters/index.js +0 -6
- package/dist/src/parameters/index.js.map +0 -1
- package/dist/src/parameters/parameters-editor-builder.js.map +0 -1
- package/dist/src/parameters/parameters-editor-popup.js.map +0 -1
- package/dist/src/parameters/parameters-editor.d.ts +0 -18
- package/dist/src/parameters/parameters-editor.js.map +0 -1
- package/src/code/code-editor.ts +0 -78
- package/src/code/index.ts +0 -6
- package/src/id/id-input.ts +0 -135
- package/src/id/id-renderer.ts +0 -12
- package/src/id/id-selector.ts +0 -189
- package/src/id/index.ts +0 -8
- package/src/object/index.ts +0 -8
- package/src/object/object-editor.ts +0 -162
- package/src/object/object-selector.ts +0 -346
- package/src/parameters/index.ts +0 -8
|
@@ -1,346 +0,0 @@
|
|
|
1
|
-
import '@operato/data-grist'
|
|
2
|
-
import '@operato/form/ox-search-form.js'
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
ColumnConfig,
|
|
6
|
-
DataGrist,
|
|
7
|
-
FetchHandler,
|
|
8
|
-
FetchOption,
|
|
9
|
-
GristData,
|
|
10
|
-
GristEventHandler,
|
|
11
|
-
GristRecord,
|
|
12
|
-
ZERO_DATA
|
|
13
|
-
} from '@operato/data-grist'
|
|
14
|
-
import { LitElement, css, html } from 'lit'
|
|
15
|
-
import { MultiColumnFormStyles, SearchForm } from '@operato/form'
|
|
16
|
-
import { buildArgs, client, gqlContext } from '@operato/graphql'
|
|
17
|
-
import { customElement, property, query } from 'lit/decorators.js'
|
|
18
|
-
|
|
19
|
-
import gql from 'graphql-tag'
|
|
20
|
-
import { i18next } from '@operato/i18n'
|
|
21
|
-
import { isMobileDevice } from '@operato/utils'
|
|
22
|
-
|
|
23
|
-
@customElement('ox-object-selector')
|
|
24
|
-
export class ObjectSelector extends LitElement {
|
|
25
|
-
static styles = [
|
|
26
|
-
MultiColumnFormStyles,
|
|
27
|
-
css`
|
|
28
|
-
:host {
|
|
29
|
-
display: flex;
|
|
30
|
-
flex-direction: column;
|
|
31
|
-
|
|
32
|
-
background-color: #fff;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
data-grist {
|
|
36
|
-
flex: 1;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
.button-container {
|
|
40
|
-
display: flex;
|
|
41
|
-
margin-left: auto;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
form {
|
|
45
|
-
position: relative;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
[search] {
|
|
49
|
-
position: absolute;
|
|
50
|
-
right: 0;
|
|
51
|
-
}
|
|
52
|
-
`
|
|
53
|
-
]
|
|
54
|
-
|
|
55
|
-
@property({ type: String }) value?: string
|
|
56
|
-
@property({ type: Object }) config: any
|
|
57
|
-
@property({ type: Object }) data: GristData = ZERO_DATA
|
|
58
|
-
@property({ type: String }) queryName!: string
|
|
59
|
-
@property({ type: Object }) basicArgs: any
|
|
60
|
-
@property({ type: Object }) confirmCallback?: (record: GristRecord | undefined) => void
|
|
61
|
-
@property({ type: Array }) selectedRecords: GristRecord[] = []
|
|
62
|
-
|
|
63
|
-
@property({ type: Array }) searchFields: any
|
|
64
|
-
@property({ type: Array }) select: {
|
|
65
|
-
type: string
|
|
66
|
-
name: string
|
|
67
|
-
header: string
|
|
68
|
-
subFields?: string[]
|
|
69
|
-
hidden: boolean
|
|
70
|
-
ignoreCondition: boolean
|
|
71
|
-
queryName: string
|
|
72
|
-
width: number
|
|
73
|
-
}[] = []
|
|
74
|
-
@property({ type: Object }) list: any
|
|
75
|
-
@property({ type: String }) valueField: string | ((item: any) => any) = 'id'
|
|
76
|
-
|
|
77
|
-
@query('ox-grist') grist!: DataGrist
|
|
78
|
-
@query('ox-search-form') searchForm!: SearchForm
|
|
79
|
-
|
|
80
|
-
render() {
|
|
81
|
-
return html`
|
|
82
|
-
<ox-search-form
|
|
83
|
-
id="search-form"
|
|
84
|
-
@keypress=${(e: KeyboardEvent) => {
|
|
85
|
-
if (e.keyCode === 13) {
|
|
86
|
-
this.grist.fetch()
|
|
87
|
-
}
|
|
88
|
-
}}
|
|
89
|
-
@submit=${(e: SubmitEvent) => this.grist.fetch()}
|
|
90
|
-
.fields=${this.searchFields}
|
|
91
|
-
></ox-search-form>
|
|
92
|
-
|
|
93
|
-
<ox-grist
|
|
94
|
-
.mode=${isMobileDevice() ? 'LIST' : 'GRID'}
|
|
95
|
-
.config=${this.config}
|
|
96
|
-
.data=${this.data}
|
|
97
|
-
.fetchHandler=${this.fetchHandler.bind(this)}
|
|
98
|
-
.selectedRecords=${this.selectedRecords}
|
|
99
|
-
></ox-grist>
|
|
100
|
-
|
|
101
|
-
<div class="button-container">
|
|
102
|
-
<mwc-button @click=${this.oncancel.bind(this)}>${i18next.t('button.cancel')}</mwc-button>
|
|
103
|
-
<mwc-button @click=${this.onconfirm.bind(this)}>${i18next.t('button.confirm')}</mwc-button>
|
|
104
|
-
</div>
|
|
105
|
-
`
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
oncancel() {
|
|
109
|
-
history.back()
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
onconfirm() {
|
|
113
|
-
this.confirmCallback && this.confirmCallback(this.selected)
|
|
114
|
-
history.back()
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
fetchHandler: FetchHandler = async ({ filters, page, limit, sorters = [] }) => {
|
|
118
|
-
const response = await client.query({
|
|
119
|
-
query: gql`
|
|
120
|
-
query {
|
|
121
|
-
fetch: ${this.queryName} (${buildArgs(await this._buildConditions({ filters, page, limit, sorters }))}) {
|
|
122
|
-
${this.getSelectFields()}
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
`,
|
|
126
|
-
context: gqlContext()
|
|
127
|
-
})
|
|
128
|
-
|
|
129
|
-
if (!response.errors) {
|
|
130
|
-
const records = response.data.fetch.items.map((item: any) => {
|
|
131
|
-
let rowValue
|
|
132
|
-
|
|
133
|
-
if (this.valueField && typeof this.valueField === 'function') {
|
|
134
|
-
rowValue = this.valueField(item)
|
|
135
|
-
} else if (this.valueField) {
|
|
136
|
-
rowValue = item[this.valueField]
|
|
137
|
-
} else {
|
|
138
|
-
rowValue = item.id
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
if (this.value && this.value === rowValue) {
|
|
142
|
-
this.selectedRecords = [item]
|
|
143
|
-
item['__selected__'] = true
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
return item
|
|
147
|
-
})
|
|
148
|
-
const total = response.data.fetch.total
|
|
149
|
-
|
|
150
|
-
return {
|
|
151
|
-
records,
|
|
152
|
-
total,
|
|
153
|
-
limit,
|
|
154
|
-
page
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
async firstUpdated() {
|
|
160
|
-
this.config = {
|
|
161
|
-
columns: [
|
|
162
|
-
{
|
|
163
|
-
type: 'gutter',
|
|
164
|
-
gutterName: 'sequence'
|
|
165
|
-
},
|
|
166
|
-
{
|
|
167
|
-
type: 'gutter',
|
|
168
|
-
gutterName: 'row-selector',
|
|
169
|
-
multiple: false
|
|
170
|
-
}
|
|
171
|
-
],
|
|
172
|
-
rows: {
|
|
173
|
-
selectable: {
|
|
174
|
-
multiple: false
|
|
175
|
-
},
|
|
176
|
-
handlers: {
|
|
177
|
-
click: 'select-row',
|
|
178
|
-
dblclick: ((columns, data, column, record, rowIndex, field) => {
|
|
179
|
-
this.onconfirm()
|
|
180
|
-
}) as GristEventHandler
|
|
181
|
-
},
|
|
182
|
-
appendable: false
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
if (this.select && this.select.length > 0) {
|
|
187
|
-
let _searchFields = this.select.filter(selectField => !selectField.hidden && !selectField.ignoreCondition)
|
|
188
|
-
if (this.list && this.list.fields && this.list.fields.length > 0) {
|
|
189
|
-
_searchFields = _searchFields.filter(searchField => this.list.fields.indexOf(searchField.name) >= 0)
|
|
190
|
-
} else {
|
|
191
|
-
_searchFields = _searchFields.slice(0, 4)
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
this.searchFields = _searchFields.map(selectField => {
|
|
195
|
-
const fieldType = (selectField.type && selectField.type.toLowerCase()) || 'string'
|
|
196
|
-
const numberTypes = ['integer', 'float']
|
|
197
|
-
return {
|
|
198
|
-
label: selectField.header || i18next.t(`field.${selectField.name}`),
|
|
199
|
-
name: selectField.name,
|
|
200
|
-
type:
|
|
201
|
-
fieldType === 'string'
|
|
202
|
-
? 'text'
|
|
203
|
-
: numberTypes.indexOf(fieldType) >= 0
|
|
204
|
-
? 'number'
|
|
205
|
-
: fieldType === 'boolean'
|
|
206
|
-
? 'checkbox'
|
|
207
|
-
: fieldType,
|
|
208
|
-
queryName: selectField.queryName,
|
|
209
|
-
props:
|
|
210
|
-
fieldType === 'string'
|
|
211
|
-
? { searchOper: 'i_like' }
|
|
212
|
-
: fieldType === 'object'
|
|
213
|
-
? { searchOper: 'in' }
|
|
214
|
-
: { searchOper: 'eq' },
|
|
215
|
-
attrs: fieldType === 'boolean' ? ['indeterminated'] : []
|
|
216
|
-
}
|
|
217
|
-
})
|
|
218
|
-
this.config = {
|
|
219
|
-
...this.config,
|
|
220
|
-
columns: [
|
|
221
|
-
...this.config.columns,
|
|
222
|
-
...this.select.map(selectField => {
|
|
223
|
-
return {
|
|
224
|
-
...selectField,
|
|
225
|
-
type: selectField.type || 'string',
|
|
226
|
-
width: selectField.width || 160,
|
|
227
|
-
header: selectField.header || i18next.t(`field.${selectField.name}`)
|
|
228
|
-
}
|
|
229
|
-
})
|
|
230
|
-
]
|
|
231
|
-
}
|
|
232
|
-
} else {
|
|
233
|
-
this.searchFields = [
|
|
234
|
-
{
|
|
235
|
-
label: i18next.t('field.name'),
|
|
236
|
-
name: 'name',
|
|
237
|
-
type: 'text',
|
|
238
|
-
props: { searchOper: 'i_like' }
|
|
239
|
-
},
|
|
240
|
-
{
|
|
241
|
-
label: i18next.t('field.description'),
|
|
242
|
-
name: 'description',
|
|
243
|
-
type: 'text',
|
|
244
|
-
props: { searchOper: 'i_like' }
|
|
245
|
-
}
|
|
246
|
-
]
|
|
247
|
-
|
|
248
|
-
this.config = {
|
|
249
|
-
...this.config,
|
|
250
|
-
columns: [
|
|
251
|
-
...this.config.columns,
|
|
252
|
-
{
|
|
253
|
-
type: 'string',
|
|
254
|
-
name: 'id',
|
|
255
|
-
header: i18next.t('field.id'),
|
|
256
|
-
hidden: true
|
|
257
|
-
},
|
|
258
|
-
{
|
|
259
|
-
type: 'string',
|
|
260
|
-
name: 'name',
|
|
261
|
-
header: i18next.t('field.name'),
|
|
262
|
-
record: {
|
|
263
|
-
align: 'left'
|
|
264
|
-
},
|
|
265
|
-
sortable: true,
|
|
266
|
-
width: 160
|
|
267
|
-
},
|
|
268
|
-
{
|
|
269
|
-
type: 'string',
|
|
270
|
-
name: 'description',
|
|
271
|
-
header: i18next.t('field.description'),
|
|
272
|
-
record: {
|
|
273
|
-
align: 'left'
|
|
274
|
-
},
|
|
275
|
-
sortable: true,
|
|
276
|
-
width: 300
|
|
277
|
-
}
|
|
278
|
-
]
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
this.config = {
|
|
283
|
-
...this.config,
|
|
284
|
-
list: {
|
|
285
|
-
...this.list,
|
|
286
|
-
fields:
|
|
287
|
-
this.list && this.list.fields && this.list.fields.length > 0
|
|
288
|
-
? this.list.fields
|
|
289
|
-
: (this.config.columns as ColumnConfig[])
|
|
290
|
-
.filter(column => column.type !== 'gutter')
|
|
291
|
-
.slice(0, 3)
|
|
292
|
-
.map(column => column.name)
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
await this.updateComplete
|
|
297
|
-
this.grist && this.grist.focus()
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
getSelectFields() {
|
|
301
|
-
if (this.select && this.select.length > 0) {
|
|
302
|
-
return `items {
|
|
303
|
-
${this.select.map(selectField => {
|
|
304
|
-
return selectField.type === 'object'
|
|
305
|
-
? `${selectField.name} { ${
|
|
306
|
-
selectField.subFields && selectField.subFields.length > 0
|
|
307
|
-
? selectField.subFields.join(' ')
|
|
308
|
-
: `id name description`
|
|
309
|
-
} }`
|
|
310
|
-
: `${selectField.name}`
|
|
311
|
-
})}
|
|
312
|
-
}
|
|
313
|
-
total`
|
|
314
|
-
} else {
|
|
315
|
-
return `
|
|
316
|
-
items {
|
|
317
|
-
id
|
|
318
|
-
name
|
|
319
|
-
description
|
|
320
|
-
}
|
|
321
|
-
total
|
|
322
|
-
`
|
|
323
|
-
}
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
async _buildConditions({ filters, page, limit, sorters }: FetchOption) {
|
|
327
|
-
const queryConditions = {
|
|
328
|
-
filters: [],
|
|
329
|
-
...this.basicArgs
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
queryConditions.filters = [...queryConditions.filters, ...(await this.searchForm.getQueryFilters())]
|
|
333
|
-
queryConditions.pagination = { page, limit }
|
|
334
|
-
queryConditions.sortings = sorters
|
|
335
|
-
|
|
336
|
-
return queryConditions
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
get selected() {
|
|
340
|
-
var grist = this.renderRoot.querySelector('ox-grist') as DataGrist
|
|
341
|
-
|
|
342
|
-
var selected = grist.selected
|
|
343
|
-
|
|
344
|
-
return selected && selected.length > 0 ? selected[0] : undefined
|
|
345
|
-
}
|
|
346
|
-
}
|
package/src/parameters/index.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { registerEditor, registerRenderer } from '@operato/data-grist'
|
|
2
|
-
|
|
3
|
-
import { ParametersEditor } from './parameters-editor.js'
|
|
4
|
-
|
|
5
|
-
/* register grist renderer/editor for id */
|
|
6
|
-
registerEditor('parameters', ParametersEditor)
|
|
7
|
-
|
|
8
|
-
// registerRenderer('id', IdRenderer)
|