2
2
<v-col cols =" 12" >
3
3
<v-card elevation =" 5" >
4
4
<v-data-table
5
+ :key =" tableOptions.tableKey"
5
6
density =" default"
6
7
:headers =" headers"
7
8
:items =" posts"
17
18
:cancel-icon =" componentOptions.cancelIcon"
18
19
:cancel-icon-color =" componentOptions.cancelIconColor"
19
20
:cancel-icon-text =" componentOptions.cancelIconText"
20
- :card-field =" componentOptions.cardField "
21
+ :card-field =" cardFieldState "
21
22
:card-offset-x =" componentOptions.cardOffsetX"
22
23
:card-offset-y =" componentOptions.cardOffsetY"
23
24
:card-props =" componentOptions.cardProps"
51
52
:cancel-button-title =" componentOptions.cancelButtonTitle"
52
53
:cancel-button-variant =" componentOptions.cancelButtonVariant"
53
54
:cancel-icon-color =" componentOptions.cancelIconColor"
54
- :card-field =" componentOptions.cardField "
55
+ :card-field =" cardFieldState "
55
56
:card-offset-x =" componentOptions.cardOffsetX"
56
57
:card-offset-y =" componentOptions.cardOffsetY"
57
58
:card-props =" componentOptions.cardProps"
96
97
<template #[` item.title ` ]=" { item } " >
97
98
<VInlineTextField
98
99
v-model =" item.raw.title"
99
- :append-icon =" componentOptions.appendIcon"
100
- :append-inner-icon =" componentOptions.appendIcon"
101
100
:cancel-button-color =" componentOptions.cancelButtonColor"
102
101
:cancel-button-title =" componentOptions.cancelButtonTitle"
103
102
:cancel-button-variant =" componentOptions.cancelButtonVariant"
104
103
:cancel-icon-color =" componentOptions.cancelIconColor"
105
- :card-field =" componentOptions.cardField "
104
+ :card-field =" cardFieldState "
106
105
:card-offset-x =" componentOptions.cardOffsetX"
107
106
:card-offset-y =" componentOptions.cardOffsetY"
108
107
:card-props =" componentOptions.cardProps"
111
110
:color =" componentOptions.color"
112
111
:density =" componentOptions.density"
113
112
:disabled =" componentOptions.disabled"
114
- :display-append-icon =" componentOptions.displayAppendIcon"
115
- :display-append-icon-color =" componentOptions.displayAppendIconColor"
116
- :display-append-inner-icon =" componentOptions.displayAppendInnerIcon"
117
- :display-append-inner-icon-color =" componentOptions.displayAppendInnerIconColor"
118
- :display-prepend-icon =" componentOptions.displayPrependIcon"
119
- :display-prepend-iconColor =" componentOptions.displayPrependIconColor"
120
- :display-prepend-inner-icon =" componentOptions.displayPrependInnerIcon"
121
- :display-prepend-inner-icon-color =" componentOptions.displayPrependInnerIconColor"
122
113
:field-only =" componentOptions.fieldOnly"
123
114
:hide-details =" componentOptions.hideDetails"
124
115
:item =" item"
125
116
:label =" componentOptions.label"
126
117
:loading =" item.raw.loading"
127
118
:loading-wait =" componentOptions.loadingWait"
128
119
name =" title"
129
- :prepend-icon =" componentOptions.appendIcon"
130
- :prepend-inner-icon =" componentOptions.appendIcon"
131
120
required
132
121
:rules =" [componentOptions.rules.required, componentOptions.rules.minLength]"
133
122
:save-button-color =" componentOptions.saveButtonColor"
144
133
@error =" showError = $event"
145
134
@update =" updatedValue(item.raw, 'title')"
146
135
>
147
- <template #[` display-append-icon ` ]>foo</template >
148
136
</VInlineTextField >
149
137
</template >
150
138
155
143
:cancel-button-title =" componentOptions.cancelButtonTitle"
156
144
:cancel-button-variant =" componentOptions.cancelButtonVariant"
157
145
:cancel-icon-color =" componentOptions.cancelIconColor"
158
- :card-field =" componentOptions.cardField "
146
+ :card-field =" cardFieldState "
159
147
:card-offset-x =" componentOptions.cardOffsetX"
160
148
:card-offset-y =" componentOptions.cardOffsetY"
161
149
:card-props =" componentOptions.cardProps"
187
175
:variant =" componentOptions.variant"
188
176
@error =" showError = $event"
189
177
@update =" updatedValue(item.raw, 'body')"
190
- />
178
+ >
179
+ </VInlineTextarea >
191
180
</template >
192
181
193
182
<template #[` item.range ` ]=" { item } " >
194
183
<VInlineCustomField
195
184
v-model =" item.raw.range"
196
- :card-field =" componentOptions.cardField "
185
+ :card-field =" cardFieldState "
197
186
:card-offset-x =" componentOptions.cardOffsetX"
198
187
:card-offset-y =" componentOptions.cardOffsetY"
199
188
:card-props =" componentOptions.cardProps"
218
207
:cancel-button-title =" componentOptions.cancelButtonTitle"
219
208
:cancel-button-variant =" componentOptions.cancelButtonVariant"
220
209
:cancel-icon-color =" componentOptions.cancelIconColor"
221
- :card-field =" componentOptions.cardField "
210
+ :card-field =" cardFieldState "
222
211
:card-offset-x =" componentOptions.cardOffsetX"
223
212
:card-offset-y =" componentOptions.cardOffsetY"
224
213
:card-props =" componentOptions.cardProps"
245
234
</v-data-table >
246
235
</v-card >
247
236
</v-col >
237
+
238
+ <v-col
239
+ class =" mb-4"
240
+ cols =" 12"
241
+ >
242
+ <v-switch
243
+ v-model =" isCardField"
244
+ class =" ms-2 align-center d-flex"
245
+ color =" primary"
246
+ density =" compact"
247
+ >
248
+ <template #label >
249
+ <div class =" switch-label" >
250
+ <div
251
+ class =" d-inline"
252
+ :class =" !isCardField ? 'text-primary' : ''"
253
+ >Inline</div >
254
+ /
255
+ <div
256
+ class =" d-inline"
257
+ :class =" isCardField ? 'text-primary' : ''"
258
+ >Card</div > Field
259
+ </div >
260
+ </template >
261
+ </v-switch >
262
+ </v-col >
248
263
</template >
249
264
250
265
251
266
<script setup>
252
267
// ? Components are already loaded via the configs/playground.ts file //
253
-
254
268
onMounted (() => {
255
269
getPosts ();
256
270
});
@@ -262,24 +276,29 @@ onBeforeMount(() => {
262
276
const tableOptions = reactive ({
263
277
itemsPerPage: 10 ,
264
278
sortBy: [{ key: ' title' , order: ' asc' }],
279
+ tableKey: new Date ().getUTCMilliseconds (),
265
280
});
266
281
282
+
283
+ // ? Changes the type of field the table uses //
284
+ const isCardField = ref (false );
285
+ const cardFieldState = computed (() => isCardField .value );
286
+
287
+ watch (() => isCardField .value , () => {
288
+ tableOptions .tableKey = new Date ().getUTCMilliseconds ();
289
+ });
290
+
291
+
292
+ // ? Use these options to play around with the component props //
267
293
const componentOptions = reactive ({
268
- // appendIcon: 'mdi:mdi-cog',
269
294
cancelButtonColor: ' default' ,
270
295
cancelButtonTitle: ' Cancel' ,
271
296
cancelButtonVariant: ' text' ,
272
297
cancelIcon: undefined ,
273
298
cancelIconColor: ' default' ,
274
- cardField: false ,
275
299
cardOffsetX: 0 ,
276
300
cardOffsetY: 0 ,
277
- cardProps: {
278
- // color: 'primary',
279
- // elevation: 5,
280
- // variant: 'flat',
281
- width: undefined ,
282
- },
301
+ cardProps: {},
283
302
clearable: false ,
284
303
closeSiblings: true ,
285
304
color: ' primary' ,
@@ -371,6 +390,23 @@ const headers = [
371
390
},
372
391
];
373
392
393
+
394
+ /**
395
+ * ? This is where you would save the item in the database.
396
+ * @param {object} item The item being updated.
397
+ * @param {string} field The field being updated.
398
+ */
399
+ function updatedValue (item ) {
400
+ item .loading = true ;
401
+
402
+ // ? Simulate a delay while item is saving.
403
+ setTimeout (() => {
404
+ item .loading = false ;
405
+ }, 1500 );
406
+ }
407
+
408
+
409
+ // ? Data loading section. You can ignore this part. //
374
410
let posts = ref ();
375
411
const users = ref (null );
376
412
const showError = ref (false );
@@ -398,26 +434,14 @@ function getUsers() {
398
434
}));
399
435
});
400
436
};
401
-
402
-
403
- /**
404
- * ? This is where you would save the item in the database.
405
- * @param {object} item The item being updated.
406
- * @param {string} field The field being updated.
407
- */
408
- function updatedValue (item , field ) {
409
- console .log (' PlaygroundPage.vue: updatedValue' , field, item);
410
- item .loading = true ;
411
-
412
- // ? Simulate a delay while item is saving.
413
- setTimeout (() => {
414
- item .loading = false ;
415
- }, 1500 );
416
- }
417
437
< / script>
418
438
419
439
< style lang= " scss" scoped>
420
440
: deep (.v - data - table__td ) {
421
441
align- items: center;
422
442
}
443
+
444
+ : deep (.v - label ) {
445
+ opacity: 1 ;
446
+ }
423
447
< / style>
0 commit comments