innoboxrr-vue-datatable 1.1.0 → 1.1.2

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": "innoboxrr-vue-datatable",
3
- "version": "1.1.0",
3
+ "version": "1.1.2",
4
4
  "description": "Datatable para vue3",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/src/DataTable.vue CHANGED
@@ -197,6 +197,11 @@
197
197
  required: true
198
198
  },
199
199
 
200
+ policyMethod: {
201
+ type: String,
202
+ default: 'post'
203
+ },
204
+
200
205
  showTopbar:{
201
206
  type: Boolean,
202
207
  default: true
@@ -473,24 +478,37 @@
473
478
 
474
479
  actionButtonClicked(actions) {
475
480
 
476
- // Recuperar el id
477
- let id = actions[0].params.id;
481
+ const id = actions[0].params.id;
478
482
 
479
- axios.post(this.policyUrl, {
483
+ const requestData = {
480
484
 
481
485
  _token: csrf_token,
482
486
 
483
487
  id: id
484
488
 
485
- }).then(res => {
489
+ };
490
+
491
+ const requestConfig = {
492
+
493
+ method: this.policyMethod,
494
+
495
+ url: this.policyUrl,
496
+
497
+ data: this.policyMethod === 'post' ? requestData : null,
498
+
499
+ params: this.policyMethod === 'get' ? requestData : null
500
+
501
+ };
502
+
503
+ axios(requestConfig).then(res => {
486
504
 
487
505
  this.fetchPoliciesAttempts = 0;
488
506
 
489
- let policies = res.data;
507
+ const policies = res.data;
490
508
 
491
- actions.forEach( action => {
509
+ actions.forEach(action => {
492
510
 
493
- if(policies[action.id]) {
511
+ if (policies[action.id]) {
494
512
 
495
513
  action.policy = true;
496
514
 
@@ -500,9 +518,9 @@
500
518
 
501
519
  }).catch(error => {
502
520
 
503
- if(this.fetchPoliciesAttempts <= 3) {
521
+ if (this.fetchPoliciesAttempts <= 3) {
504
522
 
505
- setTimeout( () => {
523
+ setTimeout(() => {
506
524
 
507
525
  ++this.fetchPoliciesAttempts;
508
526
 
@@ -512,7 +530,7 @@
512
530
 
513
531
  } else {
514
532
 
515
- setTimeout( () => {
533
+ setTimeout(() => {
516
534
 
517
535
  this.fetchPoliciesAttempts = 0;
518
536
 
@@ -8,7 +8,11 @@
8
8
 
9
9
  <li>
10
10
 
11
- <span v-if="meta.total > 0">{{ 'Showing' }} {{ meta.from }} {{ 'to' }} {{ meta.to }} {{ 'of' }} {{ meta.total }} {{ 'entries' }}</span>
11
+ <span v-if="meta.total > 0">
12
+
13
+ {{ 'Showing' }} {{ meta.from }} {{ 'to' }} {{ meta.to }} {{ 'of' }} {{ meta.total }} {{ 'entries' }}
14
+
15
+ </span>
12
16
 
13
17
  <span v-else>{{ ('No results found') }}</span>
14
18
 
@@ -36,7 +40,6 @@
36
40
  <li>
37
41
  <select
38
42
  class="uk-select"
39
- @change="updatePage()"
40
43
  v-model="current_page">
41
44
 
42
45
  <option
@@ -86,18 +89,24 @@
86
89
 
87
90
  emits: ['updatePage'],
88
91
 
89
- updated() {
92
+ data() {
90
93
 
91
- this.current_page = this.meta.current_page;
94
+ return {
95
+
96
+ current_page: 1,
97
+
98
+ }
92
99
 
93
100
  },
94
101
 
95
- data() {
102
+ watch: {
96
103
 
97
- return {
104
+ current_page(newVal, oldVal) {
105
+
106
+ this.current_page = newVal;
107
+
108
+ this.updatePage();
98
109
 
99
- current_page: this.meta.current_page,
100
-
101
110
  }
102
111
 
103
112
  },