quasar-factory-lib 0.0.49 → 0.0.51

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.49",
100
+ "version": "0.0.51",
101
101
  "author": ""
102
102
  }
@@ -3,7 +3,6 @@
3
3
  <!-- eslint-disable vue/no-v-model-argument -->
4
4
  <!-- eslint-disable vue/no-use-v-if-with-v-for -->
5
5
  <div>
6
- {{filteredRows.length}}
7
6
  <q-table
8
7
  v-if="!showSkeleton"
9
8
  ref="myTable"
@@ -12,7 +11,7 @@
12
11
  :grid="smallDevice"
13
12
  :style="tableStyle"
14
13
  flat
15
- :filter-method="customFilter"
14
+ :filter-method="customFilter"
16
15
  bordered
17
16
  :rows="rowsData"
18
17
  :columns="columns"
@@ -175,18 +174,23 @@ export default defineComponent({
175
174
  showSkeleton: {
176
175
  type: Boolean
177
176
  },
177
+ getCellClass: {
178
+ type: Function,
179
+ default: function () {}
180
+ },
181
+ // Needs to be used with additionalFilterConditions and additionalSortConditions
178
182
  filterComputedOptions: {
179
183
  type: Object,
180
184
  default: {}
181
185
  },
182
- getCellClass: {
186
+ additionalFilterConditions: {
187
+ type: Function,
188
+ default: function () {}
189
+ },
190
+ additionalSortConditions: {
183
191
  type: Function,
184
192
  default: function () {}
185
193
  }
186
- // filteredRows: {
187
- // type: Array,
188
- // required: true
189
- // }
190
194
  },
191
195
  emits: [
192
196
  'onSelectVisibleColumns',
@@ -212,8 +216,8 @@ export default defineComponent({
212
216
  loading: false,
213
217
  forceRender: false,
214
218
  totalPage: 0,
215
- pageSize: 5,
216
- filteredRows: [] as object | []
219
+ pageSize: 20,
220
+ filteredRows: [] as object [] | []
217
221
  }
218
222
  },
219
223
  computed: {
@@ -242,7 +246,6 @@ export default defineComponent({
242
246
  pageLength (): number {
243
247
  return (this.totalPage + 1) * this.pageSize
244
248
  }
245
-
246
249
  },
247
250
  watch: {
248
251
  rows (val) {
@@ -251,7 +254,6 @@ export default defineComponent({
251
254
  visibleColumns (val: string [] | []) {
252
255
  this.visibleColumnsData = val
253
256
  }
254
-
255
257
  },
256
258
  mounted () {
257
259
  },
@@ -307,18 +309,23 @@ export default defineComponent({
307
309
  toogleLoading () {
308
310
  this.loading = !this.loading
309
311
  },
310
- customSortMethod(
311
- rows,
312
- sortBy: string,
313
- descending: boolean
314
- ) {
312
+ customSortMethod(rows: object[] | [], sortBy: string, descending: boolean) {
315
313
  let data = []
316
- if (this.store.filterValue === '') {
317
- data = [...this.rows];
314
+ if (this.store.filterValue !== '') {
315
+ data = [...this.filteredRows];
316
+ }
317
+ else {
318
+ data = [...this.rows];
319
+ }
320
+ if (this.additionalSortConditions && this.additionalSortConditions.toString().replace(/\s+/g, '') !== 'function(){}') {
321
+ data = this.additionalSortConditions(this.filteredRows, rows);
318
322
  } else {
319
- data = [...this.filteredRows];
323
+ console.log('else sort')
320
324
  }
321
-
325
+ this.getSortedData(sortBy, data, descending)
326
+ return data.slice(0, this.pageLength);
327
+ },
328
+ getSortedData (sortBy: string, data: object[] | [], descending: boolean) {
322
329
  if (sortBy) {
323
330
  data.sort((a, b) => {
324
331
  const x = descending ? b : a;
@@ -329,12 +336,12 @@ export default defineComponent({
329
336
 
330
337
  const parseDate = (dateString: string): Date => {
331
338
  const [day, month, year] = dateString.split('/');
332
- return new Date(`${year}-${month}-${day}`); // Converte para 'yyyy-mm-dd'
339
+ return new Date(`${year}-${month}-${day}`);
333
340
  };
334
341
 
335
342
  const parseTime = (timeString: string): number => {
336
343
  const [hours, minutes, seconds] = timeString.split(':').map(Number);
337
- return (hours * 3600) + (minutes * 60) + seconds; // Converte para o total de segundos
344
+ return (hours * 3600) + (minutes * 60) + seconds;
338
345
  };
339
346
 
340
347
  if (typeof xValue === 'string' && typeof yValue === 'string') {
@@ -365,25 +372,37 @@ export default defineComponent({
365
372
  }
366
373
  });
367
374
  }
368
- return data.slice(0, this.pageLength);
369
375
  },
370
- customFilter(rows: string | [], terms: { search: string }) {
371
- console.log('terms', terms)
372
- if (this.store.filterValue === '') return this.rows.slice(0, this.pageLength);
373
-
374
- const filteredRows = this.rows.filter((row) => {
375
- const rowValues = Object.values(row).join(" ").toLowerCase();
376
-
377
- if (terms.search && terms.search.trim() !== '') {
378
- if (rowValues.includes(terms.search.toLowerCase())) {
379
- return true;
380
- }
376
+ containsSearchTermInRow (row: object, lowerSearch: string): boolean {
377
+ if (lowerSearch !== '') {
378
+ const values = Object.values(row)
379
+ const valuesLowerCase = values.map((x) => (x + '').toLowerCase())
380
+ for (let val = 0; val < valuesLowerCase.length; val++) {
381
+ if (valuesLowerCase[val].includes(lowerSearch)) {
382
+ return true
381
383
  }
382
- return false
383
- });
384
-
385
- this.filteredRows = filteredRows
386
- return filteredRows.slice(0, this.pageLength);
384
+ }
385
+ }
386
+ return false
387
+ },
388
+ customFilter(rows: object[] | [], terms: { search: string, prepared: boolean }) {
389
+ let filteredRows_ = []
390
+ if (terms.search !== '') {
391
+ const lowerSearch = terms.search ? terms.search.toLowerCase() : ''
392
+ for (let i = 0; i < this.rows.length; i++) {
393
+ if (this.containsSearchTermInRow(this.rows[i], lowerSearch)) {
394
+ filteredRows_.push(this.rows[i])
395
+ }
396
+ }
397
+ }
398
+ else {
399
+ filteredRows_ = rows
400
+ }
401
+ if (this.additionalFilterConditions && this.additionalFilterConditions.toString().replace(/\s+/g, '') !== 'function(){}') {
402
+ filteredRows_ = this.additionalFilterConditions(this.rows, filteredRows_)
403
+ }
404
+ this.filteredRows = filteredRows_
405
+ return filteredRows_.slice(0, this.pageLength)
387
406
  }
388
407
  }
389
408
  })
@@ -28,17 +28,17 @@
28
28
  :key="col.name"
29
29
  >
30
30
  <q-item-section>
31
- <q-item-label class="itemsFontSize ellipsis text-light-gray">
31
+ <q-item-label class="itemsFontSize ellipsis text-color-lightGray">
32
32
  {{
33
33
  col.label
34
- }}
34
+ }}xxxxx
35
35
  </q-item-label>
36
36
  </q-item-section>
37
37
 
38
38
  <q-item-section side>
39
39
  <q-item-label
40
40
  v-if="getColumnValue(col)"
41
- class="itemsFontSize text-almost-black"
41
+ class="itemsFontSize text-color-almostBlack"
42
42
  :class="getCellClass(tablePropsData.row, col)"
43
43
  >
44
44
  <q-icon
@@ -50,6 +50,9 @@
50
50
  font-weight: bold;
51
51
  color: var(--black);
52
52
  }
53
+ .my-table .itemsFontSize{
54
+ font-size: 14px;
55
+ }
53
56
  @media only screen and (max-width: 1100px) {
54
57
  .my-table .q-table__grid-content {
55
58
  overflow: auto;
@@ -1,14 +1,15 @@
1
1
  const utils = {
2
2
  setTableHeight ():string {
3
- const footer = document.getElementsByClassName('q-footer')[0]
4
- let footerHeight = ''
5
- if (footer) {
6
- const computedHeight = window.getComputedStyle(footer).height
3
+ const qPageStickBottom = document.getElementsByClassName('q-page-sticky')[0]
4
+ let footerHeightHeight = ''
5
+ if (qPageStickBottom) {
6
+ const computedHeight = window.getComputedStyle(qPageStickBottom).height
7
7
 
8
8
  if (computedHeight !== 'auto') {
9
- footerHeight = computedHeight.replace('px', '')
9
+ footerHeightHeight = computedHeight.replace('px', '')
10
10
  }
11
11
  }
12
+
12
13
  const header = document.getElementsByClassName('q-header')[0]
13
14
  let headerHeight = ''
14
15
  if (header) {
@@ -18,7 +19,7 @@ const utils = {
18
19
  headerHeight = computedHeight.replace('px', '')
19
20
  }
20
21
  }
21
- const n = Number(footerHeight) + Number(headerHeight)
22
+ const n = Number(footerHeightHeight) + Number(headerHeight)
22
23
  return `height:${window.innerHeight - n}px`
23
24
  }
24
25
  }
package/src/css/app.css CHANGED
@@ -31,10 +31,10 @@
31
31
  .bg-light-peach {
32
32
  background-color: var(--light-peach);
33
33
  }
34
- .text-color-light-gray {
34
+ .text-color-lightGray {
35
35
  color: var(--light-gray);
36
36
  }
37
- .text-color-almost-black {
37
+ .text-color-almostBlack {
38
38
  color: var(--almost-black);
39
39
  }
40
40
  .q-toolbar-unset-height .q-toolbar {
@@ -17,14 +17,14 @@
17
17
  </TaskNavBar>
18
18
  </div>
19
19
  </q-header>
20
- <q-page-container class=" full-width column justify-center">
20
+ <q-page-container>
21
21
  <q-page>
22
22
  <Table
23
23
  ref="table"
24
24
  :rows="rows"
25
25
  :columns="columns"
26
26
  :visible-columns="visibleColumns"
27
- :small-device="false"
27
+ :small-device="smallDevice"
28
28
  :store="store"
29
29
  :table-style="tableStyle"
30
30
  :show-skeleton="false"
@@ -35,6 +35,9 @@
35
35
  @on-update-customized-checkbox-value="onUpdateCustomizedCheckboxValue"
36
36
  @on-click-button="setItemNotFound"
37
37
  />
38
+ <q-page-sticky position="bottom" v-if="smallDevice">
39
+ <q-btn color="accent" icon="arrow_forward" stretch />
40
+ </q-page-sticky>
38
41
  </q-page>
39
42
  </q-page-container>
40
43
  </q-layout>
@@ -56,6 +59,7 @@ export default {
56
59
  },
57
60
  data () {
58
61
  return {
62
+ smallDevice: true,
59
63
  showDialog: false,
60
64
  store: tableStore(),
61
65
  tableStyle: '',
@@ -312,8 +316,8 @@ export default {
312
316
  this.store.cleanTableFilter()
313
317
  this.tableStyle = setTableHeight.setTableHeight()
314
318
  infiniteScroll.handleInfiniteScrollNewTable(this)
315
- this.rows = this.rowsData
316
319
  this.visibleColumns = this.store.visiblecolumns
320
+ this.rows = this.rowsData
317
321
  },
318
322
  methods: {
319
323
  saveSelectedColumns (columns: string []): void {
@@ -7,6 +7,8 @@
7
7
  <div
8
8
  class="full-width"
9
9
  >
10
+ <!-- {{ store.prepared }}
11
+ <q-btn @click="store.prepared = !store.prepared">Click</q-btn> -->
10
12
  <Table
11
13
  ref="table"
12
14
  :rows="rows"
@@ -18,7 +20,6 @@
18
20
  :show-skeleton="false"
19
21
  :selection-type="'multiple'"
20
22
  :getCellClass="getCellClass"
21
- :filtered-rows="filteredRows"
22
23
  @on-select-visible-columns="saveSelectedColumns"
23
24
  @on-update-basic-checkbox-value="onUpdateBasicCheckboxValue"
24
25
  @on-update-customized-checkbox-value="onUpdateCustomizedCheckboxValue"
@@ -32,7 +33,7 @@
32
33
  import Table from '../components/Table/Table.vue'
33
34
  import setTableHeight from '../components/Table/utils/setTableHeight'
34
35
  import infiniteScroll from '../components/Table/utils/infiniteScroll'
35
- import FilterMethod from '../components/Table/utils/filterMethod'
36
+ // import FilterMethod from '../components/Table/utils/filterMethod'
36
37
  // import TableSort from '../components/Table/utils/sort.js'
37
38
  import { tableStore } from '../store/table.js'
38
39
  export default {
@@ -151,7 +152,8 @@ export default {
151
152
  name: 'sodium',
152
153
  label: 'Sodium (mg)',
153
154
  align: 'left',
154
- field: 'sodium'
155
+ field: 'sodium',
156
+ sortable: true
155
157
  },
156
158
  {
157
159
  name: 'calcium',
@@ -321,9 +323,7 @@ export default {
321
323
  iron: '6%'
322
324
  }
323
325
  ],
324
- visibleColumns: [],
325
- sortDateValues: ['dateCreation'],
326
- filteredRows: []
326
+ visibleColumns: []
327
327
  }
328
328
  },
329
329
  mounted () {
@@ -361,9 +361,6 @@ export default {
361
361
  this.store.visiblecolumns = columns
362
362
  this.visibleColumns = columns
363
363
  },
364
- filterMethod (rows: string | [], terms: { search: string }): object[] | [] {
365
- return FilterMethod.filter(this, rows, terms)
366
- },
367
364
  onUpdateBasicCheckboxValue (rows: object []) {
368
365
  console.log(rows, 'onUpdateBasicCheckboxValue')
369
366
  },
@@ -373,21 +370,46 @@ export default {
373
370
  setItemNotFound (rows: object []) {
374
371
  console.log(rows, 'onClickButton')
375
372
  },
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
373
  getCellClass (row, col) {
386
374
  if (col.name === 'dessert' && row.dessert === 'Frozen Yogurt') {
387
375
  return 'text-color-negative-bold';
388
376
  }
389
377
  return '';
378
+ },
379
+ additionalFilterConditions (rows_: object[] | [], filteredRowsParam_: object[] | []) {
380
+ console.log('additional filter conditions')
381
+ filteredRowsParam_ = []
382
+ if (this.store.prepared) {
383
+ for (let i = 0; i < rows_.length; i++) {
384
+ if (rows_[i].sodium >= 300) {
385
+ filteredRowsParam_.push(rows_[i])
386
+ }
387
+ }
388
+ return filteredRowsParam_
389
+ } else {
390
+ return rows_
391
+ }
392
+ },
393
+ additionalSortConditions (filteredRowsData: object[] | [], rows: object[] | []) {
394
+ console.log('conditions sort function')
395
+ if (this.store.prepared) {
396
+
397
+ const filteredRows_ = []
398
+ for (let i = 0; i < rows.length; i++) {
399
+ if (rows[i].sodium >= 300) {
400
+ filteredRows_.push(rows[i])
401
+ }
402
+ }
403
+ filteredRowsData = filteredRows_
404
+ return [...filteredRowsData]
405
+ }
406
+ else if (!this.store.prepared) {
407
+ return [...rows]
408
+ }
390
409
  }
391
410
  }
392
411
  }
393
412
  </script>
413
+ <!-- :filterComputedOptions="{ preparedQuantity: store.prepared}"
414
+ :additional-sort-conditions="additionalSortConditions"
415
+ :additional-filter-conditions="additionalFilterConditions" -->