|
14 | 14 | <VInlineSwitch
|
15 | 15 | v-model="item.raw.active"
|
16 | 16 | 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" |
17 | 23 | :color="componentOptions.color"
|
18 | 24 | :disabled="componentOptions.disabled"
|
19 |
| - :do-not-save="false" |
| 25 | + :do-not-save="componentOptions.doNotSave" |
20 | 26 | :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" |
21 | 31 | :item="item"
|
22 | 32 | :label="componentOptions.label"
|
23 | 33 | name="active"
|
|
27 | 37 | :underlined="componentOptions.underlined"
|
28 | 38 | @error="showError = $event"
|
29 | 39 | @loading="loading = $event"
|
| 40 | + @update="updatedValue($event, 'switch')" |
30 | 41 | />
|
31 | 42 | </div>
|
32 | 43 | </template>
|
33 | 44 | <template #[`item.userId`]="{ item }">
|
34 | 45 | <VInlineSelect
|
35 | 46 | v-model="item.raw.user"
|
36 | 47 | 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" |
37 | 53 | :color="componentOptions.color"
|
38 | 54 | :disabled="componentOptions.disabled"
|
39 |
| - :do-not-save="false" |
| 55 | + :do-not-save="componentOptions.doNotSave" |
40 | 56 | :empty-text="componentOptions.emptyText"
|
41 | 57 | :field-only="componentOptions.fieldOnly"
|
42 | 58 | :hide-details="componentOptions.hideDetails"
|
|
48 | 64 | :label="componentOptions.label"
|
49 | 65 | name="active"
|
50 | 66 | :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" |
51 | 71 | :underline-color="componentOptions.underlineColor"
|
52 | 72 | :underline-style="componentOptions.underlineStyle"
|
53 | 73 | :underline-width="componentOptions.underlineWidth"
|
54 | 74 | :underlined="componentOptions.underlined"
|
55 | 75 | @error="showError = $event"
|
56 | 76 | @loading="loading = $event"
|
| 77 | + @update="updatedValue($event, 'select')" |
57 | 78 | >
|
58 | 79 | </VInlineSelect>
|
59 | 80 | </template>
|
| 81 | + |
60 | 82 | <template #[`item.title`]="{ item }">
|
61 | 83 | <VInlineTextField
|
62 | 84 | v-model="item.raw.title"
|
63 | 85 | 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" |
64 | 91 | :color="componentOptions.color"
|
65 | 92 | :disabled="componentOptions.disabled"
|
66 |
| - :do-not-save="false" |
| 93 | + :do-not-save="componentOptions.doNotSave" |
67 | 94 | :field-only="componentOptions.fieldOnly"
|
| 95 | + :hide-details="componentOptions.hideDetails" |
68 | 96 | :item="item"
|
69 | 97 | :label="componentOptions.label"
|
70 | 98 | 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" |
71 | 104 | :underline-color="componentOptions.underlineColor"
|
72 | 105 | :underline-style="componentOptions.underlineStyle"
|
73 | 106 | :underline-width="componentOptions.underlineWidth"
|
74 | 107 | :underlined="componentOptions.underlined"
|
75 | 108 | @error="showError = $event"
|
76 | 109 | @loading="loading = $event"
|
| 110 | + @update="updatedValue($event, 'text-field')" |
77 | 111 | />
|
78 | 112 | </template>
|
| 113 | + |
79 | 114 | <template #[`item.body`]="{ item }">
|
80 | 115 | <VInlineTextarea
|
81 | 116 | v-model="item.raw.body"
|
82 | 117 | 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" |
83 | 123 | :color="componentOptions.color"
|
84 | 124 | :disabled="componentOptions.disabled"
|
85 |
| - :do-not-save="false" |
| 125 | + :do-not-save="componentOptions.doNotSave" |
86 | 126 | :field-only="componentOptions.fieldOnly"
|
| 127 | + :hide-details="false" |
87 | 128 | :item="item"
|
88 | 129 | :label="componentOptions.label"
|
89 | 130 | 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" |
90 | 136 | :underline-color="componentOptions.underlineColor"
|
91 | 137 | :underline-style="componentOptions.underlineStyle"
|
92 | 138 | :underline-width="componentOptions.underlineWidth"
|
93 | 139 | :underlined="componentOptions.underlined"
|
94 | 140 | @error="showError = $event"
|
95 | 141 | @loading="loading = $event"
|
| 142 | + @update="updatedValue($event, 'textarea')" |
96 | 143 | />
|
97 | 144 | </template>
|
| 145 | + |
98 | 146 | <template #[`item.reviewed`]="{ item }">
|
99 | 147 | <div class="d-flex flex-align-center">
|
100 | 148 | <VInlineCheckbox
|
101 | 149 | v-model="item.raw.reviewed"
|
102 | 150 | 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" |
103 | 156 | :color="componentOptions.color"
|
104 | 157 | :disabled="componentOptions.disabled"
|
105 |
| - :do-not-save="false" |
| 158 | + :do-not-save="componentOptions.doNotSave" |
106 | 159 | :field-only="componentOptions.fieldOnly"
|
| 160 | + :icon-false-title="componentOptions.iconFalseTitle" |
| 161 | + :icon-true-title="componentOptions.iconTrueTitle" |
107 | 162 | :item="item"
|
108 | 163 | name="reviewed"
|
109 | 164 | :underline-color="componentOptions.underlineColor"
|
|
112 | 167 | :underlined="componentOptions.underlined"
|
113 | 168 | @error="showError = $event"
|
114 | 169 | @loading="loading = $event"
|
| 170 | + @update="updatedValue($event, 'checkbox')" |
115 | 171 | />
|
116 | 172 | </div>
|
117 | 173 | </template>
|
@@ -146,13 +202,36 @@ const tableOptions = reactive({
|
146 | 202 | });
|
147 | 203 |
|
148 | 204 | const componentOptions = reactive({
|
| 205 | + cancelButtonColor: 'default', |
| 206 | + cancelButtonVariant: 'text', |
| 207 | + cancelIcon: undefined, |
| 208 | + cancelIconColor: 'default', |
| 209 | + cancelIconText: 'Cancel', |
| 210 | + closeSiblings: true, |
149 | 211 | color: 'primary',
|
150 | 212 | disabled: false,
|
| 213 | + doNotSave: false, |
151 | 214 | emptyText: 'empty',
|
152 | 215 | fieldOnly: false,
|
153 | 216 | hideDetails: true,
|
154 | 217 | hideSelected: true,
|
| 218 | + iconFalse: undefined, |
| 219 | + iconFalseTitle: undefined, |
| 220 | + iconTrue: undefined, |
| 221 | + iconTrueTitle: undefined, |
155 | 222 | 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, |
156 | 235 | underlineColor: 'primary',
|
157 | 236 | underlineStyle: 'dotted',
|
158 | 237 | underlineWidth: '1px',
|
@@ -217,6 +296,19 @@ function getUsers() {
|
217 | 296 | users.value = [...json.users];
|
218 | 297 | });
|
219 | 298 | };
|
| 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 | +} |
220 | 312 | </script>
|
221 | 313 |
|
222 | 314 | <style lang="scss" scoped>
|
|
0 commit comments