@operato/grist-editor 1.0.0-alpha.22 → 1.0.0-beta.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.
Files changed (87) hide show
  1. package/.storybook/main.js +2 -2
  2. package/.storybook/server.mjs +4 -4
  3. package/LICENSE +2 -2
  4. package/README.md +29 -9
  5. package/dist/src/index.js +15 -1
  6. package/package.json +36 -26
  7. package/src/index.ts +18 -0
  8. package/src/ox-grist-editor-crontab.ts +62 -0
  9. package/src/ox-grist-editor-duration.ts +62 -0
  10. package/src/{parameters/parameters-editor.ts → ox-grist-editor-parameters.ts} +14 -27
  11. package/src/ox-grist-editor-partition-keys.ts +86 -0
  12. package/src/ox-grist-editor-value-map.ts +86 -0
  13. package/src/ox-grist-renderer-crontab.ts +31 -0
  14. package/src/{parameters/parameters-editor-builder.ts → ox-parameters-builder.ts} +6 -8
  15. package/src/ox-popup-crontab-input.ts +75 -0
  16. package/src/ox-popup-duration-input.ts +75 -0
  17. package/src/{parameters/parameters-editor-popup.ts → ox-popup-parameters-builder.ts} +10 -9
  18. package/src/ox-popup-partition-keys-input.ts +97 -0
  19. package/src/ox-popup-value-map-input.ts +102 -0
  20. package/stories/ox-grist-editor-crontab.stories.ts +429 -0
  21. package/themes/app-theme.css +142 -0
  22. package/themes/form-theme.css +75 -0
  23. package/themes/grist-theme.css +194 -0
  24. package/themes/oops-theme.css +26 -0
  25. package/themes/report-theme.css +47 -0
  26. package/translations/en.json +3 -0
  27. package/translations/ko.json +3 -0
  28. package/translations/ms.json +3 -0
  29. package/translations/zh.json +3 -0
  30. package/web-dev-server.config.mjs +9 -8
  31. package/web-test-runner.config.mjs +7 -19
  32. package/.editorconfig +0 -29
  33. package/CHANGELOG.md +0 -116
  34. package/demo/data-grist-test.html +0 -456
  35. package/demo/index.html +0 -33
  36. package/dist/src/code/code-editor.d.ts +0 -6
  37. package/dist/src/code/code-editor.js +0 -50
  38. package/dist/src/code/code-editor.js.map +0 -1
  39. package/dist/src/code/index.d.ts +0 -1
  40. package/dist/src/code/index.js +0 -5
  41. package/dist/src/code/index.js.map +0 -1
  42. package/dist/src/id/id-input.d.ts +0 -19
  43. package/dist/src/id/id-input.js +0 -119
  44. package/dist/src/id/id-input.js.map +0 -1
  45. package/dist/src/id/id-renderer.d.ts +0 -2
  46. package/dist/src/id/id-renderer.js +0 -9
  47. package/dist/src/id/id-renderer.js.map +0 -1
  48. package/dist/src/id/id-selector.d.ts +0 -23
  49. package/dist/src/id/id-selector.js +0 -197
  50. package/dist/src/id/id-selector.js.map +0 -1
  51. package/dist/src/id/index.d.ts +0 -1
  52. package/dist/src/id/index.js +0 -7
  53. package/dist/src/id/index.js.map +0 -1
  54. package/dist/src/index.d.ts +0 -0
  55. package/dist/src/index.js.map +0 -1
  56. package/dist/src/object/index.d.ts +0 -1
  57. package/dist/src/object/index.js +0 -6
  58. package/dist/src/object/index.js.map +0 -1
  59. package/dist/src/object/object-editor.d.ts +0 -18
  60. package/dist/src/object/object-editor.js +0 -152
  61. package/dist/src/object/object-editor.js.map +0 -1
  62. package/dist/src/object/object-selector.d.ts +0 -38
  63. package/dist/src/object/object-selector.js +0 -338
  64. package/dist/src/object/object-selector.js.map +0 -1
  65. package/dist/src/parameters/index.d.ts +0 -1
  66. package/dist/src/parameters/index.js +0 -6
  67. package/dist/src/parameters/index.js.map +0 -1
  68. package/dist/src/parameters/parameters-editor-builder.d.ts +0 -4
  69. package/dist/src/parameters/parameters-editor-builder.js +0 -118
  70. package/dist/src/parameters/parameters-editor-builder.js.map +0 -1
  71. package/dist/src/parameters/parameters-editor-popup.d.ts +0 -13
  72. package/dist/src/parameters/parameters-editor-popup.js +0 -111
  73. package/dist/src/parameters/parameters-editor-popup.js.map +0 -1
  74. package/dist/src/parameters/parameters-editor.d.ts +0 -18
  75. package/dist/src/parameters/parameters-editor.js +0 -106
  76. package/dist/src/parameters/parameters-editor.js.map +0 -1
  77. package/dist/tsconfig.tsbuildinfo +0 -1
  78. package/src/code/code-editor.ts +0 -78
  79. package/src/code/index.ts +0 -6
  80. package/src/id/id-input.ts +0 -135
  81. package/src/id/id-renderer.ts +0 -12
  82. package/src/id/id-selector.ts +0 -189
  83. package/src/id/index.ts +0 -8
  84. package/src/object/index.ts +0 -8
  85. package/src/object/object-editor.ts +0 -162
  86. package/src/object/object-selector.ts +0 -346
  87. package/src/parameters/index.ts +0 -8
