@nixweb/nixloc-ui 0.0.254 → 0.0.256

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": "@nixweb/nixloc-ui",
3
- "version": "0.0.254",
3
+ "version": "0.0.256",
4
4
  "description": "Componentes UI",
5
5
  "author": "Fábio Ávila <fabio@nixweb.com.br>",
6
6
  "private": false,
@@ -10,11 +10,11 @@
10
10
  <date-picker lang="pt-br" :disabled="disabled" :range="range" @confirm="executeConfirm" @change="executeConfirm"
11
11
  @clear="close" :confirm="confirm" :confirm-text="confirmText" :format="format" value-type="format"
12
12
  :time-picker-options="{
13
- start: '07:00',
14
- step: '00:30',
15
- end: '23:30',
16
- format: 'HH:mm',
17
- }" width="100%" :placeholder="placeholder" :type="type" v-model="valueLocal"
13
+ start: '07:00',
14
+ step: '00:30',
15
+ end: '23:30',
16
+ format: 'HH:mm',
17
+ }" width="100%" :placeholder="placeholder" :type="type" v-model="valueLocal"
18
18
  :class="{ 'is-invalid': notifications.length > 0 && formDirty }"></date-picker>
19
19
  </div>
20
20
 
@@ -30,7 +30,7 @@
30
30
  import Tip from "../shared/Tip";
31
31
  import DatePicker from "vue2-datepicker";
32
32
 
33
- import { mapState, mapMutations } from "vuex";
33
+ import { mapState, mapMutations, mapGetters } from "vuex";
34
34
 
35
35
  export default {
36
36
  components: { Tip, DatePicker },
@@ -72,7 +72,7 @@ export default {
72
72
  "removeValidation",
73
73
  "updateFormDirty",
74
74
  ]),
75
- ...mapMutations("generic", ["addFilter"]),
75
+ ...mapMutations("generic", ["addFilter", "removeTag", "addEvent"]),
76
76
  validate() {
77
77
  this.notifications = [];
78
78
 
@@ -91,15 +91,13 @@ export default {
91
91
  }
92
92
  },
93
93
  close() {
94
- let obj = {
95
- fieldTarget: this.fieldTarget,
96
- value: { start: "", end: "" },
97
- };
98
- this.addFilter(obj);
94
+ this.removeTag("period");
95
+ this.addEvent({ name: "tagRemoved", data: "period" });
99
96
  },
100
97
  },
101
98
  computed: {
102
99
  ...mapState("validation", ["resetForm", "validations"]),
100
+ ...mapGetters("generic", ["event"]),
103
101
  },
104
102
  watch: {
105
103
  valueLocal() {
@@ -137,6 +135,15 @@ export default {
137
135
  },
138
136
  deep: true,
139
137
  },
138
+ event: {
139
+ handler(event) {
140
+ if (event.name == "tagRemoved") {
141
+ this.valueLocal = [];
142
+
143
+ }
144
+ },
145
+ deep: true,
146
+ },
140
147
  },
141
148
  };
142
149
  </script>
@@ -5,21 +5,21 @@
5
5
  icon: 'fas fa-arrow-alt-circle-down',
6
6
  type: 'info',
7
7
  }" :buttonHide="{
8
- title: 'Menos filtros',
9
- icon: 'fas fa-arrow-alt-circle-up',
10
- type: 'warning',
11
- }">
8
+ title: 'Menos filtros',
9
+ icon: 'fas fa-arrow-alt-circle-up',
10
+ type: 'warning',
11
+ }">
12
12
  <slot name="content-filter-horizontal"></slot>
13
13
  <b-row>
14
14
  <b-col :sm="showTotalPerPage ? 10 : 12"></b-col>
15
15
  <b-col xs="12" sm="12" md="12" lg="2" xl="2" v-if="showTotalPerPage">
