@things-factory/operato-wms 3.8.13 → 3.8.15

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.
@@ -665,6 +665,7 @@ class LocationList extends connect(store)(localize(i18next)(PageView)) {
665
665
 
666
666
  /* for location record mapping */
667
667
  searchParams.append('location', record.name)
668
+ searchParams.append('originalName', record.originalName)
668
669
  searchParams.append('label', record.indicator)
669
670
 
670
671
  try {
@@ -1,12 +1,14 @@
1
1
  import '@things-factory/form-ui'
2
- import { MultiColumnFormStyles } from '@things-factory/form-ui'
3
2
  import '@things-factory/grist-ui'
3
+
4
+ import gql from 'graphql-tag'
5
+ import { css, html, LitElement } from 'lit-element'
6
+
7
+ import { MultiColumnFormStyles } from '@things-factory/form-ui'
4
8
  import { i18next, localize } from '@things-factory/i18n-base'
5
9
  import { client } from '@things-factory/shell'
6
10
  import { ScrollbarStyles } from '@things-factory/styles'
7
- import { gqlBuilder, isMobileDevice } from '@things-factory/utils'
8
- import gql from 'graphql-tag'
9
- import { css, html, LitElement } from 'lit-element'
11
+ import { isMobileDevice } from '@things-factory/utils'
10
12
 
11
13
  export class PrintLocationLabel extends localize(i18next)(LitElement) {
12
14
  static get properties() {
@@ -91,27 +93,24 @@ export class PrintLocationLabel extends localize(i18next)(LitElement) {
91
93
  <fieldset>
92
94
  <label>${i18next.t('label.label_format')}</label>
93
95
  <select
94
- name="labelFormat"
96
+ name="labelFormat"
95
97
  @change="${e => {
96
- this._fullLocationFormat =
97
- e.currentTarget.value === 'full_format'
98
- ? true
99
- : false
100
- if (this._labelIndicator.value != '') {
101
- this._getPrintPreview(this._labelIndicator.value)
102
- }
103
- }}">
98
+ this._fullLocationFormat = e.currentTarget.value === 'full_format' ? true : false
99
+ if (this._labelIndicator.value != '') this.dataGrist.fetch()
100
+ }}"
101
+ >
104
102
  <option value="full_format">A-01-01-01 (${i18next.t('text.full_format')})</option>
105
103
  <option value="partial_format">A-01-01 (${i18next.t('text.partial_format')})</option>
106
104
  </select>
107
105
 
108
106
  <label>${i18next.t('label.label_indicator')}</label>
109
- <select name="labelIndicator"
107
+ <select
108
+ name="labelIndicator"
110
109
  @change="${e => {
111
110
  let indicator = e.currentTarget.value
112
- if (indicator !== '')
113
- this._getPrintPreview(indicator)
114
- }}">
111
+ if (indicator !== '') this.dataGrist.fetch()
112
+ }}"
113
+ >
115
114
  <option value="">-- ${i18next.t('text.please_select_label_indicator')} --</option>
116
115
  <option value="zone">${i18next.t('label.zone')}</option>
117
116
  <option value="row">${i18next.t('label.row')}</option>
@@ -151,6 +150,12 @@ export class PrintLocationLabel extends localize(i18next)(LitElement) {
151
150
  header: i18next.t('field.name'),
152
151
  width: 250
153
152
  },
153
+ {
154
+ type: 'string',
155
+ name: 'originalName',
156
+ header: i18next.t('field.original_name'),
157
+ width: 250
158
+ },
154
159
  {
155
160
  type: 'string',
156
161
  name: 'indicator',
@@ -159,11 +164,6 @@ export class PrintLocationLabel extends localize(i18next)(LitElement) {
159
164
  }
160
165
  ]
161
166
  }
162
-
163
- if (this.selectedLocations && this.selectedLocations.length > 0) {
164
- this._records = []
165
- this._total = 0
166
- }
167
167
  }
168
168
 
