adminforth 1.2.59 → 1.2.60

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.
Files changed (60) hide show
  1. package/package.json +2 -2
  2. package/dist/spa/spa/.eslintrc.cjs +0 -14
  3. package/dist/spa/spa/README.md +0 -39
  4. package/dist/spa/spa/env.d.ts +0 -1
  5. package/dist/spa/spa/index.html +0 -23
  6. package/dist/spa/spa/package-lock.json +0 -4573
  7. package/dist/spa/spa/package.json +0 -49
  8. package/dist/spa/spa/postcss.config.js +0 -6
  9. package/dist/spa/spa/public/assets/favicon.png +0 -0
  10. package/dist/spa/spa/src/App.vue +0 -314
  11. package/dist/spa/spa/src/assets/base.css +0 -2
  12. package/dist/spa/spa/src/assets/logo.svg +0 -19
  13. package/dist/spa/spa/src/components/AcceptModal.vue +0 -45
  14. package/dist/spa/spa/src/components/Breadcrumbs.vue +0 -41
  15. package/dist/spa/spa/src/components/BreadcrumbsWithButtons.vue +0 -26
  16. package/dist/spa/spa/src/components/CustomDatePicker.vue +0 -176
  17. package/dist/spa/spa/src/components/CustomDateRangePicker.vue +0 -218
  18. package/dist/spa/spa/src/components/CustomRangePicker.vue +0 -152
  19. package/dist/spa/spa/src/components/Dropdown.vue +0 -168
  20. package/dist/spa/spa/src/components/Filters.vue +0 -222
  21. package/dist/spa/spa/src/components/HelloWorld.vue +0 -17
  22. package/dist/spa/spa/src/components/MenuLink.vue +0 -24
  23. package/dist/spa/spa/src/components/ResourceForm.vue +0 -294
  24. package/dist/spa/spa/src/components/ResourceListTable.vue +0 -394
  25. package/dist/spa/spa/src/components/SingleSkeletLoader.vue +0 -13
  26. package/dist/spa/spa/src/components/SkeleteLoader.vue +0 -23
  27. package/dist/spa/spa/src/components/Toast.vue +0 -77
  28. package/dist/spa/spa/src/components/ValueRenderer.vue +0 -66
  29. package/dist/spa/spa/src/components/icons/IconCalendar.vue +0 -5
  30. package/dist/spa/spa/src/components/icons/IconCommunity.vue +0 -7
  31. package/dist/spa/spa/src/components/icons/IconDocumentation.vue +0 -7
  32. package/dist/spa/spa/src/components/icons/IconEcosystem.vue +0 -7
  33. package/dist/spa/spa/src/components/icons/IconSupport.vue +0 -7
  34. package/dist/spa/spa/src/components/icons/IconTime.vue +0 -5
  35. package/dist/spa/spa/src/components/icons/IconTooling.vue +0 -19
  36. package/dist/spa/spa/src/composables/useFrontendApi.ts +0 -26
  37. package/dist/spa/spa/src/composables/useStores.ts +0 -127
  38. package/dist/spa/spa/src/index.scss +0 -27
  39. package/dist/spa/spa/src/main.ts +0 -18
  40. package/dist/spa/spa/src/router/index.ts +0 -63
  41. package/dist/spa/spa/src/spa_types/core.ts +0 -51
  42. package/dist/spa/spa/src/stores/core.ts +0 -144
  43. package/dist/spa/spa/src/stores/filters.ts +0 -22
  44. package/dist/spa/spa/src/stores/modal.ts +0 -48
  45. package/dist/spa/spa/src/stores/toast.ts +0 -15
  46. package/dist/spa/spa/src/stores/user.ts +0 -72
  47. package/dist/spa/spa/src/types/AdminForthConfig.ts +0 -1477
  48. package/dist/spa/spa/src/types/FrontendAPI.ts +0 -121
  49. package/dist/spa/spa/src/utils.ts +0 -103
  50. package/dist/spa/spa/src/views/CreateView.vue +0 -156
  51. package/dist/spa/spa/src/views/EditView.vue +0 -157
  52. package/dist/spa/spa/src/views/ListView.vue +0 -258
  53. package/dist/spa/spa/src/views/LoginView.vue +0 -160
  54. package/dist/spa/spa/src/views/ResourceParent.vue +0 -17
  55. package/dist/spa/spa/src/views/ShowView.vue +0 -184
  56. package/dist/spa/spa/tailwind.config.js +0 -17
  57. package/dist/spa/spa/tsconfig.app.json +0 -14
  58. package/dist/spa/spa/tsconfig.json +0 -11
  59. package/dist/spa/spa/tsconfig.node.json +0 -19
  60. package/dist/spa/spa/vite.config.ts +0 -56
