@things-factory/code-ui 7.0.0-alpha.8 → 7.0.0-alpha.9
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/client/bootstrap.js +6 -1
- package/client/pages/{code-management-detail.js → code-management-detail.ts} +58 -58
- package/client/pages/{code-management.js → code-management.ts} +27 -39
- package/dist-client/bootstrap.d.ts +1 -0
- package/dist-client/bootstrap.js +6 -0
- package/dist-client/bootstrap.js.map +1 -0
- package/dist-client/index.d.ts +2 -0
- package/dist-client/index.js +3 -0
- package/dist-client/index.js.map +1 -0
- package/dist-client/pages/code-management-detail.d.ts +25 -0
- package/dist-client/pages/code-management-detail.js +253 -0
- package/dist-client/pages/code-management-detail.js.map +1 -0
- package/dist-client/pages/code-management.d.ts +43 -0
- package/dist-client/pages/code-management.js +248 -0
- package/dist-client/pages/code-management.js.map +1 -0
- package/dist-client/route.d.ts +1 -0
- package/dist-client/route.js +8 -0
- package/dist-client/route.js.map +1 -0
- package/dist-client/tsconfig.tsbuildinfo +1 -0
- package/package.json +14 -10
- package/things-factory.config.js +2 -2
- package/translations/en.json +6 -2
- package/translations/ja.json +6 -2
- package/translations/ko.json +6 -2
- package/translations/ms.json +6 -2
- package/translations/zh.json +6 -2
- /package/client/{index.js → index.ts} +0 -0
- /package/client/{route.js → route.ts} +0 -0
package/client/bootstrap.js
CHANGED
|
@@ -1 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import { registerEditor as registerGristEditor } from '@operato/data-grist'
|
|
2
|
+
import { OxGristEditorI18nLabel } from '@operato/grist-editor/ox-grist-editor-i18n-label.js'
|
|
3
|
+
|
|
4
|
+
export default function bootstrap() {
|
|
5
|
+
registerGristEditor('i18n-label', OxGristEditorI18nLabel)
|
|
6
|
+
}
|
|
@@ -5,49 +5,47 @@ import '@operato/data-grist/ox-record-creator.js'
|
|
|
5
5
|
|
|
6
6
|
import gql from 'graphql-tag'
|
|
7
7
|
import { css, html, LitElement } from 'lit'
|
|
8
|
+
import { customElement, property, query, state } from 'lit/decorators.js'
|
|
8
9
|
|
|
9
10
|
import { i18next, localize } from '@operato/i18n'
|
|
10
11
|
import { client, gqlContext, buildArgs } from '@operato/graphql'
|
|
11
12
|
import { CommonGristStyles, ScrollbarStyles } from '@operato/styles'
|
|
12
13
|
import { isMobileDevice } from '@operato/utils'
|
|
13
|
-
|
|
14
14
|
import { OxPrompt } from '@operato/popup/ox-prompt.js'
|
|
15
|
+
import { DataGrist, FetchOption } from '@operato/data-grist'
|
|
16
|
+
|
|
17
|
+
import { getLanguages } from '@things-factory/auth-base/dist-client'
|
|
15
18
|
|
|
19
|
+
@customElement('code-management-detail')
|
|
16
20
|
export class CodeManagementDetail extends localize(i18next)(LitElement) {
|
|
17
|
-
static
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
:
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
.button-container {
|
|
29
|
-
padding: 10px 0 12px 0;
|
|
30
|
-
text-align: center;
|
|
31
|
-
}
|
|
32
|
-
[danger] {
|
|
33
|
-
--mdc-theme-primary: var(--mdc-danger-button-primary-color);
|
|
34
|
-
}
|
|
35
|
-
`
|
|
36
|
-
]
|
|
37
|
-
}
|
|
21
|
+
static styles = [
|
|
22
|
+
ScrollbarStyles,
|
|
23
|
+
CommonGristStyles,
|
|
24
|
+
css`
|
|
25
|
+
:host {
|
|
26
|
+
display: flex;
|
|
27
|
+
flex-direction: column;
|
|
28
|
+
overflow: hidden;
|
|
29
|
+
background-color: white;
|
|
30
|
+
}
|
|
38
31
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
mode: String
|
|
44
|
-
}
|
|
45
|
-
}
|
|
32
|
+
.button-container {
|
|
33
|
+
padding: 10px 0 12px 0;
|
|
34
|
+
text-align: center;
|
|
35
|
+
}
|
|
46
36
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
37
|
+
[danger] {
|
|
38
|
+
--mdc-theme-primary: var(--mdc-danger-button-primary-color);
|
|
39
|
+
}
|
|
40
|
+
`
|
|
41
|
+
]
|
|
42
|
+
|
|
43
|
+
@property({ type: String }) codeId?: string
|
|
44
|
+
@property({ type: Object }) config: any
|
|
45
|
+
|
|
46
|
+
@state() mode: 'LIST' | 'GRID' = isMobileDevice() ? 'LIST' : 'GRID'
|
|
47
|
+
|
|
48
|
+
@query('ox-grist') grist!: DataGrist
|
|
51
49
|
|
|
52
50
|
render() {
|
|
53
51
|
let mode = this.mode
|
|
@@ -62,16 +60,12 @@ export class CodeManagementDetail extends localize(i18next)(LitElement) {
|
|
|
62
60
|
</ox-grist>
|
|
63
61
|
|
|
64
62
|
<div class="button-container">
|
|
65
|
-
<mwc-button @click=${this.save} raised label
|
|
66
|
-
<mwc-button @click=${this.delete} raised danger label
|
|
63
|
+
<mwc-button @click=${this.save} raised label=${String(i18next.t('button.save'))}></mwc-button>
|
|
64
|
+
<mwc-button @click=${this.delete} raised danger label=${String(i18next.t('button.delete'))}></mwc-button>
|
|
67
65
|
</div>
|
|
68
66
|
`
|
|
69
67
|
}
|
|
70
68
|
|
|
71
|
-
get dataGrist() {
|
|
72
|
-
return this.shadowRoot.querySelector('ox-grist')
|
|
73
|
-
}
|
|
74
|
-
|
|
75
69
|
async firstUpdated() {
|
|
76
70
|
this.config = {
|
|
77
71
|
rows: { selectable: { multiple: true } },
|
|
@@ -92,16 +86,24 @@ export class CodeManagementDetail extends localize(i18next)(LitElement) {
|
|
|
92
86
|
type: 'string',
|
|
93
87
|
name: 'name',
|
|
94
88
|
record: { align: 'left', editable: true },
|
|
95
|
-
header: i18next.t('field.
|
|
89
|
+
header: i18next.t('field.code'),
|
|
96
90
|
sortable: true,
|
|
97
91
|
filter: 'search',
|
|
98
92
|
width: 320
|
|
99
93
|
},
|
|
100
94
|
{
|
|
101
|
-
type: '
|
|
102
|
-
name: '
|
|
103
|
-
record: {
|
|
104
|
-
|
|
95
|
+
type: 'i18n-label',
|
|
96
|
+
name: 'labels',
|
|
97
|
+
record: {
|
|
98
|
+
align: 'left',
|
|
99
|
+
editable: true,
|
|
100
|
+
renderer: (value, column, record, rowIndex, field) => html`<span>${record['description']}</span>`,
|
|
101
|
+
options: {
|
|
102
|
+
objectified: true,
|
|
103
|
+
languages: await getLanguages()
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
header: i18next.t('field.i18n-label'),
|
|
105
107
|
sortable: true,
|
|
106
108
|
filter: 'search',
|
|
107
109
|
width: 370
|
|
@@ -126,12 +128,12 @@ export class CodeManagementDetail extends localize(i18next)(LitElement) {
|
|
|
126
128
|
}
|
|
127
129
|
|
|
128
130
|
await this.updateComplete
|
|
129
|
-
this.
|
|
131
|
+
this.grist.fetch()
|
|
130
132
|
}
|
|
131
133
|
|
|
132
|
-
async fetchHandler({ filters, page, limit, sorters = [{ name: 'rank' }] }) {
|
|
134
|
+
async fetchHandler({ filters, page, limit, sorters = [{ name: 'rank' }] }: FetchOption) {
|
|
133
135
|
if (this.codeId) {
|
|
134
|
-
filters
|
|
136
|
+
filters!.push({
|
|
135
137
|
name: 'commonCodeId',
|
|
136
138
|
operator: 'eq',
|
|
137
139
|
value: this.codeId
|
|
@@ -151,6 +153,7 @@ export class CodeManagementDetail extends localize(i18next)(LitElement) {
|
|
|
151
153
|
name
|
|
152
154
|
description
|
|
153
155
|
rank
|
|
156
|
+
labels
|
|
154
157
|
updatedAt
|
|
155
158
|
updater{
|
|
156
159
|
name
|
|
@@ -180,22 +183,21 @@ export class CodeManagementDetail extends localize(i18next)(LitElement) {
|
|
|
180
183
|
|
|
181
184
|
const response = await client.query({
|
|
182
185
|
query: gql`
|
|
183
|
-
mutation {
|
|
184
|
-
updateMultipleCommonCodeDetail(${
|
|
185
|
-
patches
|
|
186
|
-
})}) {
|
|
186
|
+
mutation updateMultipleCommonCodeDetail($patches: [CommonCodeDetailPatch!]!) {
|
|
187
|
+
updateMultipleCommonCodeDetail(patches: $patches) {
|
|
187
188
|
name
|
|
188
189
|
}
|
|
189
190
|
}
|
|
190
191
|
`,
|
|
192
|
+
variables: { patches },
|
|
191
193
|
context: gqlContext()
|
|
192
194
|
})
|
|
193
195
|
|
|
194
|
-
if (!response.errors) this.
|
|
196
|
+
if (!response.errors) this.grist.fetch()
|
|
195
197
|
}
|
|
196
198
|
|
|
197
199
|
async delete() {
|
|
198
|
-
const ids = this.
|
|
200
|
+
const ids = this.grist.selected.map(record => record.id)
|
|
199
201
|
if (!ids?.length) {
|
|
200
202
|
return this.showToast(i18next.t('text.there_is_nothing_to_delete'))
|
|
201
203
|
}
|
|
@@ -226,16 +228,16 @@ export class CodeManagementDetail extends localize(i18next)(LitElement) {
|
|
|
226
228
|
confirmButton: { text: i18next.t('button.confirm') }
|
|
227
229
|
})
|
|
228
230
|
|
|
229
|
-
this.
|
|
231
|
+
this.grist.fetch()
|
|
230
232
|
}
|
|
231
233
|
}
|
|
232
234
|
}
|
|
233
235
|
|
|
234
236
|
getPatches() {
|
|
235
|
-
let patches = this.
|
|
237
|
+
let patches = this.grist.dirtyRecords
|
|
236
238
|
if (patches && patches.length) {
|
|
237
239
|
patches = patches.map(code => {
|
|
238
|
-
let patchField = code.id ? { id: code.id } : {}
|
|
240
|
+
let patchField: any = code.id ? { id: code.id } : {}
|
|
239
241
|
const dirtyFields = code.__dirtyfields__
|
|
240
242
|
for (let key in dirtyFields) {
|
|
241
243
|
patchField[key] = dirtyFields[key].after
|
|
@@ -254,5 +256,3 @@ export class CodeManagementDetail extends localize(i18next)(LitElement) {
|
|
|
254
256
|
document.dispatchEvent(new CustomEvent('notify', { detail: { message, option: { timer: 1000 } } }))
|
|
255
257
|
}
|
|
256
258
|
}
|
|
257
|
-
|
|
258
|
-
window.customElements.define('code-management-detail', CodeManagementDetail)
|
|
@@ -6,6 +6,7 @@ import '@operato/data-grist/ox-record-creator.js'
|
|
|
6
6
|
|
|
7
7
|
import gql from 'graphql-tag'
|
|
8
8
|
import { css, html } from 'lit'
|
|
9
|
+
import { customElement, property, query, state } from 'lit/decorators.js'
|
|
9
10
|
|
|
10
11
|
import { openPopup } from '@operato/layout'
|
|
11
12
|
import { i18next, localize } from '@operato/i18n'
|
|
@@ -13,37 +14,30 @@ import { client, gqlContext, buildArgs } from '@operato/graphql'
|
|
|
13
14
|
import { PageView } from '@operato/shell'
|
|
14
15
|
import { CommonButtonStyles, CommonGristStyles, ScrollbarStyles } from '@operato/styles'
|
|
15
16
|
import { isMobileDevice } from '@operato/utils'
|
|
17
|
+
import { DataGrist, FetchOption } from '@operato/data-grist'
|
|
16
18
|
|
|
17
19
|
import { OxPrompt } from '@operato/popup/ox-prompt.js'
|
|
18
20
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
21
|
+
@customElement('code-management')
|
|
22
|
+
export class CodeManagement extends localize(i18next)(PageView) {
|
|
23
|
+
static styles = [
|
|
24
|
+
ScrollbarStyles,
|
|
25
|
+
CommonGristStyles,
|
|
26
|
+
css`
|
|
27
|
+
:host {
|
|
28
|
+
display: flex;
|
|
29
|
+
flex-direction: column;
|
|
27
30
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
css`
|
|
33
|
-
:host {
|
|
34
|
-
display: flex;
|
|
35
|
-
flex-direction: column;
|
|
31
|
+
overflow: hidden;
|
|
32
|
+
}
|
|
33
|
+
`
|
|
34
|
+
]
|
|
36
35
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
]
|
|
41
|
-
}
|
|
36
|
+
@state() config?: any
|
|
37
|
+
@state() data?: any
|
|
38
|
+
@state() mode: 'LIST' | 'GRID' = isMobileDevice() ? 'LIST' : 'GRID'
|
|
42
39
|
|
|
43
|
-
|
|
44
|
-
super()
|
|
45
|
-
this.mode = isMobileDevice() ? 'LIST' : 'GRID'
|
|
46
|
-
}
|
|
40
|
+
@query('ox-grist') grist!: DataGrist
|
|
47
41
|
|
|
48
42
|
render() {
|
|
49
43
|
let mode = this.mode
|
|
@@ -78,13 +72,9 @@ class CodeManagement extends localize(i18next)(PageView) {
|
|
|
78
72
|
}
|
|
79
73
|
}
|
|
80
74
|
|
|
81
|
-
get dataGrist() {
|
|
82
|
-
return this.shadowRoot.querySelector('ox-grist')
|
|
83
|
-
}
|
|
84
|
-
|
|
85
75
|
pageUpdated(_changed, _lifecycle) {
|
|
86
76
|
if (this.active) {
|
|
87
|
-
this.
|
|
77
|
+
this.grist.fetch()
|
|
88
78
|
}
|
|
89
79
|
}
|
|
90
80
|
|
|
@@ -109,7 +99,7 @@ class CodeManagement extends localize(i18next)(PageView) {
|
|
|
109
99
|
{
|
|
110
100
|
type: 'string',
|
|
111
101
|
name: 'name',
|
|
112
|
-
header: i18next.t('field.
|
|
102
|
+
header: i18next.t('field.common-code'),
|
|
113
103
|
record: { editable: true, align: 'left' },
|
|
114
104
|
sortable: true,
|
|
115
105
|
filter: 'search',
|
|
@@ -144,7 +134,7 @@ class CodeManagement extends localize(i18next)(PageView) {
|
|
|
144
134
|
}
|
|
145
135
|
}
|
|
146
136
|
|
|
147
|
-
async fetchHandler({ filters, page, limit, sorters = [{ name: 'name' }, { name: 'updatedAt' }] }) {
|
|
137
|
+
async fetchHandler({ filters, page, limit, sorters = [{ name: 'name' }, { name: 'updatedAt' }] }: FetchOption) {
|
|
148
138
|
const response = await client.query({
|
|
149
139
|
query: gql`
|
|
150
140
|
query {
|
|
@@ -198,12 +188,12 @@ class CodeManagement extends localize(i18next)(PageView) {
|
|
|
198
188
|
|
|
199
189
|
if (!response.errors) {
|
|
200
190
|
this.showToast(i18next.t('text.data_updated_successfully'))
|
|
201
|
-
this.
|
|
191
|
+
this.grist.fetch()
|
|
202
192
|
}
|
|
203
193
|
}
|
|
204
194
|
|
|
205
195
|
async delete() {
|
|
206
|
-
const ids = this.
|
|
196
|
+
const ids = this.grist.selected.map(record => record.id)
|
|
207
197
|
if (!ids?.length) {
|
|
208
198
|
return this.showToast(i18next.t('text.there_is_nothing_to_delete'))
|
|
209
199
|
}
|
|
@@ -234,16 +224,16 @@ class CodeManagement extends localize(i18next)(PageView) {
|
|
|
234
224
|
confirmButton: { text: i18next.t('button.confirm') }
|
|
235
225
|
})
|
|
236
226
|
|
|
237
|
-
this.
|
|
227
|
+
this.grist.fetch()
|
|
238
228
|
}
|
|
239
229
|
}
|
|
240
230
|
}
|
|
241
231
|
|
|
242
232
|
getPatches() {
|
|
243
|
-
let patches = this.
|
|
233
|
+
let patches = this.grist.dirtyRecords
|
|
244
234
|
if (patches && patches.length) {
|
|
245
235
|
patches = patches.map(code => {
|
|
246
|
-
let patchField = code.id ? { id: code.id } : {}
|
|
236
|
+
let patchField: any = code.id ? { id: code.id } : {}
|
|
247
237
|
const dirtyFields = code.__dirtyfields__
|
|
248
238
|
for (let key in dirtyFields) {
|
|
249
239
|
patchField[key] = dirtyFields[key].after
|
|
@@ -269,5 +259,3 @@ class CodeManagement extends localize(i18next)(PageView) {
|
|
|
269
259
|
document.dispatchEvent(new CustomEvent('notify', { detail: { message, option: { timer: 1000 } } }))
|
|
270
260
|
}
|
|
271
261
|
}
|
|
272
|
-
|
|
273
|
-
customElements.define('code-management', CodeManagement)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function bootstrap(): void;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { registerEditor as registerGristEditor } from '@operato/data-grist';
|
|
2
|
+
import { OxGristEditorI18nLabel } from '@operato/grist-editor/ox-grist-editor-i18n-label.js';
|
|
3
|
+
export default function bootstrap() {
|
|
4
|
+
registerGristEditor('i18n-label', OxGristEditorI18nLabel);
|
|
5
|
+
}
|
|
6
|
+
//# sourceMappingURL=bootstrap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bootstrap.js","sourceRoot":"","sources":["../client/bootstrap.js"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,IAAI,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AAC3E,OAAO,EAAE,sBAAsB,EAAE,MAAM,qDAAqD,CAAA;AAE5F,MAAM,CAAC,OAAO,UAAU,SAAS;IAC/B,mBAAmB,CAAC,YAAY,EAAE,sBAAsB,CAAC,CAAA;AAC3D,CAAC","sourcesContent":["import { registerEditor as registerGristEditor } from '@operato/data-grist'\nimport { OxGristEditorI18nLabel } from '@operato/grist-editor/ox-grist-editor-i18n-label.js'\n\nexport default function bootstrap() {\n registerGristEditor('i18n-label', OxGristEditorI18nLabel)\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../client/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAA;AACvC,cAAc,gCAAgC,CAAA","sourcesContent":["export * from './pages/code-management'\nexport * from './pages/code-management-detail'\n"]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import '@operato/data-grist/ox-grist.js';
|
|
2
|
+
import '@operato/data-grist/ox-filters-form.js';
|
|
3
|
+
import '@operato/data-grist/ox-sorters-control.js';
|
|
4
|
+
import '@operato/data-grist/ox-record-creator.js';
|
|
5
|
+
import { LitElement } from 'lit';
|
|
6
|
+
import { DataGrist, FetchOption } from '@operato/data-grist';
|
|
7
|
+
declare const CodeManagementDetail_base: (new (...args: any[]) => LitElement) & typeof LitElement;
|
|
8
|
+
export declare class CodeManagementDetail extends CodeManagementDetail_base {
|
|
9
|
+
static styles: import("lit").CSSResult[];
|
|
10
|
+
codeId?: string;
|
|
11
|
+
config: any;
|
|
12
|
+
mode: 'LIST' | 'GRID';
|
|
13
|
+
grist: DataGrist;
|
|
14
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
15
|
+
firstUpdated(): Promise<void>;
|
|
16
|
+
fetchHandler({ filters, page, limit, sorters }: FetchOption): Promise<{
|
|
17
|
+
total: any;
|
|
18
|
+
records: any;
|
|
19
|
+
} | undefined>;
|
|
20
|
+
save(): Promise<void>;
|
|
21
|
+
delete(): Promise<void>;
|
|
22
|
+
getPatches(): import("@operato/data-grist").GristRecord[];
|
|
23
|
+
showToast(message: any): void;
|
|
24
|
+
}
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
import { __decorate, __metadata } from "tslib";
|
|
2
|
+
import '@operato/data-grist/ox-grist.js';
|
|
3
|
+
import '@operato/data-grist/ox-filters-form.js';
|
|
4
|
+
import '@operato/data-grist/ox-sorters-control.js';
|
|
5
|
+
import '@operato/data-grist/ox-record-creator.js';
|
|
6
|
+
import gql from 'graphql-tag';
|
|
7
|
+
import { css, html, LitElement } from 'lit';
|
|
8
|
+
import { customElement, property, query, state } from 'lit/decorators.js';
|
|
9
|
+
import { i18next, localize } from '@operato/i18n';
|
|
10
|
+
import { client, gqlContext, buildArgs } from '@operato/graphql';
|
|
11
|
+
import { CommonGristStyles, ScrollbarStyles } from '@operato/styles';
|
|
12
|
+
import { isMobileDevice } from '@operato/utils';
|
|
13
|
+
import { OxPrompt } from '@operato/popup/ox-prompt.js';
|
|
14
|
+
import { DataGrist } from '@operato/data-grist';
|
|
15
|
+
import { getLanguages } from '@things-factory/auth-base/dist-client';
|
|
16
|
+
let CodeManagementDetail = class CodeManagementDetail extends localize(i18next)(LitElement) {
|
|
17
|
+
constructor() {
|
|
18
|
+
super(...arguments);
|
|
19
|
+
this.mode = isMobileDevice() ? 'LIST' : 'GRID';
|
|
20
|
+
}
|
|
21
|
+
render() {
|
|
22
|
+
let mode = this.mode;
|
|
23
|
+
return html `
|
|
24
|
+
<ox-grist .mode=${mode} auto-fetch .config=${this.config} .fetchHandler=${this.fetchHandler.bind(this)}>
|
|
25
|
+
<div slot="headroom">
|
|
26
|
+
<div id="filters">
|
|
27
|
+
<ox-filters-form></ox-filters-form>
|
|
28
|
+
</div>
|
|
29
|
+
</div>
|
|
30
|
+
</ox-grist>
|
|
31
|
+
|
|
32
|
+
<div class="button-container">
|
|
33
|
+
<mwc-button @click=${this.save} raised label=${String(i18next.t('button.save'))}></mwc-button>
|
|
34
|
+
<mwc-button @click=${this.delete} raised danger label=${String(i18next.t('button.delete'))}></mwc-button>
|
|
35
|
+
</div>
|
|
36
|
+
`;
|
|
37
|
+
}
|
|
38
|
+
async firstUpdated() {
|
|
39
|
+
this.config = {
|
|
40
|
+
rows: { selectable: { multiple: true } },
|
|
41
|
+
pagination: { pages: [100, 200, 500] },
|
|
42
|
+
columns: [
|
|
43
|
+
{ type: 'gutter', gutterName: 'dirty' },
|
|
44
|
+
{ type: 'gutter', gutterName: 'sequence' },
|
|
45
|
+
{ type: 'gutter', gutterName: 'row-selector', multiple: true },
|
|
46
|
+
{
|
|
47
|
+
type: 'integer',
|
|
48
|
+
name: 'rank',
|
|
49
|
+
record: { align: 'left', editable: true, format: '#,###' },
|
|
50
|
+
header: i18next.t('field.rank'),
|
|
51
|
+
sortable: true,
|
|
52
|
+
width: 60
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
type: 'string',
|
|
56
|
+
name: 'name',
|
|
57
|
+
record: { align: 'left', editable: true },
|
|
58
|
+
header: i18next.t('field.code'),
|
|
59
|
+
sortable: true,
|
|
60
|
+
filter: 'search',
|
|
61
|
+
width: 320
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
type: 'i18n-label',
|
|
65
|
+
name: 'labels',
|
|
66
|
+
record: {
|
|
67
|
+
align: 'left',
|
|
68
|
+
editable: true,
|
|
69
|
+
renderer: (value, column, record, rowIndex, field) => html `<span>${record['description']}</span>`,
|
|
70
|
+
options: {
|
|
71
|
+
objectified: true,
|
|
72
|
+
languages: await getLanguages()
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
header: i18next.t('field.i18n-label'),
|
|
76
|
+
sortable: true,
|
|
77
|
+
filter: 'search',
|
|
78
|
+
width: 370
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
type: 'object',
|
|
82
|
+
name: 'updater',
|
|
83
|
+
record: { align: 'left', editable: false },
|
|
84
|
+
header: i18next.t('field.updater'),
|
|
85
|
+
sortable: true,
|
|
86
|
+
width: 90
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
type: 'datetime',
|
|
90
|
+
name: 'updatedAt',
|
|
91
|
+
header: i18next.t('field.updated_at'),
|
|
92
|
+
record: { editable: false },
|
|
93
|
+
sortable: true,
|
|
94
|
+
width: 180
|
|
95
|
+
}
|
|
96
|
+
]
|
|
97
|
+
};
|
|
98
|
+
await this.updateComplete;
|
|
99
|
+
this.grist.fetch();
|
|
100
|
+
}
|
|
101
|
+
async fetchHandler({ filters, page, limit, sorters = [{ name: 'rank' }] }) {
|
|
102
|
+
if (this.codeId) {
|
|
103
|
+
filters.push({
|
|
104
|
+
name: 'commonCodeId',
|
|
105
|
+
operator: 'eq',
|
|
106
|
+
value: this.codeId
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
const response = await client.query({
|
|
110
|
+
query: gql `
|
|
111
|
+
query {
|
|
112
|
+
commonCodeDetails(${buildArgs({
|
|
113
|
+
filters,
|
|
114
|
+
pagination: { page, limit },
|
|
115
|
+
sortings: sorters
|
|
116
|
+
})}) {
|
|
117
|
+
items {
|
|
118
|
+
id
|
|
119
|
+
name
|
|
120
|
+
description
|
|
121
|
+
rank
|
|
122
|
+
labels
|
|
123
|
+
updatedAt
|
|
124
|
+
updater{
|
|
125
|
+
name
|
|
126
|
+
description
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
total
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
`,
|
|
133
|
+
context: gqlContext()
|
|
134
|
+
});
|
|
135
|
+
if (!response.errors) {
|
|
136
|
+
return {
|
|
137
|
+
total: response.data.commonCodeDetails.total || 0,
|
|
138
|
+
records: response.data.commonCodeDetails.items || []
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
async save() {
|
|
143
|
+
const patches = this.getPatches();
|
|
144
|
+
if (!(patches === null || patches === void 0 ? void 0 : patches.length)) {
|
|
145
|
+
return this.showToast(i18next.t('text.nothing_changed'));
|
|
146
|
+
}
|
|
147
|
+
const response = await client.query({
|
|
148
|
+
query: gql `
|
|
149
|
+
mutation updateMultipleCommonCodeDetail($patches: [CommonCodeDetailPatch!]!) {
|
|
150
|
+
updateMultipleCommonCodeDetail(patches: $patches) {
|
|
151
|
+
name
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
`,
|
|
155
|
+
variables: { patches },
|
|
156
|
+
context: gqlContext()
|
|
157
|
+
});
|
|
158
|
+
if (!response.errors)
|
|
159
|
+
this.grist.fetch();
|
|
160
|
+
}
|
|
161
|
+
async delete() {
|
|
162
|
+
const ids = this.grist.selected.map(record => record.id);
|
|
163
|
+
if (!(ids === null || ids === void 0 ? void 0 : ids.length)) {
|
|
164
|
+
return this.showToast(i18next.t('text.there_is_nothing_to_delete'));
|
|
165
|
+
}
|
|
166
|
+
if (await OxPrompt.open({
|
|
167
|
+
type: 'warning',
|
|
168
|
+
title: i18next.t('button.delete'),
|
|
169
|
+
text: i18next.t('text.are_you_sure'),
|
|
170
|
+
confirmButton: { text: i18next.t('button.delete') },
|
|
171
|
+
cancelButton: { text: i18next.t('button.cancel') }
|
|
172
|
+
})) {
|
|
173
|
+
const response = await client.query({
|
|
174
|
+
query: gql `
|
|
175
|
+
mutation {
|
|
176
|
+
deleteCommonCodeDetails(${buildArgs({ ids })})
|
|
177
|
+
}
|
|
178
|
+
`,
|
|
179
|
+
context: gqlContext()
|
|
180
|
+
});
|
|
181
|
+
if (!response.errors) {
|
|
182
|
+
OxPrompt.open({
|
|
183
|
+
type: 'success',
|
|
184
|
+
title: i18next.t('text.completed'),
|
|
185
|
+
text: i18next.t('text.data_deleted_successfully'),
|
|
186
|
+
confirmButton: { text: i18next.t('button.confirm') }
|
|
187
|
+
});
|
|
188
|
+
this.grist.fetch();
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
getPatches() {
|
|
193
|
+
let patches = this.grist.dirtyRecords;
|
|
194
|
+
if (patches && patches.length) {
|
|
195
|
+
patches = patches.map(code => {
|
|
196
|
+
let patchField = code.id ? { id: code.id } : {};
|
|
197
|
+
const dirtyFields = code.__dirtyfields__;
|
|
198
|
+
for (let key in dirtyFields) {
|
|
199
|
+
patchField[key] = dirtyFields[key].after;
|
|
200
|
+
}
|
|
201
|
+
patchField.commonCode = { id: this.codeId };
|
|
202
|
+
patchField.cuFlag = code.__dirty__;
|
|
203
|
+
return patchField;
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
return patches;
|
|
207
|
+
}
|
|
208
|
+
showToast(message) {
|
|
209
|
+
document.dispatchEvent(new CustomEvent('notify', { detail: { message, option: { timer: 1000 } } }));
|
|
210
|
+
}
|
|
211
|
+
};
|
|
212
|
+
CodeManagementDetail.styles = [
|
|
213
|
+
ScrollbarStyles,
|
|
214
|
+
CommonGristStyles,
|
|
215
|
+
css `
|
|
216
|
+
:host {
|
|
217
|
+
display: flex;
|
|
218
|
+
flex-direction: column;
|
|
219
|
+
overflow: hidden;
|
|
220
|
+
background-color: white;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
.button-container {
|
|
224
|
+
padding: 10px 0 12px 0;
|
|
225
|
+
text-align: center;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
[danger] {
|
|
229
|
+
--mdc-theme-primary: var(--mdc-danger-button-primary-color);
|
|
230
|
+
}
|
|
231
|
+
`
|
|
232
|
+
];
|
|
233
|
+
__decorate([
|
|
234
|
+
property({ type: String }),
|
|
235
|
+
__metadata("design:type", String)
|
|
236
|
+
], CodeManagementDetail.prototype, "codeId", void 0);
|
|
237
|
+
__decorate([
|
|
238
|
+
property({ type: Object }),
|
|
239
|
+
__metadata("design:type", Object)
|
|
240
|
+
], CodeManagementDetail.prototype, "config", void 0);
|
|
241
|
+
__decorate([
|
|
242
|
+
state(),
|
|
243
|
+
__metadata("design:type", String)
|
|
244
|
+
], CodeManagementDetail.prototype, "mode", void 0);
|
|
245
|
+
__decorate([
|
|
246
|
+
query('ox-grist'),
|
|
247
|
+
__metadata("design:type", DataGrist)
|
|
248
|
+
], CodeManagementDetail.prototype, "grist", void 0);
|
|
249
|
+
CodeManagementDetail = __decorate([
|
|
250
|
+
customElement('code-management-detail')
|
|
251
|
+
], CodeManagementDetail);
|
|
252
|
+
export { CodeManagementDetail };
|
|
253
|
+
//# sourceMappingURL=code-management-detail.js.map
|