@kigi/components 1.26.2-alpha → 1.27.1-alpha

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kigi/components",
3
- "version": "1.26.2-alpha",
3
+ "version": "1.27.1-alpha",
4
4
  "description": "@kigi/components",
5
5
  "main": "src/components/index.ts",
6
6
  "scripts": {
@@ -42,6 +42,7 @@ class MbgAddressController {
42
42
  private GOOGLE_API_KEY = 'AIzaSyB0aH7e6XjWJ-xViji3CuXHBbLuWRALC78'
43
43
  private notFoundPremisse
44
44
  private capitalize
45
+ private onSinceUpdate: Function
45
46
 
46
47
  constructor(
47
48
  public $scope,
@@ -50,7 +51,7 @@ class MbgAddressController {
50
51
  public $timeout,
51
52
  public mbgAddressService: MbgAddressService,
52
53
  public $uibModal,
53
- ) { }
54
+ ) {}
54
55
 
55
56
  $onInit() {
56
57
  if (this.capitalize && this.address) {
@@ -59,6 +60,7 @@ class MbgAddressController {
59
60
  if (this.capitalize && this.fullAddress) {
60
61
  this.fullAddress = this.capitalizeBool(this.fullAddress || '')
61
62
  }
63
+
62
64
  this.checkScript()
63
65
  this.navigatorData = detect()
64
66
  this.navigatorData.currentVersion = Number(
@@ -93,8 +95,8 @@ class MbgAddressController {
93
95
  state: this.address.state
94
96
  ? this.address.state
95
97
  : this.address.uf && this.address.uf.initial
96
- ? this.address.uf.initial
97
- : '',
98
+ ? this.address.uf.initial
99
+ : '',
98
100
  }
99
101
  if (this.ngModel) {
100
102
  this.ngModel.EX = (this.ngModel.country || '').toLowerCase() !== 'brasil'
@@ -221,6 +223,7 @@ class MbgAddressController {
221
223
  this.fullAddress = ''
222
224
  this.resetAddress()
223
225
  this.updateSteps()
226
+ this.$timeout(() => this.onSinceUpdate())
224
227
  }
225
228
 
226
229
  checkModel() {
@@ -236,10 +239,13 @@ class MbgAddressController {
236
239
 
237
240
  createFullName() {
238
241
  if (this.address.premisse) {
239
- this.fullAddress = `${this.address.premisse ? this.address.premisse : this.ngModel.premisse
240
- } - ${this.address.neighbourhood ? this.address.neighbourhood : this.ngModel.neighbourhood
241
- }, ${this.address.localization ? this.address.localization : this.ngModel.localization} - ${this.ngModel.state
242
- }, ${this.ngModel.country}`
242
+ this.fullAddress = `${
243
+ this.address.premisse ? this.address.premisse : this.ngModel.premisse
244
+ } - ${
245
+ this.address.neighbourhood ? this.address.neighbourhood : this.ngModel.neighbourhood
246
+ }, ${this.address.localization ? this.address.localization : this.ngModel.localization} - ${
247
+ this.ngModel.state
248
+ }, ${this.ngModel.country}`
243
249
  }
244
250
  }
245
251
 
@@ -342,24 +348,28 @@ class MbgAddressController {
342
348
 
343
349
  async searchAddressByCEP() {
344
350
  if (this.address && this.address.zipCode) {
345
- const response = await this.mbgAddressService.getCep(this.address.zipCode);
351
+ const response = await this.mbgAddressService.getCep(this.address.zipCode)
346
352
 
347
353
  if (response && response.data && response.data.cep) {
348
- let street, neighborhood, city, state, ibgeCode = '';
354
+ let street,
355
+ neighborhood,
356
+ city,
357
+ state,
358
+ ibgeCode = ''
349
359
 
350
360
  if (response.key == 'viacep') {
351
- street = response.data.logradouro;
352
- neighborhood = response.data.bairro;
353
- city = response.data.localization;
354
- state = response.data.uf;
355
- ibgeCode = response.data.ibge;
361
+ street = response.data.logradouro
362
+ neighborhood = response.data.bairro
363
+ city = response.data.localization
364
+ state = response.data.uf
365
+ ibgeCode = response.data.ibge
356
366
  } else if (response.key == 'brasilApi') {
357
- street = response.data.street;
358
- neighborhood = response.data.neighborhood;
359
- city = response.data.city;
360
- state = response.data.state;
367
+ street = response.data.street
368
+ neighborhood = response.data.neighborhood
369
+ city = response.data.city
370
+ state = response.data.state
361
371
  const responseIbge = await this.mbgAddressService.getIbgeCode(response.data.city)
362
- ibgeCode = (responseIbge && responseIbge.data) && responseIbge.data.id.toString();
372
+ ibgeCode = responseIbge && responseIbge.data && responseIbge.data.id.toString()
363
373
  }
364
374
 
365
375
  const uf = getStatesBR().filter((state) => state.initial === response.data.uf)[0]
@@ -369,9 +379,7 @@ class MbgAddressController {
369
379
  this.address = {
370
380
  zipCode: this.address.zipCode.replace('-', ''),
371
381
  neighbourhood: neighborhood ? neighborhood.trim() : 'Centro',
372
- localization: city
373
- ? city
374
- : (response.data.localidade || '').trim(),
382
+ localization: city ? city : (response.data.localidade || '').trim(),
375
383
  premisse: premisse || 'CEP Único',
376
384
  number: this.address.number || '',
377
385
  information: this.address.information || '',
@@ -587,6 +595,10 @@ class MbgAddressController {
587
595
  },
588
596
  })
589
597
  modal.result.then((response) => {
598
+ this.$timeout(() => {
599
+ this.onSinceUpdate()
600
+ })
601
+
590
602
  if (response) {
591
603
  response.zipCode = response.zipCode || ''
592
604
  this.address.country = response.country || 'Brasil'
@@ -601,7 +613,7 @@ class MbgAddressController {
601
613
  }
602
614
  }
603
615
 
604
- MbgAddressController.$inject = [
616
+ MbgAddressController['$inject'] = [
605
617
  '$scope',
606
618
  '$element',
607
619
  '$attrs',
@@ -619,6 +631,7 @@ const mbgAddress = {
619
631
  manualLabel: '@?',
620
632
  notFoundPremisse: '&?',
621
633
  capitalize: '=?',
634
+ onSinceUpdate: '&?',
622
635
  },
623
636
  template,
624
637
  controller: MbgAddressController,
@@ -14,6 +14,7 @@ export class MbgListColumnController {
14
14
  private hidden: boolean
15
15
  private columnSort
16
16
  private dinamic
17
+ public markAsLastColumn
17
18
 
18
19
  constructor(public $scope, public $element, public $attrs, public $timeout, public $transclude) {}
19
20
 
@@ -23,6 +24,7 @@ export class MbgListColumnController {
23
24
  this.alignRow = this.alignRow || 'left'
24
25
  this.sortable = this.sortable !== undefined ? this.sortable : false
25
26
  this.dinamic = this.dinamic !== undefined ? this.dinamic : false
27
+ this.markAsLastColumn = this.markAsLastColumn !== undefined ? this.markAsLastColumn : false
26
28
  this.mbgList.registerColumn(this)
27
29
  this.generateTemplateColumn()
28
30
  this.generateTemplateRow()
@@ -79,7 +81,7 @@ export class MbgListColumnController {
79
81
  }
80
82
  }
81
83
 
82
- MbgListColumnController.$inject = ['$scope', '$element', '$attrs', '$timeout', '$transclude']
84
+ MbgListColumnController['$inject'] = ['$scope', '$element', '$attrs', '$timeout', '$transclude']
83
85
 
84
86
  const mbgListColumn = {
85
87
  transclude: true,
@@ -96,6 +98,7 @@ const mbgListColumn = {
96
98
  hidden: '=?',
97
99
  sortable: '=?',
98
100
  dinamic: '=?',
101
+ markAsLastColumn: '=?',
99
102
  },
100
103
  template: '',
101
104
  controller: MbgListColumnController,
@@ -24,8 +24,10 @@ export class MbgListController {
24
24
  public columnSort
25
25
  public dinamic
26
26
  public dinamicColumns
27
+ public staticColumns: Array<any>
28
+ public indexToPush
27
29
 
28
- constructor(public $scope, public $element, public $attrs, public $timeout, public $transclude) { }
30
+ constructor(public $scope, public $element, public $attrs, public $timeout, public $transclude) {}
29
31
 
30
32
  $onInit() {
31
33
  this.enableOnSelectByRow =
@@ -35,6 +37,8 @@ export class MbgListController {
35
37
  this.columns = []
36
38
  this.mbgRows = []
37
39
  this.selectedMap = {}
40
+ this.staticColumns = []
41
+
38
42
  this.$scope.$watch(
39
43
  '$ctrl.list',
40
44
  (list) => {
@@ -42,6 +46,7 @@ export class MbgListController {
42
46
  this.rows.forEach((row) => {
43
47
  row.$json = row.$json ? row.$json : JSON.stringify(row)
44
48
  })
49
+
45
50
  try {
46
51
  this.checkAll = this.isAllSelected()
47
52
  } catch (e) {
@@ -52,17 +57,34 @@ export class MbgListController {
52
57
  )
53
58
  this.observeOpenedRows()
54
59
  this.observeSelectedValues()
60
+
55
61
  if (this.dinamic) {
56
62
  this.$scope.$watch(
57
63
  '$ctrl.dinamicColumns',
58
64
  () => {
59
- const columnsNames = this.dinamicColumns.map((column) => column.name)
60
- this.columns = this.columns.filter((c: any) => {
61
- if (!c.dinamic) {
62
- return true
65
+ if (this.staticColumns.length == 0) {
66
+ this.staticColumns = this.columns
67
+ }
68
+
69
+ this.indexToPush = this.columns.findIndex((col) => col.markAsLastColumn)
70
+
71
+ let lastColumnItem = this.indexToPush > 0 && this.columns.splice(this.indexToPush, 1)[0]
72
+
73
+ if (this.dinamicColumns.length > 0) {
74
+ const newColumns = this.columns.filter(
75
+ (c: any) => c.dinamic && this.dinamicColumns.some((item) => item.id == c.name),
76
+ )
77
+
78
+ if (lastColumnItem) {
79
+ newColumns.push(lastColumnItem)
80
+ }
81
+ this.columns = this.staticColumns.concat(newColumns)
82
+ } else {
83
+ if (lastColumnItem) {
84
+ this.staticColumns.push(lastColumnItem)
63
85
  }
64
- return columnsNames.includes(c.name)
65
- })
86
+ this.columns = this.staticColumns
87
+ }
66
88
  },
67
89
  true,
68
90
  )
@@ -152,7 +174,14 @@ export class MbgListController {
152
174
  }
153
175
 
154
176
  registerColumn(column: MbgListColumnController) {
155
- this.columns.push(column)
177
+ if (!this.indexToPush || this.indexToPush < 0) return this.columns.push(column)
178
+
179
+ this.columns.splice(this.indexToPush, 0, column)
180
+ this.indexToPush++
181
+
182
+ if (column.markAsLastColumn) {
183
+ this.indexToPush = this.columns.length - 1
184
+ }
156
185
  }
157
186
 
158
187
  registerRow(row: MbgListRowController) {
@@ -264,7 +293,7 @@ export class MbgListController {
264
293
  )
265
294
  }) %
266
295
  2 ===
267
- 0
296
+ 0
268
297
  ? '#eaeaea'
269
298
  : '#F5F5F5',
270
299
  }