16
- <SelectStatic title="Mostrar" fieldTarget="totalPerPage" :initialValue="{ content: '10', id: 10 }" :data="[
17
- { content: '10', id: 10 },
18
- { content: '20', id: 20 },
19
- { content: '30', id: 30 },
20
- { content: '50', id: 50 },
21
- { content: '100', id: 100 },
22
- ]" v-model="totalPerPage" />
16
+ <SelectStatic title="Mostrar" fieldTarget="totalPerPage" :initialValue="initialValue" :data="[
17
+ { content: '10', id: 10 },
18
+ { content: '20', id: 20 },
19
+ { content: '30', id: 30 },
20
+ { content: '50', id: 50 },
21
+ { content: '100', id: 100 },
22
+ ]" v-model="totalPerPage" />
23
23
  </b-col>
24
24
  </b-row>
25
25
  </Collapse>
@@ -31,7 +31,7 @@ import Collapse from "./Collapse.vue";
31
31
  import SelectStatic from "../forms/SelectStatic.vue";
32
32
  import Select from "../forms/Select";
33
33
 
34
- import { mapMutations } from "vuex";
34
+ import { mapMutations, mapState } from "vuex";
35
35
 
36
36
  export default {
37
37
  name: "ListViewWithHandlerData",
@@ -42,10 +42,19 @@ export default {
42
42
  default: true,
43
43
  },
44
44
  },
