quasar-factory-lib 0.0.46 → 0.0.48

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
@@ -97,6 +97,6 @@
97
97
  "release": "standard-version"
98
98
  },
99
99
  "type": "module",
100
- "version": "0.0.46",
100
+ "version": "0.0.48",
101
101
  "author": ""
102
102
  }
@@ -22,7 +22,7 @@
22
22
  table-header-class="main-color"
23
23
  :filter="filterComputed"
24
24
  :filter-method="filterMethod"
25
- :sort-method="sortMethod"
25
+ :sort-method="customSortMethod"
26
26
  separator="horizontal"
27
27
  binary-state-sort
28
28
  :selected-rows-label="getSelectedString"
@@ -61,6 +61,7 @@
61
61
  v-if="!showSkeleton"
62
62
  :table-props="props"
63
63
  :selection-type="selectionType"
64
+ :getCellClass="getCellClass"
64
65
  @on-update-basic-checkbox-value="onUpdateBasicCheckboxValue"
65
66
  @on-update-customized-checkbox-value="onUpdateCustomizedCheckboxValue"
66
67
  @on-save-value-popup-edit="onSaveValuePopupEdit"
@@ -74,6 +75,7 @@
74
75
  :table-props="props"
75
76
  :selection-type="selectionType"
76
77
  :popup-edit-number-options="popupEditNumberOptions"
78
+ :getCellClass="getCellClass"
77
79
  @on-update-customized-checkbox-value="onUpdateCustomizedCheckboxValue"
78
80
  @on-update-basic-checkbox-value="onUpdateBasicCheckboxValue"
79
81
  @on-save-value-popup-edit="onSaveValuePopupEdit"
