@things-factory/product-ui 4.0.25 → 4.0.26

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.
@@ -361,8 +361,8 @@ class ProductBundleLinkPopup extends localize(i18next)(LitElement) {
361
361
  const productBundleId = this.record?.id
362
362
 
363
363
  if (productBundleId && patches) {
364
- const response = await client.query({
365
- query: gql`
364
+ const response = await client.mutate({
365
+ mutation: gql`
366
366
  mutation linkProductBundle($productBundleId: String!, $patches: [ProductBundleSettingPatch!]!) {
367
367
  linkProductBundle(productBundleId: $productBundleId, patches: $patches)
368
368
  }
@@ -349,8 +349,8 @@ class ProductCombinationSettingsPopup extends localize(i18next)(LitElement) {
349
349
  })
350
350
  const productCombinationId = this.record?.id
351
351
  if (productCombinationId && patches) {
352
- const response = await client.query({
353
- query: gql`
352
+ const response = await client.mutate({
353
+ mutation: gql`
354
354
  mutation linkProductCombination(
355
355
  $productCombinationId: String!
356
356
  $patches: [ProductCombinationSettingPatch!]!
@@ -284,8 +284,8 @@ class ProductCombinationsPopup extends localize(i18next)(LitElement) {
284
284
 
285
285
  if (!answer.value) return
286
286
 
287
- const response = await client.query({
288
- query: gql`
287
+ const response = await client.mutate({
288
+ mutation: gql`
289
289
  mutation deleteProductCombination($id: String!) {
290
290
  deleteProductCombination(id: $id)
291
291
  }
@@ -320,8 +320,8 @@ class ProductCombinationsPopup extends localize(i18next)(LitElement) {
320
320
  }
321
321
  })
322
322
  if (patches) {
323
- const response = await client.query({
324
- query: gql`
323
+ const response = await client.mutate({
324
+ mutation: gql`
325
325
  mutation updateMultipleProductCombination(
326
326
  $productDetailId: String!
327
327
  $patches: [ProductCombinationPatch!]!
@@ -3,8 +3,8 @@ import '@things-factory/form-ui'
3
3
  import '@things-factory/grist-ui'
4
4
  import { i18next, localize } from '@things-factory/i18n-base'
5
5
  import { client, CustomAlert, gqlContext } from '@things-factory/shell'
6
- import { ScrollbarStyles, CommonButtonStyles } from '@things-factory/styles'
7
- import { gqlBuilder, isMobileDevice } from '@things-factory/utils'
6
+ import { ScrollbarStyles } from '@things-factory/styles'
7
+ import { isMobileDevice } from '@things-factory/utils'
8
8
  import gql from 'graphql-tag'
9
9
  import { css, html, LitElement } from 'lit-element'
10
10
 
@@ -635,9 +635,9 @@ export class ProductSetLinkPopup extends localize(i18next)(LitElement) {
635
635
  })
636
636
  let productSetId = this.productSetId
637
637
  if (this.productSetId && patches) {
638
- const response = await client.query({
639
- query: gql`
640
- mutation($productSetId: String!, $patches: [ProductPatch]!) {
638
+ const response = await client.mutate({
639
+ mutation: gql`
640
+ mutation ($productSetId: String!, $patches: [ProductPatch]!) {
641
641
  linkProduct(productSetId: $productSetId, patches: $patches)
642
642
  }
643
643
  `,
package/client/route.js CHANGED
@@ -11,9 +11,5 @@ export default function route(page) {
11
11
  case 'products':
12
12
  import('./pages/product-list')
13
13
  return page
14
-
15
- case 'product_option_list':
16
- import('./pages/product-option-list')
17
- return page
18
14
  }
19
15
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@things-factory/product-ui",
3
- "version": "4.0.25",
3
+ "version": "4.0.26",
4
4
  "main": "dist-server/index.js",
5
5
  "browser": "client/index.js",
6
6
  "things-factory": true,
@@ -24,13 +24,13 @@
24
24
  "migration:create": "node ../../node_modules/typeorm/cli.js migration:create -d ./server/migrations"
25
25
  },
26
26
  "dependencies": {
27
- "@things-factory/form-ui": "^4.0.25",
28
- "@things-factory/grist-ui": "^4.0.25",
29
- "@things-factory/i18n-base": "^4.0.25",
30
- "@things-factory/import-ui": "^4.0.25",
31
- "@things-factory/layout-base": "^4.0.25",
32
- "@things-factory/product-base": "^4.0.25",
33
- "@things-factory/shell": "^4.0.25"
27
+ "@things-factory/form-ui": "^4.0.26",
28
+ "@things-factory/grist-ui": "^4.0.26",
29
+ "@things-factory/i18n-base": "^4.0.26",
30
+ "@things-factory/import-ui": "^4.0.26",
31
+ "@things-factory/layout-base": "^4.0.26",
32
+ "@things-factory/product-base": "^4.0.26",
33
+ "@things-factory/shell": "^4.0.26"
34
34
  },
35
- "gitHead": "9c44141d651dab7b4a9c0f0b6fecb8d6937d116f"
35
+ "gitHead": "c4b39c74b9ce2472f30c26eb36ec62054c1ecf82"
36
36
  }
@@ -15,10 +15,6 @@ export default {
15
15
  {
16
16
  tagname: 'product-list',
17
17
  page: 'products'
18
- },
19
- {
20
- tagname: 'product-option-list',
21
- page: 'product_option_list'
22
18
  }
23
19
  ],
24
20
  bootstrap
@@ -1,254 +0,0 @@
1
- import '@things-factory/form-ui'
2
- import '@things-factory/grist-ui'
3
- import { i18next, localize } from '@things-factory/i18n-base'
4
- import { openPopup } from '@things-factory/layout-base'
5
- import { client, CustomAlert, PageView } from '@things-factory/shell'
6
- import { ScrollbarStyles, CommonButtonStyles } from '@things-factory/styles'
7
- import { gqlBuilder, isMobileDevice } from '@things-factory/utils'
8
- import gql from 'graphql-tag'
9
- import { css, html } from 'lit-element'
10
- import './product-option-values'
11
-
12
- class ProductOptionList extends localize(i18next)(PageView) {
13
- static get properties() {
14
- return {
15
- searchFields: Array,
16
- config: Object
17
- }
18
- }
19
-
20
- static get styles() {
21
- return [
22
- ScrollbarStyles,
23
- css`
24
- :host {
25
- display: flex;
26
- flex-direction: column;
27
- overflow: hidden;
28
- }
29
- search-form {
30
- overflow: visible;
31
- }
32
- data-grist {
33
- overflow-y: auto;
34
- flex: 1;
35
- }
36
- `
37
- ]
38
- }
39
-
40
- render() {
41
- return html`
42
- <search-form .fields=${this.searchFields} @submit=${e => this.dataGrist.fetch()}></search-form>
43
-
44
- <data-grist
45
- .mode=${isMobileDevice() ? 'LIST' : 'GRID'}
46
- .config=${this.config}
47
- .data=${this.data}
48
- .fetchHandler="${this.fetchHandler.bind(this)}"
49
- ></data-grist>
50
- `
51
- }
52
-
53
- get context() {
54
- return {
55
- title: i18next.t('title.product_option'),
56
- actions: [
57
- {
58
- title: i18next.t('button.save'),
59
- action: () => this._saveProductOption(this.dataGrist.exportPatchList({ flagName: 'cuFlag ' })),
60
- ...CommonButtonStyles.save
61
- },
62
- {
63
- title: i18next.t('button.delete'),
64
- action: this._deleteProductOption.bind(this),
65
- ...CommonButtonStyles.delete
66
- }
67
- ]
68
- }
69
- }
70
-
71
- get searchForm() {
72
- return this.shadowRoot.querySelector('search-form')
73
- }
74
-
75
- get dataGrist() {
76
- return this.shadowRoot.querySelector('data-grist')
77
- }
78
-
79
- pageInitialized() {
80
- this.searchFields = [
81
- {
82
- label: i18next.t('field.name'),
83
- name: 'name',
84
- props: {
85
- searchOper: 'i_like'
86
- }
87
- }
88
- ]
89
-
90
- this.config = {
91
- rows: {
92
- selectable: { multiple: true }
93
- },
94
- columns: [
95
- { type: 'gutter', gutterName: 'dirty' },
96
- { type: 'gutter', gutterName: 'sequence' },
97
- { type: 'gutter', gutterName: 'row-selector', multiple: true },
98
- {
99
- type: 'gutter',
100
- gutterName: 'button',
101
- icon: 'reorder',
102
- handlers: {
103
- click: (_columns, _data, _column, record, _rowIndex) => {
104
- if (record.id) this._openProductOptionValue(record.id, record.name)
105
- }
106
- }
107
- },
108
- {
109
- type: 'string',
110
- name: 'name',
111
- record: { editable: true },
112
- header: i18next.t('field.name'),
113
- sortable: true,
114
- width: 200
115
- },
116
- {
117
- type: 'string',
118
- name: 'description',
119
- record: { editable: true },
120
- header: i18next.t('field.description'),
121
- sortable: true,
122
- width: 400
123
- },
124
- {
125
- type: 'object',
126
- name: 'updater',
127
- record: { align: 'center', editable: false },
128
- header: i18next.t('field.updater'),
129
- width: 250
130
- },
131
- {
132
- type: 'datetime',
133
- name: 'updatedAt',
134
- record: { align: 'center', editable: false },
135
- header: i18next.t('field.updated_at'),
136
- sortable: true,
137
- width: 180
138
- }
139
- ]
140
- }
141
- }
142
-
143
- pageUpdated(changes, lifecycle) {
144
- if (this.active) {
145
- this.dataGrist.fetch()
146
- }
147
- }
148
-
149
- async fetchHandler({ page, limit, sorters = [{ name: 'name' }] }) {
150
- const response = await client.query({
151
- query: gql`
152
- query {
153
- productOptions(${gqlBuilder.buildArgs({
154
- filters: await this.searchForm.getQueryFilters(),
155
- pagination: { page, limit },
156
- sortings: sorters
157
- })}) {
158
- items {
159
- id
160
- name
161
- description
162
- updater {
163
- name
164
- description
165
- }
166
- updatedAt
167
- }
168
- total
169
- }
170
- }
171
- `
172
- })
173
-
174
- if (!response.errors) {
175
- return {
176
- total: response.data.productOptions.total || 0,
177
- records: response.data.productOptions.items || []
178
- }
179
- }
180
- }
181
-
182
- async _saveProductOption(patches) {
183
- if (patches && patches.length) {
184
- const response = await client.query({
185
- query: gql`
186
- mutation {
187
- updateMultipleProductOption(${gqlBuilder.buildArgs({
188
- patches
189
- })}) {
190
- name
191
- }
192
- }
193
- `
194
- })
195
-
196
- if (!response.errors) {
197
- this.dataGrist.fetch()
198
- this.showToast(i18next.t('text.data_updated_successfully'))
199
- }
200
- } else {
201
- CustomAlert({
202
- title: i18next.t('text.nothing_changed'),
203
- text: i18next.t('text.there_is_nothing_to_save')
204
- })
205
- }
206
- }
207
-
208
- async _deleteProductOption() {
209
- const ids = this.dataGrist.selected.map(record => record.id)
210
- if (ids && ids.length) {
211
- const anwer = await CustomAlert({
212
- type: 'warning',
213
- title: i18next.t('button.delete'),
214
- text: i18next.t('text.are_you_sure'),
215
- confirmButton: { text: i18next.t('button.delete') },
216
- cancelButton: { text: i18next.t('button.cancel') }
217
- })
218
-
219
- if (!anwer.value) return
220
-
221
- const response = await client.query({
222
- query: gql`
223
- mutation {
224
- deleteProductOptions(${gqlBuilder.buildArgs({ ids })})
225
- }
226
- `
227
- })
228
-
229
- if (!response.errors) {
230
- this.dataGrist.fetch()
231
- this.showToast(i18next.t('text.data_deleted_successfully'))
232
- }
233
- } else {
234
- CustomAlert({
235
- title: i18next.t('text.nothing_selected'),
236
- text: i18next.t('text.there_is_nothing_to_delete')
237
- })
238
- }
239
- }
240
-
241
- showToast(message) {
242
- document.dispatchEvent(new CustomEvent('notify', { detail: { message } }))
243
- }
244
-
245
- _openProductOptionValue(id, name) {
246
- openPopup(html` <product-option-values .productOptionId="${id}"></product-option-values> `, {
247
- backdrop: true,
248
- size: 'large',
249
- title: i18next.t('title.product_option_values') + '(' + name + ')'
250
- })
251
- }
252
- }
253
-
254
- window.customElements.define('product-option-list', ProductOptionList)
@@ -1,261 +0,0 @@
1
- import '@things-factory/form-ui'
2
- import '@things-factory/grist-ui'
3
- import { i18next, localize } from '@things-factory/i18n-base'
4
- import { client, CustomAlert } from '@things-factory/shell'
5
- import { ScrollbarStyles, CommonButtonStyles } from '@things-factory/styles'
6
- import { gqlBuilder, isMobileDevice } from '@things-factory/utils'
7
- import gql from 'graphql-tag'
8
- import { css, html, LitElement } from 'lit-element'
9
-
10
- export class ProductOptionValues extends localize(i18next)(LitElement) {
11
- static get styles() {
12
- return [
13
- ScrollbarStyles,
14
- css`
15
- :host {
16
- display: flex;
17
- flex-direction: column;
18
- overflow: hidden;
19
- background-color: white;
20
- }
21
- search-form {
22
- overflow: visible;
23
- }
24
- .grist {
25
- display: flex;
26
- flex-direction: column;
27
- flex: 1;
28
- overflow-y: auto;
29
- }
30
- data-grist {
31
- overflow-y: hidden;
32
- flex: 1;
33
- }
34
- .button-container {
35
- padding: 10px 0 12px 0;
36
- text-align: center;
37
- }
38
- .button-container > button {
39
- background-color: var(--button-background-color);
40
- border: var(--button-border);
41
- border-radius: var(--button-border-radius);
42
- margin: var(--button-margin);
43
- padding: var(--button-padding);
44
- color: var(--button-color);
45
- font: var(--button-font);
46
- text-transform: var(--button-text-transform);
47
- }
48
- .button-container > button:hover,
49
- .button-container > button:active {
50
- background-color: var(--button-background-focus-color);
51
- }
52
- `
53
- ]
54
- }
55
-
56
- static get properties() {
57
- return {
58
- productOptionId: String,
59
- searchFields: Array,
60
- config: Object
61
- }
62
- }
63
-
64
- get searchForm() {
65
- return this.shadowRoot.querySelector('search-form')
66
- }
67
-
68
- get dataGrist() {
69
- return this.shadowRoot.querySelector('data-grist')
70
- }
71
-
72
- render() {
73
- return html`
74
- <search-form .fields=${this.searchFields} @submit=${e => this.dataGrist.fetch()}></search-form>
75
-
76
- <div class="grist">
77
- <data-grist
78
- .mode=${isMobileDevice() ? 'LIST' : 'GRID'}
79
- .config=${this.config}
80
- .fetchHandler=${this.fetchHandler.bind(this)}
81
- ></data-grist>
82
- </div>
83
-
84
- <div class="button-container">
85
- <mwc-button @click=${this._saveProductOptionValues}>${i18next.t('button.save')}</mwc-button>
86
- <mwc-button @click=${this._deleteProductOptionValues}>${i18next.t('button.delete')}</mwc-button>
87
- </div>
88
- `
89
- }
90
-
91
- firstUpdated() {
92
- this.searchFields = [
93
- {
94
- label: i18next.t('field.name'),
95
- name: 'name',
96
- type: 'text',
97
- props: { searchOper: 'i_like' }
98
- },
99
- {
100
- label: i18next.t('field.description'),
101
- name: 'description',
102
- type: 'text',
103
- props: { searchOper: 'i_like' }
104
- }
105
- ]
106
-
107
- this.config = {
108
- rows: {
109
- selectable: {
110
- multiple: true
111
- }
112
- },
113
- columns: [
114
- { type: 'gutter', gutterName: 'dirty' },
115
- { type: 'gutter', gutterName: 'sequence' },
116
- { type: 'gutter', gutterName: 'row-selector', multiple: true },
117
- {
118
- type: 'string',
119
- name: 'name',
120
- record: { align: 'left', editable: true },
121
- header: i18next.t('field.name'),
122
- width: 120
123
- },
124
- {
125
- type: 'string',
126
- name: 'description',
127
- record: { align: 'left', editable: true },
128
- header: i18next.t('field.description'),
129
- width: 220
130
- },
131
- {
132
- type: 'object',
133
- name: 'updater',
134
- record: { align: 'left', editable: false },
135
- header: i18next.t('field.updater'),
136
- width: 150
137
- },
138
- {
139
- type: 'datetime',
140
- name: 'updatedAt',
141
- record: { align: 'left', editable: false },
142
- header: i18next.t('field.updated_at'),
143
- width: 150
144
- }
145
- ]
146
- }
147
- }
148
-
149
- async fetchHandler({ page, limit, sorters = [{ name: 'name' }] }) {
150
- let filters = []
151
- if (this.productOptionId) {
152
- filters.push({
153
- name: 'productOption',
154
- operator: 'eq',
155
- value: this.productOptionId
156
- })
157
- }
158
-
159
- const response = await client.query({
160
- query: gql`
161
- query {
162
- productOptionValues(${gqlBuilder.buildArgs({
163
- filters: [...filters, ...this.searchForm.queryFilters],
164
- pagination: { page, limit },
165
- sortings: sorters
166
- })}) {
167
- items {
168
- id
169
- name
170
- description
171
- updatedAt
172
- updater{
173
- name
174
- description
175
- }
176
- }
177
- total
178
- }
179
- }
180
- `
181
- })
182
-
183
- return {
184
- total: response.data.productOptionValues.total || 0,
185
- records: response.data.productOptionValues.items || []
186
- }
187
- }
188
-
189
- async _saveProductOptionValues() {
190
- let patches = this.dataGrist.exportPatchList({ flagName: 'cuFlag' })
191
- if (patches && patches.length) {
192
- patches = patches.map(productOptionValue => {
193
- return {
194
- ...productOptionValue,
195
- productOption: { id: this.productOptionId }
196
- }
197
- })
198
-
199
- const response = await client.query({
200
- query: gql`
201
- mutation {
202
- updateMultipleProductOptionValue(${gqlBuilder.buildArgs({
203
- patches
204
- })}) {
205
- name
206
- description
207
- }
208
- }
209
- `
210
- })
211
-
212
- if (!response.errors) {
213
- this.dataGrist.fetch()
214
- this.showToast(i18next.t('text.data_updated_successfully'))
215
- }
216
- } else {
217
- CustomAlert({
218
- title: i18next.t('text.nothing_changed'),
219
- text: i18next.t('text.there_is_nothing_to_save')
220
- })
221
- }
222
- }
223
-
224
- async _deleteProductOptionValues() {
225
- const ids = this.dataGrist.selected.map(record => record.id)
226
- if (ids && ids.length > 0) {
227
- const anwer = await CustomAlert({
228
- type: 'warning',
229
- title: i18next.t('button.delete'),
230
- text: i18next.t('text.are_you_sure'),
231
- confirmButton: { text: i18next.t('button.delete') },
232
- cancelButton: { text: i18next.t('button.cancel') }
233
- })
234
-
235
- if (!anwer.value) return
236
-
237
- const response = await client.query({
238
- query: gql`
239
- mutation {
240
- deleteProductOptionValues(${gqlBuilder.buildArgs({ ids })})
241
- }
242
- `
243
- })
244
- if (!response.errors) {
245
- this.dataGrist.fetch()
246
- this.showToast(i18next.t('text.data_deleted_successfully'))
247
- }
248
- } else {
249
- CustomAlert({
250
- title: i18next.t('text.nothing_selected'),
251
- text: i18next.t('text.there_is_nothing_to_delete')
252
- })
253
- }
254
- }
255
-
256
- showToast(message) {
257
- document.dispatchEvent(new CustomEvent('notify', { detail: { message } }))
258
- }
259
- }
260
-
261
- window.customElements.define('product-option-values', ProductOptionValues)