@operato/app 1.0.0 → 1.0.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 +9 -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-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-adv.d.ts +36 -0
- package/dist/src/grist-editor/ox-selector-resource-object-adv.js +270 -0
- package/dist/src/grist-editor/ox-selector-resource-object-adv.js.map +1 -0
- 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 +1 -5
- package/dist/src/grist-editor/ox-selector-resource-object.js +66 -144
- package/dist/src/grist-editor/ox-selector-resource-object.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +12 -11
- package/src/grist-editor/ox-grist-editor-resource-object-legacy.ts +123 -0
- 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 +67 -158
|
@@ -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
|
]
|
|
@@ -76,29 +68,20 @@ export class OxSelectorResourceObject extends LitElement {
|
|
|
76
68
|
@property({ type: String }) valueField: string | ((item: any) => any) = 'id'
|
|
77
69
|
|
|
78
70
|
@query('ox-grist') grist!: DataGrist
|
|
79
|
-
@query('ox-search-form') searchForm!: SearchForm
|
|
80
71
|
|
|
81
72
|
render() {
|
|
82
73
|
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
74
|
<ox-grist
|
|
96
75
|
.mode=${isMobileDevice() ? 'LIST' : 'GRID'}
|
|
97
76
|
.config=${this.config}
|
|
98
77
|
.data=${this.data}
|
|
99
78
|
.fetchHandler=${this.fetchHandler.bind(this)}
|
|
100
79
|
.selectedRecords=${this.selectedRecords}
|
|
101
|
-
|
|
80
|
+
>
|
|
81
|
+
<div id="filters" slot="headroom">
|
|
82
|
+
<ox-filters-form autofocus></ox-filters-form>
|
|
83
|
+
</div>
|
|
84
|
+
</ox-grist>
|
|
102
85
|
|
|
103
86
|
<div class="button-container">
|
|
104
87
|
<mwc-button @click=${this.onempty.bind(this)}>${i18next.t('button.empty')}</mwc-button>
|
|
@@ -122,15 +105,21 @@ export class OxSelectorResourceObject extends LitElement {
|
|
|
122
105
|
closePopup(this)
|
|
123
106
|
}
|
|
124
107
|
|
|
125
|
-
fetchHandler: FetchHandler = async ({ filters, page, limit,
|
|
108
|
+
fetchHandler: FetchHandler = async ({ filters = [], page, limit, sortings = [] }) => {
|
|
109
|
+
if (this.basicArgs) {
|
|
110
|
+
filters = adjustFilters(filters, this.basicArgs)
|
|
111
|
+
}
|
|
112
|
+
const pagination = { page, limit }
|
|
113
|
+
|
|
126
114
|
const response = await client.query({
|
|
127
115
|
query: gql`
|
|
128
|
-
query {
|
|
129
|
-
fetch: ${this.queryName} ($
|
|
116
|
+
query($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!]) {
|
|
117
|
+
fetch: ${this.queryName} (filters: $filters, pagination: $pagination, sortings: $sortings) {
|
|
130
118
|
${this.getSelectFields()}
|
|
131
119
|
}
|
|
132
120
|
}
|
|
133
121
|
`,
|
|
122
|
+
variables: { filters, pagination, sortings },
|
|
134
123
|
context: gqlContext()
|
|
135
124
|
})
|
|
136
125
|
|
|
@@ -191,118 +180,51 @@ export class OxSelectorResourceObject extends LitElement {
|
|
|
191
180
|
}
|
|
192
181
|
}
|
|
193
182
|
|
|
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' }
|
|
183
|
+
const select = this.select || [
|
|
184
|
+
{
|
|
185
|
+
type: 'string',
|
|
186
|
+
name: 'id',
|
|
187
|
+
header: i18next.t('field.id'),
|
|
188
|
+
hidden: true
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
type: 'string',
|
|
192
|
+
name: 'name',
|
|
193
|
+
header: i18next.t('field.name'),
|
|
194
|
+
record: {
|
|
195
|
+
align: 'left'
|
|
247
196
|
},
|
|
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
|
-
]
|
|
197
|
+
sortable: true,
|
|
198
|
+
filter: 'search',
|
|
199
|
+
width: 160
|
|
200
|
+
},
|
|
201
|
+
{
|
|
202
|
+
type: 'string',
|
|
203
|
+
name: 'description',
|
|
204
|
+
header: i18next.t('field.description'),
|
|
205
|
+
record: {
|
|
206
|
+
align: 'left'
|
|
207
|
+
},
|
|
208
|
+
sortable: true,
|
|
209
|
+
filter: 'search',
|
|
210
|
+
width: 300
|
|
287
211
|
}
|
|
288
|
-
|
|
212
|
+
]
|
|
289
213
|
|
|
290
214
|
this.config = {
|
|
291
215
|
...this.config,
|
|
292
|
-
|
|
293
|
-
...this.
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
:
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
216
|
+
columns: [
|
|
217
|
+
...this.config.columns,
|
|
218
|
+
...select.map(selectField => {
|
|
219
|
+
return {
|
|
220
|
+
...selectField,
|
|
221
|
+
type: selectField.type || 'string',
|
|
222
|
+
width: selectField.width || 160,
|
|
223
|
+
header: selectField.header || i18next.t(`field.${selectField.name}`)
|
|
224
|
+
}
|
|
225
|
+
})
|
|
226
|
+
]
|
|
302
227
|
}
|
|
303
|
-
|
|
304
|
-
await this.updateComplete
|
|
305
|
-
this.grist && this.grist.focus()
|
|
306
228
|
}
|
|
307
229
|
|
|
308
230
|
getSelectFields() {
|
|
@@ -331,19 +253,6 @@ export class OxSelectorResourceObject extends LitElement {
|
|
|
331
253
|
}
|
|
332
254
|
}
|
|
333
255
|
|
|
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
256
|
get selected() {
|
|
348
257
|
var grist = this.renderRoot.querySelector('ox-grist') as DataGrist
|
|
349
258
|
|