@things-factory/code-ui 7.0.0-alpha.8 → 7.0.1-alpha.0
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} +59 -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 +254 -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/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +15 -11
- 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,25 @@ 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>${typeof value == 'object' ? value[i18next.language] : record['description']}</span>`,
|
|
101
|
+
options: {
|
|
102
|
+
objectified: true,
|
|
103
|
+
languages: await getLanguages(),
|
|
104
|
+
displayColumn: 'description'
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
header: i18next.t('field.i18n-label'),
|
|
105
108
|
sortable: true,
|
|
106
109
|
filter: 'search',
|
|
107
110
|
width: 370
|
|
@@ -126,12 +129,12 @@ export class CodeManagementDetail extends localize(i18next)(LitElement) {
|
|
|
126
129
|
}
|
|
127
130
|
|
|
128
131
|
await this.updateComplete
|
|
129
|
-
this.
|
|
132
|
+
this.grist.fetch()
|
|
130
133
|
}
|
|
131
134
|
|
|
132
|
-
async fetchHandler({ filters, page, limit, sorters = [{ name: 'rank' }] }) {
|
|
135
|
+
async fetchHandler({ filters, page, limit, sorters = [{ name: 'rank' }] }: FetchOption) {
|
|
133
136
|
if (this.codeId) {
|
|
134
|
-
filters
|
|
137
|
+
filters!.push({
|
|
135
138
|
name: 'commonCodeId',
|
|
136
139
|
operator: 'eq',
|
|
137
140
|
value: this.codeId
|
|
@@ -151,6 +154,7 @@ export class CodeManagementDetail extends localize(i18next)(LitElement) {
|
|
|
151
154
|
name
|
|
152
155
|
description
|
|
153
156
|
rank
|
|
157
|
+
labels
|
|
154
158
|
updatedAt
|
|
155
159
|
updater{
|
|
156
160
|
name
|
|
@@ -180,22 +184,21 @@ export class CodeManagementDetail extends localize(i18next)(LitElement) {
|
|
|
180
184
|
|
|
181
185
|
const response = await client.query({
|
|
182
186
|
query: gql`
|
|
183
|
-
mutation {
|
|
184
|
-
updateMultipleCommonCodeDetail(${
|
|
185
|
-
patches
|
|
186
|
-
})}) {
|
|
187
|
+
mutation updateMultipleCommonCodeDetail($patches: [CommonCodeDetailPatch!]!) {
|
|
188
|
+
updateMultipleCommonCodeDetail(patches: $patches) {
|
|
187
189
|
name
|
|
188
190
|
}
|
|
189
191
|
}
|
|
190
192
|
`,
|
|
193
|
+
variables: { patches },
|
|
191
194
|
context: gqlContext()
|
|
192
195
|
})
|
|
193
196
|
|
|
194
|
-
if (!response.errors) this.
|
|
197
|
+
if (!response.errors) this.grist.fetch()
|
|
195
198
|
}
|
|
196
199
|
|
|
197
200
|
async delete() {
|
|
198
|
-
const ids = this.
|
|
201
|
+
const ids = this.grist.selected.map(record => record.id)
|
|
199
202
|
if (!ids?.length) {
|
|
200
203
|
return this.showToast(i18next.t('text.there_is_nothing_to_delete'))
|
|
201
204
|
}
|
|
@@ -226,16 +229,16 @@ export class CodeManagementDetail extends localize(i18next)(LitElement) {
|
|
|
226
229
|
confirmButton: { text: i18next.t('button.confirm') }
|
|
227
230
|
})
|
|
228
231
|
|
|
229
|
-
this.
|
|
232
|
+
this.grist.fetch()
|
|
230
233
|
}
|
|
231
234
|
}
|
|
232
235
|
}
|
|
233
236
|
|
|
234
237
|
getPatches() {
|
|
235
|
-
let patches = this.
|
|
238
|
+
let patches = this.grist.dirtyRecords
|
|
236
239
|
if (patches && patches.length) {
|
|
237
240
|
patches = patches.map(code => {
|
|
238
|
-
let patchField = code.id ? { id: code.id } : {}
|
|
241
|
+
let patchField: any = code.id ? { id: code.id } : {}
|
|
239
242
|
const dirtyFields = code.__dirtyfields__
|
|
240
243
|
for (let key in dirtyFields) {
|
|
241
244
|
patchField[key] = dirtyFields[key].after
|
|
@@ -254,5 +257,3 @@ export class CodeManagementDetail extends localize(i18next)(LitElement) {
|
|
|
254
257
|
document.dispatchEvent(new CustomEvent('notify', { detail: { message, option: { timer: 1000 } } }))
|
|
255
258
|
}
|
|
256
259
|
}
|
|
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,254 @@
|
|
|
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>${typeof value == 'object' ? value[i18next.language] : record['description']}</span>`,
|
|
70
|
+
options: {
|
|
71
|
+
objectified: true,
|
|
72
|
+
languages: await getLanguages(),
|
|
73
|
+
displayColumn: 'description'
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
header: i18next.t('field.i18n-label'),
|
|
77
|
+
sortable: true,
|
|
78
|
+
filter: 'search',
|
|
79
|
+
width: 370
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
type: 'object',
|
|
83
|
+
name: 'updater',
|
|
84
|
+
record: { align: 'left', editable: false },
|
|
85
|
+
header: i18next.t('field.updater'),
|
|
86
|
+
sortable: true,
|
|
87
|
+
width: 90
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
type: 'datetime',
|
|
91
|
+
name: 'updatedAt',
|
|
92
|
+
header: i18next.t('field.updated_at'),
|
|
93
|
+
record: { editable: false },
|
|
94
|
+
sortable: true,
|
|
95
|
+
width: 180
|
|
96
|
+
}
|
|
97
|
+
]
|
|
98
|
+
};
|
|
99
|
+
await this.updateComplete;
|
|
100
|
+
this.grist.fetch();
|
|
101
|
+
}
|
|
102
|
+
async fetchHandler({ filters, page, limit, sorters = [{ name: 'rank' }] }) {
|
|
103
|
+
if (this.codeId) {
|
|
104
|
+
filters.push({
|
|
105
|
+
name: 'commonCodeId',
|
|
106
|
+
operator: 'eq',
|
|
107
|
+
value: this.codeId
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
const response = await client.query({
|
|
111
|
+
query: gql `
|
|
112
|
+
query {
|
|
113
|
+
commonCodeDetails(${buildArgs({
|
|
114
|
+
filters,
|
|
115
|
+
pagination: { page, limit },
|
|
116
|
+
sortings: sorters
|
|
117
|
+
})}) {
|
|
118
|
+
items {
|
|
119
|
+
id
|
|
120
|
+
name
|
|
121
|
+
description
|
|
122
|
+
rank
|
|
123
|
+
labels
|
|
124
|
+
updatedAt
|
|
125
|
+
updater{
|
|
126
|
+
name
|
|
127
|
+
description
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
total
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
`,
|
|
134
|
+
context: gqlContext()
|
|
135
|
+
});
|
|
136
|
+
if (!response.errors) {
|
|
137
|
+
return {
|
|
138
|
+
total: response.data.commonCodeDetails.total || 0,
|
|
139
|
+
records: response.data.commonCodeDetails.items || []
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
async save() {
|
|
144
|
+
const patches = this.getPatches();
|
|
145
|
+
if (!(patches === null || patches === void 0 ? void 0 : patches.length)) {
|
|
146
|
+
return this.showToast(i18next.t('text.nothing_changed'));
|
|
147
|
+
}
|
|
148
|
+
const response = await client.query({
|
|
149
|
+
query: gql `
|
|
150
|
+
mutation updateMultipleCommonCodeDetail($patches: [CommonCodeDetailPatch!]!) {
|
|
151
|
+
updateMultipleCommonCodeDetail(patches: $patches) {
|
|
152
|
+
name
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
`,
|
|
156
|
+
variables: { patches },
|
|
157
|
+
context: gqlContext()
|
|
158
|
+
});
|
|
159
|
+
if (!response.errors)
|
|
160
|
+
this.grist.fetch();
|
|
161
|
+
}
|
|
162
|
+
async delete() {
|
|
163
|
+
const ids = this.grist.selected.map(record => record.id);
|
|
164
|
+
if (!(ids === null || ids === void 0 ? void 0 : ids.length)) {
|
|
165
|
+
return this.showToast(i18next.t('text.there_is_nothing_to_delete'));
|
|
166
|
+
}
|
|
167
|
+
if (await OxPrompt.open({
|
|
168
|
+
type: 'warning',
|
|
169
|
+
title: i18next.t('button.delete'),
|
|
170
|
+
text: i18next.t('text.are_you_sure'),
|
|
171
|
+
confirmButton: { text: i18next.t('button.delete') },
|
|
172
|
+
cancelButton: { text: i18next.t('button.cancel') }
|
|
173
|
+
})) {
|
|
174
|
+
const response = await client.query({
|
|
175
|
+
query: gql `
|
|
176
|
+
mutation {
|
|
177
|
+
deleteCommonCodeDetails(${buildArgs({ ids })})
|
|
178
|
+
}
|
|
179
|
+
`,
|
|
180
|
+
context: gqlContext()
|
|
181
|
+
});
|
|
182
|
+
if (!response.errors) {
|
|
183
|
+
OxPrompt.open({
|
|
184
|
+
type: 'success',
|
|
185
|
+
title: i18next.t('text.completed'),
|
|
186
|
+
text: i18next.t('text.data_deleted_successfully'),
|
|
187
|
+
confirmButton: { text: i18next.t('button.confirm') }
|
|
188
|
+
});
|
|
189
|
+
this.grist.fetch();
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
getPatches() {
|
|
194
|
+
let patches = this.grist.dirtyRecords;
|
|
195
|
+
if (patches && patches.length) {
|
|
196
|
+
patches = patches.map(code => {
|
|
197
|
+
let patchField = code.id ? { id: code.id } : {};
|
|
198
|
+
const dirtyFields = code.__dirtyfields__;
|
|
199
|
+
for (let key in dirtyFields) {
|
|
200
|
+
patchField[key] = dirtyFields[key].after;
|
|
201
|
+
}
|
|
202
|
+
patchField.commonCode = { id: this.codeId };
|
|
203
|
+
patchField.cuFlag = code.__dirty__;
|
|
204
|
+
return patchField;
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
return patches;
|
|
208
|
+
}
|
|
209
|
+
showToast(message) {
|
|
210
|
+
document.dispatchEvent(new CustomEvent('notify', { detail: { message, option: { timer: 1000 } } }));
|
|
211
|
+
}
|
|
212
|
+
};
|
|
213
|
+
CodeManagementDetail.styles = [
|
|
214
|
+
ScrollbarStyles,
|
|
215
|
+
CommonGristStyles,
|
|
216
|
+
css `
|
|
217
|
+
:host {
|
|
218
|
+
display: flex;
|
|
219
|
+
flex-direction: column;
|
|
220
|
+
overflow: hidden;
|
|
221
|
+
background-color: white;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
.button-container {
|
|
225
|
+
padding: 10px 0 12px 0;
|
|
226
|
+
text-align: center;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
[danger] {
|
|
230
|
+
--mdc-theme-primary: var(--mdc-danger-button-primary-color);
|
|
231
|
+
}
|
|
232
|
+
`
|
|
233
|
+
];
|
|
234
|
+
__decorate([
|
|
235
|
+
property({ type: String }),
|
|
236
|
+
__metadata("design:type", String)
|
|
237
|
+
], CodeManagementDetail.prototype, "codeId", void 0);
|
|
238
|
+
__decorate([
|
|
239
|
+
property({ type: Object }),
|
|
240
|
+
__metadata("design:type", Object)
|
|
241
|
+
], CodeManagementDetail.prototype, "config", void 0);
|
|
242
|
+
__decorate([
|
|
243
|
+
state(),
|
|
244
|
+
__metadata("design:type", String)
|
|
245
|
+
], CodeManagementDetail.prototype, "mode", void 0);
|
|
246
|
+
__decorate([
|
|
247
|
+
query('ox-grist'),
|
|
248
|
+
__metadata("design:type", DataGrist)
|
|
249
|
+
], CodeManagementDetail.prototype, "grist", void 0);
|
|
250
|
+
CodeManagementDetail = __decorate([
|
|
251
|
+
customElement('code-management-detail')
|
|
252
|
+
], CodeManagementDetail);
|
|
253
|
+
export { CodeManagementDetail };
|
|
254
|
+
//# sourceMappingURL=code-management-detail.js.map
|