@@ -1,189 +0,0 @@
1
- import '@operato/data-grist'
2
-
3
- import { DataGrist, FetchOption, GristData, GristRecord, ZERO_DATA } from '@operato/data-grist'
4
- import { LitElement, css, html } from 'lit'
5
- import { customElement, property, query } from 'lit/decorators.js'
6
-
7
- import { client } from '@operato/graphql'
8
- import gql from 'graphql-tag'
9
- import { i18next } from '@operato/i18n'
10
- import { isMobileDevice } from '@operato/utils'
11
-
12
- @customElement('ox-id-selector')
13
- export class IdSelector extends LitElement {
14
- static styles = css`
15
- :host {
16
- display: flex;
17
- flex-direction: column;
18
-
19
- background-color: #fff;
20
-
21
- width: var(--overlay-center-normal-width, 50%);
22
- height: var(--overlay-center-normal-height, 50%);
23
- }
24
-
25
- ox-grist {
26
- flex: 1;
27
- }
28
-
29
- #filters {
30
- display: flex;
31
- flex-direction: row;
32
- justify-content: space-between;
33
- }
34
-
35
- #filters > * {
36
- padding: var(--padding-default) var(--padding-wide);
37
- }
38
-
39
- .button-container {
40
- display: flex;
41
- margin-left: auto;
42
- }
43
- `
44
-
45
- @property({ type: String }) value?: string
46
- @property({ type: Object }) config: any
47
- @property({ type: Object }) data: GristData = ZERO_DATA
48
- @property({ type: String }) queryName!: string
49
- @property({ type: Object }) basicArgs: any
50
- @property({ type: Object }) confirmCallback?: (record: GristRecord | undefined) => void
51
- @property({ type: Array }) selectedRecords: GristRecord[] = []
52
-
53
- @query('ox-grist') grist!: DataGrist
54
-
55
- render() {
56
- return html`
57
- <ox-grist
58
- .mode=${isMobileDevice() ? 'LIST' : 'GRID'}
59
- .config=${this.config}
60
- .fetchHandler=${this.fetchHandler.bind(this)}
61
- .selectedRecords=${this.selectedRecords}
62
- >
63
- <div id="filters" slot="headroom">
64
- <ox-filters-form></ox-filters-form>
65
- </div>
66
- </ox-grist>
67
-
68
- <div class="button-container">
69
- <mwc-button @click=${this.oncancel.bind(this)}>${i18next.t('button.cancel')}</mwc-button>
70
- <mwc-button @click=${this.onconfirm.bind(this)}>${i18next.t('button.confirm')}</mwc-button>
71
- </div>
72
- `
73
- }
74
-
75
- oncancel() {
76
- history.back()
77
- }
78
-
79
- onconfirm() {
80
- this.confirmCallback && this.confirmCallback(this.selected)
81
- history.back()
82
- }
83
-
84
- async firstUpdated() {
85
- this.config = {
86
- columns: [
87
- {
88
- type: 'gutter',
89
- gutterName: 'sequence'
90
- },
91
- {
92
- type: 'gutter',
93
- gutterName: 'row-selector',
94
- multiple: false
95
- },
96
- {
97
- type: 'string',
98
- name: 'id',
99
- header: i18next.t('field.id'),
100
- hidden: true
101
- },
102
- {
103
- type: 'string',
104
- name: 'name',
105
- header: i18next.t('field.name'),
106
- record: {
107
- align: 'left'
108
- },
109
- filter: 'search',
110
- sortable: true,
111
- width: 160
112
- },
113
- {
114
- type: 'string',
115
- name: 'description',
116
- header: i18next.t('field.description'),
117
- record: {
118
- align: 'left'
119
- },
120
- filter: 'search',
121
- sortable: true,
122
- width: 300
123
- }
124
- ],
125
- rows: {
126
- selectable: {
127
- multiple: false
128
- },
129
- handlers: {
130
- click: 'select-row'
131
- }
132
- },
133
- pagination: {
134
- infinite: true
135
- }
136
- }
137
-
138
- await this.updateComplete
139
-
140
- /* TODO config가 설정될 때, fetch() 가 동작하므로, fetch 완료 이벤트를 받아서, selected를 설정해주는 것이 좋겠다.
141
- 현재는 fetch() 가 두번 일어난다.
142
- */
143
- await this.grist.fetch()
144
-
145
- var selected = this.grist.data.records.find(item => this.value == item.id)
146
- if (selected) {
147
- this.selectedRecords = [selected]
148
- }
149
- /* TODO config가 설정될 때, fetch() 가 동작하므로, fetch 완료 이벤트를 받아서, selected를 설정해주는 것이 좋겠다. */
150
-
151
- await this.updateComplete
152
- this.grist.focus()
153
- }
154
-
155
- async fetchHandler({ page = 1, limit = 100, sorters = [], filters = [] }: FetchOption) {
156
- const response = await client.query({
157
- query: gql`
158
- query ($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!]) {
159
- q: ${this.queryName}(filters: $filters, pagination: $pagination, sortings: $sortings) {
160
- items {
161
- id
162
- name
163
- description
164
- }
165
- total
166
- }
167
- }
168
- `,
169
- variables: {
170
- filters,
171
- pagination: { page, limit },
172
- sortings: sorters
173
- }
174
- })
175
-
176
- return {
177
- total: response.data.q.total || 0,
178
- records: response.data.q.items || []
179
- }
180
- }
181
-
182
- get selected() {
183
- var grist = this.renderRoot.querySelector('ox-grist') as DataGrist
184
-
185
- var selected = grist.selected
186
-
187
- return selected && selected.length > 0 ? selected[0] : undefined
188
- }
189
- }
package/src/id/index.ts DELETED
@@ -1,8 +0,0 @@
1
- import { registerEditor, registerRenderer } from '@operato/data-grist'
2
-
3
- import { IdInput } from './id-input.js'
4
- import { IdRenderer } from './id-renderer.js'
5
-
6
- /* register grist renderer/editor for id */
7
- registerEditor('id', IdInput)
8
- registerRenderer('id', IdRenderer)
@@ -1,8 +0,0 @@
1
- import { registerEditor, registerRenderer } from '@operato/data-grist'
2
-
3
- import { ObjectEditor } from './object-editor'
4
-
5
- /* register grist renderer/editor for id */
6
- registerEditor('object', ObjectEditor)
7
-
8
- // registerRenderer('id', IdRenderer)
@@ -1,162 +0,0 @@
1
- import '@material/mwc-icon'
2
- import '../../elements/object-selector'
3
-
4
- import {
5
- ColumnConfig,
6
- GristData,
7
- GristRecord,
8
- InputEditor,
9
- ZERO_COLUMN,
10
- ZERO_CONFIG,
11
- ZERO_RECORD
12
- } from '@operato/data-grist'
13
- import { LitElement, TemplateResult, css, html } from 'lit'
14
- import { PopupHandle, openPopup } from '@operato/layout'
15
- import { customElement, property } from 'lit/decorators.js'
16
-
17
- import { i18next } from '@operato/i18n'
18
-
19
- @customElement('ox-object-editor')
20
- export class ObjectEditor extends InputEditor {
21
- static styles = css`
22
- :host {
23
- display: flex;
24
- flex-flow: row nowrap;
25
-
26
- padding: 7px 0px;
27
- box-sizing: border-box;
28
-
29
- width: 100%;
30
- height: 100%;
31
-
32
- border: 0;
33
- background-color: transparent;
34
-
35
- font: var(--grist-object-editor-font);
36
- color: var(--grist-object-editor-color);
37
- justify-content: inherit;
38
- }
39
-
40
- span {
41
- display: flex;
42
- flex: auto;
43
-
44
- justify-content: inherit;
45
- }
46
-
47
- mwc-icon {
48
- width: 20px;
49
- font-size: 1.5em;
50
- margin-left: auto;
51
- }
52
- `
53
-
54
- @property({ type: Object }) value: { [prop: string]: any } = {}
55
- @property({ type: Object }) column: ColumnConfig = ZERO_COLUMN
56
- @property({ type: Object }) record: GristRecord = ZERO_RECORD
57
- @property({ type: Number }) row?: number
58
-
59
- private popup?: PopupHandle
60
- private template?: TemplateResult
61
-
62
- render() {
63
- var value = this.value || {}
64
-
65
- var { nameField = 'name', descriptionField = 'description' } = this.column.record.options || {}
66
- var name, description
67
- if (typeof nameField === 'function') {
68
- name = nameField(value)
69
- } else {
70
- name = value[nameField]
71
- }
72
-
73
- if (typeof descriptionField === 'function') {
74
- description = descriptionField(value)
75
- } else {
76
- description = value[descriptionField] && `(${value[descriptionField]})`
77
- }
78
-
79
- return html`
80
- ${!value ? html`` : html` <span>${name || ''}${description || ''}</span> `}
81
- <mwc-icon>arrow_drop_down</mwc-icon>
82
- `
83
- }
84
-
85
- async firstUpdated() {
86
- this.value = this.record[this.column.name]
87
- this.template = ((this.column.record || {}).options || {}).template
88
-
89
- await this.updateComplete
90
-
91
- this.renderRoot.addEventListener('click', e => {
92
- e.stopPropagation()
93
-
94
- this.openSelector()
95
- })
96
- }
97
-
98
- openSelector() {
99
- if (this.popup) {
100
- delete this.popup
101
- }
102
-
103
- const confirmCallback = (selected: { [field: string]: any }) => {
104
- var { idField = 'id', nameField = 'name', descriptionField = 'description' } = this.column.record.options || {}
105
-
106
- this.dispatchEvent(
107
- new CustomEvent('field-change', {
108
- bubbles: true,
109
- composed: true,
110
- detail: {
111
- before: this.value,
112
- after: {
113
- ...(this.column.record.options.select || [])
114
- .map((field: any) => field.name)
115
- .reduce((obj: { [field: string]: any }, fieldName: string) => {
116
- return (obj = {
117
- ...obj,
118
- [fieldName]: selected[fieldName]
119
- })
120
- }, {} as { [field: string]: any }),
121
- [idField]: selected[idField],
122
- [nameField]: selected[nameField],
123
- [descriptionField]: selected[descriptionField]
124
- },
125
- record: this.record,
126
- column: this.column,
127
- row: this.row
128
- }
129
- })
130
- )
131
- }
132
-
133
- var value = this.value || {}
134
- var valueField: string | ((item: any) => any) = this.column.record.options.valueField || 'id'
135
- var actualValue
136
- if (typeof valueField === 'function') {
137
- actualValue = valueField(value)
138
- } else {
139
- actualValue = value[valueField]
140
- }
141
-
142
- var template =
143
- this.template ||
144
- html`
145
- <object-selector
146
- .value=${actualValue}
147
- .confirmCallback=${confirmCallback.bind(this)}
148
- .queryName=${this.column.record.options.queryName}
149
- .select=${this.column.record.options.select}
150
- .list=${this.column.record.options.list}
151
- .basicArgs=${this.column.record.options.basicArgs}
152
- .valueField=${this.column.record.options.valueField}
153
- ></object-selector>
154
- `
155
-
156
- this.popup = openPopup(template, {
157
- backdrop: true,
158
- size: 'large',
159
- title: i18next.t('title.select_item')
160
- })
161
- }
162
- }
@@ -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
- }