169
169
  get _labelIndicator() {
@@ -174,171 +174,157 @@ export class PrintLocationLabel extends localize(i18next)(LitElement) {
174
174
  return this.shadowRoot.querySelector('data-grist')
175
175
  }
176
176
 
177
- async fetchHandler() {
178
- return {
179
- records: this._records || [],
180
- total: this._total || 0
181
- }
182
- }
177
+ async fetchHandler({ page, limit, sorters = [{ name: 'name' }] }) {
178
+ if (this._labelIndicator.value == '') return
179
+ const fetcherDetail = { page, limit, sorters }
180
+ const indicator = this._labelIndicator.value || ''
183
181
 
184
- async _getPrintPreview(indicator) {
185
- let locations = []
186
- let filters = []
182
+ let filters = [
183
+ {
184
+ name: 'warehouse_id',
185
+ operator: 'eq',
186
+ value: this.warehouseId
187
+ }
188
+ ]
189
+
190
+ let locations = [],
191
+ totalLocations = 0
187
192
 
188
- if (this.selectedLocations && this.selectedLocations.length > 0) {
189
- locations = this.selectedLocations
193
+ if (this.selectedLocations && this.selectedLocations.length) {
194
+ filters.push({
195
+ name: 'name',
196
+ operator: 'in',
197
+ value: this.selectedLocations.map(location => location.name)
198
+ })
199
+ const { records, total } = await this._fetchLocations(filters, fetcherDetail)
200
+ locations = records
201
+ totalLocations = total
190
202
  } else {
191
- if (this.warehouseId) {
192
- if (this._fullLocationFormat) {
193
- filters = [
194
- {
195
- name: 'warehouse_id',
196
- operator: 'eq',
197
- value: this.warehouseId
198
- },
199
- {
200
- name: 'type',
201
- operator: 'noteq',
202
- value: 'BUFFER'
203
- }
204
- ]
205
- locations = await this._fetchLocations(filters)
206
- }
203
+ if (this._fullLocationFormat) {
204
+ filters.push({
205
+ name: 'type',
206
+ operator: 'noteq',
207
+ value: 'BUFFER'
208
+ })
209
+ const { records, total } = await this._fetchLocations(filters, fetcherDetail)
210
+ locations = records
211
+ totalLocations = total
212
+ } else {
207
213
  // if partial format:
208
- // prevent from printing same location label. eg: A-01-01-01, A-01-01-02 > will print A-01-01 twice
209
- else {
210
- if (indicator === 'shelf') {
211
- this._showToast({
212
- level: 'error',
213
- message: i18next.t('text.shelf_is_not_allowed_as_an_indicator_for_partial_format')
214
- })
215
- return
216
- } else {
217
- filters = [{
218
- name: 'warehouse_id',
219
- operator: 'eq',
220
- value: this.warehouseId
221
- }]
222
- locations = await this._fetchLocationsByGroup(filters)
223
- }
214
+ // prevent from printing same location label. eg: A-01-01-01, A-01-01-02 > will print A-01-01 twice{
215
+ if (indicator == 'shelf') {
216
+ this._showToast({
217
+ level: 'error',
218
+ message: i18next.t('text.shelf_is_not_allowed_as_an_indicator_for_partial_format')
219
+ })
220
+ return
221
+ } else {
222
+ const { records, total } = await this._fetchLocationsByGroup(filters, fetcherDetail)
223
+ locations = records
224
+ totalLocations = total
224
225
  }
225
226
  }
226
227
  }
227
228
 
228
- locations = locations.map(location => {
229
- if (location.type === 'BUFFER') {
230
- return {
231
- ...location,
232
- indicator: location[indicator]
233
- }
234
- }
235
-
236
- else {
229
+ return {
230
+ total: totalLocations,
231
+ records: locations.map(location => {
237
232
  return {
238
233
  ...location,
239
- name: this._fullLocationFormat // check if full location format is true
240
- ? `${location.zone}-${location.row}-${location.column}-${location.shelf}`
241
- : `${location.zone}-${location.row}-${location.column}`,
242
- indicator: location[indicator]
234
+ indicator: location[indicator],
235
+ originalName: location.name,
236
+ name:
237
+ location.type === 'BUFFER'
238
+ ? ''
239
+ : this._fullLocationFormat // check if full location format is true
240
+ ? `${location.zone}-${location.row}-${location.column}-${location.shelf}`
241
+ : `${location.zone}-${location.row}-${location.column}`
243
242
  }
244
- }
245
- })
246
-
247
- this._records = locations
248
- this._total = locations.length
249
-
250
- this._config = {
251
- ...this._config,
252
- pagination: { pages: [20, 50, 100, 200] }
243
+ })
253
244
  }
254
-
255
- this.dataGrist.fetch()
256
245
  }
257
246
 
258
- async _fetchLocations(filters) {
259
- const sorters = [{ name: 'name', desc: false }]
260
-
261
- if (this.warehouseId) {
262
- try {
263
- this.dataGrist.showSpinner()
264
-
265
- const response = await client.query({
266
- query: gql`
267
- query {
268
- locations(${gqlBuilder.buildArgs({
269
- filters,
270
- sortings: sorters
271
- })}) {
272
- items {
273
- name
274
- zone
275
- row
276
- column
277
- shelf
278
- }
279
- total
247
+ async _fetchLocations(filters, fetcherDetail) {
248
+ try {
249
+ const response = await client.query({
250
+ query: gql`
251
+ query locations($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!]) {
252
+ locations(filters: $filters, pagination: $pagination, sortings: $sortings) {
253
+ items {
254
+ name
255
+ zone
256
+ row
257
+ column
258
+ shelf
259
+ type
280
260
  }
261
+ total
281
262
  }
282
- `
283
- })
263
+ }
264
+ `,
265
+ variables: {
266
+ filters,
267
+ paginations: { page: fetcherDetail.page, limit: fetcherDetail.limit },
268
+ sortings: fetcherDetail.sorters
269
+ }
270
+ })
284
271
 
285
- if (!response.errors) {
286
- return response.data.locations.items || []
272
+ if (!response.errors) {
273
+ return {
274
+ records: response.data.locations.items || [],
275
+ total: response.data.locations.total || 0
287
276
  }
288
- } catch (e) {
289
- this._showToast({
290
- level: 'error',
291
- message: e
292
- })
293
- } finally {
294
- this.dataGrist.hideSpinner()
295
277
  }
278
+ } catch (e) {
279
+ this._showToast({
280
+ level: 'error',
281
+ message: e
282
+ })
296
283
  }
297
284
  }
298
285
 
299
- async _fetchLocationsByGroup(filters) {
300
- const sorters = [{ name: 'name', desc: false }]
301
-
302
- if (this.warehouseId) {
303
- try {
304
- this.dataGrist.showSpinner()
305
-
306
- const response = await client.query({
307
- query: gql`
308
- query {
309
- locationsByGroup(${gqlBuilder.buildArgs({
310
- filters,
311
- sortings: sorters
312
- })}) {
313
- items {
314
- name
315
- zone
316
- row
317
- column
318
- }
319
- total
286
+ async _fetchLocationsByGroup(filters, fetcherDetail) {
287
+ try {
288
+ const response = await client.query({
289
+ query: gql`
290
+ query locationsByGroup($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!]) {
291
+ locationsByGroup(filters: $filters, pagination: $pagination, sortings: $sortings) {
292
+ items {
293
+ name
294
+ zone
295
+ row
296
+ column
297
+ type
320
298
  }
299
+ total
321
300
  }
322
- `
323
- })
301
+ }
302
+ `,
303
+ variables: {
304
+ filters,
305
+ paginations: { page: fetcherDetail.page, limit: fetcherDetail.limit },
306
+ sortings: fetcherDetail.sorters
307
+ }
308
+ })
324
309
 
325
- if (!response.errors) {
326
- return response.data.locationsByGroup.items || []
310
+ if (!response.errors) {
311
+ return {
312
+ records: response.data.locationsByGroup.items || [],
313
+ total: response.data.locationsByGroup.total || 0
327
314
  }
328
- } catch (e) {
329
- this._showToast({
330
- level: 'error',
331
- message: e
332
- })
333
- } finally {
334
- this.dataGrist.hideSpinner()
335
315
  }
316
+ } catch (e) {
317
+ this._showToast({
318
+ level: 'error',
319
+ message: e
320
+ })
336
321
  }
337
322
  }
338
323
 
339
324
  _printLocations() {
340
- if (this._records && this._records.length > 0) {
341
- this.dispatchEvent(new CustomEvent(i18next.t('text.printing'), { detail: this._records }))
325
+ const records = this.dataGrist.data && this.dataGrist.data.records
326
+ if (records && records.length) {
327
+ this.dispatchEvent(new CustomEvent(i18next.t('text.printing'), { detail: records }))
342
328
  history.back()
343
329
  } else {
344
330
  this._showToast({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@things-factory/operato-wms",
3
- "version": "3.8.13",
3
+ "version": "3.8.15",
4
4
  "main": "dist-server/index.js",
5
5
  "browser": "client/index.js",
6
6
  "things-factory": true,
@@ -108,5 +108,5 @@
108
108
  "devDependencies": {
109
109
  "@things-factory/builder": "^3.7.5"
110
110
  },
111
- "gitHead": "9ef0c5b4dab02fcd97623eb2d72431d2776bd3c6"
111
+ "gitHead": "19c5659022fadb625ef251b09aea65ab70588ef9"
112
112
  }