adminforth 1.6.2-next.1 → 1.6.2-next.3

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 (93) hide show
  1. package/dist/index.d.ts.map +1 -1
  2. package/dist/index.js +1 -0
  3. package/dist/index.js.map +1 -1
  4. package/package.json +1 -4
  5. package/dist/spa/.eslintrc.cjs +0 -14
  6. package/dist/spa/README.md +0 -39
  7. package/dist/spa/env.d.ts +0 -1
  8. package/dist/spa/index.html +0 -23
  9. package/dist/spa/package-lock.json +0 -5062
  10. package/dist/spa/package.json +0 -58
  11. package/dist/spa/postcss.config.js +0 -6
  12. package/dist/spa/public/assets/favicon.png +0 -0
  13. package/dist/spa/src/App.vue +0 -432
  14. package/dist/spa/src/adminforth.ts +0 -160
  15. package/dist/spa/src/afcl/AreaChart.vue +0 -160
  16. package/dist/spa/src/afcl/BarChart.vue +0 -170
  17. package/dist/spa/src/afcl/Button.vue +0 -27
  18. package/dist/spa/src/afcl/Checkbox.vue +0 -24
  19. package/dist/spa/src/afcl/Dropzone.vue +0 -128
  20. package/dist/spa/src/afcl/Input.vue +0 -41
  21. package/dist/spa/src/afcl/Link.vue +0 -17
  22. package/dist/spa/src/afcl/LinkButton.vue +0 -25
  23. package/dist/spa/src/afcl/PieChart.vue +0 -175
  24. package/dist/spa/src/afcl/ProgressBar.vue +0 -57
  25. package/dist/spa/src/afcl/Select.vue +0 -246
  26. package/dist/spa/src/afcl/Skeleton.vue +0 -26
  27. package/dist/spa/src/afcl/Spinner.vue +0 -9
  28. package/dist/spa/src/afcl/Table.vue +0 -116
  29. package/dist/spa/src/afcl/Tooltip.vue +0 -43
  30. package/dist/spa/src/afcl/VerticalTabs.vue +0 -49
  31. package/dist/spa/src/afcl/index.ts +0 -20
  32. package/dist/spa/src/assets/base.css +0 -2
  33. package/dist/spa/src/assets/logo.svg +0 -19
  34. package/dist/spa/src/components/AcceptModal.vue +0 -44
  35. package/dist/spa/src/components/Breadcrumbs.vue +0 -41
  36. package/dist/spa/src/components/BreadcrumbsWithButtons.vue +0 -25
  37. package/dist/spa/src/components/CustomDatePicker.vue +0 -180
  38. package/dist/spa/src/components/CustomDateRangePicker.vue +0 -218
  39. package/dist/spa/src/components/CustomRangePicker.vue +0 -156
  40. package/dist/spa/src/components/Filters.vue +0 -232
  41. package/dist/spa/src/components/GroupsTable.vue +0 -218
  42. package/dist/spa/src/components/HelloWorld.vue +0 -17
  43. package/dist/spa/src/components/MenuLink.vue +0 -41
  44. package/dist/spa/src/components/ResourceForm.vue +0 -260
  45. package/dist/spa/src/components/ResourceListTable.vue +0 -486
  46. package/dist/spa/src/components/ShowTable.vue +0 -81
  47. package/dist/spa/src/components/SingleSkeletLoader.vue +0 -13
  48. package/dist/spa/src/components/SkeleteLoader.vue +0 -18
  49. package/dist/spa/src/components/ThreeDotsMenu.vue +0 -43
  50. package/dist/spa/src/components/Toast.vue +0 -78
  51. package/dist/spa/src/components/ValueRenderer.vue +0 -141
  52. package/dist/spa/src/components/icons/IconCalendar.vue +0 -5
  53. package/dist/spa/src/components/icons/IconCommunity.vue +0 -7
  54. package/dist/spa/src/components/icons/IconDocumentation.vue +0 -7
  55. package/dist/spa/src/components/icons/IconEcosystem.vue +0 -7
  56. package/dist/spa/src/components/icons/IconSupport.vue +0 -7
  57. package/dist/spa/src/components/icons/IconTime.vue +0 -5
  58. package/dist/spa/src/components/icons/IconTooling.vue +0 -19
  59. package/dist/spa/src/composables/useFrontendApi.ts +0 -28
  60. package/dist/spa/src/i18n.ts +0 -54
  61. package/dist/spa/src/index.scss +0 -34
  62. package/dist/spa/src/main.ts +0 -22
  63. package/dist/spa/src/renderers/CompactField.vue +0 -46
  64. package/dist/spa/src/renderers/CompactUUID.vue +0 -46
  65. package/dist/spa/src/renderers/CountryFlag.vue +0 -65
  66. package/dist/spa/src/renderers/HumanNumber.vue +0 -58
  67. package/dist/spa/src/renderers/RelativeTime.vue +0 -42
  68. package/dist/spa/src/renderers/URL.vue +0 -18
  69. package/dist/spa/src/router/index.ts +0 -70
  70. package/dist/spa/src/spa_types/core.ts +0 -51
  71. package/dist/spa/src/stores/core.ts +0 -228
  72. package/dist/spa/src/stores/filters.ts +0 -27
  73. package/dist/spa/src/stores/modal.ts +0 -48
  74. package/dist/spa/src/stores/toast.ts +0 -30
  75. package/dist/spa/src/stores/user.ts +0 -79
  76. package/dist/spa/src/types/Adapters.ts +0 -26
  77. package/dist/spa/src/types/Back.ts +0 -1344
  78. package/dist/spa/src/types/Common.ts +0 -940
  79. package/dist/spa/src/types/FrontendAPI.ts +0 -189
  80. package/dist/spa/src/utils.ts +0 -184
  81. package/dist/spa/src/views/CreateView.vue +0 -167
  82. package/dist/spa/src/views/EditView.vue +0 -171
  83. package/dist/spa/src/views/ListView.vue +0 -442
  84. package/dist/spa/src/views/LoginView.vue +0 -199
  85. package/dist/spa/src/views/PageNotFound.vue +0 -20
  86. package/dist/spa/src/views/ResourceParent.vue +0 -50
  87. package/dist/spa/src/views/ShowView.vue +0 -209
  88. package/dist/spa/src/websocket.ts +0 -129
  89. package/dist/spa/tailwind.config.js +0 -19
  90. package/dist/spa/tsconfig.app.json +0 -14
  91. package/dist/spa/tsconfig.json +0 -11
  92. package/dist/spa/tsconfig.node.json +0 -19
  93. package/dist/spa/vite.config.ts +0 -52
