@nixweb/nixloc-ui 0.0.269 → 0.0.271

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.269",
3
+ "version": "0.0.271",
4
4
  "description": "Componentes UI",
5
5
  "author": "Fábio Ávila <fabio@nixweb.com.br>",
6
6
  "private": false,
@@ -12,7 +12,7 @@
12
12
  danger: type === 'danger',
13
13
  disabled: disabled,
14
14
  }" :disabled="disabled" @click="execute()">
15
- <i :class="classIcon" v-if="!isLoading(this._key) && classIcon"></i>
15
+ <i class="div-icon-btn" :class="classIcon" v-if="!isLoading(this._key) && classIcon"></i>
16
16
  <span v-if="!isLoading(this._key)">{{ title }}</span>
17
17
  <vue-loading v-if="isLoading(this._key)" type="bubbles" color="#fff"
18
18
  :size="{ width: '26px', height: '26px' }"></vue-loading>
@@ -64,6 +64,10 @@ export default {
64
64
  margin-left: 5px;
65
65
  }
66
66
 
67
+ .div-icon-btn {
68
+ margin-right: 3px;
69
+ }
70
+
67
71
  .title {
68
72
  margin: 2px;
69
73
  }
@@ -0,0 +1,192 @@
1
+ <template>
2
+ <div>
3
+ <div>
4
+ <div class="div-btn side-by-side">
5
+ <Button _key="btnShow" color="black" backGroundColor="#F0F0F0"
6
+ :title="' ' + quantitySelected + ' ' + title + ' selecionado(s)'"
7
+ classIcon="fa-sharp fa-solid fa-ballot-check" size="small" :clicked="showHide" />
8
+ </div>
9
+ <div v-show="show" class="side-by-side">
10
+ <div class="input-container">
11
+ <input type="text" v-model="baseParams.search" placeholder="Pesquisar..." />
12
+ </div>
13
+ </div>
14
+
15
+ </div>
16
+ <div v-show="show">
17
+ <div class="div-loading">
18
+ <Loading type="line" :center="false" v-show="loading" />
19
+ </div>
20
+ <ScrollBar :minHeight="0" :maxHeight="200">
21
+ <div class="div-check">
22
+ <div class="div-items" v-for="item in data" :key="item.id">
23
+ <b-form-checkbox v-model="item.selected" @change="add(item)">
24
+ <span class="title">{{ item.content }}</span>
25
+ </b-form-checkbox>
26
+ </div>
27
+ </div>
28
+ <div v-if="totalRecords > 20 && data.length < totalRecords">
29
+ <div class="after-list text-center">
30
+ <Button key="loadingMore" type="info" title="Carregar mais..." classIcon="fas fa-redo-alt" size="small"
31
+ :clicked="loadingMore" />
32
+ </div>
33
+ </div>
34
+ </ScrollBar>
35
+ </div>
36
+ </div>
37
+ </template>
38
+
39
+ <script>
40
+ import Button from "@nixweb/nixloc-ui/src/component/forms/Button";
41
+ import ScrollBar from "@nixweb/nixloc-ui/src/component/layout/ScrollBar.vue";
42
+ import Loading from "@nixweb/nixloc-ui/src/component/shared/Loading.vue";
43
+ import InputText from "@nixweb/nixloc-ui/src/component/forms/InputText";
44
+
45
+ import { mapGetters, mapMutations, mapActions } from "vuex";
46
+
47
+ export default {
48
+ name: "CheckboxServer",
49
+ components: {
50
+ Button, ScrollBar, Loading, InputText
51
+ },
52
+ props: {
53
+ title: String,
54
+ url: String,
55
+ propsParams: Object,
56
+ value: Array,
57
+ },
58
+ data() {
59
+ return {
60
+ show: false,
61
+ loading: true,
62
+ data: [],
63
+ selected: [],
64
+ totalRecords: 0,
65
+ baseParams: {
66
+ search: "",
67
+ currentPage: 1,
68
+ totalPerPage: 20,
69
+ },
70
+ };
71
+ },
72
+ mounted() {
73
+ this.getAll();
74
+
75
+ if (this.value.length > 0) {
76
+ this.selected = this.value;
77
+ }
78
+
79
+ },
80
+ computed: {
81
+ ...mapGetters("generic", ["showModal", "event"]),
82
+ quantitySelected() {
83
+ return this.selected.length > 0 ? this.selected.length : 0;
84
+ }
85
+ },
86
+ methods: {
87
+ ...mapMutations("generic", ["removeLoading"]),
88
+ ...mapActions("generic", ["getApi"]),
89
+ getAll() {
90
+ let obj = { ...this.baseParams, ...this.propsParams };
91
+ let params = { url: this.url, obj: obj };
92
+ this.loading = true;
93
+ this.getApi(params).then((response) => {
94
+ this.totalRecords = response.content.totalRecords;
95
+ if (this.baseParams.currentPage == 1) {
96
+ this.data = [];
97
+ }
98
+
99
+ let self = this;
100
+ response.content.data.forEach(item => {
101
+ self.data.push(item);
102
+ });
103
+
104
+ this.markSelected();
105
+
106
+ this.loading = false;
107
+ this.removeLoading(["loadingMore"]);
108
+ });
109
+ },
110
+ loadingMore() {
111
+ this.baseParams.currentPage++;
112
+ this.getAll();
113
+ },
114
+ add(item) {
115
+ const index = this.selected.indexOf(item.content);
116
+ if (index > -1) {
117
+ this.selected.splice(index, 1);
118
+ } else {
119
+ this.selected.push(item.content);
120
+ }
121
+ },
122
+ showHide() {
123
+ this.show = this.show == true ? false : true;
124
+ this.removeLoading(["btnShow"]);
125
+ },
126
+ markSelected() {
127
+ this.data.forEach(item => {
128
+ if (this.selected.includes(item.content)) {
129
+ item.selected = true;
130
+ }
131
+ });
132
+ }
133
+ },
134
+ watch: {
135
+ selected: {
136
+ handler(value) {
137
+ this.$emit("input", value);
138
+ },
139
+ deep: true,
140
+ },
141
+ 'baseParams.search': {
142
+ handler(value) {
143
+ this.getAll();
144
+ },
145
+ deep: true,
146
+ },
147
+ },
148
+ };
149
+ </script>
150
+
151
+ <style scoped>
152
+ .div-check {
153
+ margin: 10px;
154
+ }
155
+
156
+ .div-items {
157
+ margin-left: 10px;
158
+ }
159
+
160
+ .div-loading {
161
+ margin-top: 3px;
162
+ }
163
+
164
+ .div-btn {
165
+ padding-bottom: 5px;
166
+ }
167
+
168
+ .div-icon {
169
+ margin-left: 10px;
170
+ font-size: 16px;
171
+ color: green;
172
+ cursor: pointer;
173
+ }
174
+
175
+ .input-container {
176
+ display: flex;
177
+ justify-content: center;
178
+ margin: 20px;
179
+ }
180
+
181
+ input {
182
+ padding-left: 10px;
183
+ padding-right: 10px;
184
+ padding-top: 4px;
185
+ padding-bottom: 4px;
186
+ border: 1px solid #E5E4E8;
187
+ border-radius: 20px;
188
+ outline: none;
189
+ font-size: 13px;
190
+ width: 300px;
191
+ }
192
+ </style>
@@ -23,11 +23,9 @@ export default {
23
23
  <style scoped>
24
24
  .main {
25
25
  background-color: white;
26
- min-height: 900px;
27
26
  }
28
27
 
29
28
  .content {
30
- width: 1024px;
31
29
  margin: auto;
32
30
  }
33
31
  </style>
@@ -22,10 +22,8 @@
22
22
  </b-row>
23
23
  </div>
24
24
  </div>
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">
25
+ <div v-if="hasActiveFilter">
26
+ <div>
29
27
  <div class="div-filter">
30
28
  Filtro Ativo
31
29
  <span class="icon-close" @click="removeFilter()">
@@ -34,7 +32,6 @@
34
32
  </div>
35
33
  </div>
36
34
  </div>
37
-
38
35
  </b-col>
39
36
  <b-col xs="4" sm="4" md="4" lg="4" xl="4">
40
37
  <div class="div-button">
@@ -63,6 +60,7 @@ export default {
63
60
  }
64
61
  },