@@ -129,10 +131,10 @@ export default defineComponent({
129
131
  type: Function,
130
132
  default: function () {}
131
133
  },
132
- sortMethod: {
133
- type: Function,
134
- default: function () {}
135
- },
134
+ // sortMethod: {
135
+ // type: Function,
136
+ // default: function () {}
137
+ // },
136
138
  selectionType: {
137
139
  type: String as () => 'none' | 'single' | 'multiple',
138
140
  default: 'none'
@@ -171,6 +173,14 @@ export default defineComponent({
171
173
  },
172
174
  showSkeleton: {
173
175
  type: Boolean
176
+ },
177
+ filterComputedOptions: {
178
+ type: Object,
179
+ default: {}
180
+ },
181
+ getCellClass: {
182
+ type: Function,
183
+ default: function () {}
174
184
  }
175
185
  },
176
186
  emits: [
@@ -219,7 +229,8 @@ export default defineComponent({
219
229
  filterComputed ():object {
220
230
  return {
221
231
  search: this.store.filterValue,
222
- forceRender: this.forceRender
232
+ forceRender: this.forceRender,
233
+ ...this.filterComputedOptions
223
234
  }
224
235
  },
225
236
  pageLength (): number {
@@ -287,7 +298,63 @@ export default defineComponent({
287
298
  },
288
299
  toogleLoading () {
289
300
  this.loading = !this.loading
301
+ },
302
+ customSortMethod(
303
+ rows,
304
+ sortBy: string,
305
+ descending: boolean
306
+ ) {
307
+ const data = [...rows];
308
+
309
+ if (sortBy) {
310
+ data.sort((a, b) => {
311
+ const x = descending ? b : a;
312
+ const y = descending ? a : b;
313
+
314
+ const xValue = x[sortBy];
315
+ const yValue = y[sortBy];
316
+
317
+ const parseDate = (dateString: string): Date => {
318
+ const [day, month, year] = dateString.split('/');
319
+ return new Date(`${year}-${month}-${day}`); // Converte para 'yyyy-mm-dd'
320
+ };
321
+
322
+ const parseTime = (timeString: string): number => {
323
+ const [hours, minutes, seconds] = timeString.split(':').map(Number);
324
+ return (hours * 3600) + (minutes * 60) + seconds; // Converte para o total de segundos
325
+ };
326
+
327
+ if (typeof xValue === 'string' && typeof yValue === 'string') {
328
+ const xDate = parseDate(xValue);
329
+ const yDate = parseDate(yValue);
330
+
331
+ if (!isNaN(xDate.getTime()) && !isNaN(yDate.getTime())) {
332
+ return xDate.getTime() - yDate.getTime();
333
+ }
334
+
335
+ const xTime = parseTime(xValue);
336
+ const yTime = parseTime(yValue);
337
+
338
+ if (!isNaN(xTime) && !isNaN(yTime)) {
339
+ return xTime - yTime;
340
+ } else {
341
+ return xValue.localeCompare(yValue);
342
+ }
343
+ }
344
+ else if (typeof xValue === 'number' && typeof yValue === 'number') {
345
+ return xValue - yValue;
346
+ }
347
+ else if (typeof xValue === 'boolean' && typeof yValue === 'boolean') {
348
+ return xValue === yValue ? 0 : xValue ? 1 : -1;
349
+ }
350
+ else {
351
+ return String(xValue) > String(yValue) ? 1 : String(xValue) < String(yValue) ? -1 : 0;
352
+ }
353
+ });
354
+ }
355
+ return data;
290
356
  }
357
+
291
358
  }
292
359
  })
293
360
  </script>
@@ -19,7 +19,7 @@
19
19
  :props="tablePropsData"
20
20
  >
21
21
  <span
22
- :style="tablePropsData.row.tdStyle"
22
+ :class="getCellClass(tablePropsData.row, col)"
23
23
  v-if="getColumnValue(col)"
24
24
  v-html="tablePropsData.row[col.name]"
25
25
  />
@@ -114,6 +114,10 @@ export default {
114
114
  selectionType: {
115
115
  type: String,
116
116
  default: 'none'
117
+ },
118
+ getCellClass: {
119
+ type: Function,
120
+ default: function () {}
117
121
  }
118
122
  },
119
123
  watch: {
@@ -39,7 +39,7 @@
39
39
  <q-item-label
40
40
  v-if="getColumnValue(col)"
41
41
  class="itemsFontSize text-almost-black"
42
- :style="tablePropsData.row.tdStyle"
42
+ :class="getCellClass(tablePropsData.row, col)"
43
43
  >
44
44
  <q-icon
45
45
  v-if="col.editable"
@@ -147,6 +147,10 @@ export default {
147
147
  },
148
148
  popupEditNumberOptions: {
149
149
  type: Array
150
+ },
151
+ getCellClass: {
152
+ type: Function,
153
+ default: function () {}
150
154
  }
151
155
  },
152
156
  emits: [
package/src/css/app.css CHANGED
@@ -44,4 +44,13 @@
44
44
 
45
45
  .text-color-positive {
46
46
  color: var(--positive);
47
- }
47
+ font-weight: bold;
48
+ }
49
+ .text-color-negative-bold {
50
+ color: var(--negative);
51
+ font-weight: bold;
52
+ font-size: 30px;
53
+ }
54
+
55
+ /* const labelTextColor = 'color: #597765 !important;'
56
+ const labelTextColorBold = 'color: #597765 !important; font-weight: bold;' */
@@ -30,7 +30,6 @@
30
30
  :show-skeleton="false"
31
31
  :selection-type="'multiple'"
32
32
  :filter-method="filterMethod"
33
- :filter-computed="filter"
34
33
  @on-select-visible-columns="saveSelectedColumns"
35
34
  @on-update-basic-checkbox-value="onUpdateBasicCheckboxValue"
36
35
  @on-update-customized-checkbox-value="onUpdateCustomizedCheckboxValue"
@@ -58,10 +57,7 @@ export default {
58
57
  data () {
59
58
  return {
60
59
  showDialog: false,
61
- forceRender: false,
62
60
  store: tableStore(),
63
- totalPage: 0,
64
- pageSize: 20,
65
61
  tableStyle: '',
66
62
  columns: [{
67
63
  name: 'name',
@@ -312,17 +308,6 @@ export default {
312
308
  visibleColumns: []
313
309
  }
314
310
  },
315
- computed: {
316
- pageLength (): number {
317
- return (this.totalPage + 1) * this.pageSize
318
- },
319
- filter ():object {
320
- return {
321
- search: this.store.filterValue,
322
- forceRender: this.forceRender
323
- }
324
- }
325
- },
326
311
  mounted () {
327
312
  this.store.cleanTableFilter()
328
313
  this.tableStyle = setTableHeight.setTableHeight()
@@ -8,6 +8,7 @@
8
8
  class="full-width"
9
9
  >
10
10
  <Table
11
+ ref="table"
11
12
  :rows="rows"
12
13
  :columns="columns"
13
14
  :visible-columns="visibleColumns"
@@ -16,9 +17,8 @@
16
17
  :table-style="tableStyle"
17
18
  :show-skeleton="false"
18
19
  :selection-type="'multiple'"
20
+ :getCellClass="getCellClass"
19
21
  :filter-method="filterMethod"
20
- :filter-computed="filter"
21
- :sort-method="sortMethod"
22
22
  @on-select-visible-columns="saveSelectedColumns"
23
23
  @on-update-basic-checkbox-value="onUpdateBasicCheckboxValue"
24
24
  @on-update-customized-checkbox-value="onUpdateCustomizedCheckboxValue"
@@ -33,7 +33,7 @@ import Table from '../components/Table/Table.vue'
33
33
  import setTableHeight from '../components/Table/utils/setTableHeight'
34
34
  import infiniteScroll from '../components/Table/utils/infiniteScroll'
35
35
  import FilterMethod from '../components/Table/utils/filterMethod'
36
- import TableSort from '../components/Table/utils/sort.js'
36
+ // import TableSort from '../components/Table/utils/sort.js'
37
37
  import { tableStore } from '../store/table.js'
38
38
  export default {
39
39
  components: {
@@ -42,17 +42,32 @@ export default {
42
42
  data () {
43
43
  return {
44
44
  showDialog: false,
45
- forceRender: false,
46
45
  store: tableStore(),
47
- totalPage: 0,
48
- pageSize: 20,
49
46
  tableStyle: '',
50
- columns: [{
51
- name: 'name',
47
+ columns: [
48
+ {
49
+ name: 'date',
50
+ required: true,
51
+ label: 'Date',
52
+ align: 'left',
53
+ sortable: true,
54
+ field: 'date',
55
+ },
56
+ {
57
+ name: 'time',
58
+ required: true,
59
+ label: 'Time',
60
+ align: 'left',
61
+ sortable: true,
62
+ field: 'time',
63
+ },
64
+ {
65
+ name: 'dessert',
52
66
  required: true,
53
- label: 'Dessert (100g serving)',
67
+ label: 'Dessert',
54
68
  align: 'left',
55
- sortable: true
69
+ sortable: true,
70
+ field: 'dessert'
56
71
  },
57
72
  {
58
73
  name: 'available',
@@ -60,7 +75,8 @@ export default {
60
75
  label: 'Available',
61
76
  align: 'left',
62
77
  sortable: true,
63
- showBasicCheckbox: true
78
+ showBasicCheckbox: true,
79
+ field: 'available'
64
80
  },
65
81
  {
66
82
  name: 'booleanIcon',
@@ -72,10 +88,10 @@ export default {
72
88
  },
73
89
  {
74
90
  name: 'calories',
75
- align: 'center',
76
91
  label: 'Calories',
77
92
  field: 'calories',
78
93
  sortable: true,
94
+ align: 'left',
79
95
  editable: true,
80
96
  showEditIcon: true,
81
97
  popupEditEmit: 'onSaveValuePopupEdit',
@@ -88,6 +104,7 @@ export default {
88
104
  label: 'Fat (g)',
89
105
  field: 'fat',
90
106
  sortable: true,
107
+ align: 'left',
91
108
  showCustomizedButton: true,
92
109
  btnIcon: 'save',
93
110
  btnEmit: 'onClickButton',
@@ -97,7 +114,10 @@ export default {
97
114
  {
98
115
  name: 'carbs',
99
116
  label: 'Carbs (g)',
100
- field: 'carbs'
117
+ field: 'carbs',
118
+ align: 'left',
119
+ sortable: true,
120
+ format: (val: number) => `${val}`
101
121
  },
102
122
  {
103
123
  name: 'checked',
@@ -105,6 +125,7 @@ export default {
105
125
  field: 'carbs',
106
126
  sortable: true,
107
127
  required: true,
128
+ align: 'left',
108
129
  showCustomizedCheckBox: true,
109
130
  checkedIcon: 'check_circle',
110
131
  uncheckedIcon: 'cancel',
@@ -116,6 +137,7 @@ export default {
116
137
  name: 'protein',
117
138
  label: 'Protein (g)',
118
139
  field: 'protein',
140
+ align: 'left',
119
141
  sortable: true,
120
142
  required: true,
121
143
  editable: true,
@@ -128,26 +150,30 @@ export default {
128
150
  {
129
151
  name: 'sodium',
130
152
  label: 'Sodium (mg)',
153
+ align: 'left',
131
154
  field: 'sodium'
132
155
  },
133
156
  {
134
157
  name: 'calcium',
135
158
  label: 'Calcium (%)',
136
159
  field: 'calcium',
160
+ align: 'left',
137
161
  sortable: true
138
162
  },
139
163
  {
140
164
  name: 'iron',
141
165
  label: 'Iron (%)',
142
166
  field: 'iron',
167
+ align: 'left',
143
168
  sortable: true
144
169
  }
145
170
  ],
146
171
  rows: [],
147
172
  rowsData: [
148
173
  {
149
- tdStyle: "color: #597765 !important; font-weight: bold;",
150
- name: 'Frozen Yogurt',
174
+ date: '12/12/2024',
175
+ time: '12:20:40',
176
+ dessert: 'Frozen Yogurt',
151
177
  booleanIcon: true,
152
178
  available: true,
153
179
  calories: 159,
@@ -160,7 +186,9 @@ export default {
160
186
  iron: '1%'
161
187
  },
162
188
  {
163
- name: 'Ice cream sandwich',
189
+ date: '18/12/2024',
190
+ time: '11:00:54',
191
+ dessert: 'Ice cream sandwich',
164
192
  booleanIcon: true,
165
193
  available: false,
166
194
  calories: 237,
@@ -173,7 +201,9 @@ export default {
173
201
  iron: '1%'
174
202
  },
175
203
  {
176
- name: 'Eclair',
204
+ date: '05/07/2024',
205
+ time: ' 7:01:24',
206
+ dessert: 'Eclair',
177
207
  booleanIcon: true,
178
208
  available: true,
179
209
  calories: 262,
@@ -186,7 +216,9 @@ export default {
186
216
  iron: '7%'
187
217
  },
188
218
  {
189
- name: 'Cupcake',
219
+ date: '10/12/2023',
220
+ time: '12:04:33',
221
+ dessert: 'Cupcake',
190
222
  booleanIcon: false,
191
223
  available: false,
192
224
  calories: 305,
@@ -199,7 +231,9 @@ export default {
199
231
  iron: '8%'
200
232
  },
201
233
  {
202
- name: 'Gingerbread',
234
+ date: '16/05/1999',
235
+ time: '10:43:25',
236
+ dessert: 'Gingerbread',
203
237
  booleanIcon: true,
204
238
  available: true,
205
239
  calories: 356,
@@ -212,7 +246,9 @@ export default {
212
246
  iron: '16%'
213
247
  },
214
248
  {
215
- name: 'Jelly bean',
249
+ date: '01/01/0001',
250
+ time: '11:35:04',
251
+ dessert: 'Jelly bean',
216
252
  booleanIcon: false,
217
253
  available: false,
218
254
  calories: 375,
@@ -225,7 +261,9 @@ export default {
225
261
  iron: '0%'
226
262
  },
227
263
  {
228
- name: 'Lollipop',
264
+ date: '12/12/2024',
265
+ time: '12:51:01',
266
+ dessert: 'Lollipop',
229
267
  booleanIcon: true,
230
268
  available: true,
231
269
  calories: 392,
@@ -238,7 +276,9 @@ export default {
238
276
  iron: '2%'
239
277
  },
240
278
  {
241
- name: 'Honeycomb',
279
+ date: '05/07/2022',
280
+ time: '14:39:34',
281
+ dessert: 'Honeycomb',
242
282
  booleanIcon: true,
243
283
  available: false,
244
284
  calories: 408,
@@ -251,7 +291,9 @@ export default {
251
291
  iron: '45%'
252
292
  },
253
293
  {
254
- name: 'Donut',
294
+ date: '14/03/2023',
295
+ time: '10:43:26',
296
+ dessert: 'Donut',
255
297
  booleanIcon: true,
256
298
  available: true,
257
299
  calories: 452,
@@ -264,7 +306,9 @@ export default {
264
306
  iron: '22%'
265
307
  },
266
308
  {
267
- name: 'KitKat',
309
+ date: '12/12/2023',
310
+ time: '07:45:12',
311
+ dessert: 'KitKat',
268
312
  booleanIcon: false,
269
313
  available: false,
270
314
  calories: 518,
@@ -282,25 +326,37 @@ export default {
282
326
  filteredRows: []
283
327
  }
284
328
  },
285
- computed: {
286
- pageLength (): number {
287
- return (this.totalPage + 1) * this.pageSize
288
- },
289
- filter ():object {
290
- return {
291
- search: this.store.filterValue,
292
- forceRender: this.forceRender
293
- }
294
- }
295
- },
296
329
  mounted () {
297
330
  this.store.cleanTableFilter()
298
331
  this.visibleColumns = this.store.visiblecolumns
299
332
  this.tableStyle = setTableHeight.setTableHeight()
300
333
  infiniteScroll.handleInfiniteScrollNewTable(this)
301
- this.rows = this.rowsData
334
+ this.getRows()
335
+
302
336
  },
303
337
  methods: {
338
+ getRows () {
339
+ this.rows = []
340
+ const lista = this.rowsData
341
+ for (let i = 0; i < lista.length; i++) {
342
+ this.rows.push({
343
+ id: i + '-' + lista[i].dessert,
344
+ date: lista[i].date,
345
+ time: lista[i].time,
346
+ dessert: lista[i].dessert,
347
+ booleanIcon: lista[i].booleanIcon,
348
+ available: lista[i].available,
349
+ calories: lista[i].calories,
350
+ fat: lista[i].fat,
351
+ carbs: lista[i].carbs,
352
+ checked: lista[i].checked,
353
+ protein: lista[i].protein,
354
+ sodium: lista[i].sodium,
355
+ calcium: lista[i].calcium,
356
+ iron: lista[i].iron
357
+ })
358
+ }
359
+ },
304
360
  saveSelectedColumns (columns: string []): void {
305
361
  this.store.visiblecolumns = columns
306
362
  this.visibleColumns = columns
@@ -317,14 +373,20 @@ export default {
317
373
  setItemNotFound (rows: object []) {
318
374
  console.log(rows, 'onClickButton')
319
375
  },
320
- sortMethod (rows: object[], sortBy: string, descending: boolean): object[] | [] {
321
- let allrowsSorted = []
322
- if (this.store.filterValue !== '') {
323
- allrowsSorted = TableSort.sortMethod(this.filteredRows, sortBy, descending, this.sortDateValues)
324
- } else {
325
- allrowsSorted = TableSort.sortMethod(this.rows, sortBy, descending, this.sortDateValues)
376
+ // sortMethod (rows: object[], sortBy: string, descending: boolean): object[] | [] {
377
+ // let allrowsSorted = []
378
+ // if (this.store.filterValue !== '') {
379
+ // allrowsSorted = TableSort.sortMethod(this.filteredRows, sortBy, descending, this.sortDateValues)
380
+ // } else {
381
+ // allrowsSorted = TableSort.sortMethod(this.rows, sortBy, descending, this.sortDateValues)
382
+ // }
383
+ // return allrowsSorted.slice(0, rows.length)
384
+ // },
385
+ getCellClass (row, col) {
386
+ if (col.name === 'dessert' && row.dessert === 'Frozen Yogurt') {
387
+ return 'text-color-negative-bold';
326
388
  }
327
- return allrowsSorted.slice(0, rows.length)
389
+ return '';
328
390
  }
329
391
  }
330
392
  }