@things-factory/code-ui 7.0.0-alpha.8 → 7.0.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.
@@ -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
+
4
+ export default function bootstrap() {
5
+ registerGristEditor('i18n-label', OxGristEditorI18nLabel)
6
+ }
@@ -5,73 +5,63 @@ 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
- import { CommonGristStyles, ScrollbarStyles } from '@operato/styles'
12
+ import { ButtonContainerStyles, CommonHeaderStyles, 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 get styles() {
18
- return [
19
- ScrollbarStyles,
20
- CommonGristStyles,
21
- css`
22
- :host {
23
- display: flex;
24
- flex-direction: column;
25
- overflow: hidden;
26
- background-color: white;
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
+ ButtonContainerStyles,
24
+ CommonHeaderStyles,
25
+ css`
26
+ :host {
27
+ display: flex;
28
+ flex-direction: column;
29
+ overflow: hidden;
30
+ background-color: var(--md-sys-color-surface);
31
+ }
38
32
 
39
- static get properties() {
40
- return {
41
- codeId: String,
42
- config: Object,
43
- mode: String
44
- }
45
- }
33
+ ox-grist {
34
+ flex: 1;
35
+ }
36
+ `
37
+ ]
46
38
 
47
- constructor() {
48
- super()
49
- this.mode = isMobileDevice() ? 'LIST' : 'GRID'
50
- }
39
+ @property({ type: String }) codeId?: string
40
+ @property({ type: Object }) config: any
41
+
42
+ @state() mode: 'LIST' | 'GRID' = isMobileDevice() ? 'LIST' : 'GRID'
43
+
44
+ @query('ox-grist') grist!: DataGrist
51
45
 
52
46
  render() {
53
47
  let mode = this.mode
54
48
 
55
49
  return html`
56
50
  <ox-grist .mode=${mode} auto-fetch .config=${this.config} .fetchHandler=${this.fetchHandler.bind(this)}>
57
- <div slot="headroom">
58
- <div id="filters">
51
+ <div slot="headroom" class="header">
52
+ <div class="filters">
59
53
  <ox-filters-form></ox-filters-form>
60
54
  </div>
61
55
  </div>
62
56
  </ox-grist>
63
57
 
64
58
  <div class="button-container">
65
- <mwc-button @click=${this.save} raised label="${i18next.t('button.save')}"></mwc-button>
66
- <mwc-button @click=${this.delete} raised danger label="${i18next.t('button.delete')}"></mwc-button>
59
+ <button @click=${this.save}><md-icon>save</md-icon>${String(i18next.t('button.save'))}</button>
60
+ <button @click=${this.delete} danger><md-icon>delete</md-icon>${String(i18next.t('button.delete'))}</button>
67
61
  </div>
68
62
  `
69
63
  }
70
64
 
71
- get dataGrist() {
72
- return this.shadowRoot.querySelector('ox-grist')
73
- }
74
-
75
65
  async firstUpdated() {
76
66
  this.config = {
77
67
  rows: { selectable: { multiple: true } },
@@ -92,16 +82,26 @@ export class CodeManagementDetail extends localize(i18next)(LitElement) {
92
82
  type: 'string',
93
83
  name: 'name',
94
84
  record: { align: 'left', editable: true },
95
- header: i18next.t('field.name'),
85
+ header: i18next.t('field.code'),
96
86
  sortable: true,
97
87
  filter: 'search',
98
88
  width: 320
99
89
  },
100
90
  {
101
- type: 'string',
102
- name: 'description',
103
- record: { align: 'left', editable: true },
104
- header: i18next.t('field.description'),
91
+ type: 'i18n-label',
92
+ name: 'labels',
93
+ record: {
94
+ align: 'left',
95
+ editable: true,
96
+ renderer: (value, column, record, rowIndex, field) =>
97
+ html`<span>${value && typeof value == 'object' ? value[i18next.language] : record['description']}</span>`,
98
+ options: {
99
+ objectified: true,
100
+ languages: await getLanguages(),
101
+ displayColumn: 'description'
102
+ }
103
+ },
104
+ header: i18next.t('field.i18n-label'),
105
105
  sortable: true,
106
106
  filter: 'search',
107
107
  width: 370
@@ -126,12 +126,12 @@ export class CodeManagementDetail extends localize(i18next)(LitElement) {
126
126
  }
127
127
 
128
128
  await this.updateComplete
129
- this.dataGrist.fetch()
129
+ this.grist.fetch()
130
130
  }
131
131
 
132
- async fetchHandler({ filters, page, limit, sorters = [{ name: 'rank' }] }) {
132
+ async fetchHandler({ filters, page, limit, sorters = [{ name: 'rank' }] }: FetchOption) {
133
133
  if (this.codeId) {
134
- filters.push({
134
+ filters!.push({
135
135
  name: 'commonCodeId',
136
136
  operator: 'eq',
137
137
  value: this.codeId
@@ -151,6 +151,7 @@ export class CodeManagementDetail extends localize(i18next)(LitElement) {
151
151
  name
152
152
  description
153
153
  rank
154
+ labels
154
155
  updatedAt
155
156
  updater{
156
157
  name
@@ -180,22 +181,21 @@ export class CodeManagementDetail extends localize(i18next)(LitElement) {
180
181
 
181
182
  const response = await client.query({
182
183
  query: gql`
183
- mutation {
184
- updateMultipleCommonCodeDetail(${buildArgs({
185
- patches
186
- })}) {
184
+ mutation updateMultipleCommonCodeDetail($patches: [CommonCodeDetailPatch!]!) {
185
+ updateMultipleCommonCodeDetail(patches: $patches) {
187
186
  name
188
187
  }
189
188
  }
190
189
  `,
190
+ variables: { patches },
191
191
  context: gqlContext()
192
192
  })
193
193
 
194
- if (!response.errors) this.dataGrist.fetch()
194
+ if (!response.errors) this.grist.fetch()
195
195
  }
196
196
 
197
197
  async delete() {
198
- const ids = this.dataGrist.selected.map(record => record.id)
198
+ const ids = this.grist.selected.map(record => record.id)
199
199
  if (!ids?.length) {
200
200
  return this.showToast(i18next.t('text.there_is_nothing_to_delete'))
201
201
  }
@@ -226,16 +226,16 @@ export class CodeManagementDetail extends localize(i18next)(LitElement) {
226
226
  confirmButton: { text: i18next.t('button.confirm') }
227
227
  })
228
228
 
229
- this.dataGrist.fetch()
229
+ this.grist.fetch()
230
230
  }
231
231
  }
232
232
  }
233
233
 
234
234
  getPatches() {
235
- let patches = this.dataGrist.dirtyRecords
235
+ let patches = this.grist.dirtyRecords
236
236
  if (patches && patches.length) {
237
237
  patches = patches.map(code => {
238
- let patchField = code.id ? { id: code.id } : {}
238
+ let patchField: any = code.id ? { id: code.id } : {}
239
239
  const dirtyFields = code.__dirtyfields__
240
240
  for (let key in dirtyFields) {
241
241
  patchField[key] = dirtyFields[key].after
@@ -254,5 +254,3 @@ export class CodeManagementDetail extends localize(i18next)(LitElement) {
254
254
  document.dispatchEvent(new CustomEvent('notify', { detail: { message, option: { timer: 1000 } } }))
255
255
  }
256
256
  }
257
-
258
- window.customElements.define('code-management-detail', CodeManagementDetail)
@@ -6,52 +6,46 @@ 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'
12
13
  import { client, gqlContext, buildArgs } from '@operato/graphql'
13
14
  import { PageView } from '@operato/shell'
14
- import { CommonButtonStyles, CommonGristStyles, ScrollbarStyles } from '@operato/styles'
15
+ import { CommonButtonStyles, CommonHeaderStyles, 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
- class CodeManagement extends localize(i18next)(PageView) {
20
- static get properties() {
21
- return {
22
- config: Object,
23
- data: Object,
24
- mode: String
25
- }
26
- }
21
+ @customElement('code-management')
22
+ export class CodeManagement extends localize(i18next)(PageView) {
23
+ static styles = [
24
+ ScrollbarStyles,
25
+ CommonHeaderStyles,
26
+ css`
27
+ :host {
28
+ display: flex;
29
+ flex-direction: column;
27
30
 
28
- static get styles() {
29
- return [
30
- ScrollbarStyles,
31
- CommonGristStyles,
32
- css`
33
- :host {
34
- display: flex;
35
- flex-direction: column;
31
+ overflow: hidden;
32
+ }
33
+ `
34
+ ]
36
35
 
37
- overflow: hidden;
38
- }
39
- `
40
- ]
41
- }
36
+ @state() config?: any
37
+ @state() data?: any
38
+ @state() mode: 'LIST' | 'GRID' = isMobileDevice() ? 'LIST' : 'GRID'
42
39
 
43
- constructor() {
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
50
44
 
51
45
  return html`
52
46
  <ox-grist .mode=${mode} auto-fetch .config=${this.config} .fetchHandler=${this.fetchHandler.bind(this)}>
53
- <div slot="headroom">
54
- <div id="filters">
47
+ <div slot="headroom" class="header">
48
+ <div class="filters">
55
49
  <ox-filters-form></ox-filters-form>
56
50
  </div>
57
51
  </div>
@@ -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.dataGrist.fetch()
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.name'),
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.dataGrist.fetch()
191
+ this.grist.fetch()
202
192
  }
203
193
  }
204
194
 
205
195
  async delete() {
206
- const ids = this.dataGrist.selected.map(record => record.id)
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.dataGrist.fetch()
227
+ this.grist.fetch()
238
228
  }
239
229
  }
240
230
  }
241
231
 
242
232
  getPatches() {
243
- let patches = this.dataGrist.dirtyRecords
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.ts"],"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,2 @@
1
+ export * from './pages/code-management';
2
+ export * from './pages/code-management-detail';
@@ -0,0 +1,3 @@
1
+ export * from './pages/code-management';
2
+ export * from './pages/code-management-detail';
3
+ //# sourceMappingURL=index.js.map
@@ -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,250 @@
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 { ButtonContainerStyles, CommonHeaderStyles, 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" class="header">
26
+ <div class="filters">
27
+ <ox-filters-form></ox-filters-form>
28
+ </div>
29
+ </div>
30
+ </ox-grist>
31
+
32
+ <div class="button-container">
33
+ <button @click=${this.save}><md-icon>save</md-icon>${String(i18next.t('button.save'))}</button>
34
+ <button @click=${this.delete} danger><md-icon>delete</md-icon>${String(i18next.t('button.delete'))}</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>${value && 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
+ ButtonContainerStyles,
216
+ CommonHeaderStyles,
217
+ css `
218
+ :host {
219
+ display: flex;
220
+ flex-direction: column;
221
+ overflow: hidden;
222
+ background-color: var(--md-sys-color-surface);
223
+ }
224
+
225
+ ox-grist {
226
+ flex: 1;
227
+ }
228
+ `
229
+ ];
230
+ __decorate([
231
+ property({ type: String }),
232
+ __metadata("design:type", String)
233
+ ], CodeManagementDetail.prototype, "codeId", void 0);
234
+ __decorate([
235
+ property({ type: Object }),
236
+ __metadata("design:type", Object)
237
+ ], CodeManagementDetail.prototype, "config", void 0);
238
+ __decorate([
239
+ state(),
240
+ __metadata("design:type", String)
241
+ ], CodeManagementDetail.prototype, "mode", void 0);
242
+ __decorate([
243
+ query('ox-grist'),
244
+ __metadata("design:type", DataGrist)
245
+ ], CodeManagementDetail.prototype, "grist", void 0);
246
+ CodeManagementDetail = __decorate([
247
+ customElement('code-management-detail')
248
+ ], CodeManagementDetail);
249
+ export { CodeManagementDetail };
250
+ //# sourceMappingURL=code-management-detail.js.map