65
62
  computed: {
63
+ ...mapState("generic", ["queryTags"]),
66
64
  ...mapGetters("generic", ["getFilterStorage"]),
67
65
  search: {
68
66
  get() {
@@ -72,6 +70,14 @@ export default {
72
70
  this.updateSearch(value);
73
71
  },
74
72
  },
73
+ hasActiveFilter() {
74
+ const filterStorage = this.getFilterStorage(this.$route.name);
75
+ return filterStorage && (
76
+ filterStorage.baseParams.search !== '' ||
77
+ filterStorage.baseParams.currentPage !== 1 ||
78
+ this.queryTags.length > 0
79
+ );
80
+ },
75
81
  },
76
82
  methods: {
77
83
  ...mapMutations("generic", [
@@ -93,6 +99,7 @@ export default {
93
99
  },
94
100
  removeFilter() {
95
101
  this.addEvent({ name: "filterStorageRemoved" });
102
+ this.executeClean();
96
103
  }
97
104
  },
98
105
  };
@@ -5,12 +5,6 @@
5
5
  <SelectStatic title="Tipo" :onlyQuery="true" :data="options" :markFormDirty="true"
6
6
  v-model="filterSelected" />
7
7
  </b-col>
8
- <b-col sm="3">
9
- <div class="div-btn">
10
- <Button _key="btnAddFilter" backGroundColor="#156EBE" color="white"
11
- classIcon="fa-regular fa-plus-large" size="small" :clicked="add" />
12
- </div>
13
- </b-col>
14
8
  </b-row>
15
9
  <div>
16
10
  <div v-for="item in filtersAdded">
@@ -18,14 +12,12 @@
18
12
  <b-row>
19
13
  <b-col sm="11">
20
14
  <CheckboxGroup v-if="item.type == 'options'" :title="item.title" :options="item.options"
21
- v-model="item.value" />
22
-
15
+ :initialValue="item.value" v-model="item.value" />
23
16
  <div class="div-date">
24
17
  <DateTime v-if="item.type == 'date' || item.type == 'dateRange'" :title="item.title"
25
18
  format="DD/MM/YYYY" type="date" :range="true" :confirm="true" confirmText="Ok"
26
19
  placeholder v-model="item.value" />
27
20
  </div>
28
-
29
21
  <div v-if="item.type == 'decimal'">
30
22
  <b-row>
31
23
  <b-col sm="6">
@@ -36,8 +28,11 @@
36
28
  </b-col>
37
29
  </b-row>
38
30
  </div>
39
-
40
-
31
+ <div v-if="item.type == 'multiOptions'">
32
+ <div class="div-multi-options">
33
+ <CheckboxServer :title="item.title" :url="item.url" v-model="item.value" />
34
+ </div>
35
+ </div>
41
36
  <InputText v-if="item.type == 'text'" :title="item.title" v-model="item.value" />
42
37
  </b-col>
43
38
  <b-col sm="1">
@@ -49,7 +44,7 @@
49
44
  </div>
50
45
  </div>
51
46
  <div class="text-center">
52
- <Button _key="btnApply" title="Aplicar" backGroundColor="#156EBE" color="white" size="small"
47
+ <Button _key="btnApply" title="Aplicar" backGroundColor="#017AFF" color="white" size="small"
53
48
  :clicked="apply" />
54
49
  </div>
55
50
  </div>
@@ -63,23 +58,30 @@ import InputText from "@nixweb/nixloc-ui/src/component/forms/InputText";
63
58
  import InputDecimal from "@nixweb/nixloc-ui/src/component/forms/InputDecimal";
64
59
  import SelectStatic from "@nixweb/nixloc-ui/src/component/forms/SelectStatic";
65
60
  import CheckboxGroup from "@nixweb/nixloc-ui/src/component/forms/CheckboxGroup";
61
+ import CheckboxServer from "@nixweb/nixloc-ui/src/component/forms/CheckboxServer";
66
62
  import ScrollBar from "@nixweb/nixloc-ui/src/component/layout/ScrollBar.vue";
67
63
  import DateTime from "@nixweb/nixloc-ui/src/component/forms/DateTime";
68
64
 
69
- import { mapMutations, mapGetters } from "vuex";
65
+ import { mapMutations, mapState, mapGetters } from "vuex";
70
66
 
71
67
  export default {
72
68
  name: "FilterBuilder",
73
69
  props: ["filters", "value"],
74
- components: { SelectStatic, Button, CheckboxGroup, InputText, ScrollBar, DateTime, InputDecimal },
70
+ components: { SelectStatic, Button, CheckboxGroup, CheckboxServer, InputText, ScrollBar, DateTime, InputDecimal },
75
71
  data() {
76
72
  return {
77
73
  filterSelected: {},
78
74
  filtersAdded: [],
79
75
  }
80
76
  },
77
+ mounted() {
78
+ var filterStorage = this.getQueryFilter(this.$route.name);
79
+ this.filtersAdded = filterStorage.filtersAdded;
80
+ this.addEvent({ name: "stringFilter", data: this.filterFinal });
81
+ },
81
82
  computed: {
82
- ...mapGetters("generic", ["event"]),
83
+ ...mapGetters("generic", ["event", "getQueryFilter"]),
84
+ ...mapState("generic", ["filterQuery"]),
83
85
  options() {
84
86
  let options = [];
85
87
  this.filters.forEach(filter => {
@@ -91,6 +93,7 @@ export default {
91
93
  options: filter.options,
92
94
  title: filter.title,
93
95
  type: filter.type,
96
+ url: filter.url,
94
97
  value: filter.value
95
98
  });
96
99
  });
@@ -107,7 +110,7 @@ export default {
107
110
  },
108
111
  },
109
112
  methods: {
110
- ...mapMutations("generic", ["addEvent", "hideModal", "removeLoading"]),
113
+ ...mapMutations("generic", ["addEvent", "hideModal", "removeLoading", "addFilterQuery"]),
111
114
  add() {
112
115
  if (this.filterSelected.id && !this.contentExists(this.filterSelected.field)) {
113
116
  this.filtersAdded.push(this.filterSelected);
@@ -134,12 +137,24 @@ export default {
134
137
  this.removeItem(event.data.field);
135
138
  this.addEvent({ name: "stringFilter" });
136
139
  }
140
+
141
+ if (event.name == "filterStorageRemoved") {
142
+ this.filtersAdded = [];
143
+ this.addEvent({ name: "stringFilter", data: this.filterFinal });
144
+ }
137
145
  },
138
146
  deep: true,
139
147
  },
140
148
  filterFinal: {
141
149
  handler(filterFinal) {
142
150
  this.$emit("input", filterFinal);
151
+ this.addFilterQuery({ routeName: this.$route.name, filtersAdded: this.filtersAdded });
152
+ },
153
+ deep: true,
154
+ },
155
+ filterSelected: {
156
+ handler(filterSelected) {
157
+ this.add();
143
158
  },
144
159
  deep: true,
145
160
  },
@@ -168,10 +183,16 @@ export default {
168
183
  margin-bottom: 10px;
169
184
  }
170
185
 
186
+
171
187
  .icon-remove {
188
+ display: flex;
189
+ align-items: center;
190
+ justify-content: center;
191
+ height: 60px;
192
+ width: 30px;
193
+ cursor: pointer;
172
194
  color: #F0134D;
173
195
  cursor: pointer;
174
- margin-top: 15px;
175
196
  font-size: 17px;
176
197
  }
177
198
  </style>
@@ -44,7 +44,7 @@ export default {
44
44
  ...mapGetters("generic", ["showModal", "event"]),
45
45
  },
46
46
  methods: {
47
- ...mapMutations("generic", ["openModal", "addEvent", "removeLoading"]),
47
+ ...mapMutations("generic", ["openModal", "addEvent", "removeLoading", "updateQueryTags"]),
48
48
  openFilter() {
49
49
  this.openModal("filter");
50
50
  this.removeLoading(["btnFilter"]);
@@ -70,6 +70,12 @@ export default {
70
70
  },
71
71
  deep: true,
72
72
  },
73
+ tags: {
74
+ handler(tags) {
75
+ this.updateQueryTags(tags);
76
+ },
77
+ deep: true,
78
+ },
73
79
  },
74
80
 
75
81
  }
@@ -10,13 +10,10 @@
10
10
  </div>
11
11
  <div slot="content-main">
12
12
  <slot name="content-between-search-table"></slot>
13
- <div class="div-tag">
14
- <div class="side-by-side" v-for="tag in tags">
15
- <Tag :_key="tag.key" :disabled="propsParam.showAll" :title="tag.tag" />
16
- </div>
17
- </div>
13
+ <!-- <FilterQuery v-if="filters.length > 0" :filters="filters" v-model="stringFilter" />-->
18
14
  <Molded>
19
- <ListViewWithDataHandler :templateList="templateList" :propsParam="propsParam" :isFilterStorage="true"
15
+ <ListViewWithDataHandler :templateList="templateList"
16
+ :propsParam="{ stringFilter: JSON.stringify(stringFilter) }" :isFilterStorage="true"
20
17
  :buttonRemove="buttonRemove">
21
18
  <div slot="content-buttons-table-header">
22
19
  <slot name="content-buttons-table-header"></slot>
@@ -37,26 +34,28 @@
37
34
  <script>
38
35
  import Panel from "@nixweb/nixloc-ui/src/component/layout/Panel.vue";
39
36
  import Molded from "@nixweb/nixloc-ui/src/component/layout/Molded";
40
- import Tag from "@nixweb/nixloc-ui/src/component/layout/Tag.vue";
41
-
42
37
  import ListViewWithDataHandler from "@nixweb/nixloc-ui/src/component/template/ListViewWithDataHandler.vue";
43
-
44
- import { mapState } from "vuex";
38
+ import FilterQuery from '@nixweb/nixloc-ui/src/component/shared/filter-builder/FilterQuery.vue'
45
39
 
46
40
  export default {
47
41
  name: "TemplateView",
48
- components: { Panel, Molded, Tag, ListViewWithDataHandler },
42
+ components: { Panel, Molded, ListViewWithDataHandler, FilterQuery },
49
43
  props: {
50
44
  panel: Object,
51
45
  templateList: Object,
52
- propsParam: Object,
46
+ filters: {
47
+ type: Array,
48
+ default: [],
49
+ },
53
50
  buttonRemove: {
54
51
  type: Boolean,
55
52
  default: true,
56
53
  },
57
54
  },
58
- computed: {
59
- ...mapState("generic", ["tags"]),
55
+ data() {
56
+ return {
57
+ stringFilter: [],
58
+ }
60
59
  },
61
60
  };
62
61
  </script>
@@ -41,6 +41,8 @@ export default {
41
41
  clearedSearch: false,
42
42
  methodExecutedApi: undefined,
43
43
  filterStorage: [],
44
+ filterQuery: [],
45
+ queryTags: [],
44
46
  },
45
47
  getters: {
46
48
  tip: (state) => (tipId) => {
@@ -69,6 +71,9 @@ export default {
69
71
  getFilterStorage: (state) => (key) => {
70
72
  return state.filterStorage.find(x => x.key === key);
71
73
  },
74
+ getQueryFilter: (state) => (routeName) => {
75
+ return state.filterQuery.find(x => x.routeName === routeName);
76
+ },
72
77
  paramsFilterStorage: (state) => (route, key, returnIfNull) => {
73
78
  var filter = state.filterStorage.find(x => x.key === route);
74
79
 
@@ -360,6 +365,19 @@ export default {
360
365
  let filter = state.filterStorage.filter(x => x.key != key);
361
366
  state.filterStorage = filter;
362
367
  },
368
+ addFilterQuery: (state, obj) => {
369
+ // função abaixo é para não deixar duplicidade
370
+ const index = state.filterQuery.findIndex(x => x.routeName === obj.routeName);
371
+ if (index !== -1) {
372
+ state.filterQuery[index] = obj;
373
+
374
+ } else {
375
+ state.filterQuery.push(obj);
376
+ }
377
+ },
378
+ updateQueryTags: (state, tags) => {
379
+ state.queryTags = tags;
380
+ },
363
381
  },
364
382
  actions: {
365
383
  postApi: async function (context, params) {