@things-factory/code-ui 7.0.49 → 7.0.56

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.
@@ -8,11 +8,11 @@ import { css, html, LitElement } from 'lit'
8
8
  import { customElement, property, query, state } from 'lit/decorators.js'
9
9
 
10
10
  import { i18next, localize } from '@operato/i18n'
11
- import { client, gqlContext, buildArgs } from '@operato/graphql'
12
- import { ButtonContainerStyles, CommonHeaderStyles, ScrollbarStyles } from '@operato/styles'
13
- import { isMobileDevice } from '@operato/utils'
11
+ import { client } from '@operato/graphql'
12
+ import { ButtonContainerStyles, CommonGristStyles, CommonHeaderStyles, ScrollbarStyles } from '@operato/styles'
13
+ import { isMobileDevice, adjustFilters } from '@operato/utils'
14
14
  import { OxPrompt } from '@operato/popup/ox-prompt.js'
15
- import { DataGrist, FetchOption } from '@operato/data-grist'
15
+ import { DataGrist, FetchOption, QueryFilter } from '@operato/data-grist'
16
16
 
17
17
  import { getLanguages } from '@things-factory/auth-base/dist-client'
18
18
 
@@ -21,6 +21,7 @@ export class CodeManagementDetail extends localize(i18next)(LitElement) {
21
21
  static styles = [
22
22
  ScrollbarStyles,
23
23
  ButtonContainerStyles,
24
+ CommonGristStyles,
24
25
  CommonHeaderStyles,
25
26
  css`
26
27
  :host {
@@ -55,9 +56,10 @@ export class CodeManagementDetail extends localize(i18next)(LitElement) {
55
56
  </div>
56
57
  </ox-grist>
57
58
 
58
- <div class="button-container">
59
- <button @click=${this.save}><md-icon>save</md-icon>${String(i18next.t('button.save'))}</button>
59
+ <div class="footer">
60
+ <div filler></div>
60
61
  <button @click=${this.delete} danger><md-icon>delete</md-icon>${String(i18next.t('button.delete'))}</button>
62
+ <button @click=${this.save} done><md-icon>save</md-icon>${String(i18next.t('button.save'))}</button>
61
63
  </div>
62
64
  `
63
65
  }
@@ -131,21 +133,19 @@ export class CodeManagementDetail extends localize(i18next)(LitElement) {
131
133
 
132
134
  async fetchHandler({ filters, page, limit, sorters = [{ name: 'rank' }] }: FetchOption) {
133
135
  if (this.codeId) {
134
- filters!.push({
135
- name: 'commonCodeId',
136
- operator: 'eq',
137
- value: this.codeId
138
- })
136
+ filters = adjustFilters(filters || [], [
137
+ {
138
+ name: 'commonCode',
139
+ operator: 'eq',
140
+ value: this.codeId
141
+ }
142
+ ]) as QueryFilter[]
139
143
  }
140
144
 
141
145
  const response = await client.query({
142
146
  query: gql`
143
- query {
144
- commonCodeDetails(${buildArgs({
145
- filters,
146
- pagination: { page, limit },
147
- sortings: sorters
148
- })}) {
147
+ query CommonCodeDetails($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!]) {
148
+ commonCodeDetails(filters: $filters, pagination: $pagination, sortings: $sortings) {
149
149
  items {
150
150
  id
151
151
  name
@@ -153,7 +153,7 @@ export class CodeManagementDetail extends localize(i18next)(LitElement) {
153
153
  rank
154
154
  labels
155
155
  updatedAt
156
- updater{
156
+ updater {
157
157
  name
158
158
  description
159
159
  }
@@ -162,7 +162,11 @@ export class CodeManagementDetail extends localize(i18next)(LitElement) {
162
162
  }
163
163
  }
164
164
  `,
165
- context: gqlContext()
165
+ variables: {
166
+ filters,
167
+ pagination: { page, limit },
168
+ sorters
169
+ }
166
170
  })
167
171
 
168
172
  if (!response.errors) {
@@ -179,16 +183,15 @@ export class CodeManagementDetail extends localize(i18next)(LitElement) {
179
183
  return this.showToast(i18next.t('text.nothing_changed'))
180
184
  }
181
185
 
182
- const response = await client.query({
183
- query: gql`
186
+ const response = await client.mutate({
187
+ mutation: gql`
184
188
  mutation updateMultipleCommonCodeDetail($patches: [CommonCodeDetailPatch!]!) {
185
189
  updateMultipleCommonCodeDetail(patches: $patches) {
186
190
  name
187
191
  }
188
192
  }
189
193
  `,
190
- variables: { patches },
191
- context: gqlContext()
194
+ variables: { patches }
192
195
  })
193
196
 
194
197
  if (!response.errors) this.grist.fetch()
@@ -209,13 +212,15 @@ export class CodeManagementDetail extends localize(i18next)(LitElement) {
209
212
  cancelButton: { text: i18next.t('button.cancel') }
210
213
  })
211
214
  ) {
212
- const response = await client.query({
213
- query: gql`
214
- mutation {
215
- deleteCommonCodeDetails(${buildArgs({ ids })})
215
+ const response = await client.mutate({
216
+ mutation: gql`
217
+ mutation DeleteCommonCodeDetails($ids: [String!]!) {
218
+ deleteCommonCodeDetails(ids: $ids)
216
219
  }
217
220
  `,
218
- context: gqlContext()
221
+ variables: {
222
+ ids
223
+ }
219
224
  })
220
225
 
221
226
  if (!response.errors) {
@@ -10,9 +10,9 @@ import { customElement, property, query, state } from 'lit/decorators.js'
10
10
 
11
11
  import { openPopup } from '@operato/layout'
12
12
  import { i18next, localize } from '@operato/i18n'
13
- import { client, gqlContext, buildArgs } from '@operato/graphql'
13
+ import { client } from '@operato/graphql'
14
14
  import { PageView } from '@operato/shell'
15
- import { CommonButtonStyles, CommonHeaderStyles, ScrollbarStyles } from '@operato/styles'
15
+ import { CommonButtonStyles, CommonGristStyles, CommonHeaderStyles, ScrollbarStyles } from '@operato/styles'
16
16
  import { isMobileDevice } from '@operato/utils'
17
17
  import { DataGrist, FetchOption } from '@operato/data-grist'
18
18
 
@@ -22,13 +22,25 @@ import { OxPrompt } from '@operato/popup/ox-prompt.js'
22
22
  export class CodeManagement extends localize(i18next)(PageView) {
23
23
  static styles = [
24
24
  ScrollbarStyles,
25
+ CommonGristStyles,
25
26
  CommonHeaderStyles,
26
27
  css`
27
28
  :host {
28
29
  display: flex;
29
- flex-direction: column;
30
30
 
31
- overflow: hidden;
31
+ width: 100%;
32
+
33
+ --grid-record-emphasized-background-color: #8b0000;
34
+ --grid-record-emphasized-color: #ff6b6b;
35
+ }
36
+
37
+ ox-grist {
38
+ overflow-y: auto;
39
+ flex: 1;
40
+ }
41
+
42
+ .header {
43
+ grid-template-areas: 'filters actions';
32
44
  }
33
45
  `
34
46
  ]
@@ -55,7 +67,7 @@ export class CodeManagement extends localize(i18next)(PageView) {
55
67
 
56
68
  get context() {
57
69
  return {
58
- title: i18next.t('title.code_management'),
70
+ title: i18next.t('title.code-management'),
59
71
  actions: [
60
72
  {
61
73
  title: i18next.t('button.save'),
@@ -137,18 +149,14 @@ export class CodeManagement extends localize(i18next)(PageView) {
137
149
  async fetchHandler({ filters, page, limit, sorters = [{ name: 'name' }, { name: 'updatedAt' }] }: FetchOption) {
138
150
  const response = await client.query({
139
151
  query: gql`
140
- query {
141
- commonCodes(${buildArgs({
142
- filters,
143
- pagination: { page, limit },
144
- sortings: sorters
145
- })}) {
152
+ query CommonCodes($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!]) {
153
+ commonCodes(filters: $filters, pagination: $pagination, sortings: $sortings) {
146
154
  items {
147
155
  id
148
156
  name
149
157
  description
150
158
  updatedAt
151
- updater{
159
+ updater {
152
160
  id
153
161
  name
154
162
  description
@@ -158,7 +166,11 @@ export class CodeManagement extends localize(i18next)(PageView) {
158
166
  }
159
167
  }
160
168
  `,
161
- context: gqlContext()
169
+ variables: {
170
+ filters,
171
+ pagination: { page, limit },
172
+ sorters
173
+ }
162
174
  })
163
175
 
164
176
  return {
@@ -173,17 +185,15 @@ export class CodeManagement extends localize(i18next)(PageView) {
173
185
  return this.showToast(i18next.t('text.nothing_changed'))
174
186
  }
175
187
 
176
- const response = await client.query({
177
- query: gql`
178
- mutation {
179
- updateMultipleCommonCode(${buildArgs({
180
- patches
181
- })}) {
182
- name
183
- }
188
+ const response = await client.mutate({
189
+ mutation: gql`
190
+ mutation UpdateMultipleCommonCode($patches: [CommonCodePatch!]!) {
191
+ updateMultipleCommonCode(patches: $patches) {
192
+ name
184
193
  }
185
- `,
186
- context: gqlContext()
194
+ }
195
+ `,
196
+ variables: { patches }
187
197
  })
188
198
 
189
199
  if (!response.errors) {
@@ -207,13 +217,15 @@ export class CodeManagement extends localize(i18next)(PageView) {
207
217
  cancelButton: { text: i18next.t('button.cancel') }
208
218
  })
209
219
  ) {
210
- const response = await client.query({
211
- query: gql`
212
- mutation {
213
- deleteCommonCodes(${buildArgs({ ids })})
220
+ const response = await client.mutate({
221
+ mutation: gql`
222
+ mutation DeleteCommonCodes($ids: [String!]!) {
223
+ deleteCommonCodes(ids: $ids)
214
224
  }
215
225
  `,
216
- context: gqlContext()
226
+ variables: {
227
+ ids
228
+ }
217
229
  })
218
230
 
219
231
  if (!response.errors) {
@@ -251,7 +263,7 @@ export class CodeManagement extends localize(i18next)(PageView) {
251
263
  openPopup(html` <code-management-detail .codeId="${codeId}"></code-management-detail> `, {
252
264
  backdrop: true,
253
265
  size: 'large',
254
- title: `${i18next.t('title.code_management_detail')} - ${codeName}`
266
+ title: `${i18next.t('title.code-management-detail')} - ${codeName}`
255
267
  })
256
268
  }
257
269
 
@@ -11,7 +11,7 @@ export declare class CodeManagementDetail extends CodeManagementDetail_base {
11
11
  config: any;
12
12
  mode: 'LIST' | 'GRID';
13
13
  grist: DataGrist;
14
- render(): import("lit").TemplateResult<1>;
14
+ render(): import("lit-html").TemplateResult<1>;
15
15
  firstUpdated(): Promise<void>;
16
16
  fetchHandler({ filters, page, limit, sorters }: FetchOption): Promise<{
17
17
  total: any;
@@ -7,9 +7,9 @@ import gql from 'graphql-tag';
7
7
  import { css, html, LitElement } from 'lit';
8
8
  import { customElement, property, query, state } from 'lit/decorators.js';
9
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';
10
+ import { client } from '@operato/graphql';
11
+ import { ButtonContainerStyles, CommonGristStyles, CommonHeaderStyles, ScrollbarStyles } from '@operato/styles';
12
+ import { isMobileDevice, adjustFilters } from '@operato/utils';
13
13
  import { OxPrompt } from '@operato/popup/ox-prompt.js';
14
14
  import { DataGrist } from '@operato/data-grist';
15
15
  import { getLanguages } from '@things-factory/auth-base/dist-client';
@@ -29,9 +29,10 @@ let CodeManagementDetail = class CodeManagementDetail extends localize(i18next)(
29
29
  </div>
30
30
  </ox-grist>
31
31
 
32
- <div class="button-container">
33
- <button @click=${this.save}><md-icon>save</md-icon>${String(i18next.t('button.save'))}</button>
32
+ <div class="footer">
33
+ <div filler></div>
34
34
  <button @click=${this.delete} danger><md-icon>delete</md-icon>${String(i18next.t('button.delete'))}</button>
35
+ <button @click=${this.save} done><md-icon>save</md-icon>${String(i18next.t('button.save'))}</button>
35
36
  </div>
36
37
  `;
37
38
  }
@@ -101,20 +102,18 @@ let CodeManagementDetail = class CodeManagementDetail extends localize(i18next)(
101
102
  }
102
103
  async fetchHandler({ filters, page, limit, sorters = [{ name: 'rank' }] }) {
103
104
  if (this.codeId) {
104
- filters.push({
105
- name: 'commonCodeId',
106
- operator: 'eq',
107
- value: this.codeId
108
- });
105
+ filters = adjustFilters(filters || [], [
106
+ {
107
+ name: 'commonCode',
108
+ operator: 'eq',
109
+ value: this.codeId
110
+ }
111
+ ]);
109
112
  }
110
113
  const response = await client.query({
111
114
  query: gql `
112
- query {
113
- commonCodeDetails(${buildArgs({
114
- filters,
115
- pagination: { page, limit },
116
- sortings: sorters
117
- })}) {
115
+ query CommonCodeDetails($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!]) {
116
+ commonCodeDetails(filters: $filters, pagination: $pagination, sortings: $sortings) {
118
117
  items {
119
118
  id
120
119
  name
@@ -122,7 +121,7 @@ let CodeManagementDetail = class CodeManagementDetail extends localize(i18next)(
122
121
  rank
123
122
  labels
124
123
  updatedAt
125
- updater{
124
+ updater {
126
125
  name
127
126
  description
128
127
  }
@@ -131,7 +130,11 @@ let CodeManagementDetail = class CodeManagementDetail extends localize(i18next)(
131
130
  }
132
131
  }
133
132
  `,
134
- context: gqlContext()
133
+ variables: {
134
+ filters,
135
+ pagination: { page, limit },
136
+ sorters
137
+ }
135
138
  });
136
139
  if (!response.errors) {
137
140
  return {
@@ -145,16 +148,15 @@ let CodeManagementDetail = class CodeManagementDetail extends localize(i18next)(
145
148
  if (!(patches === null || patches === void 0 ? void 0 : patches.length)) {
146
149
  return this.showToast(i18next.t('text.nothing_changed'));
147
150
  }
148
- const response = await client.query({
149
- query: gql `
151
+ const response = await client.mutate({
152
+ mutation: gql `
150
153
  mutation updateMultipleCommonCodeDetail($patches: [CommonCodeDetailPatch!]!) {
151
154
  updateMultipleCommonCodeDetail(patches: $patches) {
152
155
  name
153
156
  }
154
157
  }
155
158
  `,
156
- variables: { patches },
157
- context: gqlContext()
159
+ variables: { patches }
158
160
  });
159
161
  if (!response.errors)
160
162
  this.grist.fetch();
@@ -171,13 +173,15 @@ let CodeManagementDetail = class CodeManagementDetail extends localize(i18next)(
171
173
  confirmButton: { text: i18next.t('button.delete') },
172
174
  cancelButton: { text: i18next.t('button.cancel') }
173
175
  })) {
174
- const response = await client.query({
175
- query: gql `
176
- mutation {
177
- deleteCommonCodeDetails(${buildArgs({ ids })})
176
+ const response = await client.mutate({
177
+ mutation: gql `
178
+ mutation DeleteCommonCodeDetails($ids: [String!]!) {
179
+ deleteCommonCodeDetails(ids: $ids)
178
180
  }
179
181
  `,
180
- context: gqlContext()
182
+ variables: {
183
+ ids
184
+ }
181
185
  });
182
186
  if (!response.errors) {
183
187
  OxPrompt.open({
@@ -213,6 +217,7 @@ let CodeManagementDetail = class CodeManagementDetail extends localize(i18next)(
213
217
  CodeManagementDetail.styles = [
214
218
  ScrollbarStyles,
215
219
  ButtonContainerStyles,
220
+ CommonGristStyles,
216
221
  CommonHeaderStyles,
217
222
  css `
218
223
  :host {
@@ -1 +1 @@
1
- {"version":3,"file":"code-management-detail.js","sourceRoot":"","sources":["../../client/pages/code-management-detail.ts"],"names":[],"mappings":";AAAA,OAAO,iCAAiC,CAAA;AACxC,OAAO,wCAAwC,CAAA;AAC/C,OAAO,2CAA2C,CAAA;AAClD,OAAO,0CAA0C,CAAA;AAEjD,OAAO,GAAG,MAAM,aAAa,CAAA;AAC7B,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAA;AAC3C,OAAO,EAAE,aAAa,EAAE,QAAQ,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ox-sorters-control.js'\nimport '@operato/data-grist/ox-record-creator.js'\n\nimport gql from 'graphql-tag'\nimport { css, html, LitElement } from 'lit'\nimport { customElement, property, query, state } from 'lit/decorators.js'\n\nimport { i18next, localize } from '@operato/i18n'\nimport { client, gqlContext, buildArgs } from '@operato/graphql'\nimport { ButtonContainerStyles, CommonHeaderStyles, ScrollbarStyles } from '@operato/styles'\nimport { isMobileDevice } from '@operato/utils'\nimport { OxPrompt } from '@operato/popup/ox-prompt.js'\nimport { DataGrist, FetchOption } from '@operato/data-grist'\n\nimport { getLanguages } from '@things-factory/auth-base/dist-client'\n\n@customElement('code-management-detail')\nexport class CodeManagementDetail extends localize(i18next)(LitElement) {\n static styles = [\n ScrollbarStyles,\n ButtonContainerStyles,\n CommonHeaderStyles,\n css`\n :host {\n display: flex;\n flex-direction: column;\n overflow: hidden;\n background-color: var(--md-sys-color-surface);\n }\n\n ox-grist {\n flex: 1;\n }\n `\n ]\n\n @property({ type: String }) codeId?: string\n @property({ type: Object }) config: any\n\n @state() mode: 'LIST' | 'GRID' = isMobileDevice() ? 'LIST' : 'GRID'\n\n @query('ox-grist') grist!: DataGrist\n\n render() {\n let mode = this.mode\n\n return html`\n <ox-grist .mode=${mode} auto-fetch .config=${this.config} .fetchHandler=${this.fetchHandler.bind(this)}>\n <div slot=\"headroom\" class=\"header\">\n <div class=\"filters\">\n <ox-filters-form></ox-filters-form>\n </div>\n </div>\n </ox-grist>\n\n <div class=\"button-container\">\n <button @click=${this.save}><md-icon>save</md-icon>${String(i18next.t('button.save'))}</button>\n <button @click=${this.delete} danger><md-icon>delete</md-icon>${String(i18next.t('button.delete'))}</button>\n </div>\n `\n }\n\n async firstUpdated() {\n this.config = {\n rows: { selectable: { multiple: true } },\n pagination: { pages: [100, 200, 500] },\n columns: [\n { type: 'gutter', gutterName: 'dirty' },\n { type: 'gutter', gutterName: 'sequence' },\n { type: 'gutter', gutterName: 'row-selector', multiple: true },\n {\n type: 'integer',\n name: 'rank',\n record: { align: 'left', editable: true, format: '#,###' },\n header: i18next.t('field.rank'),\n sortable: true,\n width: 60\n },\n {\n type: 'string',\n name: 'name',\n record: { align: 'left', editable: true },\n header: i18next.t('field.code'),\n sortable: true,\n filter: 'search',\n width: 320\n },\n {\n type: 'i18n-label',\n name: 'labels',\n record: {\n align: 'left',\n editable: true,\n renderer: (value, column, record, rowIndex, field) =>\n html`<span>${value && typeof value == 'object' ? value[i18next.language] : record['description']}</span>`,\n options: {\n objectified: true,\n languages: await getLanguages(),\n displayColumn: 'description'\n }\n },\n header: i18next.t('field.i18n-label'),\n sortable: true,\n filter: 'search',\n width: 370\n },\n {\n type: 'object',\n name: 'updater',\n record: { align: 'left', editable: false },\n header: i18next.t('field.updater'),\n sortable: true,\n width: 90\n },\n {\n type: 'datetime',\n name: 'updatedAt',\n header: i18next.t('field.updated_at'),\n record: { editable: false },\n sortable: true,\n width: 180\n }\n ]\n }\n\n await this.updateComplete\n this.grist.fetch()\n }\n\n async fetchHandler({ filters, page, limit, sorters = [{ name: 'rank' }] }: FetchOption) {\n if (this.codeId) {\n filters!.push({\n name: 'commonCodeId',\n operator: 'eq',\n value: this.codeId\n })\n }\n\n const response = await client.query({\n query: gql`\n query {\n commonCodeDetails(${buildArgs({\n filters,\n pagination: { page, limit },\n sortings: sorters\n })}) {\n items {\n id\n name\n description\n rank\n labels\n updatedAt\n updater{\n name\n description\n }\n }\n total\n }\n }\n `,\n context: gqlContext()\n })\n\n if (!response.errors) {\n return {\n total: response.data.commonCodeDetails.total || 0,\n records: response.data.commonCodeDetails.items || []\n }\n }\n }\n\n async save() {\n const patches = this.getPatches()\n if (!patches?.length) {\n return this.showToast(i18next.t('text.nothing_changed'))\n }\n\n const response = await client.query({\n query: gql`\n mutation updateMultipleCommonCodeDetail($patches: [CommonCodeDetailPatch!]!) {\n updateMultipleCommonCodeDetail(patches: $patches) {\n name\n }\n }\n `,\n variables: { patches },\n context: gqlContext()\n })\n\n if (!response.errors) this.grist.fetch()\n }\n\n async delete() {\n const ids = this.grist.selected.map(record => record.id)\n if (!ids?.length) {\n return this.showToast(i18next.t('text.there_is_nothing_to_delete'))\n }\n\n if (\n await OxPrompt.open({\n type: 'warning',\n title: i18next.t('button.delete'),\n text: i18next.t('text.are_you_sure'),\n confirmButton: { text: i18next.t('button.delete') },\n cancelButton: { text: i18next.t('button.cancel') }\n })\n ) {\n const response = await client.query({\n query: gql`\n mutation {\n deleteCommonCodeDetails(${buildArgs({ ids })})\n }\n `,\n context: gqlContext()\n })\n\n if (!response.errors) {\n OxPrompt.open({\n type: 'success',\n title: i18next.t('text.completed'),\n text: i18next.t('text.data_deleted_successfully'),\n confirmButton: { text: i18next.t('button.confirm') }\n })\n\n this.grist.fetch()\n }\n }\n }\n\n getPatches() {\n let patches = this.grist.dirtyRecords\n if (patches && patches.length) {\n patches = patches.map(code => {\n let patchField: any = code.id ? { id: code.id } : {}\n const dirtyFields = code.__dirtyfields__\n for (let key in dirtyFields) {\n patchField[key] = dirtyFields[key].after\n }\n patchField.commonCode = { id: this.codeId }\n patchField.cuFlag = code.__dirty__\n\n return patchField\n })\n }\n\n return patches\n }\n\n showToast(message) {\n document.dispatchEvent(new CustomEvent('notify', { detail: { message, option: { timer: 1000 } } }))\n }\n}\n"]}
1
+ {"version":3,"file":"code-management-detail.js","sourceRoot":"","sources":["../../client/pages/code-management-detail.ts"],"names":[],"mappings":";AAAA,OAAO,iCAAiC,CAAA;AACxC,OAAO,wCAAwC,CAAA;AAC/C,OAAO,2CAA2C,CAAA;AAClD,OAAO,0CAA0C,CAAA;AAEjD,OAAO,GAAG,MAAM,aAAa,CAAA;AAC7B,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAA;AAC3C,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAEzE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACjD,OAAO,E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B,UAAU,CAAC,GAAG,CAAC,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC,KAAK,CAAA;gBAC1C,CAAC;gBACD,UAAU,CAAC,UAAU,GAAG,EAAE,EAAE,EAAE,IAAI,CAAC,MAAM,EAAE,CAAA;gBAC3C,UAAU,CAAC,MAAM,GAAG,IAAI,CAAC,SAAS,CAAA;gBAElC,OAAO,UAAU,CAAA;YACnB,CAAC,CAAC,CAAA;QACJ,CAAC;QAED,OAAO,OAAO,CAAA;IAChB,CAAC;IAED,SAAS,CAAC,OAAO;QACf,QAAQ,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,QAAQ,EAAE,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC,CAAA;IACrG,CAAC;;AA/OM,2BAAM,GAAG;IACd,eAAe;IACf,qBAAqB;IACrB,iBAAiB;IACjB,kBAAkB;IAClB,GAAG,CAAA;;;;;;;;;;;KAWF;CACF,AAjBY,CAiBZ;AAE2B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;oDAAgB;AACf;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;oDAAY;AAE9B;IAAR,KAAK,EAAE;;kDAA2D;AAEhD;IAAlB,KAAK,CAAC,UAAU,CAAC;8BAAS,SAAS;mDAAA;AAzBzB,oBAAoB;IADhC,aAAa,CAAC,wBAAwB,CAAC;GAC3B,oBAAoB,CAiPhC","sourcesContent":["import '@operato/data-grist/ox-grist.js'\nimport '@operato/data-grist/ox-filters-form.js'\nimport '@operato/data-grist/ox-sorters-control.js'\nimport '@operato/data-grist/ox-record-creator.js'\n\nimport gql from 'graphql-tag'\nimport { css, html, LitElement } from 'lit'\nimport { customElement, property, query, state } from 'lit/decorators.js'\n\nimport { i18next, localize } from '@operato/i18n'\nimport { client } from '@operato/graphql'\nimport { ButtonContainerStyles, CommonGristStyles, CommonHeaderStyles, ScrollbarStyles } from '@operato/styles'\nimport { isMobileDevice, adjustFilters } from '@operato/utils'\nimport { OxPrompt } from '@operato/popup/ox-prompt.js'\nimport { DataGrist, FetchOption, QueryFilter } from '@operato/data-grist'\n\nimport { getLanguages } from '@things-factory/auth-base/dist-client'\n\n@customElement('code-management-detail')\nexport class CodeManagementDetail extends localize(i18next)(LitElement) {\n static styles = [\n ScrollbarStyles,\n ButtonContainerStyles,\n CommonGristStyles,\n CommonHeaderStyles,\n css`\n :host {\n display: flex;\n flex-direction: column;\n overflow: hidden;\n background-color: var(--md-sys-color-surface);\n }\n\n ox-grist {\n flex: 1;\n }\n `\n ]\n\n @property({ type: String }) codeId?: string\n @property({ type: Object }) config: any\n\n @state() mode: 'LIST' | 'GRID' = isMobileDevice() ? 'LIST' : 'GRID'\n\n @query('ox-grist') grist!: DataGrist\n\n render() {\n let mode = this.mode\n\n return html`\n <ox-grist .mode=${mode} auto-fetch .config=${this.config} .fetchHandler=${this.fetchHandler.bind(this)}>\n <div slot=\"headroom\" class=\"header\">\n <div class=\"filters\">\n <ox-filters-form></ox-filters-form>\n </div>\n </div>\n </ox-grist>\n\n <div class=\"footer\">\n <div filler></div>\n <button @click=${this.delete} danger><md-icon>delete</md-icon>${String(i18next.t('button.delete'))}</button>\n <button @click=${this.save} done><md-icon>save</md-icon>${String(i18next.t('button.save'))}</button>\n </div>\n `\n }\n\n async firstUpdated() {\n this.config = {\n rows: { selectable: { multiple: true } },\n pagination: { pages: [100, 200, 500] },\n columns: [\n { type: 'gutter', gutterName: 'dirty' },\n { type: 'gutter', gutterName: 'sequence' },\n { type: 'gutter', gutterName: 'row-selector', multiple: true },\n {\n type: 'integer',\n name: 'rank',\n record: { align: 'left', editable: true, format: '#,###' },\n header: i18next.t('field.rank'),\n sortable: true,\n width: 60\n },\n {\n type: 'string',\n name: 'name',\n record: { align: 'left', editable: true },\n header: i18next.t('field.code'),\n sortable: true,\n filter: 'search',\n width: 320\n },\n {\n type: 'i18n-label',\n name: 'labels',\n record: {\n align: 'left',\n editable: true,\n renderer: (value, column, record, rowIndex, field) =>\n html`<span>${value && typeof value == 'object' ? value[i18next.language] : record['description']}</span>`,\n options: {\n objectified: true,\n languages: await getLanguages(),\n displayColumn: 'description'\n }\n },\n header: i18next.t('field.i18n-label'),\n sortable: true,\n filter: 'search',\n width: 370\n },\n {\n type: 'object',\n name: 'updater',\n record: { align: 'left', editable: false },\n header: i18next.t('field.updater'),\n sortable: true,\n width: 90\n },\n {\n type: 'datetime',\n name: 'updatedAt',\n header: i18next.t('field.updated_at'),\n record: { editable: false },\n sortable: true,\n width: 180\n }\n ]\n }\n\n await this.updateComplete\n this.grist.fetch()\n }\n\n async fetchHandler({ filters, page, limit, sorters = [{ name: 'rank' }] }: FetchOption) {\n if (this.codeId) {\n filters = adjustFilters(filters || [], [\n {\n name: 'commonCode',\n operator: 'eq',\n value: this.codeId\n }\n ]) as QueryFilter[]\n }\n\n const response = await client.query({\n query: gql`\n query CommonCodeDetails($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!]) {\n commonCodeDetails(filters: $filters, pagination: $pagination, sortings: $sortings) {\n items {\n id\n name\n description\n rank\n labels\n updatedAt\n updater {\n name\n description\n }\n }\n total\n }\n }\n `,\n variables: {\n filters,\n pagination: { page, limit },\n sorters\n }\n })\n\n if (!response.errors) {\n return {\n total: response.data.commonCodeDetails.total || 0,\n records: response.data.commonCodeDetails.items || []\n }\n }\n }\n\n async save() {\n const patches = this.getPatches()\n if (!patches?.length) {\n return this.showToast(i18next.t('text.nothing_changed'))\n }\n\n const response = await client.mutate({\n mutation: gql`\n mutation updateMultipleCommonCodeDetail($patches: [CommonCodeDetailPatch!]!) {\n updateMultipleCommonCodeDetail(patches: $patches) {\n name\n }\n }\n `,\n variables: { patches }\n })\n\n if (!response.errors) this.grist.fetch()\n }\n\n async delete() {\n const ids = this.grist.selected.map(record => record.id)\n if (!ids?.length) {\n return this.showToast(i18next.t('text.there_is_nothing_to_delete'))\n }\n\n if (\n await OxPrompt.open({\n type: 'warning',\n title: i18next.t('button.delete'),\n text: i18next.t('text.are_you_sure'),\n confirmButton: { text: i18next.t('button.delete') },\n cancelButton: { text: i18next.t('button.cancel') }\n })\n ) {\n const response = await client.mutate({\n mutation: gql`\n mutation DeleteCommonCodeDetails($ids: [String!]!) {\n deleteCommonCodeDetails(ids: $ids)\n }\n `,\n variables: {\n ids\n }\n })\n\n if (!response.errors) {\n OxPrompt.open({\n type: 'success',\n title: i18next.t('text.completed'),\n text: i18next.t('text.data_deleted_successfully'),\n confirmButton: { text: i18next.t('button.confirm') }\n })\n\n this.grist.fetch()\n }\n }\n }\n\n getPatches() {\n let patches = this.grist.dirtyRecords\n if (patches && patches.length) {\n patches = patches.map(code => {\n let patchField: any = code.id ? { id: code.id } : {}\n const dirtyFields = code.__dirtyfields__\n for (let key in dirtyFields) {\n patchField[key] = dirtyFields[key].after\n }\n patchField.commonCode = { id: this.codeId }\n patchField.cuFlag = code.__dirty__\n\n return patchField\n })\n }\n\n return patches\n }\n\n showToast(message) {\n document.dispatchEvent(new CustomEvent('notify', { detail: { message, option: { timer: 1000 } } }))\n }\n}\n"]}
@@ -12,7 +12,7 @@ export declare class CodeManagement extends CodeManagement_base {
12
12
  data?: any;
13
13
  mode: 'LIST' | 'GRID';
14
14
  grist: DataGrist;
15
- render(): import("lit").TemplateResult<1>;
15
+ render(): import("lit-html").TemplateResult<1>;
16
16
  get context(): {
17
17
  title: string;
18
18
  actions: {
@@ -9,9 +9,9 @@ import { css, html } from 'lit';
9
9
  import { customElement, query, state } from 'lit/decorators.js';
10
10
  import { openPopup } from '@operato/layout';
11
11
  import { i18next, localize } from '@operato/i18n';
12
- import { client, gqlContext, buildArgs } from '@operato/graphql';
12
+ import { client } from '@operato/graphql';
13
13
  import { PageView } from '@operato/shell';
14
- import { CommonButtonStyles, CommonHeaderStyles, ScrollbarStyles } from '@operato/styles';
14
+ import { CommonButtonStyles, CommonGristStyles, CommonHeaderStyles, ScrollbarStyles } from '@operato/styles';
15
15
  import { isMobileDevice } from '@operato/utils';
16
16
  import { DataGrist } from '@operato/data-grist';
17
17
  import { OxPrompt } from '@operato/popup/ox-prompt.js';
@@ -34,7 +34,7 @@ let CodeManagement = class CodeManagement extends localize(i18next)(PageView) {
34
34
  }
35
35
  get context() {
36
36
  return {
37
- title: i18next.t('title.code_management'),
37
+ title: i18next.t('title.code-management'),
38
38
  actions: [
39
39
  Object.assign({ title: i18next.t('button.save'), action: this.save.bind(this) }, CommonButtonStyles.save),
40
40
  Object.assign({ title: i18next.t('button.delete'), action: this.delete.bind(this) }, CommonButtonStyles.delete)
@@ -106,18 +106,14 @@ let CodeManagement = class CodeManagement extends localize(i18next)(PageView) {
106
106
  async fetchHandler({ filters, page, limit, sorters = [{ name: 'name' }, { name: 'updatedAt' }] }) {
107
107
  const response = await client.query({
108
108
  query: gql `
109
- query {
110
- commonCodes(${buildArgs({
111
- filters,
112
- pagination: { page, limit },
113
- sortings: sorters
114
- })}) {
109
+ query CommonCodes($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!]) {
110
+ commonCodes(filters: $filters, pagination: $pagination, sortings: $sortings) {
115
111
  items {
116
112
  id
117
113
  name
118
114
  description
119
115
  updatedAt
120
- updater{
116
+ updater {
121
117
  id
122
118
  name
123
119
  description
@@ -127,7 +123,11 @@ let CodeManagement = class CodeManagement extends localize(i18next)(PageView) {
127
123
  }
128
124
  }
129
125
  `,
130
- context: gqlContext()
126
+ variables: {
127
+ filters,
128
+ pagination: { page, limit },
129
+ sorters
130
+ }
131
131
  });
132
132
  return {
133
133
  total: response.data.commonCodes.total || 0,
@@ -139,17 +139,15 @@ let CodeManagement = class CodeManagement extends localize(i18next)(PageView) {
139
139
  if (!(patches === null || patches === void 0 ? void 0 : patches.length)) {
140
140
  return this.showToast(i18next.t('text.nothing_changed'));
141
141
  }
142
- const response = await client.query({
143
- query: gql `
144
- mutation {
145
- updateMultipleCommonCode(${buildArgs({
146
- patches
147
- })}) {
148
- name
149
- }
142
+ const response = await client.mutate({
143
+ mutation: gql `
144
+ mutation UpdateMultipleCommonCode($patches: [CommonCodePatch!]!) {
145
+ updateMultipleCommonCode(patches: $patches) {
146
+ name
150
147
  }
151
- `,
152
- context: gqlContext()
148
+ }
149
+ `,
150
+ variables: { patches }
153
151
  });
154
152
  if (!response.errors) {
155
153
  this.showToast(i18next.t('text.data_updated_successfully'));
@@ -168,13 +166,15 @@ let CodeManagement = class CodeManagement extends localize(i18next)(PageView) {
168
166
  confirmButton: { text: i18next.t('button.delete') },
169
167
  cancelButton: { text: i18next.t('button.cancel') }
170
168
  })) {
171
- const response = await client.query({
172
- query: gql `
173
- mutation {
174
- deleteCommonCodes(${buildArgs({ ids })})
169
+ const response = await client.mutate({
170
+ mutation: gql `
171
+ mutation DeleteCommonCodes($ids: [String!]!) {
172
+ deleteCommonCodes(ids: $ids)
175
173
  }
176
174
  `,
177
- context: gqlContext()
175
+ variables: {
176
+ ids
177
+ }
178
178
  });
179
179
  if (!response.errors) {
180
180
  OxPrompt.open({
@@ -206,7 +206,7 @@ let CodeManagement = class CodeManagement extends localize(i18next)(PageView) {
206
206
  openPopup(html ` <code-management-detail .codeId="${codeId}"></code-management-detail> `, {
207
207
  backdrop: true,
208
208
  size: 'large',
209
- title: `${i18next.t('title.code_management_detail')} - ${codeName}`
209
+ title: `${i18next.t('title.code-management-detail')} - ${codeName}`
210
210
  });
211
211
  }
212
212
  showToast(message) {
@@ -215,13 +215,25 @@ let CodeManagement = class CodeManagement extends localize(i18next)(PageView) {
215
215
  };
216
216
  CodeManagement.styles = [
217
217
  ScrollbarStyles,
218
+ CommonGristStyles,
218
219
  CommonHeaderStyles,
219
220
  css `
220
221
  :host {
221
222
  display: flex;
222
- flex-direction: column;
223
223
 
224
- overflow: hidden;
224
+ width: 100%;
225
+
226
+ --grid-record-emphasized-background-color: #8b0000;
227
+ --grid-record-emphasized-color: #ff6b6b;
228
+ }
229
+
230
+ ox-grist {
231
+ overflow-y: auto;
232
+ flex: 1;
233
+ }
234
+
235
+ .header {
236
+ grid-template-areas: 'filters actions';
225
237
  }
226
238
  `
227
239
  ];