@freteclick/quasar-financial-ui 1.0.113 → 1.0.114

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": "@freteclick/quasar-financial-ui",
3
- "version": "1.0.113",
3
+ "version": "1.0.114",
4
4
  "author": "FreteClick",
5
5
  "description": "FreteClick financial Quasar UI Component",
6
6
  "license": "MIT",
@@ -1,12 +1,34 @@
1
1
  <template>
2
- <q-card class="row q-pa-md">
3
- <div class="col-xs-12 q-pb-md text-h6">Faturas</div>
4
- <div class="col-sm-6 col-xs-12 q-pa-md">
5
- <q-input stack-label label="Buscar por" debounce="1000" v-model="filters.text" class="full-width" />
2
+ <q-card
3
+ class="row q-pa-md invoice-filters"
4
+ :class="{ 'invoice-filters--drawer': variant === 'receivables-drawer' }"
5
+ >
6
+ <div v-if="variant !== 'receivables-drawer'" class="col-xs-12 q-pb-md text-h6">
7
+ Faturas
6
8
  </div>
7
- <div class="col-sm-6 col-xs-12 q-pa-md">
8
- <q-select stack-label label="Status da fatura" v-model="filters.status" :options="statuses" class="full-width"
9
- :loading="loadingStatuses">
9
+
10
+ <div class="col-sm-6 col-xs-12 q-pa-md invoice-filters__field">
11
+ <q-input
12
+ v-model="filters.text"
13
+ stack-label
14
+ label="Buscar por"
15
+ debounce="1000"
16
+ :outlined="variant === 'receivables-drawer'"
17
+ :dense="variant === 'receivables-drawer'"
18
+ class="full-width"
19
+ />
20
+ </div>
21
+ <div class="col-sm-6 col-xs-12 q-pa-md invoice-filters__field">
22
+ <q-select
23
+ v-model="filters.status"
24
+ :options="statuses"
25
+ stack-label
26
+ label="Status da fatura"
27
+ :outlined="variant === 'receivables-drawer'"
28
+ :dense="variant === 'receivables-drawer'"
29
+ :loading="loadingStatuses"
30
+ class="full-width"
31
+ >
10
32
  <template v-slot:no-option>
11
33
  <q-item>
12
34
  <q-item-section class="text-grey"> Sem resultados </q-item-section>
@@ -14,9 +36,35 @@
14
36
  </template>
15
37
  </q-select>
16
38
  </div>
17
- <div class="col-6">
18
- <q-select stack-label label="Tipo de Fatura" v-model="filters.orderType" :options="orderType" class="full-width"
19
- :loading="loadingOrderType">
39
+ <div v-if="showCategory" class="col-sm-6 col-xs-12 q-pa-md invoice-filters__field">
40
+ <q-select
41
+ v-model="filters.category"
42
+ :options="categories"
43
+ stack-label
44
+ label="Categoria"
45
+ :outlined="variant === 'receivables-drawer'"
46
+ :dense="variant === 'receivables-drawer'"
47
+ :loading="loadingCategories"
48
+ class="full-width"
49
+ >
50
+ <template v-slot:no-option>
51
+ <q-item>
52
+ <q-item-section class="text-grey">Sem categorias</q-item-section>
53
+ </q-item>
54
+ </template>
55
+ </q-select>
56
+ </div>
57
+ <div class="col-6 q-pa-md invoice-filters__field">
58
+ <q-select
59
+ v-model="filters.orderType"
60
+ :options="orderType"
61
+ stack-label
62
+ label="Tipo de Fatura"
63
+ :outlined="variant === 'receivables-drawer'"
64
+ :dense="variant === 'receivables-drawer'"
65
+ :loading="loadingOrderType"
66
+ class="full-width"
67
+ >
20
68
  <template v-slot:no-option>
21
69
  <q-item>
22
70
  <q-item-section class="text-grey"> Sem resultados </q-item-section>
@@ -24,7 +72,7 @@
24
72
  </template>
25
73
  </q-select>
26
74
  </div>
27
- <div class="col-6">
75
+ <div class="col-6 q-pa-md invoice-filters__field invoice-filters__date">
28
76
  <DataFilter :fromDate="filters.date.from" :toDate="filters.date.to" :showButton="false"
29
77
  @dateChanged="dateChanged" />
30
78
  </div>
@@ -45,10 +93,19 @@ export default {
45
93
  type: Object,
46
94
  required: true,
47
95
  },
96
+ variant: {
97
+ type: String,
98
+ default: "default",
99
+ },
100
+ showCategory: {
101
+ type: Boolean,
102
+ default: false,
103
+ },
48
104
  },
49
105
 
50
106
  created() {
51
107
  this.requestStatuses();
108
+ if (this.showCategory) this.requestCategories(this.filters.company);
52
109
  },
53
110
 
