@tagplus/components 0.2.94 → 0.2.95

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/package.json CHANGED
@@ -7,7 +7,7 @@
7
7
  "email": "bruno@tagplus.com.br"
8
8
  }
9
9
  ],
10
- "version": "0.2.94",
10
+ "version": "0.2.95",
11
11
  "main": "./dist/tp.common.js",
12
12
  "directories": {
13
13
  "lib": "src/lib"
@@ -363,20 +363,17 @@ export default {
363
363
  let newVal = ''
364
364
  if (typeof this.value === 'boolean') {
365
365
  newVal = ''
366
- } else if (Array.isArray(this.value)) {
367
- newVal = this.value
368
- } else if (this.value && typeof this.value === 'object') {
369
- if (!this.value[this.valueKey]) {
370
- if (process.env.DEBUG === 'true') {
371
- throw new TypeError(
372
- 'Autosuggest this.value doesn\'t have a valueKey \'' +
373
- this.valueKey +
374
- '\' key'
375
- )
366
+ }
367
+ else if (Array.isArray(this.value)) {
368
+ this.value.forEach((item) => {
369
+ if (!item[this.valueKey]) {
370
+ if (process.env.DEBUG === 'true') {
371
+ throw new TypeError('Autosuggest this.value doesn\'t have a valueKey \'' + this.valueKey + '\' key')
372
+ }
376
373
  }
377
- } else {
378
- newVal = this.value[this.valueKey]
379
- }
374
+ })
375
+
376
+ newVal = this.value
380
377
  }
381
378
 
382
379
  return newVal
@@ -459,6 +456,19 @@ export default {
459
456
  this.handleQueryChange(e.target.value, forceBusca)
460
457
  }
461
458
  })
459
+
460
+ this.value.forEach((item,key) => {
461
+ if (item[this.valueKey]) {
462
+ this.selectedLabelsArray.push(item)
463
+ this.value[key] = item[this.valueKey]
464
+ }
465
+ })
466
+
467
+ this.selectedLabels = this.selectedLabelsArray
468
+ .map(item => {
469
+ return item[this.labelKey]
470
+ })
471
+ .join(', ')
462
472
  },
463
473
 
464
474
  beforeMount () {
@@ -509,20 +519,18 @@ export default {
509
519
  value = ''
510
520
  } else if (Array.isArray(val)) {
511
521
  value = val
512
- } else if (val && typeof val === 'object') {
513
- // Se val for Object converte para outro tipo
514
- if (!this.value[this.valueKey]) {
515
- throw new TypeError(
516
- 'Autosuggest this.value doesn\'t have a valueKey \'' +
517
- this.valueKey +
518
- '\' key'
519
- )
522
+ }
523
+ else if (val && typeof val === 'object') {
524
+ // Se val for Object converte para outro tipo
525
+ if (!val[this.valueKey]) {
526
+ throw new TypeError('Autosuggest this.value doesn\'t have a valueKey \'' + this.valueKey + '\' key')
520
527
  } else {
521
528
  // Se mandou a label no objeto value
522
- if (this.value[this.labelKey]) {
523
- initialLabel = this.value[this.labelKey]
529
+ if (val[this.labelKey]) {
530
+ initialLabel = val[this.labelKey]
524
531
  }
525
- value = this.value[this.valueKey]
532
+
533
+ value = val
526
534
  }
527
535
  } else {
528
536
  value = val