45
+ data() {
46
+ return {
47
+ initialValue: {}
48
+ }
49
+ },
50
+ created() {
51
+ this.initialValue = { content: this.paginations.totalPerPage, id: this.paginations.totalPerPage }
52
+ },
45
53
  computed: {
54
+ ...mapState("generic", ["paginations"]),
46
55
  totalPerPage: {
47
56
  get() {
48
- return this.$store.state.generic.totalPerPage;
57
+ return this.$store.state.generic.paginations.totalPerPage;
49
58
  },
50
59
  set(value) {
51
60
  this.updateTotalPerPage(value);
@@ -1,71 +1,109 @@
1
1
  <template>
2
2
  <div>
3
- <b-pagination v-model="pagination(_key).currentPage" align="right" :hide-goto-end-buttons="true"
4
- :per-page="totalPerPage.id" :total-rows="totalRecords">
5
- <template #first-text>
6
- <i class="fa-regular fa-chevron-left"></i>
7
- </template>
8
- <template #prev-text>
9
- <i class="fa-regular fa-chevron-left"></i>
10
- </template>
11
- <template #next-text>
12
- <i class="fa-regular fa-chevron-right"></i>
13
- </template>
14
- <template #last-text>
15
- <i class="fa-regular fa-chevron-right"></i>
16
- </template>
17
- </b-pagination>
3
+ <div class="pagination">
4
+ <button class="btn-pagination" @click="previousPage" :disabled="currentPage === 1 || currentPage > totalPages">
5
+ <i class="fa-solid fa-chevron-left"></i>
6
+ </button>
7
+ <div class="div-pagination text-center">
8
+ <span v-if="isLoading('loadingLine')">
9
+ <vue-loading type="bubbles" color="#FCA944" :size="{ width: '26px', height: '26px' }"></vue-loading>
10
+ </span>
11
+ <span v-else>
12
+ <div v-if="currentPage < totalPages">
13
+ {{ currentPage }} de {{ totalPages }}
14
+ </div>
15
+ <div v-else>
16
+ 1 de 1
17
+ </div>
18
+ </span>
19
+ </div>
20
+ <button class="btn-pagination" @click="nextPage"
21
+ :disabled="currentPage === totalPages || currentPage > totalPages">
22
+ <i class="fa-solid fa-chevron-right"></i>
23
+ </button>
24
+ </div>
18
25
  </div>
19
26
  </template>
20
-
21
27
  <script>
28
+
22
29
  import { mapGetters, mapMutations, mapState } from "vuex";
23
30
 
24
31
  export default {
25
- name: "Pagination",
26
32
  props: {
27
- _key: String,
28
33
  totalRecords: Number,
29
34
  },
30
- created() {
31
- this.addPagination({
32
- key: this._key,
35
+ data() {
36
+ return {
33
37
  currentPage: 1,
34
- totalPerPage: 10,
35
- });
38
+ totalPerPage: 10 // Substitua pelo número de registros por página desejado
39
+ };
40
+ },
41
+ created() {
42
+ var filter = this.getFilterStorage(this.$route.name);
43
+ if (filter)
44
+ this.currentPage = filter.baseParams.currentPage;
36
45
  },
37
46
  computed: {
38
- ...mapGetters("generic", ["pagination"]),
39
- ...mapState("generic", ["totalPerPage"]),
47
+ ...mapState("generic", ["paginations"]),
48
+ ...mapGetters("generic", ["isLoading", "getFilterStorage"]),
49
+ totalPages() {
50
+ return Math.ceil(this.totalRecords / this.paginations.totalPerPage);
51
+ },
52
+ paginatedData() {
53
+ const startIndex = (this.currentPage - 1) * this.paginations.totalPerPage;
54
+ const endIndex = Math.min(startIndex + this.paginations.totalPerPage, this.totalRecords);
55
+ return Array.from({ length: endIndex - startIndex }, (_, index) => index + startIndex + 1);
56
+ }
40
57
  },
41
58
  methods: {
42
- ...mapMutations("generic", ["addPagination"]),
43
- },
59
+ ...mapMutations("generic", ["addEvent"]),
60
+ nextPage() {
61
+ if (this.currentPage < this.totalPages) {
62
+ this.currentPage++;
63
+ }
64
+ this.addEvent({ name: "page-click", data: this.currentPage });
65
+ },
66
+ previousPage() {
67
+ if (this.currentPage > 1) {
68
+ this.currentPage--;
69
+ }
70
+ this.addEvent({ name: "page-click", data: this.currentPage });
71
+ }
72
+ }
44
73
  };
45
74
  </script>
46
75
 
47
- <style>
48
- .page-item {
49
- font-size: 15px !important;
50
- border: 0px solid !important;
51
- width: 50px !important;
52
- font-weight: 700 !important;
76
+ <style scoped>
77
+ .div-pagination {
78
+ width: 100px;
79
+ }
80
+
81
+ .btn-pagination {
82
+ padding: 5px;
83
+ cursor: pointer;
84
+ border: none;
85
+ min-width: 35px;
86
+ border-radius: 30px !important;
87
+ font-size: 13px !important;
88
+ font-weight: 400;
89
+ letter-spacing: 1px !important;
90
+ }
91
+
92
+
93
+ .pagination {
94
+ display: flex;
95
+ justify-content: end;
96
+ align-items: center;
97
+ margin-right: 10px;
98
+ margin-bottom: 10px;
53
99
  }
54
100
 
55
- .page-item.active .page-link {
56
- z-index: 3 !important;
57
- color: black !important;
58
- background-color: #ECECEC !important;
59
- border-radius: 50px !important;
60
- width: 37px !important;
61
- height: 37px !important;
101
+ .pagination-button:hover {
102
+ background-color: #ccc;
62
103
  }
63
104
 
64
- .page-link {
65
- color: #6c757d !important;
66
- border: 0px solid #dee2e6 !important;
67
- border-radius: 50px !important;
68
- width: 37px !important;
69
- height: 37px !important;
105
+ .pagination-button:disabled {
106
+ opacity: 0.5;
107
+ cursor: not-allowed;
70
108
  }
71
109
  </style>
@@ -1,46 +1,69 @@
1
1
  <template>
2
- <b-row>
3
- <b-col xs="12" sm="12" md="12" lg="7" xl="6">
4
- <div class="margin">
5
- <div class="molded">
6
- <b-row>
7
- <b-col sm="9">
8
- <input class="input-search" type="text" name="search" placeholder="Pesquisar ..."
9
- @keyup="verifyCleanSearch()" @keyup.enter.prevent="executeSearch()" v-model="search.content" /></b-col>
10
- <b-col sm="3">
11
- <div class="div-select">
12
- <SelectStatic classCss="select-search" fieldTarget="filter" :onlyQuery="true"
13
- :initialValue="{ content: 'Contém', id: 'contains' }" v-model="search.filter" :showBorder="false" :data="[
2
+ <div>
3
+ <b-row>
4
+ <b-col xs="12" sm="12" md="12" lg="7" xl="6">
5
+ <div class="margin">
6
+ <div class="molded">
7
+ <b-row>
8
+ <b-col sm="9">
9
+ <input class="input-search" type="text" name="search" placeholder="Pesquisar ..."
10
+ @keyup="verifyCleanSearch()" @keyup.enter.prevent="executeSearch()" v-model="search.content" />
11
+ </b-col>
12
+ <b-col sm="3">
13
+ <div class="div-select">
14
+ <SelectStatic classCss="select-search" fieldTarget="filter" :onlyQuery="true"
15
+ :initialValue="{ content: 'Contém', id: 'contains' }" v-model="search.filter" :showBorder="false"
16
+ :data="[
14
17
  { content: 'Contém', id: 'contains' },
15
18
  { content: 'Igual', id: 'equal' },
16
19
  ]" />
17
- </div>
18
- </b-col>
19
- </b-row>
20
+ </div>
21
+ </b-col>
22
+ </b-row>
23
+ </div>
20
24
  </div>
21
- </div>
22
- </b-col>
23
- <b-col xs="4" sm="4" md="4" lg="4" xl="4">
24
- <div class="div-button">
25
- <Button _key="btnSearch" type="info" title="Buscar" classIcon="fas fa-search" size="small"
26
- :clicked="executeSearch" />
27
- <Button _key="btnClean" type="info" title="Limpar" classIcon="fas fa-broom" size="small"
28
- :clicked="executeClean" />
29
- </div>
30
- </b-col>
31
- </b-row>
25
+ <div v-if="getFilterStorage($route.name)">
26
+ <div v-if="getFilterStorage($route.name).paramsFilter.length !== 0
27
+ || getFilterStorage($route.name).baseParams.search !== ''
28
+ || getFilterStorage($route.name).baseParams.currentPage !== 1">
29
+ <div class="div-filter">
30
+ Filtro Ativo
31
+ <span class="icon-close" @click="removeFilter()">
32
+ <i class="icon-tag fas fa-times-circle"></i>
33
+ </span>
34
+ </div>
35
+ </div>
36
+ </div>
37
+
38
+ </b-col>
39
+ <b-col xs="4" sm="4" md="4" lg="4" xl="4">
40
+ <div class="div-button">
41
+ <Button _key="btnSearch" type="info" title="Buscar" classIcon="fas fa-search" size="small"
42
+ :clicked="executeSearch" />
43
+ <Button _key="btnClean" type="info" title="Limpar" classIcon="fas fa-broom" size="small"
44
+ :clicked="executeClean" />
45
+ </div>
46
+ </b-col>
47
+ </b-row>
48
+ </div>
32
49
  </template>
33
50
 
34
51
  <script>
35
52
  import Button from "../forms/Button";
36
53
  import SelectStatic from "../forms/SelectStatic.vue";
37
54
 
38
- import { mapMutations } from "vuex";
55
+ import { mapMutations, mapGetters, mapState } from "vuex";
39
56
 
40
57
  export default {
41
58
  components: { Button, SelectStatic },
42
59
  name: "Search",
60
+ data() {
61
+ return {
62
+ showFilterStorage: false,
63
+ }
64
+ },
43
65
  computed: {
66
+ ...mapGetters("generic", ["getFilterStorage"]),
44
67
  search: {
45
68
  get() {
46
69
  return this.$store.state.generic.search;
@@ -55,6 +78,7 @@ export default {
55
78
  "updateSearch",
56
79
  "executedSearch",
57
80
  "clearedSearch",
81
+ "addEvent"
58
82
  ]),
59
83
  executeSearch() {
60
84
  this.executedSearch();
@@ -67,6 +91,9 @@ export default {
67
91
  verifyCleanSearch() {
68
92
  if (this.search.content.length == 0) this.clearedSearch();
69
93
  },
94
+ removeFilter() {
95
+ this.addEvent({ name: "filterStorageRemoved" });
96
+ }
70
97
  },
71
98
  };
72
99
  </script>
@@ -85,7 +112,7 @@ export default {
85
112
  }
86
113
 
87
114
  .molded {
88
- width: 100%;
115
+
89
116
  height: 45px;
90
117
  font-size: 14px;
91
118
  padding: 5px 8px 6px 15px;
@@ -95,8 +122,6 @@ export default {
95
122
  box-sizing: border-box;
96
123
  box-shadow: none;
97
124
  color: rgb(38, 41, 44);
98
- opacity: 1;
99
- transition: background-color 0.1s ease-in 0s, border 0.1s ease-in 0s;
100
125
  }
101
126
 
102
127
  input[type="text"] {
@@ -105,7 +130,6 @@ input[type="text"] {
105
130
  font-size: 14px;
106
131
  border: 0px solid white;
107
132
  background-color: rgb(255, 255, 255);
108
- margin-bottom: 50px;
109
133
  }
110
134
 
111
135
  input[type="text"]:focus {
@@ -116,4 +140,28 @@ input[type="text"]:focus {
116
140
  margin-top: -30px;
117
141
  margin-right: 5px;
118
142
  }
143
+
144
+ .filter-active {
145
+ margin-right: 13px;
146
+ margin-left: -10px;
147
+ color: #F1BC31;
148
+ }
149
+
150
+ .div-filter {
151
+ margin-left: 13px;
152
+ font-size: 12px;
153
+ background-color: #F1BC31;
154
+ color: white;
155
+ margin-top: 5px;
156
+ padding-left: 7px;
157
+ padding-right: 5px;
158
+ border-radius: 15px;
159
+ width: 110px;
160
+ cursor: pointer !important;
161
+ }
162
+
163
+ .icon-close {
164
+ font-size: 15px;
165
+ cursor: pointer !important;
166
+ }
119
167
  </style>
@@ -21,8 +21,8 @@
21
21
  </div>
22
22
  </div>
23
23
  <div class="div-btn" v-if="showButtonNext">
24
- <Button _key="btnClickedNext" type="info" title="Avançar" :disabled="selected == null" :classIcon="buttonClassIcon"
25
- :size="buttonSize" :clicked="execute" />
24
+ <Button _key="btnClickedNext" type="info" title="Avançar" :disabled="selected == null"
25
+ :classIcon="buttonClassIcon" :size="buttonSize" :clicked="execute" />
26
26
  </div>
27
27
  </div>
28
28
  </template>
@@ -87,6 +87,14 @@ export default {
87
87
  computed: {
88
88
  ...mapGetters("generic", ["tip"]),
89
89
  },
90
+ watch: {
91
+ value: {
92
+ handler(value) {
93
+ this.selected = value;
94
+ },
95
+ deep: true,
96
+ },
97
+ }
90
98
  };
91
99
  </script>
92
100
  <style scoped>
@@ -18,9 +18,9 @@
18
18
  <b-row>
19
19
  <b-col sm="3">
20
20
  <RadioGroup :options="[
21
- { text: 'e', value: 'and' },
22
- { text: 'ou', value: 'or' },
23
- ]" v-model="andOr" />
21
+ { text: 'e', value: 'and' },
22
+ { text: 'ou', value: 'or' },
23
+ ]" v-model="andOr" />
24
24
  </b-col>
25
25
  </b-row>
26
26
  </div>
@@ -115,7 +115,7 @@ export default {
115
115
  totalRecords: 0,
116
116
  },
117
117
  baseParams: {
118
- search: undefined,
118
+ search: "",
119
119
  filter: "contains",
120
120
  currentPage: 1,
121
121
  totalPerPage: 10,
@@ -126,13 +126,11 @@ export default {
126
126
  };
127
127
  },
128
128
  created() {
129
- // o carregamento inicial getAll() é feito pela mudança no paginationKey
130
- },
131
- mounted() {
132
- this.updatePagination({
133
- key: "templateList",
134
- totalPerPage: this.totalPerPage.id,
135
- });
129
+ var filter = this.getFilterStorage(this.$route.name);
130
+ if (filter) {
131
+ this.updateCurrentPage(filter.baseParams.currentPage);
132
+ }
133
+ this.getAll();
136
134
  },
137
135
  beforeDestroy() {
138
136
  let search = { content: "", filter: { content: "Contém", id: "contains" } };
@@ -148,12 +146,11 @@ export default {
148
146
  "clearedSearch",
149
147
  "totalPerPage",
150
148
  "selectStatic",
149
+ "paginations",
150
+ "filterStorage",
151
151
  "tags"
152
152
  ]),
153
- ...mapGetters("generic", ["pagination", "isLoading", "event", "showModal"]),
154
- paginationKey: function () {
155
- return this.pagination("templateList");
156
- },
153
+ ...mapGetters("generic", ["isLoading", "getFilterStorage", "event", "showModal"]),
157
154
  },
158
155
  methods: {
159
156
  ...mapActions("generic", ["getApi", "orderAllApi", "deleteAllApi"]),
@@ -162,30 +159,50 @@ export default {
162
159
  "addLoading",
163
160
  "removeLoading",
164
161
  "addSelected",
165
- "updatePagination",
166
162
  "updateSearch",
163
+ "updateCurrentPage",
167
164
  "addTag",
168
165
  "removeTag",
169
166
  "cleanTags",
170
167
  "openModal",
171
- "hideModal"
168
+ "hideModal",
169
+ "addFilterStorage",
170
+ "removeFilterStorage"
172
171
  ]),
173
172
  getAll() {
174
- this.baseParams.totalPerPage = this.totalPerPage.id
173
+ this.addLoading("loadingLine");
174
+ var filter = this.getFilterStorage(this.$route.name);
175
+
176
+ let self = this;
177
+ if (filter) {
178
+ this.baseParams = filter.baseParams;
179
+ this.dynamicFilter = filter.dynamicFilter;
180
+ this.propsParam = filter.propsParam;
181
+ this.paramsFilter = filter.paramsFilter;
175
182
 
176
- let obj = {
177
- ...this.baseParams,
178
- ...this.dynamicFilter,
179
- ...this.propsParam,
180
- };
181
- let params = { url: this.templateList.urlGetApi, obj: obj };
182
- this.getApi(params).then((response) => {
183
- this.content = response.content;
184
- let self = this;
185
183
  setTimeout(function () {
186
- self.removeLoading(["panel", "loadingLine", "btnSearch", "btnClean"]);
187
- }, 350);
188
- });
184
+ let search = { content: filter.baseParams.search, filter: { content: "Contém", id: "contains" } };
185
+ self.updateSearch(search);
186
+ self.updateCurrentPage(filter.baseParams.currentPage);
187
+ self.generateDynamicFilter();
188
+ }, 200);
189
+ }
190
+
191
+ setTimeout(function () {
192
+ let obj = {
193
+ ...self.baseParams,
194
+ ...self.dynamicFilter,
195
+ ...self.propsParam,
196
+ };
197
+
198
+ let params = { url: self.templateList.urlGetApi, obj: obj };
199
+ self.getApi(params).then((response) => {
200
+ self.content = response.content;
201
+ setTimeout(function () {
202
+ self.removeLoading(["panel", "loadingLine", "btnSearch", "btnClean"]);
203
+ }, 350);
204
+ });
205
+ }, 250);
189
206
  },
190
207
  orderAll(data) {
191
208
  if (this.templateList.urlOrderAllApi) {
@@ -201,26 +218,43 @@ export default {
201
218
  }
202
219
  },
203
220
  selectFilter(value) {
221
+
204
222
  let fieldTarget = value.fieldTarget;
205
- let obj = { tag: value.tag, key: fieldTarget, value: value.value };
206
223
 
207
- if (obj.value != "")
208
- this.paramsFilter.push(obj);
224
+ if (fieldTarget != "totalPerPage") {
225
+ let obj = { tag: value.tag, key: fieldTarget, value: value.value };
209
226
 
227
+ if (obj.value !== "") {
228
+ const existingIndex = this.paramsFilter.findIndex(item => item.key === obj.key);
229
+ if (existingIndex !== -1) {
230
+ // Se já existe, atualiza o valor
231
+ this.paramsFilter[existingIndex] = obj;
232
+ } else {
233
+ // Se não existe, adiciona ao paramsFilter
234
+ this.paramsFilter.push(obj);
235
+ }
236
+ }
237
+ } else { this.baseParams.currentPage = 1; }
210
238
  this.convertToObjectAndGetAll();
211
239
  },
212
240
  convertToObjectAndGetAll() {
241
+ this.generateDynamicFilter();
242
+ this.getAll();
243
+ },
244
+ generateDynamicFilter() {
213
245
  var result = {};
214
246
  for (var i = 0; i < this.paramsFilter.length; i++) {
215
247
  let key = this.paramsFilter[i].key;
216
248
  let value = this.paramsFilter[i].value;
217
249
  let tag = this.paramsFilter[i].tag;
218
250
 
219
-
220
251
  if (key == "period") {
221
252
  result["start"] = value.start;
222
253
  result["end"] = value.end;
223
254
 
255
+ if (value.start)
256
+ tag = `Período: ${value.start}-${value.end}`;
257
+
224
258
  } else {
225
259
  result[key] = value;
226
260
  }
@@ -233,17 +267,9 @@ export default {
233
267
  } else {
234
268
  this.removeTag(key);
235
269
  }
236
-
237
270
  }
238
271
 
239
272
  this.dynamicFilter = result;
240
-
241
- this.updatePagination({
242
- key: "templateList",
243
- totalPerPage: this.dynamicFilter.totalPerPage,
244
- });
245
-
246
- this.getAll();
247
273
  },
248
274
  confirmRemoved() {
249
275
  this.removeLoading(["remove"]);
@@ -263,6 +289,17 @@ export default {
263
289
  cleanParams() {
264
290
  this.baseParams.currentPage = 1;
265
291
  },
292
+ addStorage() {
293
+ let obj =
294
+ {
295
+ key: this.$route.name,
296
+ baseParams: this.baseParams,
297
+ dynamicFilter: this.dynamicFilter,
298
+ propsParam: this.propsParam,
299
+ paramsFilter: this.paramsFilter
300
+ };
301
+ this.addFilterStorage(obj);
302
+ }
266
303
  },
267
304
  watch: {
268
305
  event: {
@@ -272,16 +309,48 @@ export default {
272
309
  if (event.name == "tagRemoved") {
273
310
 
274
311
  this.removeTag(event.data);
312
+
275
313
  let filter = this.paramsFilter.filter(x => x.key != event.data);
276
314
  this.paramsFilter = filter;
277
315
 
278
- this.convertToObjectAndGetAll();
316
+ this.addStorage();
317
+ this.getAll();
279
318
  }
319
+
320
+ if (event.name == "filterStorageRemoved") {
321
+
322
+ let self = this;
323
+ this.tags.forEach(tag => {
324
+ self.removeTag(tag.key);
325
+ self.addEvent({ name: "tagRemoved", data: tag.key });
326
+ });
327
+
328
+ this.paramsFilter = [];
329
+
330
+ this.baseParams.search = "";
331
+ this.baseParams.filter = "contains";
332
+ this.baseParams.currentPage = 1;
333
+ this.baseParams.totalPerPage = 10;
334
+ this.propsParam = {};
335
+
336
+
337
+
338
+ this.addStorage();
339
+ this.getAll();
340
+ }
341
+
342
+
343
+
280
344
  if (event.name == "getAllListViewWithDataHandler") {
281
345
  this.addSelected([]);
282
346
  this.getAll();
283
347
  }
284
348
 
349
+ if (event.name == "page-click") {
350
+ this.baseParams.currentPage = event.data;
351
+ this.addStorage();
352
+ this.getAll();
353
+ }
285
354
  },
286
355
  deep: true,
287
356
  },
@@ -296,6 +365,8 @@ export default {
296
365
  }
297
366
  },
298
367
  executedSearch: function () {
368
+ this.addStorage();
369
+
299
370
  this.baseParams.search = this.search.content;
300
371
  if (this.search.filter.id) this.baseParams.filter = this.search.filter.id;
301
372
  this.cleanParams();
@@ -307,17 +378,28 @@ export default {
307
378
  this.cleanParams();
308
379
  this.getAll();
309
380
  },
310
- paginationKey: {
381
+ selectStatic: {
311
382
  handler(value) {
312
- this.cleanParams();
313
- this.baseParams.currentPage = value.currentPage;
314
- this.getAll();
383
+ this.selectFilter(value);
315
384
  },
316
385
  deep: true,
317
386
  },
318
- selectStatic: {
387
+ dynamicFilter: {
319
388
  handler(value) {
320
- this.selectFilter(value);
389
+ this.addStorage();
390
+ },
391
+ deep: true,
392
+ },
393
+ propsParam: {
394
+ handler(value) {
395
+ this.addStorage();
396
+ },
397
+ deep: true,
398
+ },
399
+ paginations: {
400
+ handler(value) {
401
+ this.baseParams.totalPerPage = value.totalPerPage;
402
+ this.addStorage();
321
403
  },
322
404
  deep: true,
323
405
  },
@@ -19,6 +19,7 @@ export default {
19
19
  },
20
20
  notifications: [],
21
21
  pagination: [],
22
+ paginations: { currentPage: 1, totalPerPage: 10 },
22
23
  totalPerPage: { "content": "10", "id": 10 },
23
24
  selected: [],
24
25
  loading: [],
@@ -65,6 +66,19 @@ export default {
65
66
  if (loading) return true;
66
67
  return false;
67
68
  },
69
+ getFilterStorage: (state) => (key) => {
70
+ return state.filterStorage.find(x => x.key === key);
71
+ },
72
+ paramsFilterStorage: (state) => (route, key, returnIfNull) => {
73
+ var filter = state.filterStorage.find(x => x.key === route);
74
+
75
+ if (filter) {
76
+ var obj = filter.paramsFilter.find(x => x.key === key);
77
+ if (obj) return obj.value;
78
+ return returnIfNull;
79
+ }
80
+ return returnIfNull;
81
+ },
68
82
  pagination: (state) => (key) => {
69
83
  return state.pagination.find(obj => {
70
84
  return obj.key === key
@@ -243,8 +257,11 @@ export default {
243
257
  clearedSearch: (state) => {
244
258
  state.clearedSearch = state.clearedSearch = !state.clearedSearch
245
259
  },
260
+ updateCurrentPage: (state, value) => {
261
+ state.paginations.currentPage = value;
262
+ },
246
263
  updateTotalPerPage: (state, value) => {
247
- state.totalPerPage = value;
264
+ state.paginations.totalPerPage = value.id;
248
265
  },
249
266
  addSelected: (state, selected) => {
250
267
  state.selected = selected;
@@ -268,7 +285,6 @@ export default {
268
285
  state.methodExecutedApi = "";
269
286
  }, 100);
270
287
  },
271
-
272
288
  addLoading: (state, key) => {
273
289
  state.loading.push(key);
274
290
  },
@@ -280,15 +296,6 @@ export default {
280
296
  state.loading = filter;
281
297
  });
282
298
  },
283
- addPagination: (state, pagination) => {
284
- state.pagination.push(pagination);
285
- },
286
- updatePagination: (state, pagination) => {
287
- state.pagination.forEach(function (obj) {
288
- if (obj.key == pagination.key)
289
- obj.totalPerPage = pagination.totalPerPage;
290
- });
291
- },
292
299
  updateDocumentHtml: (state, value) => {
293
300
  state.documentHtml = value;
294
301
  },
@@ -336,6 +343,23 @@ export default {
336
343
  cleanTags: (state) => {
337
344
  state.tags = []
338
345
  },
346
+ openModal: (state, name) => {
347
+ state.modal.name = name;
348
+ state.modal.open = true;
349
+ },
350
+ addFilterStorage: (state, obj) => {
351
+ const index = state.filterStorage.findIndex(x => x.key === obj.key);
352
+ if (index !== -1) {
353
+ state.filterStorage[index] = obj;
354
+
355
+ } else {
356
+ state.filterStorage.push(obj);
357
+ }
358
+ },
359
+ removeFilterStorage: (state, key) => {
360
+ let filter = state.filterStorage.filter(x => x.key != key);
361
+ state.filterStorage = filter;
362
+ },
339
363
  },
340
364
  actions: {
341
365
  postApi: async function (context, params) {
@@ -419,8 +443,6 @@ export default {
419
443
  })
420
444
  .then((response) => {
421
445
 
422
- console.log(response);
423
-
424
446
  if (response.data.success) {
425
447
  context.commit('addMethodExecutedApi', params.methodExecutedApi);
426
448
  context.commit('removeNotificarions');