@operato/app 1.0.0 → 1.0.6
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 +51 -0
- package/dist/src/grist-editor/ox-grist-editor-resource-object-legacy.d.ts +10 -0
- package/dist/src/grist-editor/ox-grist-editor-resource-object-legacy.js +99 -0
- package/dist/src/grist-editor/ox-grist-editor-resource-object-legacy.js.map +1 -0
- package/dist/src/grist-editor/ox-grist-editor-resource-object.js +5 -3
- package/dist/src/grist-editor/ox-grist-editor-resource-object.js.map +1 -1
- package/dist/src/grist-editor/ox-selector-resource-id.js +1 -1
- package/dist/src/grist-editor/ox-selector-resource-id.js.map +1 -1
- package/dist/src/grist-editor/ox-selector-resource-object-legacy.d.ts +39 -0
- package/dist/src/grist-editor/ox-selector-resource-object-legacy.js +351 -0
- package/dist/src/grist-editor/ox-selector-resource-object-legacy.js.map +1 -0
- package/dist/src/grist-editor/ox-selector-resource-object.d.ts +3 -8
- package/dist/src/grist-editor/ox-selector-resource-object.js +72 -150
- package/dist/src/grist-editor/ox-selector-resource-object.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +77 -15
- package/src/grist-editor/ox-grist-editor-resource-object-legacy.ts +123 -0
- package/src/grist-editor/ox-grist-editor-resource-object.ts +6 -2
- package/src/grist-editor/ox-selector-resource-id.ts +1 -1
- package/src/grist-editor/ox-selector-resource-object-legacy.ts +360 -0
- package/src/grist-editor/ox-selector-resource-object.ts +72 -164
|
@@ -1,54 +1,46 @@
|
|
|
1
1
|
import '@operato/data-grist'
|
|
2
|
-
import '@operato/form/ox-search-form.js'
|
|
3
2
|
|
|
4
3
|
import gql from 'graphql-tag'
|
|
5
4
|
import { css, html, LitElement } from 'lit'
|
|
6
5
|
import { customElement, property, query } from 'lit/decorators.js'
|
|
7
6
|
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
DataGrist,
|
|
11
|
-
FetchHandler,
|
|
12
|
-
FetchOption,
|
|
13
|
-
GristData,
|
|
14
|
-
GristEventHandler,
|
|
15
|
-
GristRecord,
|
|
16
|
-
ZERO_DATA
|
|
17
|
-
} from '@operato/data-grist'
|
|
18
|
-
import { MultiColumnFormStyles, SearchForm } from '@operato/form'
|
|
19
|
-
import { buildArgs, client, gqlContext } from '@operato/graphql'
|
|
7
|
+
import { DataGrist, FetchHandler, GristData, GristEventHandler, GristRecord, ZERO_DATA } from '@operato/data-grist'
|
|
8
|
+
import { client, gqlContext } from '@operato/graphql'
|
|
20
9
|
import { i18next } from '@operato/i18n'
|
|
21
10
|
import { closePopup } from '@operato/popup'
|
|
22
|
-
import { isMobileDevice } from '@operato/utils'
|
|
11
|
+
import { adjustFilters, isMobileDevice } from '@operato/utils'
|
|
23
12
|
|
|
24
13
|
@customElement('ox-selector-resource-object')
|
|
25
14
|
export class OxSelectorResourceObject extends LitElement {
|
|
26
15
|
static styles = [
|
|
27
|
-
MultiColumnFormStyles,
|
|
28
16
|
css`
|
|
29
17
|
:host {
|
|
30
18
|
display: flex;
|
|
31
19
|
flex-direction: column;
|
|
32
20
|
|
|
33
21
|
background-color: #fff;
|
|
22
|
+
|
|
23
|
+
width: var(--overlay-center-normal-width, 50%);
|
|
24
|
+
height: var(--overlay-center-normal-height, 50%);
|
|
34
25
|
}
|
|
35
26
|
|
|
36
27
|
ox-grist {
|
|
37
28
|
flex: 1;
|
|
38
29
|
}
|
|
39
30
|
|
|
40
|
-
|
|
31
|
+
#filters {
|
|
41
32
|
display: flex;
|
|
42
|
-
|
|
33
|
+
flex-direction: row;
|
|
34
|
+
justify-content: space-between;
|
|
43
35
|
}
|
|
44
36
|
|
|
45
|
-
|
|
46
|
-
|
|
37
|
+
#filters > * {
|
|
38
|
+
padding: var(--padding-default) var(--padding-wide);
|
|
47
39
|
}
|
|
48
40
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
41
|
+
.button-container {
|
|
42
|
+
display: flex;
|
|
43
|
+
margin-left: auto;
|
|
52
44
|
}
|
|
53
45
|
`
|
|
54
46
|
]
|
|
@@ -62,13 +54,12 @@ export class OxSelectorResourceObject extends LitElement {
|
|
|
62
54
|
@property({ type: Array }) selectedRecords: GristRecord[] = []
|
|
63
55
|
|
|
64
56
|
@property({ type: Array }) searchFields: any
|
|
65
|
-
@property({ type: Array })
|
|
57
|
+
@property({ type: Array }) columns: {
|
|
66
58
|
type: string
|
|
67
59
|
name: string
|
|
68
60
|
header: string
|
|
69
61
|
subFields?: string[]
|
|
70
62
|
hidden: boolean
|
|
71
|
-
ignoreCondition: boolean
|
|
72
63
|
queryName: string
|
|
73
64
|
width: number
|
|
74
65
|
}[] = []
|
|
@@ -76,29 +67,20 @@ export class OxSelectorResourceObject extends LitElement {
|
|
|
76
67
|
@property({ type: String }) valueField: string | ((item: any) => any) = 'id'
|
|
77
68
|
|
|
78
69
|
@query('ox-grist') grist!: DataGrist
|
|
79
|
-
@query('ox-search-form') searchForm!: SearchForm
|
|
80
70
|
|
|
81
71
|
render() {
|
|
82
72
|
return html`
|
|
83
|
-
<ox-search-form
|
|
84
|
-
id="search-form"
|
|
85
|
-
@keypress=${(e: KeyboardEvent) => {
|
|
86
|
-
if (e.key === 'Enter') {
|
|
87
|
-
this.grist.fetch()
|
|
88
|
-
}
|
|
89
|
-
}}
|
|
90
|
-
@submit=${(e: SubmitEvent) => this.grist.fetch()}
|
|
91
|
-
.fields=${this.searchFields}
|
|
92
|
-
autofocus
|
|
93
|
-
></ox-search-form>
|
|
94
|
-
|
|
95
73
|
<ox-grist
|
|
96
74
|
.mode=${isMobileDevice() ? 'LIST' : 'GRID'}
|
|
97
75
|
.config=${this.config}
|
|
98
76
|
.data=${this.data}
|
|
99
77
|
.fetchHandler=${this.fetchHandler.bind(this)}
|
|
100
78
|
.selectedRecords=${this.selectedRecords}
|
|
101
|
-
|
|
79
|
+
>
|
|
80
|
+
<div id="filters" slot="headroom">
|
|
81
|
+
<ox-filters-form autofocus></ox-filters-form>
|
|
82
|
+
</div>
|
|
83
|
+
</ox-grist>
|
|
102
84
|
|
|
103
85
|
<div class="button-container">
|
|
104
86
|
<mwc-button @click=${this.onempty.bind(this)}>${i18next.t('button.empty')}</mwc-button>
|
|
@@ -122,15 +104,21 @@ export class OxSelectorResourceObject extends LitElement {
|
|
|
122
104
|
closePopup(this)
|
|
123
105
|
}
|
|
124
106
|
|
|
125
|
-
fetchHandler: FetchHandler = async ({ filters, page, limit,
|
|
107
|
+
fetchHandler: FetchHandler = async ({ filters = [], page, limit, sortings = [] }) => {
|
|
108
|
+
if (this.basicArgs) {
|
|
109
|
+
filters = adjustFilters(filters, this.basicArgs)
|
|
110
|
+
}
|
|
111
|
+
const pagination = { page, limit }
|
|
112
|
+
|
|
126
113
|
const response = await client.query({
|
|
127
114
|
query: gql`
|
|
128
|
-
query {
|
|
129
|
-
fetch: ${this.queryName} ($
|
|
130
|
-
${this.
|
|
115
|
+
query($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!]) {
|
|
116
|
+
fetch: ${this.queryName} (filters: $filters, pagination: $pagination, sortings: $sortings) {
|
|
117
|
+
${this.getQueryFields()}
|
|
131
118
|
}
|
|
132
119
|
}
|
|
133
120
|
`,
|
|
121
|
+
variables: { filters, pagination, sortings },
|
|
134
122
|
context: gqlContext()
|
|
135
123
|
})
|
|
136
124
|
|
|
@@ -191,124 +179,57 @@ export class OxSelectorResourceObject extends LitElement {
|
|
|
191
179
|
}
|
|
192
180
|
}
|
|
193
181
|
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
name: selectField.name,
|
|
208
|
-
type:
|
|
209
|
-
fieldType === 'string'
|
|
210
|
-
? 'text'
|
|
211
|
-
: numberTypes.indexOf(fieldType) >= 0
|
|
212
|
-
? 'number'
|
|
213
|
-
: fieldType === 'boolean'
|
|
214
|
-
? 'checkbox'
|
|
215
|
-
: fieldType,
|
|
216
|
-
queryName: selectField.queryName,
|
|
217
|
-
props:
|
|
218
|
-
fieldType === 'string'
|
|
219
|
-
? { searchOper: 'i_like' }
|
|
220
|
-
: fieldType === 'object'
|
|
221
|
-
? { searchOper: 'in' }
|
|
222
|
-
: { searchOper: 'eq' },
|
|
223
|
-
attrs: fieldType === 'boolean' ? ['indeterminated'] : []
|
|
224
|
-
}
|
|
225
|
-
})
|
|
226
|
-
this.config = {
|
|
227
|
-
...this.config,
|
|
228
|
-
columns: [
|
|
229
|
-
...this.config.columns,
|
|
230
|
-
...this.select.map(selectField => {
|
|
231
|
-
return {
|
|
232
|
-
...selectField,
|
|
233
|
-
type: selectField.type || 'string',
|
|
234
|
-
width: selectField.width || 160,
|
|
235
|
-
header: selectField.header || i18next.t(`field.${selectField.name}`)
|
|
236
|
-
}
|
|
237
|
-
})
|
|
238
|
-
]
|
|
239
|
-
}
|
|
240
|
-
} else {
|
|
241
|
-
this.searchFields = [
|
|
242
|
-
{
|
|
243
|
-
label: i18next.t('field.name'),
|
|
244
|
-
name: 'name',
|
|
245
|
-
type: 'text',
|
|
246
|
-
props: { searchOper: 'i_like' }
|
|
182
|
+
const columns = this.columns || [
|
|
183
|
+
{
|
|
184
|
+
type: 'string',
|
|
185
|
+
name: 'id',
|
|
186
|
+
header: i18next.t('field.id'),
|
|
187
|
+
hidden: true
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
type: 'string',
|
|
191
|
+
name: 'name',
|
|
192
|
+
header: i18next.t('field.name'),
|
|
193
|
+
record: {
|
|
194
|
+
align: 'left'
|
|
247
195
|
},
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
name: 'id',
|
|
263
|
-
header: i18next.t('field.id'),
|
|
264
|
-
hidden: true
|
|
265
|
-
},
|
|
266
|
-
{
|
|
267
|
-
type: 'string',
|
|
268
|
-
name: 'name',
|
|
269
|
-
header: i18next.t('field.name'),
|
|
270
|
-
record: {
|
|
271
|
-
align: 'left'
|
|
272
|
-
},
|
|
273
|
-
sortable: true,
|
|
274
|
-
width: 160
|
|
275
|
-
},
|
|
276
|
-
{
|
|
277
|
-
type: 'string',
|
|
278
|
-
name: 'description',
|
|
279
|
-
header: i18next.t('field.description'),
|
|
280
|
-
record: {
|
|
281
|
-
align: 'left'
|
|
282
|
-
},
|
|
283
|
-
sortable: true,
|
|
284
|
-
width: 300
|
|
285
|
-
}
|
|
286
|
-
]
|
|
196
|
+
sortable: true,
|
|
197
|
+
filter: 'search',
|
|
198
|
+
width: 160
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
type: 'string',
|
|
202
|
+
name: 'description',
|
|
203
|
+
header: i18next.t('field.description'),
|
|
204
|
+
record: {
|
|
205
|
+
align: 'left'
|
|
206
|
+
},
|
|
207
|
+
sortable: true,
|
|
208
|
+
filter: 'search',
|
|
209
|
+
width: 300
|
|
287
210
|
}
|
|
288
|
-
|
|
211
|
+
]
|
|
289
212
|
|
|
290
213
|
this.config = {
|
|
291
214
|
...this.config,
|
|
292
|
-
|
|
293
|
-
...this.
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
:
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
215
|
+
columns: [
|
|
216
|
+
...this.config.columns,
|
|
217
|
+
...columns.map(selectField => {
|
|
218
|
+
return {
|
|
219
|
+
...selectField,
|
|
220
|
+
type: selectField.type || 'string',
|
|
221
|
+
width: selectField.width || 160,
|
|
222
|
+
header: selectField.header || i18next.t(`field.${selectField.name}`)
|
|
223
|
+
}
|
|
224
|
+
})
|
|
225
|
+
]
|
|
302
226
|
}
|
|
303
|
-
|
|
304
|
-
await this.updateComplete
|
|
305
|
-
this.grist && this.grist.focus()
|
|
306
227
|
}
|
|
307
228
|
|
|
308
|
-
|
|
309
|
-
if (this.
|
|
229
|
+
getQueryFields() {
|
|
230
|
+
if (this.columns && this.columns.length > 0) {
|
|
310
231
|
return `items {
|
|
311
|
-
${this.
|
|
232
|
+
${this.columns.map(selectField => {
|
|
312
233
|
return selectField.type === 'object'
|
|
313
234
|
? `${selectField.name} { ${
|
|
314
235
|
selectField.subFields && selectField.subFields.length > 0
|
|
@@ -331,19 +252,6 @@ export class OxSelectorResourceObject extends LitElement {
|
|
|
331
252
|
}
|
|
332
253
|
}
|
|
333
254
|
|
|
334
|
-
async _buildConditions({ filters, page, limit, sorters }: FetchOption) {
|
|
335
|
-
const queryConditions = {
|
|
336
|
-
filters: [],
|
|
337
|
-
...this.basicArgs
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
queryConditions.filters = [...queryConditions.filters, ...(await this.searchForm.getQueryFilters())]
|
|
341
|
-
queryConditions.pagination = { page, limit }
|
|
342
|
-
queryConditions.sortings = sorters
|
|
343
|
-
|
|
344
|
-
return queryConditions
|
|
345
|
-
}
|
|
346
|
-
|
|
347
255
|
get selected() {
|
|
348
256
|
var grist = this.renderRoot.querySelector('ox-grist') as DataGrist
|
|
349
257
|
|