@@ -1,260 +0,0 @@
1
- <template>
2
- <div class="rounded-default">
3
- <pre>
4
- </pre>
5
- <form autocomplete="off" @submit.prevent>
6
- <div v-if="!groups || groups.length === 0">
7
- <GroupsTable
8
- :source="source"
9
- :group="{groupName: '', columns: editableColumns}"
10
- :currentValues="currentValues"
11
- :editableColumns="editableColumns"
12
- :mode="mode"
13
- :unmasked="unmasked"
14
- :columnOptions="columnOptions"
15
- :validating="validating"
16
- :columnError="columnError"
17
- :setCurrentValue="setCurrentValue"
18
- @update:customComponentsInValidity="(data) => customComponentsInValidity.value = { ...customComponentsInValidity.value, ...data }"
19
- @update:customComponentsEmptiness="(data) => customComponentsEmptiness.value = { ...customComponentsEmptiness.value, ...data }"
20
- />
21
- </div>
22
- <div v-else class="flex flex-col gap-4">
23
- <template v-for="group in groupedColumns" :key="group.groupName">
24
- <GroupsTable
25
- :source="source"
26
- :group="group"
27
- :currentValues="currentValues"
28
- :editableColumns="editableColumns"
29
- :mode="mode"
30
- :unmasked="unmasked"
31
- :columnOptions="columnOptions"
32
- :validating="validating"
33
- :columnError="columnError"
34
- :setCurrentValue="setCurrentValue"
35
- @update:customComponentsInValidity="(data) => customComponentsInValidity.value = { ...customComponentsInValidity.value, ...data }"
36
- @update:customComponentsEmptiness="(data) => customComponentsEmptiness.value = { ...customComponentsEmptiness.value, ...data }"
37
- />
38
- </template>
39
- <div v-if="otherColumns.length > 0">
40
- <GroupsTable
41
- :source="source"
42
- :group="{groupName: $t('Other'), columns: otherColumns}"
43
- :currentValues="currentValues"
44
- :editableColumns="editableColumns"
45
- :mode="mode"
46
- :unmasked="unmasked"
47
- :columnOptions="columnOptions"
48
- :validating="validating"
49
- :columnError="columnError"
50
- :setCurrentValue="setCurrentValue"
51
- @update:customComponentsInValidity="(data) => customComponentsInValidity.value = { ...customComponentsInValidity.value, ...data }"
52
- @update:customComponentsEmptiness="(data) => customComponentsEmptiness.value = { ...customComponentsEmptiness.value, ...data }"
53
- />
54
- </div>
55
- </div>
56
- </form>
57
- </div>
58
-
59
- </template>
60
-
61
- <script setup>
62
-
63
- import { applyRegexValidation, callAdminForthApi} from '@/utils';
64
- import { computedAsync } from '@vueuse/core';
65
- import { computed, onMounted, ref, watch } from 'vue';
66
- import { useRouter, useRoute } from 'vue-router';
67
- import { useCoreStore } from "@/stores/core";
68
- import GroupsTable from '@/components/GroupsTable.vue';
69
- import { useI18n } from 'vue-i18n';
70
-
71
- const { t } = useI18n();
72
-
73
- const coreStore = useCoreStore();
74
- const router = useRouter();
75
- const route = useRoute();
76
- const props = defineProps({
77
- resource: Object,
78
- record: Object,
79
- validating: Boolean,
80
- source: String,
81
- });
82
-
83
- const unmasked = ref({});
84
-
85
- const mode = computed(() => route.name === 'resource-create' ? 'create' : 'edit');
86
-
87
- const emit = defineEmits(['update:record', 'update:isValid']);
88
-
89
- const currentValues = ref(null);
90
- const customComponentsInValidity = ref({});
91
- const customComponentsEmptiness = ref({});
92
-
93
- const columnError = (column) => {
94
- const val = computed(() => {
95
- if (!currentValues.value) {
96
- return null;
97
- }
98
- if (customComponentsInValidity.value[column.name]) {
99
- return customComponentsInValidity.value[column.name];
100
- }
101
-
102
- if (
103
- column.required[mode.value] &&
104
- (currentValues.value[column.name] === undefined || currentValues.value[column.name] === null || currentValues.value[column.name] === '') &&
105
- // if component is custum it might tell other criteria for emptiness by emitting 'update:emptiness'
106
- // components which do not emit 'update:emptiness' will have undefined value in customComponentsEmptiness
107
- (customComponentsEmptiness.value[column.name] !== false)
108
-
109
- ) {
110
- return t('This field is required');
111
- }
112
- if (column.type === 'json' && currentValues.value[column.name]) {
113
- try {
114
- JSON.parse(currentValues.value[column.name]);
115
- } catch (e) {
116
- return t('Invalid JSON');
117
- }
118
- }
119
- if ( column.type === 'string' || column.type === 'text' ) {
120
- if ( column.maxLength && currentValues.value[column.name]?.length > column.maxLength ) {
121
- return t('This field must be shorter than {maxLength} characters', { maxLength: column.maxLength });
122
- }
123
-
124
- if ( column.minLength && currentValues.value[column.name]?.length < column.minLength ) {
125
- // if column.required[mode.value] is false, then we check if the field is empty
126
- let needToCheckEmpty = column.required[mode.value] || currentValues.value[column.name]?.length > 0;
127
- if (!needToCheckEmpty) {
128
- return null;
129
- }
130
- return t('This field must be longer than {minLength} characters', { minLength: column.minLength });
131
- }
132
- }
133
- if ( ['integer', 'decimal', 'float'].includes(column.type) ) {
134
- if ( column.minValue !== undefined
135
- && currentValues.value[column.name] !== null
136
- && currentValues.value[column.name] < column.minValue
137
- ) {
138
- return t('This field must be greater than {minValue}', { minValue: column.minValue });
139
- }
140
- if ( column.maxValue !== undefined && currentValues.value[column.name] > column.maxValue ) {
141
- return t('This field must be less than {maxValue}', { maxValue: column.maxValue });
142
- }
143
- }
144
- if (currentValues.value[column.name] && column.validation) {
145
- const error = applyRegexValidation(currentValues.value[column.name], column.validation);
146
- if (error) {
147
- return error;
148
- }
149
- }
150
-
151
- return null;
152
- });
153
- return val.value;
154
- };
155
-
156
-
157
- const setCurrentValue = (key, value) => {
158
- const col = props.resource.columns.find((column) => column.name === key);
159
- if (['integer', 'float'].includes(col.type) && (value || value === 0)) {
160
- currentValues.value[key] = +value;
161
- } else {
162
- currentValues.value[key] = value;
163
- }
164
- if (['text', 'richtext', 'string'].includes(col.type) && col.enforceLowerCase) {
165
- currentValues.value[key] = currentValues.value[key].toLowerCase();
166
- }
167
-
168
- currentValues.value = { ...currentValues.value };
169
-
170
- //json fields should transform to object
171
- const up = {...currentValues.value};
172
- props.resource.columns.forEach((column) => {
173
- if (column.type === 'json' && up[column.name]) {
174
- try {
175
- up[column.name] = JSON.parse(up[column.name]);
176
- } catch (e) {
177
- // do nothing
178
- }
179
- }
180
- });
181
- emit('update:record', up);
182
- };
183
-
184
- onMounted(() => {
185
- currentValues.value = Object.assign({}, props.record);
186
- // json values should transform to string
187
- props.resource.columns.forEach((column) => {
188
- if (column.type === 'json' && currentValues.value[column.name]) {
189
- currentValues.value[column.name] = JSON.stringify(currentValues.value[column.name], null, 2);
190
- }
191
- });
192
- emit('update:isValid', isValid.value);
193
- });
194
-
195
- const columnOptions = computedAsync(async () => {
196
- return (await Promise.all(
197
- Object.values(props.resource.columns).map(async (column) => {
198
- if (column.foreignResource) {
199
- const list = await callAdminForthApi({
200
- method: 'POST',
201
- path: `/get_resource_foreign_data`,
202
- body: {
203
- resourceId: router.currentRoute.value.params.resourceId,
204
- column: column.name,
205
- limit: 1000,
206
- offset: 0,
207
- },
208
- });
209
- return { [column.name]: list.items };
210
- }
211
- })
212
- )).reduce((acc, val) => Object.assign(acc, val), {})
213
-
214
- }, {});
215
-
216
-
217
- const editableColumns = computed(() => {
218
- return props.resource?.columns?.filter(column => column.showIn.includes(mode.value));
219
- });
220
-
221
- const isValid = computed(() => {
222
- return editableColumns.value?.every(column => !columnError(column));
223
- });
224
-
225
-
226
- const groups = computed(() => {
227
- let fieldGroupType;
228
- if (mode.value === 'edit' && coreStore.resource.options?.editFieldGroups !== undefined) {
229
- fieldGroupType = coreStore.resource.options.editFieldGroups;
230
- } else if (mode.value === 'create' && coreStore.resource.options?.createFieldGroups !== undefined) {
231
- fieldGroupType = coreStore.resource.options.createFieldGroups;
232
- } else {
233
- fieldGroupType = coreStore.resource.options?.fieldGroups;
234
- }
235
- return fieldGroupType ?? [];
236
- });
237
-
238
- const groupedColumns = computed(() => {
239
- if (!groups.value || groups.value.length === 0) return [];
240
-
241
- return groups.value.map(group => ({
242
- ...group,
243
- columns: props.resource.columns.filter(col => group.columns.includes(col.name) && editableColumns.value.includes(col))
244
- }));
245
- });
246
-
247
- const getOtherColumns = () => {
248
- if (!groups.value || groups.value.length === 0) return;
249
-
250
- const groupedColumnNames = new Set(groupedColumns.value.flatMap(group => group.columns.map(col => col.name)));
251
- return editableColumns.value.filter(col => !groupedColumnNames.has(col.name));
252
- };
253
-
254
- const otherColumns = getOtherColumns();
255
-
256
- watch(() => isValid.value, (value) => {
257
- emit('update:isValid', value);
258
- });
259
-
260
- </script>