Skip to content

Commit 5eadc7b

Browse files
Updated template
1 parent e470a64 commit 5eadc7b

File tree

1 file changed

+97
-5
lines changed

1 file changed

+97
-5
lines changed

src/playground/configs/PlaygroundPage.template.vue

Lines changed: 97 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,20 @@
1414
<VInlineSwitch
1515
v-model="item.raw.active"
1616
api-route="api/posts"
17+
:cancel-button-color="componentOptions.cancelButtonColor"
18+
:cancel-button-variant="componentOptions.cancelButtonVariant"
19+
:cancel-icon="componentOptions.cancelIcon"
20+
:cancel-icon-color="componentOptions.cancelIconColor"
21+
:cancel-icon-text="componentOptions.cancelIconText"
22+
:close-siblings="componentOptions.closeSiblings"
1723
:color="componentOptions.color"
1824
:disabled="componentOptions.disabled"
19-
:do-not-save="false"
25+
:do-not-save="componentOptions.doNotSave"
2026
:field-only="componentOptions.fieldOnly"
27+
:icon-false="componentOptions.iconFalse"
28+
:icon-false-title="componentOptions.iconFalseTitle"
29+
:icon-true="componentOptions.iconTrue"
30+
:icon-true-title="componentOptions.iconTrueTitle"
2131
:item="item"
2232
:label="componentOptions.label"
2333
name="active"
@@ -27,16 +37,22 @@
2737
:underlined="componentOptions.underlined"
2838
@error="showError = $event"
2939
@loading="loading = $event"
40+
@update="updatedValue($event, 'switch')"
3041
/>
3142
</div>
3243
</template>
3344
<template #[`item.userId`]="{ item }">
3445
<VInlineSelect
3546
v-model="item.raw.user"
3647
api-route="api/posts"
48+
:cancel-button-color="componentOptions.cancelButtonColor"
49+
:cancel-button-variant="componentOptions.cancelButtonVariant"
50+
:cancel-icon-color="componentOptions.cancelIconColor"
51+
:cancel-icon-text="componentOptions.cancelIconText"
52+
:close-siblings="componentOptions.closeSiblings"
3753
:color="componentOptions.color"
3854
:disabled="componentOptions.disabled"
39-
:do-not-save="false"
55+
:do-not-save="componentOptions.doNotSave"
4056
:empty-text="componentOptions.emptyText"
4157
:field-only="componentOptions.fieldOnly"
4258
:hide-details="componentOptions.hideDetails"
@@ -48,62 +64,101 @@
4864
:label="componentOptions.label"
4965
name="active"
5066
:return-object="true"
67+
:save-button-color="componentOptions.saveButtonColor"
68+
:save-icon="componentOptions.saveIcon"
69+
:save-icon-color="componentOptions.saveIconColor"
70+
:save-icon-text="componentOptions.saveIconText"
5171
:underline-color="componentOptions.underlineColor"
5272
:underline-style="componentOptions.underlineStyle"
5373
:underline-width="componentOptions.underlineWidth"
5474
:underlined="componentOptions.underlined"
5575
@error="showError = $event"
5676
@loading="loading = $event"
77+
@update="updatedValue($event, 'select')"
5778
>
5879
</VInlineSelect>
5980
</template>
81+
6082
<template #[`item.title`]="{ item }">
6183
<VInlineTextField
6284
v-model="item.raw.title"
6385
api-route="api/posts"
86+
:cancel-button-color="componentOptions.cancelButtonColor"
87+
:cancel-button-variant="componentOptions.cancelButtonVariant"
88+
:cancel-icon-color="componentOptions.cancelIconColor"
89+
:cancel-icon-text="componentOptions.cancelIconText"
90+
:close-siblings="componentOptions.closeSiblings"
6491
:color="componentOptions.color"
6592
:disabled="componentOptions.disabled"
66-
:do-not-save="false"
93+
:do-not-save="componentOptions.doNotSave"
6794
:field-only="componentOptions.fieldOnly"
95+
:hide-details="componentOptions.hideDetails"
6896
:item="item"
6997
:label="componentOptions.label"
7098
name="title"
99+
required
100+
:save-button-color="componentOptions.saveButtonColor"
101+
:save-icon-color="componentOptions.saveIconColor"
102+
:save-icon-text="componentOptions.saveIconText"
103+
:truncate-length="componentOptions.truncateTextFieldLength"
71104
:underline-color="componentOptions.underlineColor"
72105
:underline-style="componentOptions.underlineStyle"
73106
:underline-width="componentOptions.underlineWidth"
74107
:underlined="componentOptions.underlined"
75108
@error="showError = $event"
76109
@loading="loading = $event"
110+
@update="updatedValue($event, 'text-field')"
77111
/>
78112
</template>
113+
79114
<template #[`item.body`]="{ item }">
80115
<VInlineTextarea
81116
v-model="item.raw.body"
82117
api-route="api/posts"
118+
:cancel-button-color="componentOptions.cancelButtonColor"
119+
:cancel-button-variant="componentOptions.cancelButtonVariant"
120+
:cancel-icon-color="componentOptions.cancelIconColor"
121+
:cancel-icon-text="componentOptions.cancelIconText"
122+
:close-siblings="componentOptions.closeSiblings"
83123
:color="componentOptions.color"
84124
:disabled="componentOptions.disabled"
85-
:do-not-save="false"
125+
:do-not-save="componentOptions.doNotSave"
86126
:field-only="componentOptions.fieldOnly"
127+
:hide-details="false"
87128
:item="item"
88129
:label="componentOptions.label"
89130
name="body"
131+
:rules="[componentOptions.rules.required, componentOptions.rules.minLength]"
132+
:save-button-color="componentOptions.saveButtonColor"
133+
:save-icon-color="componentOptions.saveIconColor"
134+
:save-icon-text="componentOptions.saveIconText"
135+
:truncate-length="componentOptions.truncateTextareaLength"
90136
:underline-color="componentOptions.underlineColor"
91137
:underline-style="componentOptions.underlineStyle"
92138
:underline-width="componentOptions.underlineWidth"
93139
:underlined="componentOptions.underlined"
94140
@error="showError = $event"
95141
@loading="loading = $event"
142+
@update="updatedValue($event, 'textarea')"
96143
/>
97144
</template>
145+
98146
<template #[`item.reviewed`]="{ item }">
99147
<div class="d-flex flex-align-center">
100148
<VInlineCheckbox
101149
v-model="item.raw.reviewed"
102150
api-route="api/posts"
151+
:cancel-button-color="componentOptions.cancelButtonColor"
152+
:cancel-button-variant="componentOptions.cancelButtonVariant"
153+
:cancel-icon-color="componentOptions.cancelIconColor"
154+
:cancel-icon-text="componentOptions.cancelIconText"
155+
:close-siblings="componentOptions.closeSiblings"
103156
:color="componentOptions.color"
104157
:disabled="componentOptions.disabled"
105-
:do-not-save="false"
158+
:do-not-save="componentOptions.doNotSave"
106159
:field-only="componentOptions.fieldOnly"
160+
:icon-false-title="componentOptions.iconFalseTitle"
161+
:icon-true-title="componentOptions.iconTrueTitle"
107162
:item="item"
108163
name="reviewed"
109164
:underline-color="componentOptions.underlineColor"
@@ -112,6 +167,7 @@
112167
:underlined="componentOptions.underlined"
113168
@error="showError = $event"
114169
@loading="loading = $event"
170+
@update="updatedValue($event, 'checkbox')"
115171
/>
116172
</div>
117173
</template>
@@ -146,13 +202,36 @@ const tableOptions = reactive({
146202
});
147203
148204
const componentOptions = reactive({
205+
cancelButtonColor: 'default',
206+
cancelButtonVariant: 'text',
207+
cancelIcon: undefined,
208+
cancelIconColor: 'default',
209+
cancelIconText: 'Cancel',
210+
closeSiblings: true,
149211
color: 'primary',
150212
disabled: false,
213+
doNotSave: false,
151214
emptyText: 'empty',
152215
fieldOnly: false,
153216
hideDetails: true,
154217
hideSelected: true,
218+
iconFalse: undefined,
219+
iconFalseTitle: undefined,
220+
iconTrue: undefined,
221+
iconTrueTitle: undefined,
155222
label: '',
223+
rules: {
224+
minLength(value) {
225+
return value?.length >= 5 || 'Min 5 characters';
226+
},
227+
required: value => !!value || 'Field is required',
228+
},
229+
saveButtonColor: 'default',
230+
saveIcon: undefined,
231+
saveIconColor: 'primary',
232+
saveIconText: 'Save',
233+
truncateTextFieldLength: 25,
234+
truncateTextareaLength: 75,
156235
underlineColor: 'primary',
157236
underlineStyle: 'dotted',
158237
underlineWidth: '1px',
@@ -217,6 +296,19 @@ function getUsers() {
217296
users.value = [...json.users];
218297
});
219298
};
299+
300+
/**
301+
* ? You can use this function to update the value in the database.
302+
* ? Instead of using the internal axios call.
303+
*
304+
* @param {any} val
305+
* @param {string} field
306+
*/
307+
// eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars
308+
function updatedValue(val, field) {
309+
// Save updated values
310+
// console.log('updatedValue', val, field);
311+
}
220312
</script>
221313
222314
<style lang="scss" scoped>

0 commit comments

Comments
 (0)