quasar-factory-lib 0.0.1 → 0.0.2

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
@@ -102,5 +102,5 @@
102
102
  "release": "standard-version"
103
103
  },
104
104
  "type": "module",
105
- "version": "0.0.1"
105
+ "version": "0.0.2"
106
106
  }
@@ -0,0 +1,292 @@
1
+ <template lang="">
2
+ <!-- eslint-disable-file vue/no-v-model-argument -->
3
+ <!-- eslint-disable vue/no-v-model-argument -->
4
+ <!-- eslint-disable vue/no-use-v-if-with-v-for -->
5
+ <div>
6
+ <q-table
7
+ v-if="!showSkeleton"
8
+ ref="myTable"
9
+ v-model:selected="selected"
10
+ class="k-table"
11
+ :grid="smallDevice"
12
+ :style="tableStyle"
13
+ flat
14
+ bordered
15
+ :rows="rowsData"
16
+ :columns="columns"
17
+ :row-key="rowKey"
18
+ :rows-per-page-options="[0]"
19
+ :selection="selectionType"
20
+ :visible-columns="visibleColumns"
21
+ table-class="text-grey-9"
22
+ table-header-class="main-color"
23
+ :filter="filterComputed"
24
+ :filter-method="filterMethod"
25
+ :sort-method="sortMethod"
26
+ separator="horizontal"
27
+ binary-state-sort
28
+ :selected-rows-label="getSelectedString"
29
+ :loading="loading"
30
+ pagination.sync="0"
31
+ :grid-header="showGridHeader"
32
+ >
33
+ <template #top-right="props">
34
+ <q-separator />
35
+ <TableFilter
36
+ v-if="getTableInputSearchVisibility && !hideFilter"
37
+ ref="filterInput"
38
+ class="q-pl-xs"
39
+ :table-props="props"
40
+ :store="store"
41
+ @input-focus="filterInputFocus"
42
+ />
43
+ <TableColumnsSelector
44
+ v-if="getColumnsSelectorVisibility && !hideColumnsSelector "
45
+ class="q-pl-xs"
46
+ :table-props="props"
47
+ :columns="columns"
48
+ :visible-columns="visibleColumns"
49
+ @on-select-visible-columns="onSelectVisibleColumns"
50
+ />
51
+ </template>
52
+ <template #header="props">
53
+ <TableSlotHeader
54
+ :table-props="props"
55
+ :selection-type="selectionType"
56
+ :small-device="smallDevice"
57
+ />
58
+ </template>
59
+ <template #body="props">
60
+ <TableSlotBody
61
+ v-if="!showSkeleton"
62
+ :table-props="props"
63
+ :selection-type="selectionType"
64
+ @on-update-checkbox-value="onUpdateCheckboxValue"
65
+ @on-save-value-popup-edit="onSaveValuePopupEdit"
66
+ @on-click-button="onClickButton"
67
+ @click="onRowClick(props.row)"
68
+ />
69
+ </template>
70
+ <template #item="props">
71
+ <TableSlotGrid
72
+ :table-props="props"
73
+ :selection-type="selectionType"
74
+ :popup-edit-number-options="popupEditNumberOptions"
75
+ @on-update-checkbox-value="onUpdateCheckboxValue"
76
+ @on-save-value-popup-edit="onSaveValuePopupEdit"
77
+ @on-click-button="onClickButton"
78
+ @click="onRowClick(props.row)"
79
+ />
80
+ </template>
81
+ </q-table>
82
+ <TableSkeleton
83
+ v-if="getTableSkeletonVisibility"
84
+ id="tableSkeleton"
85
+ />
86
+ <CardListSkeleton
87
+ v-if="getGridSkeletonVisibility"
88
+ id="cardListSkeleton"
89
+ />
90
+ </div>
91
+ </template>
92
+ <script lang="ts">
93
+ import { defineComponent } from 'vue'
94
+ import type { QTable } from 'quasar'
95
+ import TableSlotHeader from './components/TableSlotHeader.vue'
96
+ import TableColumnsSelector from './components/TableColumnsSelector.vue'
97
+ import TableSlotBody from './components/TableSlotBody.vue'
98
+ import TableSlotGrid from './components/TableSlotGrid.vue'
99
+ import TableFilter from './components/TableFilter.vue'
100
+ import TableSort from './utils/sort.js'
101
+ import TableSkeleton from './components/TableSkeleton.vue'
102
+ import CardListSkeleton from './components/CardListSkeleton.vue'
103
+
104
+ export default defineComponent({
105
+ components: {
106
+ TableSlotHeader,
107
+ TableColumnsSelector,
108
+ TableSlotBody,
109
+ TableSlotGrid,
110
+ TableFilter,
111
+ TableSkeleton,
112
+ CardListSkeleton
113
+ },
114
+ props: {
115
+ columns: {
116
+ type: Array as () => object[],
117
+ required: true
118
+ },
119
+ rows: {
120
+ type: Array as () => object[],
121
+ required: true
122
+ },
123
+ visibleColumns: {
124
+ type: Array as () => string[],
125
+ required: true
126
+ },
127
+ filterMethod: {
128
+ type: Function,
129
+ default: function () {}
130
+ },
131
+ filterComputed: {
132
+ type: Object,
133
+ default: () => {}
134
+ },
135
+ sortDataValues: {
136
+ type: Array,
137
+ default: () => ['']
138
+ },
139
+ selectionType: {
140
+ type: String as () => 'none' | 'single' | 'multiple',
141
+ default: 'none'
142
+ },
143
+ rowKey: {
144
+ type: String,
145
+ default: 'id'
146
+ },
147
+ tableStyle: {
148
+ type: String,
149
+ default: ''
150
+ },
151
+ popupEditNumberOptions: {
152
+ type: Array,
153
+ default: () => []
154
+ },
155
+ smallDevice: {
156
+ type: Boolean,
157
+ required: true
158
+ },
159
+ store: {
160
+ type: Object,
161
+ required: true
162
+ },
163
+ tableId: {
164
+ type: String,
165
+ default: ''
166
+ },
167
+ hideColumnsSelector: {
168
+ type: Boolean,
169
+ default: false
170
+ },
171
+ hideFilter: {
172
+ type: Boolean,
173
+ default: false
174
+ },
175
+ showSkeleton: {
176
+ type: Boolean
177
+ }
178
+ },
179
+ emits: [
180
+ 'onSelectVisibleColumns',
181
+ 'onUpdateCheckboxValue',
182
+ 'onSaveValuePopupEdit',
183
+ 'onClickButton',
184
+ 'storeUpdated',
185
+ 'deleteItem',
186
+ 'openModalWithTable',
187
+ 'setItemNotFound',
188
+ 'onRowClick'],
189
+ data () {
190
+ return {
191
+ selected: [],
192
+ filter: '',
193
+ visibleColumnsData: this.visibleColumns,
194
+ rowsData: [] as object[],
195
+ gridRowsSelected: false,
196
+ selectedRows: [] as number[],
197
+ showColumnsSelector: false,
198
+ showSearch: false,
199
+ loading: false,
200
+ storeData: this.store,
201
+ forceRender: false
202
+ }
203
+ },
204
+ computed: {
205
+ getColumnsSelectorVisibility () {
206
+ return !this.smallDevice || this.showColumnsSelector
207
+ },
208
+ getTableInputSearchVisibility () {
209
+ return !this.smallDevice || this.showSearch
210
+ },
211
+ showGridHeader () {
212
+ return this.selectionType === 'multiple'
213
+ },
214
+ getTableSkeletonVisibility () {
215
+ return !this.smallDevice && this.showSkeleton
216
+ },
217
+ getGridSkeletonVisibility () {
218
+ return this.smallDevice && this.showSkeleton
219
+ }
220
+ },
221
+ watch: {
222
+ rows (val) {
223
+ this.rowsData = val
224
+ }
225
+ },
226
+ mounted () {
227
+ },
228
+ methods: {
229
+ getSelectedString (val: number): string {
230
+ const rowsSelectedLength = val
231
+ if (rowsSelectedLength === 0) {
232
+ return ''
233
+ }
234
+ const recordString = rowsSelectedLength > 1 ? 'records' : 'record'
235
+ return `${rowsSelectedLength} ${recordString} selected`
236
+ },
237
+ onSelectVisibleColumns (columns: string[]) {
238
+ this.$emit('onSelectVisibleColumns', columns)
239
+ },
240
+ onSaveValuePopupEdit (row: object) {
241
+ this.$emit('onSaveValuePopupEdit', row)
242
+ },
243
+ onUpdateCheckboxValue (row: object) {
244
+ this.$emit('onUpdateCheckboxValue', row)
245
+ },
246
+ onClickButton (emit: 'onClickButton', row: object) {
247
+ this.$emit(emit, row)
248
+ },
249
+ onRowClick (row: object) {
250
+ this.$emit('onRowClick', row)
251
+ },
252
+ deleteItem (row: object) {
253
+ this.$emit('deleteItem', row)
254
+ },
255
+ clearTableSelection () {
256
+ const table = this.$refs.myTable as QTable
257
+ table.clearSelection()
258
+ },
259
+ toggleSearchVisibility (store: {disableScannerButtons: boolean, lastFilterValue: string, valueInputFilterTable: string}) {
260
+ this.showSearch = !this.showSearch
261
+ store.disableScannerButtons = false
262
+ store.lastFilterValue = ''
263
+ store.valueInputFilterTable = ''
264
+ },
265
+ toogleColumnsSelectorVisibility () {
266
+ this.showColumnsSelector = !this.showColumnsSelector
267
+ },
268
+ filterInputFocus () {
269
+ setTimeout(() => {
270
+ if (this.$refs.filterInput) {
271
+ this.$refs.filterInput.inputFocus()
272
+ }
273
+ }, 10)
274
+ },
275
+ toogleLoading () {
276
+ this.loading = !this.loading
277
+ },
278
+ sortMethod (rows: object[], sortBy: string, descending: boolean): object[] | [] {
279
+ const allrowsSorted = TableSort.sortMethod(rows, sortBy, descending, this.sortDataValues)
280
+ const rowsSliced = allrowsSorted.slice(0, rows.length)
281
+ if (this.store.valueInputFilterTable === '') {
282
+ return rowsSliced
283
+ } else {
284
+ return TableSort.sortMethod(rows, sortBy, descending, this.sortDataValues)
285
+ }
286
+ }
287
+ }
288
+ })
289
+ </script>
290
+ <style>
291
+ @import url('./style.css');
292
+ </style>
@@ -0,0 +1,35 @@
1
+ <template>
2
+ <q-checkbox
3
+ v-model="modelData"
4
+ :data-cy="dataCy"
5
+ @update:model-value="(val) => {
6
+ $emit('checkBoxEmit', val)
7
+ }"
8
+ />
9
+ </template>
10
+ <script lang="ts">
11
+ export default {
12
+ name: 'BasicCheckBox',
13
+ props: {
14
+ model: {
15
+ type: Boolean,
16
+ required: true
17
+ },
18
+ tableProps: {
19
+ type: Object,
20
+ required: true
21
+ },
22
+ dataCy: {
23
+ type: String,
24
+ required: true
25
+ }
26
+ },
27
+ emits: ['checkBoxEmit'],
28
+ data () {
29
+ return {
30
+ tablePropsData: this.tableProps,
31
+ modelData: this.model
32
+ }
33
+ }
34
+ }
35
+ </script>
@@ -0,0 +1,82 @@
1
+ <template>
2
+ <div>
3
+ <q-item
4
+ v-for="n in 2"
5
+ :key="n"
6
+ >
7
+ <q-card style="width: 100%">
8
+ <q-item>
9
+ <q-item-section>
10
+ <q-item-label>
11
+ <q-skeleton
12
+ type="text"
13
+ width="60%"
14
+ />
15
+ </q-item-label>
16
+ <q-item-label caption>
17
+ <q-skeleton
18
+ type="text"
19
+ width="60%"
20
+ />
21
+ </q-item-label>
22
+ </q-item-section>
23
+ </q-item>
24
+ <q-item>
25
+ <q-item-section>
26
+ <q-item-label>
27
+ <q-skeleton
28
+ type="text"
29
+ width="70%"
30
+ />
31
+ </q-item-label>
32
+ <q-item-label caption>
33
+ <q-skeleton
34
+ type="text"
35
+ width="70%"
36
+ />
37
+ </q-item-label>
38
+ </q-item-section>
39
+ </q-item>
40
+ <q-item>
41
+ <q-item-section>
42
+ <q-item-label>
43
+ <q-skeleton
44
+ type="text"
45
+ width="80%"
46
+ />
47
+ </q-item-label>
48
+ <q-item-label caption>
49
+ <q-skeleton
50
+ type="text"
51
+ width="80%"
52
+ />
53
+ </q-item-label>
54
+ </q-item-section>
55
+ </q-item>
56
+ <q-item>
57
+ <q-item-section>
58
+ <q-item-label>
59
+ <q-skeleton
60
+ type="text"
61
+ width="90%"
62
+ />
63
+ </q-item-label>
64
+ <q-item-label caption>
65
+ <q-skeleton
66
+ type="text"
67
+ width="90%"
68
+ />
69
+ </q-item-label>
70
+ </q-item-section>
71
+ </q-item>
72
+ </q-card>
73
+ </q-item>
74
+ </div>
75
+ </template>
76
+ <script lang="ts">
77
+ export default {
78
+ name: 'CardListSkeleton'
79
+ }
80
+ </script>
81
+
82
+ <style></style>
@@ -0,0 +1,37 @@
1
+ <template>
2
+ <q-btn
3
+ :data-cy="dataCy"
4
+ flat
5
+ round
6
+ :color="btnColor"
7
+ size="md"
8
+ @click="$emit('onClickButton')"
9
+ >
10
+ <q-icon :name="btnIcon" />
11
+ </q-btn>
12
+ </template>
13
+ <script lang="ts">
14
+ export default {
15
+ name: 'CustomizedButton',
16
+ props: {
17
+ dataCy: {
18
+ type: String,
19
+ required: true
20
+ },
21
+ btnColor: {
22
+ type: String,
23
+ required: true
24
+ },
25
+ btnIcon: {
26
+ type: String,
27
+ required: true
28
+ }
29
+
30
+ },
31
+ emits: ['onClickButton'],
32
+ data: function () {
33
+ return {
34
+ }
35
+ }
36
+ }
37
+ </script>
@@ -0,0 +1,56 @@
1
+ <template>
2
+ <q-checkbox
3
+ v-model="modelData"
4
+ :data-cy="dataCy"
5
+ :size="checkBoxIconSize"
6
+ :color="checkBoxColor"
7
+ :keep-color="true"
8
+ :checked-icon="checkedIcon"
9
+ :unchecked-icon="uncheckedIcon"
10
+ @update:model-value="(val) => {
11
+ $emit('checkBoxEmit', val)
12
+ }"
13
+ />
14
+ </template>
15
+ <script lang="ts">
16
+ export default {
17
+ name: 'CustomizedCheckBox',
18
+ props: {
19
+ model: {
20
+ type: Boolean,
21
+ required: true
22
+ },
23
+ tableProps: {
24
+ type: Object,
25
+ required: true
26
+ },
27
+ dataCy: {
28
+ type: String,
29
+ required: true
30
+ },
31
+ checkBoxColor: {
32
+ type: String,
33
+ required: true
34
+ },
35
+ checkBoxIconSize: {
36
+ type: String,
37
+ required: true
38
+ },
39
+ checkedIcon: {
40
+ type: String,
41
+ required: true
42
+ },
43
+ uncheckedIcon: {
44
+ type: String,
45
+ required: true
46
+ }
47
+ },
48
+ emits: ['checkBoxEmit'],
49
+ data () {
50
+ return {
51
+ tablePropsData: this.tableProps,
52
+ modelData: this.model
53
+ }
54
+ }
55
+ }
56
+ </script>
@@ -0,0 +1,34 @@
1
+ <template>
2
+ <q-icon
3
+ :name="
4
+ customizedIconName? customizedIconName : model
5
+ ? 'fa-solid fa-circle-check'
6
+ : 'fa-solid fa-circle-xmark'"
7
+ :color="
8
+ customizedIconColor? customizedIconColor : model? 'green': 'red'"
9
+ :size="customizedIconSize"
10
+ />
11
+ </template>
12
+ <script lang="ts">
13
+ export default {
14
+ name: 'CustomizedIcon',
15
+ props: {
16
+ model: {
17
+ type: Boolean,
18
+ required: true
19
+ },
20
+ customizedIconSize: {
21
+ type: String,
22
+ required: true
23
+ },
24
+ customizedIconName: {
25
+ type: String,
26
+ required: true
27
+ },
28
+ customizedIconColor: {
29
+ type: String,
30
+ required: true
31
+ }
32
+ }
33
+ }
34
+ </script>
@@ -0,0 +1,71 @@
1
+ <template>
2
+ <q-select
3
+ v-model="visibleColumnsData"
4
+ multiple
5
+ outlined
6
+ dense
7
+ options-dense
8
+ :display-value="$q.lang.table.columns"
9
+ emit-value
10
+ map-options
11
+ :options="columns"
12
+ option-value="name"
13
+ options-cover
14
+ class="selectColumns"
15
+ options-selected-class="addicional-visible-columns"
16
+ @update:model-value="onSelectVisibleColumns"
17
+ >
18
+ <template #option="scope">
19
+ <q-item
20
+ v-bind="scope.itemProps"
21
+ :class="scope.opt.required ? 'required-table-columns' : ''"
22
+ >
23
+ <q-item-section>
24
+ <q-item-label>{{ scope.opt.label }}</q-item-label>
25
+ </q-item-section>
26
+ </q-item>
27
+ </template>
28
+ </q-select>
29
+ </template>
30
+ <script lang="ts">
31
+ export default {
32
+ name: 'TableColumnsSelector',
33
+ props: {
34
+ columns: {
35
+ type: Array
36
+ },
37
+ visibleColumns: {
38
+ type: Array,
39
+ required: true
40
+ }
41
+ },
42
+ emits: ['onSelectVisibleColumns'],
43
+ data () {
44
+ return {
45
+ visibleColumnsData: [] as { name: string; required: boolean; label: string }[]
46
+ }
47
+ },
48
+ watch: {
49
+ visibleColumns (value): void {
50
+ this.visibleColumnsData = value
51
+ }
52
+ },
53
+ methods: {
54
+ onSelectVisibleColumns (columns: string[]): void {
55
+ this.$emit('onSelectVisibleColumns', columns)
56
+ }
57
+ }
58
+ }
59
+ </script>
60
+ <style scoped>
61
+ .q-select {
62
+ width: 250px;
63
+ min-width: 150px;
64
+ flex: 1;
65
+ }
66
+ @media only screen and (max-width: 1100px) {
67
+ .q-select {
68
+ padding-top: 5px;
69
+ }
70
+ }
71
+ </style>
@@ -0,0 +1,74 @@
1
+ <template>
2
+ <q-input
3
+ ref="filterRef"
4
+ v-model="localStore.valueInputFilterTable"
5
+ borderless
6
+ dense
7
+ debounce="300"
8
+ class="auto-width"
9
+ placeholder="Search"
10
+ outlined
11
+ >
12
+ <template #append>
13
+ <q-icon
14
+ v-if="localStore.valueInputFilterTable === ''"
15
+ name="search"
16
+ color="black"
17
+ />
18
+ <q-icon
19
+ v-else
20
+ name="clear"
21
+ class="cursor-pointer"
22
+ @click="cleanSearchValue"
23
+ />
24
+ </template>
25
+ </q-input>
26
+ </template>
27
+ <script lang="ts">
28
+ import type { QInput } from 'quasar'
29
+ export default {
30
+ name: 'TableFilter',
31
+ props: {
32
+ store: {
33
+ type: Object,
34
+ required: true
35
+ }
36
+ },
37
+ data () {
38
+ return {
39
+ localStore: this.store
40
+ }
41
+ },
42
+ beforeMount () {
43
+ this.localStore.disableScannerButtons = false
44
+ this.localStore.valueInputFilterTable = ''
45
+ this.localStore.lastFilterValue = ''
46
+ },
47
+ mounted () {
48
+ },
49
+ methods: {
50
+ inputFocus () {
51
+ setTimeout(() => {
52
+ const input = this.$refs.filterRef as QInput
53
+ input.focus()
54
+ }, 10)
55
+ },
56
+ cleanSearchValue () {
57
+ this.localStore.valueInputFilterTable = ''
58
+ this.localStore.lastFilterValue = ''
59
+ }
60
+ }
61
+ }
62
+ </script>
63
+ <style scoped>
64
+ .q-input {
65
+ width: 250px;
66
+ flex: 1;
67
+
68
+ }
69
+ @media only screen and (max-width: 1100px) {
70
+ .q-input {
71
+ padding-top: 5px;
72
+ }
73
+ }
74
+ </style>