@tablemodels/fontawesome-vuetify 1.0.5

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.
@@ -0,0 +1,347 @@
1
+ <script lang="ts">
2
+ import { ref } from 'vue'
3
+ import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
4
+ import { faRefresh, faSearch } from '@fortawesome/free-solid-svg-icons';
5
+ import { HeaderModel } from './../models/tablemodels';
6
+ import { PaginatonModel } from './../models/tablemodels';
7
+ import { change, Id, load, rowClick, search } from '../helpers/resources';
8
+ import Date from '../headerFilters/Date.vue';
9
+ import Search from '../search/SearchView.vue';
10
+ import Text from '../headerFilters/Text.vue';
11
+ import Number from '../headerFilters/Number.vue';
12
+ import Filters from '../headerFilters/Filters.vue';
13
+ import SortView from '../sort/SortView.vue';
14
+ import PaginationView from '../pagination/PaginationView.vue';
15
+ import DataItem from './data/ItemView.vue';
16
+
17
+ export default {
18
+ props: {
19
+ dataheader: {
20
+ type: Array<HeaderModel[]>,
21
+ default: () => []
22
+ },
23
+ key: {
24
+ type: String,
25
+ default: () => 'Id'
26
+ },
27
+ name: {
28
+ type: String
29
+ },
30
+ dataItems: {
31
+ type: Array<Object[]>,
32
+ required: true
33
+ },
34
+ currentItem: {
35
+ type: Object,
36
+ required: false
37
+ },
38
+ currentId: {
39
+ type: Number,
40
+ required: false
41
+ },
42
+ loading: {
43
+ type: Boolean,
44
+ required: false,
45
+ default: false
46
+ },
47
+ crud: {
48
+ type: Boolean,
49
+ required: false,
50
+ default: false
51
+ },
52
+ showFilters: {
53
+ type: Boolean,
54
+ required: false,
55
+ default: () => false
56
+ },
57
+ dialogWidth: {
58
+ type: Number,
59
+ default: () => 800
60
+ },
61
+ itemsPerPage: {
62
+ type: Number,
63
+ default: () => 10
64
+ },
65
+ pagination: {
66
+ type: PaginatonModel,
67
+ required: false,
68
+ default: () => new PaginatonModel()
69
+ },
70
+ showTime: {
71
+ type: Boolean,
72
+ required: false,
73
+ default: () => false
74
+ }
75
+ },
76
+ components: {
77
+ FontAwesomeIcon: FontAwesomeIcon,
78
+ Date: Date,
79
+ Text: Text,
80
+ Number: Number,
81
+ SortView: SortView,
82
+ PaginationView: PaginationView,
83
+ Filters: Filters,
84
+ DataItem: DataItem,
85
+ Search: Search
86
+ },
87
+ mounted() {
88
+ this.firstChange = true;
89
+ this.load({});
90
+ },
91
+ watch: {
92
+ dataItems(newValue, oldValue) {
93
+ this.dataItems = newValue;
94
+ if(this.firstChange){
95
+ this.initFilters();
96
+ this.firstChange = false;
97
+ }
98
+ },
99
+ pagination(newValue: PaginatonModel, oldValue) {
100
+ this.page = newValue.CurrentPage;
101
+ this.perPage = newValue.PerPage;
102
+ this.pageCount = newValue.PageCount;
103
+ this.totalCount = newValue.TotalCount;
104
+ }
105
+ },
106
+ emits: [change, load, rowClick, search],
107
+ data() {
108
+ return {
109
+ dataheader: this.dataheader,
110
+ dataItems: this.dataItems,
111
+ dialog: false,
112
+ new: true,
113
+ key: this.key ?? Id,
114
+ name: this.name,
115
+ currentId: this.currentId,
116
+ currentItem: this.currentItem,
117
+ loading: this.loading,
118
+ faSearch: faSearch,
119
+ reload: faRefresh,
120
+ lastItem: {},
121
+ completes: this.completes,
122
+ filters: { CurrentPage: 1, PerPage: 10, SortColumn: '', SortDirection: 1 } as any,
123
+ showFilters: this.showFilters,
124
+ modelValue: ref([]),
125
+ firstChange: true,
126
+ perPage: this.pagination!.PerPage,
127
+ page: this.pagination!.CurrentPage,
128
+ pageCount: this.pagination!.PageCount,
129
+ totalCount:this.pagination!.TotalCount,
130
+ showTime: this.showTime,
131
+ };
132
+ },
133
+ methods: {
134
+ rowClick(event: {}){
135
+ this.$emit(rowClick, event);
136
+ },
137
+ load(event: {}){
138
+ if(this.onLoad) this.onLoad(event);
139
+ },
140
+ refresh(){
141
+ this.clear();
142
+ this.search();
143
+ },
144
+ clear(){
145
+ for(let prop of Object.keys(this.filters)){
146
+ this.filters[prop] = null;
147
+ }
148
+ },
149
+ initFilters() {
150
+ let item = this.dataItems[0];
151
+ for(let key of Object.keys(item)){
152
+ this.filters[key] = null;
153
+ }
154
+ this.filters.CurrentPage = 0;
155
+ this.filters.PerPage = 0;
156
+ },
157
+ search(){
158
+ if(this.filters != undefined){
159
+ this.$emit(search, this.filters);
160
+ }
161
+ },
162
+ async updateItem(item: any, event: any){
163
+ event.preventDefault();
164
+ if(!this.crud){
165
+ this.rowClick(item);
166
+ }else{
167
+ this.currentId = item[this.key!];
168
+ this.$emit(change, item);
169
+ }
170
+ },
171
+ filterValue(event: any, dataItem: any){
172
+ let item = dataItem;
173
+ let value = event.target.value;
174
+ if(item != null){
175
+ dataItem = value == '' ? null : value;
176
+ }else{
177
+ dataItem = value;
178
+ }
179
+ },
180
+ filterDate(event: any, dataItem: any){
181
+ let item = dataItem;
182
+ if(item != null){
183
+ dataItem = event == '' ? null : new window.Date(event);
184
+ }else{
185
+ dataItem = new window.Date(event);
186
+ }
187
+ },
188
+ isNumber(n: any) {
189
+ return !isNaN(parseFloat(n)) && !isNaN(n - 0)
190
+ },
191
+ options(event: any){
192
+ this.page = event!.page;
193
+ this.filters.CurrentPage = this.page;
194
+ this.search();
195
+ },
196
+ nextPage(event: any){
197
+ if(this.page < this.pageCount){
198
+ this.page = this.page + 1;
199
+ this.filters.CurrentPage = this.page;
200
+ this.search();
201
+ }
202
+ },
203
+ previousPage(event: any){
204
+ if(this.page > 1){
205
+ this.page = this.page - 1;
206
+ this.filters.CurrentPage = this.page;
207
+ this.search();
208
+ }
209
+ },
210
+ firstPage(event: any){
211
+ this.page = 1;
212
+ this.filters.CurrentPage = this.page;
213
+ this.search();
214
+ },
215
+ lastPage(event: any){
216
+ this.page = this.pageCount;
217
+ this.filters.CurrentPage = this.page;
218
+ this.search();
219
+ },
220
+ pageChange(event: any){
221
+ this.page = event;
222
+ this.filters.CurrentPage = this.page;
223
+ this.search();
224
+ },
225
+ pageSize(event: any){
226
+ console.log(event);
227
+ this.perPage = event;
228
+ this.filters.PerPage = this.perPage;
229
+ this.search();
230
+ },
231
+ sort(event: any, prop: any, index: number){
232
+ prop.sort = prop.sort == true ? false : true;
233
+ this.filters.SortColumn = Object.keys(this.dataItems[0])[index];
234
+ this.filters.SortDirection = window.Number(prop.sort);
235
+ console.log(this.filters);
236
+ this.search();
237
+ }
238
+ }
239
+ }
240
+ </script>
241
+
242
+ <template>
243
+ <div>
244
+ <v-container>
245
+ <v-row style="border-bottom: 1px solid #393E46; padding: 10px">
246
+ <v-btn @click="search()" style="margin-right: 10px" color="#1697f6" v-if="showFilters" v-tooltip="'Search'">
247
+ <FontAwesomeIcon :icon="faSearch"></FontAwesomeIcon>
248
+ </v-btn>
249
+ <v-btn @click="refresh()" style="margin-right: 10px" color="#1697f6" v-if="showFilters" v-tooltip="'Refresh'">
250
+ <FontAwesomeIcon :icon="reload"></FontAwesomeIcon>
251
+ </v-btn>
252
+ </v-row>
253
+ <v-row>
254
+ <v-data-table
255
+ :color="'white'"
256
+ :striped="'odd'"
257
+ :v-bind:loading-text="'Loading... Please wait'"
258
+ :loading="loading"
259
+ :v-bind:model-value="modelValue"
260
+ :items="dataItems"
261
+ @update:options="options($event)"
262
+ :items-per-page="perPage"
263
+ :page="page"
264
+ hide-default-header
265
+ hide-default-footer
266
+ multi-sort
267
+ return-object>
268
+ <template v-slot:item="{ item, index }" >
269
+ <tr v-if="index == 0 && showFilters" class="filter-items" >
270
+ <td v-for="(prop, index) in dataheader">
271
+ <SortView
272
+ :prop="prop"
273
+ :index="index"
274
+ @sort="sort($event, prop, index)">
275
+ </SortView>
276
+ </td>
277
+ </tr>
278
+ <tr v-if="index == 0 && showFilters" class="filter-items" >
279
+ <td v-for="(prop, index) in Object.keys(item)">
280
+ <Filters
281
+ :item="item"
282
+ :filters="filters"
283
+ :showFilters="showFilters"
284
+ :key="key"
285
+ :prop="prop"
286
+ @filterValue="filterValue($event, filters[prop])">
287
+ </Filters>
288
+ </td>
289
+ </tr>
290
+ <tr @dblclick="updateItem(item, $event)">
291
+ <td v-for="(prop) in Object.keys(item)">
292
+ <DataItem
293
+ :item="item"
294
+ :prop="prop"
295
+ :key="key"
296
+ :index="index">
297
+ </DataItem>
298
+ </td>
299
+ </tr>
300
+ </template>
301
+ </v-data-table>
302
+ </v-row>
303
+ <PaginationView
304
+ :page="page"
305
+ :perPage="perPage"
306
+ :pageCount="pageCount"
307
+ :totalCount="totalCount"
308
+ @pageChange="pageChange($event)"
309
+ @pageSize="pageSize($event)"
310
+ @firstPage="firstPage($event)"
311
+ @previousPage="previousPage($event)"
312
+ @nextPage="nextPage($event)"
313
+ @lastPage="lastPage($event)"/>
314
+ </v-container>
315
+ </div>
316
+ </template>
317
+
318
+ <style>
319
+ @media (min-width: 1024px) {
320
+ .about {
321
+ min-height: 100vh;
322
+ display: flex;
323
+ align-items: center;
324
+ }
325
+ }
326
+
327
+ .filter-items{
328
+ height: 56px;
329
+ }
330
+
331
+ .filter-items .v-input__control{
332
+ height: 56px;
333
+ }
334
+
335
+ .filter-items span{
336
+ height: 56px;
337
+ }
338
+
339
+ .filter-items span div{
340
+ height: 56px;
341
+ }
342
+
343
+ .filter-items span div div{
344
+ height: 56px;
345
+ }
346
+
347
+ </style>
@@ -0,0 +1,45 @@
1
+ <script lang="ts">
2
+ import { isDateTime, toDate } from '../../helpers/instances';
3
+ export default {
4
+ props: {
5
+ item: {
6
+ type: Object,
7
+ required: true
8
+ },
9
+ index: {
10
+ type: Number,
11
+ required: true
12
+ },
13
+ prop: {
14
+ type: String,
15
+ required: true
16
+ },
17
+ key: {
18
+ type: String,
19
+ required: false
20
+ }
21
+ },
22
+ data() {
23
+ return {
24
+ item: this.item,
25
+ index: this.index,
26
+ prop: this.prop,
27
+ key: this.key,
28
+ isDateTime: isDateTime,
29
+ toDate: toDate
30
+ }
31
+ }
32
+ }
33
+
34
+ </script>
35
+ <template>
36
+ <span v-if="prop == key!">
37
+ {{ index + 1 }}
38
+ </span>
39
+ <span v-else-if="isDateTime(item[prop])">
40
+ {{ toDate(item[prop]) }}
41
+ </span>
42
+ <span v-else>
43
+ {{ item[prop] }}
44
+ </span>
45
+ </template>