@@ -1,294 +0,0 @@
1
- <template>
2
- <div class="rounded-default">
3
- <div
4
- class="relative shadow-resourseFormShadow dark:shadow-darkResourseFormShadow sm:rounded-lg dark:shadow-2xl rounded-default"
5
- >
6
- <form autocomplete="off" @submit.prevent>
7
- <table class="w-full text-sm text-left rtl:text-right text-gray-500 dark:text-gray-400 ">
8
- <thead class="text-xs text-gray-700 uppercase bg-lightFormHeading dark:bg-gray-700 dark:text-gray-400 block md:table-row-group">
9
- <tr>
10
- <th scope="col" class="px-6 py-3 hidden md:table-cell">
11
- Field
12
- </th>
13
- <th scope="col" class="px-6 py-3 w-5/6 hidden md:table-cell">
14
- Value
15
- </th>
16
-
17
-
18
- </tr>
19
- </thead>
20
- <tbody>
21
- <tr v-for="column, i in editableColumns" :key="column.name"
22
- v-if="currentValues !== null"
23
- class="bg-ligftForm dark:bg-gray-800 border-b dark:border-gray-700 block md:table-row"
24
- >
25
- <td class="px-6 py-4 sm:pb-0 whitespace-nowrap flex items-center block md:table-cell"> <!--align-top-->
26
- {{ column.label }}
27
- <span :data-tooltip-target="`tooltip-show-${i}`" class="ml-1 relative inline-block">
28
- <IconExclamationCircleSolid v-if="column.required[mode]" class="w-4 h-4"
29
- :class="(columnError(column) && validating) ? 'text-red-500 dark:text-red-400' : 'text-gray-400 dark:text-gray-500'"
30
- />
31
- </span>
32
- <div :id="`tooltip-show-${i}`"
33
- role="tooltip"
34
- class="ml-1 absolute z-10 invisible inline-block px-3 py-2 text-sm font-medium text-white transition-opacity duration-300 bg-gray-900 rounded-lg shadow-sm opacity-0 tooltip dark:bg-gray-700">
35
- Required field
36
- <div class="tooltip-arrow" data-popper-arrow></div>
37
- </div>
38
- </td>
39
- <td class="px-6 py-4 whitespace-nowrap whitespace-pre-wrap relative block md:table-cell">
40
- <template v-if="column?.components?.[props.source]?.file">
41
- <component
42
- :is="getCustomComponent(column.components[props.source])"
43
- :column="column"
44
- :value="currentValues[column.name]"
45
- @update:value="setCurrentValue(column.name, $event)"
46
- :meta="column.components[props.source].meta"
47
- :record="currentValues"
48
- @update:inValidity="customComponentsInValidity[column.name] = $event"
49
- @update:emptiness="customComponentsEmptiness[column.name] = $event"
50
- />
51
- </template>
52
- <template v-else>
53
- <Dropdown
54
- single
55
- v-if="column.foreignResource"
56
- :options="columnOptions[column.name] || []"
57
- :placeholder = "columnOptions[column.name]?.length ?'Select...': 'There are no options available'"
58
- :modelValue="currentValues[column.name]"
59
- @update:modelValue="setCurrentValue(column.name, $event)"
60
- ></Dropdown>
61
- <Dropdown
62
- single
63
- v-else-if="column.enum"
64
- :options="column.enum"
65
- :modelValue="currentValues[column.name]"
66
- @update:modelValue="setCurrentValue(column.name, $event)"
67
- />
68
- <Dropdown
69
- single
70
- v-else-if="column.type === 'boolean'"
71
- :options="[{ label: 'Yes', value: true }, { label: 'No', value: false }, { label: 'Unset', value: null }]"
72
- :modelValue="currentValues[column.name]"
73
- @update:modelValue="setCurrentValue(column.name, $event)"
74
- />
75
- <input
76
- v-else-if="['integer'].includes(column.type)"
77
- type="number"
78
- step="1"
79
- class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-40 p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"
80
- placeholder="0"
81
- :value="currentValues[column.name]"
82
- @input="setCurrentValue(column.name, $event.target.value)"
83
- >
84
- <CustomDatePicker
85
- v-else-if="['datetime'].includes(column.type)"
86
- :column="column"
87
- :valueStart="currentValues[column.name]"
88
- auto-hide
89
- @update:valueStart="setCurrentValue(column.name, $event)"
90
- />
91
- <input
92
- v-else-if="['decimal', 'float'].includes(column.type)"
93
- type="number"
94
- step="0.1"
95
- class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-40 p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"
96
- placeholder="0.0"
97
- :value="currentValues[column.name]"
98
- @input="setCurrentValue(column.name, $event.target.value)"
99
- />
100
- <textarea
101
- v-else-if="['text', 'richtext'].includes(column.type)"
102
- class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"
103
- placeholder="Text"
104
- :value="currentValues[column.name]"
105
- @input="setCurrentValue(column.name, $event.target.value)"
106
- >
107
- </textarea>
108
- <input
109
- v-else
110
- :type="!column.masked || unmasked[column.name] ? 'text' : 'password'"
111
- class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"
112
- placeholder="Text"
113
- :value="currentValues[column.name]"
114
- @input="setCurrentValue(column.name, $event.target.value)"
115
- autocomplete="false"
116
- data-lpignore="true"
117
- readonly
118
- onfocus="this.removeAttribute('readonly');"
119
- >
120
-
121
- <button
122
- v-if="column.masked"
123
- type="button"
124
- @click="unmasked[column.name] = !unmasked[column.name]"
125
- class="h-6 absolute inset-y-2 top-6 right-6 flex items-center pr-2 z-index-100 focus:outline-none"
126
- >
127
- <IconEyeSolid class="w-6 h-6 text-gray-400" v-if="!unmasked[column.name]" />
128
- <IconEyeSlashSolid class="w-6 h-6 text-gray-400" v-else />
129
- </button>
130
- </template>
131
- <div v-if="columnError(column) && validating" class="mt-1 text-xs text-red-500 dark:text-red-400">{{ columnError(column) }}</div>
132
-
133
- <div v-if="column.editingNote && column.editingNote[mode]" class="mt-1 text-xs text-gray-400 dark:text-gray-500">{{ column.editingNote[mode] }}</div>
134
-
135
- </td>
136
- </tr>
137
-
138
- </tbody>
139
- </table>
140
- </form>
141
- </div>
142
- </div>
143
-
144
- </template>
145
-
146
- <script setup>
147
-
148
- import CustomDatePicker from "@/components/CustomDatePicker.vue";
149
- import Dropdown from '@/components/Dropdown.vue';
150
- import { useCoreStore } from '@/stores/core';
151
- import { callAdminForthApi, getCustomComponent } from '@/utils';
152
- import { IconExclamationCircleSolid, IconEyeSlashSolid, IconEyeSolid } from '@iconify-prerendered/vue-flowbite';
153
- import { computedAsync } from '@vueuse/core';
154
- import { initFlowbite } from 'flowbite';
155
- import { computed, onMounted, ref, watch } from 'vue';
156
- import { useRouter } from 'vue-router';
157
-
158
- const router = useRouter();
159
-
160
- const props = defineProps({
161
- loading: Boolean,
162
- resource: Object,
163
- record: Object,
164
- validating: Boolean,
165
- source: String,
166
- });
167
-
168
- const unmasked = ref({});
169
-
170
- const mode = computed(() => props.record && Object.keys(props.record).length ? 'edit' : 'create');
171
-
172
- const emit = defineEmits(['update:record', 'update:isValid']);
173
-
174
- const currentValues = ref(null);
175
-
176
- const customComponentsInValidity = ref({});
177
- const customComponentsEmptiness = ref({});
178
-
179
-
180
- const columnError = (column) => {
181
- const val = computed(() => {
182
- if (!currentValues.value) {
183
- return null;
184
- }
185
- if (customComponentsInValidity.value[column.name]) {
186
- return customComponentsInValidity.value[column.name];
187
- }
188
-
189
- if (
190
- column.required[mode.value] &&
191
- (currentValues.value[column.name] === undefined || currentValues.value[column.name] === null || currentValues.value[column.name] === '') &&
192
- // if component is custum it might tell other criteria for emptiness by emitting 'update:emptiness'
193
- // components which do not emit 'update:emptiness' will have undefined value in customComponentsEmptiness
194
- (customComponentsEmptiness.value[column.name] !== false)
195
-
196
- ) {
197
- return 'This field is required';
198
- }
199
- if ( column.type === 'string' || column.type === 'text' ) {
200
- if ( column.maxLength && currentValues.value[column.name]?.length > column.maxLength ) {
201
- return `This field must be shorter than ${column.maxLength} characters`;
202
- }
203
- if ( column.minLength && currentValues.value[column.name]?.length < column.minLength ) {
204
- return `This field must be longer than ${column.minLength} characters`;
205
- }
206
- }
207
- if ( ['integer', 'decimal', 'float'].includes(column.type) ) {
208
- if ( column.minValue !== undefined
209
- && currentValues.value[column.name] !== null
210
- && currentValues.value[column.name] < column.minValue
211
- ) {
212
- return `This field must be greater than ${column.minValue}`;
213
- }
214
- if ( column.maxValue !== undefined && currentValues.value[column.name] > column.maxValue ) {
215
- return `This field must be less than ${column.maxValue}`;
216
- }
217
- }
218
- if ( column.validation && column.validation.length ) {
219
- const validationArray = column.validation;
220
- for (let i = 0; i < validationArray.length; i++) {
221
- if (validationArray[i].regExp) {
222
- const regExp = new RegExp(validationArray[i].regExp);
223
- let value = currentValues.value[column.name];
224
- if (value === undefined || value === null) {
225
- value = '';
226
- }
227
- if (!regExp.test(value)) {
228
- return validationArray[i].message;
229
- }
230
- }
231
- }
232
-
233
- }
234
- return null;
235
- });
236
- return val.value;
237
- };
238
-
239
-
240
- const setCurrentValue = (key, value) => {
241
- const col = props.resource.columns.find((column) => column.name === key);
242
- if (['integer', 'float'].includes(col.type) && (value || value === 0)) {
243
- currentValues.value[key] = +value;
244
- } else {
245
- currentValues.value[key] = value;
246
- }
247
- currentValues.value = { ...currentValues.value };
248
- console.log('3️⃣ setCurrentValue', key, value);
249
- emit('update:record', currentValues.value);
250
- };
251
-
252
- onMounted(() => {
253
- currentValues.value = Object.assign({}, props.record);
254
- console.log('2️⃣ currentValues', JSON.stringify(currentValues.value));
255
- initFlowbite();
256
- emit('update:isValid', isValid.value);
257
- });
258
-
259
- const columnOptions = computedAsync(async () => {
260
- return (await Promise.all(
261
- Object.values(props.resource.columns).map(async (column) => {
262
- if (column.foreignResource) {
263
- const list = await callAdminForthApi({
264
- method: 'POST',
265
- path: `/get_resource_foreign_data`,
266
- body: {
267
- resourceId: router.currentRoute.value.params.resourceId,
268
- column: column.name,
269
- limit: 1000,
270
- offset: 0,
271
- },
272
- });
273
- return { [column.name]: list.items };
274
- }
275
- })
276
- )).reduce((acc, val) => Object.assign(acc, val), {})
277
-
278
- }, {});
279
-
280
-
281
- const editableColumns = computed(() => {
282
- const mode = props.record ? 'edit' : 'create';
283
- return props.resource?.columns?.filter(column => column.showIn.includes(mode));
284
- });
285
-
286
- const isValid = computed(() => {
287
- return editableColumns.value?.every(column => !columnError(column));
288
- });
289
-
290
- watch(() => isValid.value, (value) => {
291
- emit('update:isValid', value);
292
- });
293
-
294
- </script>