54
111
  data() {
@@ -56,7 +113,9 @@ export default {
56
113
 
57
114
  return {
58
115
  statuses: statuses,
116
+ categories: [{ label: "Todas", value: null }],
59
117
  loadingStatuses: false,
118
+ loadingCategories: false,
60
119
  loadingOrderType: false,
61
120
  orderType: [
62
121
  {
@@ -95,39 +154,80 @@ export default {
95
154
  "filters.status"() {
96
155
  this.$emit("onRequest");
97
156
  },
157
+ "filters.category"() {
158
+ if (this.showCategory) this.$emit("onRequest");
159
+ },
160
+ "filters.company"(company) {
161
+ if (this.showCategory) this.requestCategories(company);
162
+ },
98
163
  },
99
164
 
100
165
  methods: {
101
166
  ...mapActions({
102
167
  getStatuses: "receiveInvoice/getStatuses",
168
+ getCategories: "categories/getCategories",
103
169
  }),
104
170
 
171
+ requestCategories(company) {
172
+ if (!company || !company.id) {
173
+ this.categories = [{ label: "Todas", value: null }];
174
+ return Promise.resolve(this.categories);
175
+ }
176
+
177
+ this.loadingCategories = true;
178
+ return this.getCategories({
179
+ params: {
180
+ context: "expense",
181
+ company: company.id,
182
+ },
183
+ })
184
+ .then((members) => {
185
+ const options = [{ label: "Todas", value: null }];
186
+ (members || []).forEach((category) => {
187
+ const idFromIri = String(category["@id"] || "").match(/\/categories\/(\d+)$/);
188
+ const id = Number(category.id || (idFromIri && idFromIri[1]));
189
+
190
+ if (id) options.push({ label: category.name, value: id });
191
+ });
192
+ this.categories = options;
193
+ return options;
194
+ })
195
+ .catch(() => {
196
+ this.categories = [{ label: "Todas", value: null }];
197
+ return this.categories;
198
+ })
199
+ .finally(() => {
200
+ this.loadingCategories = false;
201
+ });
202
+ },
203
+
105
204
  requestStatuses() {
106
205
  this.loadingStatuses = true;
107
- this.getStatuses({
206
+ return this.getStatuses({
108
207
  visibility: "public",
109
208
  context: "invoice",
110
209
  realStatus: ["open", "pending", "canceled", "closed"],
111
- }).then((statuses) => {
112
- if (statuses.length) {
113
- let data = [];
210
+ })
211
+ .then((statuses) => {
212
+ const data = [{ label: "Todos", value: null }];
213
+ (Array.isArray(statuses) ? statuses : []).forEach((status) => {
214
+ const id = String(status["@id"] || "").replace(/[^0-9]/g, "");
215
+ if (!id) return;
114
216
 
115
- data.push({
116
- label: "Todos",
117
- value: null,
118
- });
119
-
120
- for (let index in statuses) {
121
217
  data.push({
122
- label: this.$t(`invoice.statuses.${statuses[index].status}`),
123
- value: statuses[index]["@id"].replace(/[^0-9]/g, ""),
218
+ label: this.$t(`invoice.statuses.${status.status}`),
219
+ value: id,
124
220
  });
125
- }
221
+ });
126
222
 
127
223
  this.statuses = data;
128
- }
129
- this.loadingStatuses = false;
130
- });
224
+ })
225
+ .catch(() => {
226
+ this.statuses = [{ label: "Todos", value: null }];
227
+ })
228
+ .finally(() => {
229
+ this.loadingStatuses = false;
230
+ });
131
231
  },
132
232
  dateChanged(item) {
133
233
  this.filters.date = item;
@@ -135,4 +235,58 @@ export default {
135
235
  },
136
236
  },
137
237
  };
138
- </script>
238
+ </script>
239
+
240
+ <style lang="scss" scoped>
241
+ .invoice-filters--drawer {
242
+ display: flex;
243
+ flex-flow: column nowrap;
244
+ align-items: stretch;
245
+ gap: 14px;
246
+ width: 100%;
247
+ padding: 0;
248
+ border: 0;
249
+ border-radius: 0;
250
+ background: transparent;
251
+ box-shadow: none;
252
+ }
253
+
254
+ .invoice-filters--drawer > .invoice-filters__field {
255
+ flex: 0 0 auto;
256
+ width: 100%;
257
+ min-width: 0;
258
+ max-width: none;
259
+ margin: 0;
260
+ padding: 0 !important;
261
+ }
262
+
263
+ .invoice-filters--drawer :deep(.q-field) {
264
+ width: 100%;
265
+ min-width: 0;
266
+ }
267
+
268
+ .invoice-filters--drawer :deep(.q-field__control),
269
+ .invoice-filters--drawer :deep(.q-field__control:before),
270
+ .invoice-filters--drawer :deep(.q-field__control:after) {
271
+ min-height: 42px;
272
+ border-radius: 10px;
273
+ }
274
+
275
+ .invoice-filters--drawer :deep(.container-filter) {
276
+ flex-direction: column;
277
+ align-items: stretch;
278
+ justify-content: flex-start;
279
+ gap: 10px;
280
+ padding: 0;
281
+ }
282
+
283
+ .invoice-filters--drawer :deep(.date-filter__field) {
284
+ flex: 0 0 auto;
285
+ width: 100%;
286
+ max-width: none;
287
+ min-width: 0;
288
+ min-height: 0;
289
+ margin: 0;
290
+ }
291
+
292
+ </style>