adminforth 2.4.0-next.26 → 2.4.0-next.261
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.
- package/commands/callTsProxy.js +14 -4
- package/commands/cli.js +10 -3
- package/commands/createApp/templates/api.ts.hbs +10 -0
- package/commands/createApp/templates/custom/tsconfig.json.hbs +2 -3
- package/commands/createApp/templates/index.ts.hbs +12 -1
- package/commands/createApp/utils.js +25 -8
- package/commands/createCustomComponent/configLoader.js +17 -4
- package/commands/createCustomComponent/main.js +1 -0
- package/commands/createCustomComponent/templates/customCrud/beforeActionButtons.vue.hbs +38 -0
- package/commands/createPlugin/templates/custom/tsconfig.json.hbs +2 -5
- package/commands/createPlugin/templates/package.json.hbs +1 -1
- package/commands/generateModels.js +30 -22
- package/dist/auth.d.ts +9 -1
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +21 -2
- package/dist/auth.js.map +1 -1
- package/dist/dataConnectors/baseConnector.d.ts.map +1 -1
- package/dist/dataConnectors/baseConnector.js +46 -15
- package/dist/dataConnectors/baseConnector.js.map +1 -1
- package/dist/dataConnectors/clickhouse.d.ts.map +1 -1
- package/dist/dataConnectors/clickhouse.js +15 -0
- package/dist/dataConnectors/clickhouse.js.map +1 -1
- package/dist/dataConnectors/mongo.d.ts.map +1 -1
- package/dist/dataConnectors/mongo.js +50 -15
- package/dist/dataConnectors/mongo.js.map +1 -1
- package/dist/dataConnectors/mysql.d.ts.map +1 -1
- package/dist/dataConnectors/mysql.js +11 -0
- package/dist/dataConnectors/mysql.js.map +1 -1
- package/dist/dataConnectors/postgres.d.ts.map +1 -1
- package/dist/dataConnectors/postgres.js +43 -14
- package/dist/dataConnectors/postgres.js.map +1 -1
- package/dist/dataConnectors/sqlite.d.ts.map +1 -1
- package/dist/dataConnectors/sqlite.js +11 -0
- package/dist/dataConnectors/sqlite.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +23 -9
- package/dist/index.js.map +1 -1
- package/dist/modules/codeInjector.d.ts +2 -0
- package/dist/modules/codeInjector.d.ts.map +1 -1
- package/dist/modules/codeInjector.js +50 -6
- package/dist/modules/codeInjector.js.map +1 -1
- package/dist/modules/configValidator.d.ts +6 -0
- package/dist/modules/configValidator.d.ts.map +1 -1
- package/dist/modules/configValidator.js +184 -19
- package/dist/modules/configValidator.js.map +1 -1
- package/dist/modules/restApi.d.ts.map +1 -1
- package/dist/modules/restApi.js +164 -26
- package/dist/modules/restApi.js.map +1 -1
- package/dist/modules/styles.d.ts +499 -13
- package/dist/modules/styles.d.ts.map +1 -1
- package/dist/modules/styles.js +555 -31
- package/dist/modules/styles.js.map +1 -1
- package/dist/modules/utils.d.ts +7 -15
- package/dist/modules/utils.d.ts.map +1 -1
- package/dist/modules/utils.js +45 -68
- package/dist/modules/utils.js.map +1 -1
- package/dist/servers/express.d.ts +5 -0
- package/dist/servers/express.d.ts.map +1 -1
- package/dist/servers/express.js +40 -1
- package/dist/servers/express.js.map +1 -1
- package/dist/spa/index.html +1 -1
- package/dist/spa/package-lock.json +5 -4
- package/dist/spa/package.json +1 -1
- package/dist/spa/src/App.vue +58 -173
- package/dist/spa/src/adminforth.ts +42 -18
- package/dist/spa/src/afcl/BarChart.vue +2 -2
- package/dist/spa/src/afcl/Button.vue +6 -6
- package/dist/spa/src/afcl/ButtonGroup.vue +91 -0
- package/dist/spa/src/afcl/Card.vue +25 -0
- package/dist/spa/src/afcl/Checkbox.vue +21 -13
- package/dist/spa/src/afcl/CountryFlag.vue +4 -1
- package/dist/spa/src/{components/CustomDatePicker.vue → afcl/DatePicker.vue} +95 -9
- package/dist/spa/src/afcl/Dialog.vue +47 -27
- package/dist/spa/src/afcl/Dropzone.vue +12 -12
- package/dist/spa/src/afcl/Input.vue +5 -5
- package/dist/spa/src/afcl/JsonViewer.vue +25 -0
- package/dist/spa/src/afcl/LinkButton.vue +3 -3
- package/dist/spa/src/afcl/PieChart.vue +5 -5
- package/dist/spa/src/afcl/ProgressBar.vue +7 -7
- package/dist/spa/src/afcl/Select.vue +68 -34
- package/dist/spa/src/afcl/Skeleton.vue +6 -6
- package/dist/spa/src/afcl/Table.vue +213 -74
- package/dist/spa/src/afcl/Textarea.vue +31 -0
- package/dist/spa/src/afcl/Toggle.vue +32 -0
- package/dist/spa/src/afcl/Tooltip.vue +26 -18
- package/dist/spa/src/afcl/VerticalTabs.vue +16 -7
- package/dist/spa/src/afcl/index.ts +6 -3
- package/dist/spa/src/components/AcceptModal.vue +48 -14
- package/dist/spa/src/components/Breadcrumbs.vue +5 -5
- package/dist/spa/src/components/ColumnValueInput.vue +38 -18
- package/dist/spa/src/components/ColumnValueInputWrapper.vue +4 -3
- package/dist/spa/src/components/CustomDateRangePicker.vue +9 -8
- package/dist/spa/src/components/CustomRangePicker.vue +37 -8
- package/dist/spa/src/components/ErrorMessage.vue +21 -0
- package/dist/spa/src/components/Filters.vue +85 -39
- package/dist/spa/src/components/GroupsTable.vue +9 -8
- package/dist/spa/src/components/MenuLink.vue +90 -23
- package/dist/spa/src/components/ResourceForm.vue +94 -51
- package/dist/spa/src/components/ResourceListTable.vue +90 -80
- package/dist/spa/src/components/ResourceListTableVirtual.vue +86 -76
- package/dist/spa/src/components/ShowTable.vue +21 -15
- package/dist/spa/src/components/Sidebar.vue +470 -0
- package/dist/spa/src/components/SingleSkeletLoader.vue +6 -6
- package/dist/spa/src/components/SkeleteLoader.vue +3 -3
- package/dist/spa/src/components/ThreeDotsMenu.vue +73 -14
- package/dist/spa/src/components/Toast.vue +27 -9
- package/dist/spa/src/components/UserMenuSettingsButton.vue +69 -0
- package/dist/spa/src/components/ValueRenderer.vue +43 -16
- package/dist/spa/src/controls/BoolToggle.vue +34 -0
- package/dist/spa/src/i18n.ts +1 -1
- package/dist/spa/src/renderers/CompactField.vue +1 -1
- package/dist/spa/src/renderers/CompactUUID.vue +1 -1
- package/dist/spa/src/router/index.ts +8 -0
- package/dist/spa/src/shims-vue.d.ts +5 -0
- package/dist/spa/src/spa_types/core.ts +13 -1
- package/dist/spa/src/stores/core.ts +13 -1
- package/dist/spa/src/stores/filters.ts +29 -2
- package/dist/spa/src/stores/modal.ts +6 -1
- package/dist/spa/src/stores/toast.ts +22 -3
- package/dist/spa/src/types/Back.ts +158 -22
- package/dist/spa/src/types/Common.ts +81 -32
- package/dist/spa/src/types/FrontendAPI.ts +31 -5
- package/dist/spa/src/types/adapters/CaptchaAdapter.ts +34 -0
- package/dist/spa/src/types/adapters/EmailAdapter.ts +2 -2
- package/dist/spa/src/types/adapters/ImageVisionAdapter.ts +30 -0
- package/dist/spa/src/types/adapters/KeyValueAdapter.ts +16 -0
- package/dist/spa/src/types/adapters/index.ts +8 -0
- package/dist/spa/src/utils.ts +279 -9
- package/dist/spa/src/views/CreateView.vue +18 -19
- package/dist/spa/src/views/EditView.vue +25 -19
- package/dist/spa/src/views/ListView.vue +144 -87
- package/dist/spa/src/views/LoginView.vue +26 -35
- package/dist/spa/src/views/ResourceParent.vue +2 -2
- package/dist/spa/src/views/SettingsView.vue +121 -0
- package/dist/spa/src/views/ShowView.vue +59 -39
- package/dist/spa/src/websocket.ts +6 -1
- package/dist/spa/tsconfig.app.json +1 -1
- package/dist/spa/vite.config.ts +45 -2
- package/dist/types/Back.d.ts +134 -14
- package/dist/types/Back.d.ts.map +1 -1
- package/dist/types/Back.js +15 -0
- package/dist/types/Back.js.map +1 -1
- package/dist/types/Common.d.ts +96 -29
- package/dist/types/Common.d.ts.map +1 -1
- package/dist/types/Common.js.map +1 -1
- package/dist/types/FrontendAPI.d.ts +31 -3
- package/dist/types/FrontendAPI.d.ts.map +1 -1
- package/dist/types/FrontendAPI.js.map +1 -1
- package/dist/types/adapters/CaptchaAdapter.d.ts +30 -0
- package/dist/types/adapters/CaptchaAdapter.d.ts.map +1 -0
- package/dist/types/adapters/CaptchaAdapter.js +5 -0
- package/dist/types/adapters/CaptchaAdapter.js.map +1 -0
- package/dist/types/adapters/EmailAdapter.d.ts +1 -1
- package/dist/types/adapters/ImageVisionAdapter.d.ts +25 -0
- package/dist/types/adapters/ImageVisionAdapter.d.ts.map +1 -0
- package/dist/types/adapters/ImageVisionAdapter.js +2 -0
- package/dist/types/adapters/ImageVisionAdapter.js.map +1 -0
- package/dist/types/adapters/KeyValueAdapter.d.ts +10 -0
- package/dist/types/adapters/KeyValueAdapter.d.ts.map +1 -0
- package/dist/types/adapters/KeyValueAdapter.js +2 -0
- package/dist/types/adapters/KeyValueAdapter.js.map +1 -0
- package/dist/types/adapters/index.d.ts +9 -0
- package/dist/types/adapters/index.d.ts.map +1 -0
- package/dist/types/adapters/index.js +2 -0
- package/dist/types/adapters/index.js.map +1 -0
- package/package.json +4 -2
- package/dist/spa/src/types/adapters/index.js +0 -5
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div v-if="error" class="af-login-modal-error flex items-center p-4 mb-4 text-sm text-red-800 rounded-lg bg-red-50 dark:bg-gray-800 dark:text-red-400" role="alert">
|
|
3
|
+
<svg class="flex-shrink-0 inline w-4 h-4 me-3" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 20 20">
|
|
4
|
+
<path d="M10 .5a9.5 9.5 0 1 0 9.5 9.5A9.51 9.51 0 0 0 10 .5ZM9.5 4a1.5 1.5 0 1 1 0 3 1.5 1.5 0 0 1 0-3ZM12 15H8a1 1 0 0 1 0-2h1v-3H8a1 1 0 0 1 0-2h2a1 1 0 0 1 1 1v4h1a1 1 0 0 1 0 2Z"/>
|
|
5
|
+
</svg>
|
|
6
|
+
<span class="sr-only">{{ $t('Info') }}</span>
|
|
7
|
+
<div>
|
|
8
|
+
{{ error }}
|
|
9
|
+
</div>
|
|
10
|
+
</div>
|
|
11
|
+
</template>
|
|
12
|
+
|
|
13
|
+
<script setup>
|
|
14
|
+
|
|
15
|
+
defineProps({
|
|
16
|
+
error: {
|
|
17
|
+
type: String,
|
|
18
|
+
default: null
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
</script>
|
|
@@ -2,16 +2,16 @@
|
|
|
2
2
|
<!-- drawer component -->
|
|
3
3
|
<div id="drawer-navigation"
|
|
4
4
|
|
|
5
|
-
class="fixed
|
|
5
|
+
class="af-filters-sidebar fixed right-0 z-50 p-4 overflow-y-auto transition-transform translate-x-full bg-lightFiltersBackgroung w-80 dark:bg-darkFiltersBackgroung shadow-xl dark:shadow-gray-900"
|
|
6
6
|
|
|
7
7
|
:class="show ? 'top-0 transform-none' : ''"
|
|
8
8
|
tabindex="-1" aria-labelledby="drawer-navigation-label"
|
|
9
9
|
:style="{ height: `calc(100dvh ` }"
|
|
10
10
|
>
|
|
11
|
-
<h5 id="drawer-navigation-label" class="text-base font-semibold text-
|
|
11
|
+
<h5 id="drawer-navigation-label" class="text-base font-semibold text-lightFiltersHeaderText uppercase dark:text-darkFiltersHeaderText">
|
|
12
12
|
{{ $t('Filters') }}
|
|
13
13
|
|
|
14
|
-
<button type="button" @click="$emit('hide')" class="text-
|
|
14
|
+
<button type="button" @click="$emit('hide')" class="text-lightFiltersCloseIcon bg-transparent hover:bg-lightFiltersCloseIconHoverBackground hover:text-lightFiltersCloseIconHover rounded-lg text-sm p-1.5 absolute end-2.5 inline-flex items-center dark:text-darkFiltersCloseIcon dark:hover:bg-darkFiltersCloseIconHoverBackground dark:hover:text-darkFiltersCloseIconHover" >
|
|
15
15
|
<svg aria-hidden="true" class="w-5 h-5" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" d="M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z" clip-rule="evenodd"></path></svg>
|
|
16
16
|
<span class="sr-only">{{ $t('Close menu') }}</span>
|
|
17
17
|
</button>
|
|
@@ -43,9 +43,23 @@
|
|
|
43
43
|
:multiple="c.filterOptions.multiselect"
|
|
44
44
|
class="w-full"
|
|
45
45
|
:options="columnOptions[c.name] || []"
|
|
46
|
+
:searchDisabled="!c.foreignResource.searchableFields"
|
|
47
|
+
@scroll-near-end="loadMoreOptions(c.name)"
|
|
48
|
+
@search="(searchTerm) => {
|
|
49
|
+
if (c.foreignResource.searchableFields && onSearchInput[c.name]) {
|
|
50
|
+
onSearchInput[c.name](searchTerm);
|
|
51
|
+
}
|
|
52
|
+
}"
|
|
46
53
|
@update:modelValue="onFilterInput[c.name]({ column: c, operator: c.filterOptions.multiselect ? 'in' : 'eq', value: c.filterOptions.multiselect ? ($event.length ? $event : undefined) : $event || undefined })"
|
|
47
54
|
:modelValue="filtersStore.filters.find(f => f.field === c.name && f.operator === (c.filterOptions.multiselect ? 'in' : 'eq'))?.value || (c.filterOptions.multiselect ? [] : '')"
|
|
48
|
-
|
|
55
|
+
>
|
|
56
|
+
<template #extra-item v-if="columnLoadingState[c.name]?.loading">
|
|
57
|
+
<div class="text-center text-gray-400 dark:text-gray-300 py-2 flex items-center justify-center gap-2">
|
|
58
|
+
<Spinner class="w-4 h-4" />
|
|
59
|
+
{{ $t('Loading...') }}
|
|
60
|
+
</div>
|
|
61
|
+
</template>
|
|
62
|
+
</Select>
|
|
49
63
|
<Select
|
|
50
64
|
:multiple="c.filterOptions.multiselect"
|
|
51
65
|
class="w-full"
|
|
@@ -94,9 +108,9 @@
|
|
|
94
108
|
:min="getFilterMinValue(c.name)"
|
|
95
109
|
:max="getFilterMaxValue(c.name)"
|
|
96
110
|
:valueStart="getFilterItem({ column: c, operator: 'gte' })"
|
|
97
|
-
@update:valueStart="onFilterInput[c.name]({ column: c, operator: 'gte', value: $event
|
|
111
|
+
@update:valueStart="onFilterInput[c.name]({ column: c, operator: 'gte', value: ($event !== '' && $event !== null) ? $event : undefined })"
|
|
98
112
|
:valueEnd="getFilterItem({ column: c, operator: 'lte' })"
|
|
99
|
-
@update:valueEnd="onFilterInput[c.name]({ column: c, operator: 'lte', value: $event
|
|
113
|
+
@update:valueEnd="onFilterInput[c.name]({ column: c, operator: 'lte', value: ($event !== '' && $event !== null) ? $event : undefined })"
|
|
100
114
|
/>
|
|
101
115
|
|
|
102
116
|
<div v-else-if="['integer', 'decimal', 'float'].includes(c.type)" class="flex gap-2">
|
|
@@ -104,14 +118,14 @@
|
|
|
104
118
|
type="number"
|
|
105
119
|
aria-describedby="helper-text-explanation"
|
|
106
120
|
:placeholder="$t('From')"
|
|
107
|
-
@update:modelValue="onFilterInput[c.name]({ column: c, operator: 'gte', value: $event
|
|
121
|
+
@update:modelValue="onFilterInput[c.name]({ column: c, operator: 'gte', value: ($event !== '' && $event !== null) ? $event : undefined })"
|
|
108
122
|
:modelValue="getFilterItem({ column: c, operator: 'gte' })"
|
|
109
123
|
/>
|
|
110
124
|
<Input
|
|
111
125
|
type="number"
|
|
112
126
|
aria-describedby="helper-text-explanation"
|
|
113
127
|
:placeholder="$t('To')"
|
|
114
|
-
@update:modelValue="onFilterInput[c.name]({ column: c, operator: 'lte', value: $event
|
|
128
|
+
@update:modelValue="onFilterInput[c.name]({ column: c, operator: 'lte', value: ($event !== '' && $event !== null) ? $event : undefined })"
|
|
115
129
|
:modelValue="getFilterItem({ column: c, operator: 'lte' })"
|
|
116
130
|
/>
|
|
117
131
|
</div>
|
|
@@ -122,9 +136,9 @@
|
|
|
122
136
|
|
|
123
137
|
<div class="flex justify-end gap-2">
|
|
124
138
|
<button
|
|
125
|
-
:disabled="!filtersStore.
|
|
139
|
+
:disabled="!filtersStore.visibleFiltersCount"
|
|
126
140
|
type="button"
|
|
127
|
-
class="flex items-center py-1 px-3 text-sm font-medium text-
|
|
141
|
+
class="flex items-center py-1 px-3 text-sm font-medium text-lightFiltersClearAllButtonText focus:outline-none bg-lightFiltersClearAllButtonBackground rounded border border-lightFiltersClearAllButtonBorder hover:bg-lightFiltersClearAllButtonBackgroundHover hover:text-lightFiltersClearAllButtonTextHover focus:z-10 focus:ring-4 focus:ring-lightFiltersClearAllButtonFocus dark:focus:ring-darkFiltersClearAllButtonFocus dark:bg-darkFiltersClearAllButtonBackground dark:text-darkFiltersClearAllButtonText dark:border-darkFiltersClearAllButtonBorder dark:hover:text-darkFiltersClearAllButtonTextHover dark:hover:bg-darkFiltersClearAllButtonBackgroundHover disabled:opacity-50 disabled:cursor-not-allowed"
|
|
128
142
|
@click="clear">{{ $t('Clear all') }}</button>
|
|
129
143
|
|
|
130
144
|
</div>
|
|
@@ -136,17 +150,17 @@
|
|
|
136
150
|
</template>
|
|
137
151
|
|
|
138
152
|
<script setup>
|
|
139
|
-
import { watch, computed } from 'vue';
|
|
153
|
+
import { watch, computed, ref, reactive } from 'vue';
|
|
140
154
|
import { useI18n } from 'vue-i18n';
|
|
141
155
|
import CustomDateRangePicker from '@/components/CustomDateRangePicker.vue';
|
|
142
|
-
import { callAdminForthApi } from '@/utils';
|
|
156
|
+
import { callAdminForthApi, loadMoreForeignOptions, searchForeignOptions, createSearchInputHandlers } from '@/utils';
|
|
143
157
|
import { useRouter } from 'vue-router';
|
|
144
|
-
import { computedAsync } from '@vueuse/core'
|
|
145
158
|
import CustomRangePicker from "@/components/CustomRangePicker.vue";
|
|
146
159
|
import { useFiltersStore } from '@/stores/filters';
|
|
147
160
|
import { getCustomComponent } from '@/utils';
|
|
148
161
|
import Input from '@/afcl/Input.vue';
|
|
149
162
|
import Select from '@/afcl/Select.vue';
|
|
163
|
+
import Spinner from '@/afcl/Spinner.vue';
|
|
150
164
|
import debounce from 'debounce';
|
|
151
165
|
|
|
152
166
|
const filtersStore = useFiltersStore();
|
|
@@ -165,31 +179,54 @@ const columnsWithFilter = computed(
|
|
|
165
179
|
() => props.columns?.filter(column => column.showIn.filter) || []
|
|
166
180
|
);
|
|
167
181
|
|
|
168
|
-
const columnOptions =
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
});
|
|
186
|
-
ret[column.name] = list.items;
|
|
182
|
+
const columnOptions = ref({});
|
|
183
|
+
const columnLoadingState = reactive({});
|
|
184
|
+
const columnOffsets = reactive({});
|
|
185
|
+
const columnEmptyResultsCount = reactive({});
|
|
186
|
+
|
|
187
|
+
watch(() => props.columns, async (newColumns) => {
|
|
188
|
+
if (!newColumns) return;
|
|
189
|
+
|
|
190
|
+
for (const column of newColumns) {
|
|
191
|
+
if (column.foreignResource) {
|
|
192
|
+
if (!columnOptions.value[column.name]) {
|
|
193
|
+
columnOptions.value[column.name] = [];
|
|
194
|
+
columnLoadingState[column.name] = { loading: false, hasMore: true };
|
|
195
|
+
columnOffsets[column.name] = 0;
|
|
196
|
+
columnEmptyResultsCount[column.name] = 0;
|
|
197
|
+
|
|
198
|
+
await loadMoreOptions(column.name);
|
|
187
199
|
}
|
|
188
|
-
}
|
|
189
|
-
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
}, { immediate: true });
|
|
203
|
+
|
|
204
|
+
// Function to load more options for a specific column
|
|
205
|
+
async function loadMoreOptions(columnName, searchTerm = '') {
|
|
206
|
+
return loadMoreForeignOptions({
|
|
207
|
+
columnName,
|
|
208
|
+
searchTerm,
|
|
209
|
+
columns: props.columns,
|
|
210
|
+
resourceId: router.currentRoute.value.params.resourceId,
|
|
211
|
+
columnOptions,
|
|
212
|
+
columnLoadingState,
|
|
213
|
+
columnOffsets,
|
|
214
|
+
columnEmptyResultsCount
|
|
215
|
+
});
|
|
216
|
+
}
|
|
190
217
|
|
|
191
|
-
|
|
192
|
-
|
|
218
|
+
async function searchOptions(columnName, searchTerm) {
|
|
219
|
+
return searchForeignOptions({
|
|
220
|
+
columnName,
|
|
221
|
+
searchTerm,
|
|
222
|
+
columns: props.columns,
|
|
223
|
+
resourceId: router.currentRoute.value.params.resourceId,
|
|
224
|
+
columnOptions,
|
|
225
|
+
columnLoadingState,
|
|
226
|
+
columnOffsets,
|
|
227
|
+
columnEmptyResultsCount
|
|
228
|
+
});
|
|
229
|
+
}
|
|
193
230
|
|
|
194
231
|
|
|
195
232
|
// sync 'body' class 'overflow-hidden' with show prop show
|
|
@@ -221,10 +258,18 @@ const onFilterInput = computed(() => {
|
|
|
221
258
|
}, {});
|
|
222
259
|
});
|
|
223
260
|
|
|
261
|
+
const onSearchInput = computed(() => {
|
|
262
|
+
return createSearchInputHandlers(
|
|
263
|
+
props.columns,
|
|
264
|
+
searchOptions,
|
|
265
|
+
(column) => column.filterOptions?.debounceTimeMs || 300
|
|
266
|
+
);
|
|
267
|
+
});
|
|
268
|
+
|
|
224
269
|
function setFilterItem({ column, operator, value }) {
|
|
225
270
|
|
|
226
271
|
const index = filtersStore.filters.findIndex(f => f.field === column.name && f.operator === operator);
|
|
227
|
-
if (value === undefined) {
|
|
272
|
+
if (value === undefined || value === '' || value === null) {
|
|
228
273
|
if (index !== -1) {
|
|
229
274
|
filtersStore.filters.splice(index, 1);
|
|
230
275
|
}
|
|
@@ -239,11 +284,12 @@ function setFilterItem({ column, operator, value }) {
|
|
|
239
284
|
}
|
|
240
285
|
|
|
241
286
|
function getFilterItem({ column, operator }) {
|
|
242
|
-
|
|
287
|
+
const filterValue = filtersStore.filters.find(f => f.field === column.name && f.operator === operator)?.value;
|
|
288
|
+
return filterValue !== undefined ? filterValue : '';
|
|
243
289
|
}
|
|
244
290
|
|
|
245
291
|
async function clear() {
|
|
246
|
-
filtersStore.
|
|
292
|
+
filtersStore.filters = [...filtersStore.filters.filter(f => filtersStore.shouldFilterBeHidden(f.field))];
|
|
247
293
|
emits('update:filters', [...filtersStore.filters]);
|
|
248
294
|
}
|
|
249
295
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="rounded-lg shadow-resourseFormShadow dark:shadow-darkResourseFormShadow dark:shadow-2xl">
|
|
3
|
-
<div v-if="group.groupName && !group.noTitle" class="text-md font-semibold px-6 py-3 flex flex-1 items-center dark:border-
|
|
3
|
+
<div v-if="group.groupName && !group.noTitle" class="text-md font-semibold px-6 py-3 flex flex-1 items-center dark:border-darkFormBorder text-lightListTableHeadingText bg-lightFormHeading dark:bg-darkFormHeading dark:text-darkListTableHeadingText rounded-t-lg">
|
|
4
4
|
{{ group.groupName }}
|
|
5
5
|
</div>
|
|
6
|
-
<table class="w-full text-sm text-left rtl:text-right text-
|
|
7
|
-
<thead v-if="!allColumnsHaveCustomComponent" class="text-xs text-
|
|
6
|
+
<table class="w-full text-sm text-left rtl:text-right text-lightFormFieldTextColor dark:text-darkFormFieldTextColor">
|
|
7
|
+
<thead v-if="!allColumnsHaveCustomComponent" class="text-xs text-lightListTableHeadingText uppercase dark:text-darkListTableHeadingText bg-lightFormHeading dark:bg-darkFormHeading block md:table-row-group ">
|
|
8
8
|
<tr>
|
|
9
9
|
<th scope="col" :class="{'rounded-tl-lg': !group.groupName}" class="px-6 py-3 hidden md:w-52 md:table-cell">
|
|
10
10
|
{{ $t('Field') }}
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
v-for="(column, i) in group.columns"
|
|
20
20
|
:key="column.name"
|
|
21
21
|
v-if="currentValues !== null"
|
|
22
|
-
class="bg-
|
|
22
|
+
class="bg-lightForm dark:bg-darkForm dark:border-darkFormBorder block md:table-row"
|
|
23
23
|
:class="{ 'border-b': i !== group.columns.length - 1}"
|
|
24
24
|
>
|
|
25
25
|
<td class="px-6 py-4 flex items-center block md:table-cell pb-0 md:pb-4"
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
<Tooltip v-if="column.required[mode]">
|
|
30
30
|
|
|
31
31
|
<IconExclamationCircleSolid v-if="column.required[mode]" class="w-4 h-4"
|
|
32
|
-
:class="(columnError(column) && validating) ? 'text-
|
|
32
|
+
:class="(columnError(column) && validating) ? 'text-lightInputErrorColor dark:text-darkInputErrorColor' : 'text-lightRequiredIconColor dark:text-darkRequiredIconColor'"
|
|
33
33
|
/>
|
|
34
34
|
|
|
35
35
|
<template #tooltip>
|
|
@@ -55,8 +55,8 @@
|
|
|
55
55
|
@update:emptiness="customComponentsEmptiness[$event.name] = $event.value"
|
|
56
56
|
:readonly="readonlyColumns?.includes(column.name)"
|
|
57
57
|
/>
|
|
58
|
-
<div v-if="columnError(column) && validating" class="mt-1 text-xs text-
|
|
59
|
-
<div v-if="column.editingNote && column.editingNote[mode]" class="mt-1 text-xs text-
|
|
58
|
+
<div v-if="columnError(column) && validating" class="mt-1 text-xs text-lightInputErrorColor dark:text-darkInputErrorColor">{{ columnError(column) }}</div>
|
|
59
|
+
<div v-if="column.editingNote && column.editingNote[mode]" class="mt-1 text-xs text-lightFormFieldTextColor dark:text-darkFormFieldTextColor">{{ column.editingNote[mode] }}</div>
|
|
60
60
|
</td>
|
|
61
61
|
</tr>
|
|
62
62
|
</tbody>
|
|
@@ -70,6 +70,7 @@
|
|
|
70
70
|
import { ref, computed, watch, nextTick, type Ref } from 'vue';
|
|
71
71
|
import { useI18n } from 'vue-i18n';
|
|
72
72
|
import ColumnValueInputWrapper from "@/components/ColumnValueInputWrapper.vue";
|
|
73
|
+
import type { AdminForthResourceColumnInputCommon } from '@/types/Common';
|
|
73
74
|
|
|
74
75
|
const { t } = useI18n();
|
|
75
76
|
|
|
@@ -89,7 +90,7 @@
|
|
|
89
90
|
const customComponentsInValidity: Ref<Record<string, boolean>> = ref({});
|
|
90
91
|
const customComponentsEmptiness: Ref<Record<string, boolean>> = ref({});
|
|
91
92
|
const allColumnsHaveCustomComponent = computed(() => {
|
|
92
|
-
return props.group.columns.every(column => {
|
|
93
|
+
return props.group.columns.every((column: AdminForthResourceColumnInputCommon) => {
|
|
93
94
|
const componentKey = `${props.source}Row` as keyof typeof column.components;
|
|
94
95
|
return column.components?.[componentKey];
|
|
95
96
|
});
|
|
@@ -1,42 +1,109 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<RouterLink
|
|
3
3
|
:to="{name: item.resourceId ? 'resource-list' : item.path, params: item.resourceId ? { resourceId: item.resourceId }: {}}"
|
|
4
|
-
class="flex group items-center py-2 text-lightSidebarText dark:text-darkSidebarText rounded-default
|
|
4
|
+
class="af-menu-link flex group relative items-center w-full py-2 text-lightSidebarText dark:text-darkSidebarText rounded-default transition-all duration-200 ease-in-out"
|
|
5
5
|
:class="{
|
|
6
|
-
'
|
|
7
|
-
'
|
|
6
|
+
'hover:bg-lightSidebarItemHover hover:text-lightSidebarTextHover dark:hover:bg-darkSidebarItemHover dark:hover:text-darkSidebarTextHover active:bg-lightSidebarActive dark:active:bg-darkSidebarHover': !['divider', 'gap', 'heading'].includes(item.type),
|
|
7
|
+
'pl-6 pr-3.5': (isChild && !isSidebarIconOnly && !isSidebarHovering) || (isChild && isSidebarIconOnly && isSidebarHovering),
|
|
8
|
+
'px-3.5 ': !isChild || (isSidebarIconOnly && !isSidebarHovering),
|
|
9
|
+
'max-w-12': isSidebarIconOnly && !isSidebarHovering,
|
|
8
10
|
'bg-lightSidebarItemActive dark:bg-darkSidebarItemActive': item.resourceId ?
|
|
9
11
|
($route.params.resourceId === item.resourceId && $route.name === 'resource-list') :
|
|
10
12
|
($route.name === item.path)
|
|
11
13
|
}"
|
|
12
14
|
>
|
|
13
|
-
<component v-if="item.icon" :is="getIcon(item.icon)"
|
|
14
|
-
|
|
15
|
-
<span v-if="item.badge"
|
|
15
|
+
<component v-if="item.icon" :is="getIcon(item.icon)"
|
|
16
|
+
class="min-w-5 min-h-5 text-lightSidebarIcons dark:text-darkSidebarIcons group-hover:text-lightSidebarIconsHover dark:group-hover:text-darkSidebarIconsHover transition-all duration-200 ease-in-out"
|
|
16
17
|
>
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
18
|
+
</component>
|
|
19
|
+
<div
|
|
20
|
+
class="overflow-hidden block ms-3 pr-4 text-left rtl:text-right transition-all duration-200 ease-in-out"
|
|
21
|
+
:class="{
|
|
22
|
+
'opacity-0 ms-0 translate-x-4 flex-none': isSidebarIconOnly && !isSidebarHovering,
|
|
23
|
+
'opacity-100 ms-3 translate-x-0 flex-1': !isSidebarIconOnly || (isSidebarIconOnly && isSidebarHovering),
|
|
24
|
+
}"
|
|
25
|
+
:style="isSidebarIconOnly ? {
|
|
26
|
+
minWidth: isChild
|
|
27
|
+
? 'calc(16.5rem - 0.75rem*2 - 1.5rem*2 - 1.25rem - 0.75rem)'
|
|
28
|
+
: 'calc(16.5rem - 0.75rem*2 - 0.875rem*2 - 1.25rem - 0.75rem)',
|
|
29
|
+
width: isChild
|
|
30
|
+
? 'calc(16.5rem - 0.75rem*2 - 1.5rem*2 - 1.25rem - 0.75rem)'
|
|
31
|
+
: 'calc(16.5rem - 0.75rem*2 - 0.875rem*2 - 1.25rem - 0.75rem)'
|
|
32
|
+
} : {}"
|
|
33
|
+
>
|
|
34
|
+
{{ item.label }}
|
|
35
|
+
</div>
|
|
36
|
+
<span class="absolute right-1 top-1/2 -translate-y-1/2" v-if="item.badge && showExpandedBadge">
|
|
37
|
+
<Tooltip v-if="item.badgeTooltip">
|
|
38
|
+
<div class="af-badge inline-flex items-center justify-center h-3 py-2.5 px-1 ms-3 text-xs font-medium rounded-full bg-lightAnnouncementBG dark:bg-darkAnnouncementBG
|
|
39
|
+
fill-lightAnnouncementText dark:fill-darkAccent text-lightAnnouncementText dark:text-darkAccent min-w-[1.5rem] max-w-[3rem]">{{ item.badge }}</div>
|
|
40
|
+
<template #tooltip>
|
|
41
|
+
{{ item.badgeTooltip }}
|
|
42
|
+
</template>
|
|
43
|
+
</Tooltip>
|
|
44
|
+
<template v-else>
|
|
45
|
+
<div class="af-badge inline-flex items-center justify-center h-3 py-2.5 px-1 ms-3 text-xs font-medium rounded-full bg-lightAnnouncementBG dark:bg-darkAnnouncementBG
|
|
46
|
+
fill-lightAnnouncementText dark:fill-darkAccent text-lightAnnouncementText dark:text-darkAccent min-w-[1.5rem] max-w-[3rem]">{{ item.badge }}</div>
|
|
47
|
+
</template>
|
|
31
48
|
</span>
|
|
32
|
-
|
|
49
|
+
<div v-if="item.badge && isSidebarIconOnly && !isSidebarHovering" class="af-badge absolute right-0.5 bottom-1 -translate-y-1/2 inline-flex items-center justify-center h-2 w-2 text-sm font-medium rounded-full bg-lightAnnouncementBG dark:bg-darkAnnouncementBG
|
|
50
|
+
fill-lightAnnouncementText dark:fill-darkAccent text-lightAnnouncementText dark:text-darkAccent">
|
|
51
|
+
</div>
|
|
33
52
|
</RouterLink>
|
|
34
53
|
</template>
|
|
35
54
|
|
|
36
|
-
<script setup lang="ts">
|
|
55
|
+
<script setup lang="ts">
|
|
37
56
|
import { getIcon } from '@/utils';
|
|
38
57
|
import { Tooltip } from '@/afcl';
|
|
39
|
-
|
|
58
|
+
import { ref, watch } from 'vue';
|
|
59
|
+
|
|
60
|
+
const props = defineProps(['item', 'isChild', 'isSidebarIconOnly', 'isSidebarHovering']);
|
|
61
|
+
|
|
62
|
+
const BADGE_SHOW_DELAY_MS = 200;
|
|
63
|
+
const showExpandedBadge = ref(false);
|
|
64
|
+
let showBadgeTimer: ReturnType<typeof setTimeout> | null = null;
|
|
65
|
+
|
|
66
|
+
function cancelShowBadgeTimer() {
|
|
67
|
+
if (showBadgeTimer) {
|
|
68
|
+
clearTimeout(showBadgeTimer);
|
|
69
|
+
showBadgeTimer = null;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function showBadgeImmediately() {
|
|
74
|
+
cancelShowBadgeTimer();
|
|
75
|
+
showExpandedBadge.value = true;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function hideBadgeImmediately() {
|
|
79
|
+
cancelShowBadgeTimer();
|
|
80
|
+
showExpandedBadge.value = false;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function showBadgeAfterDelay() {
|
|
84
|
+
cancelShowBadgeTimer();
|
|
85
|
+
showBadgeTimer = setTimeout(() => {
|
|
86
|
+
showExpandedBadge.value = true;
|
|
87
|
+
showBadgeTimer = null;
|
|
88
|
+
}, BADGE_SHOW_DELAY_MS);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
watch(
|
|
92
|
+
[() => props.isSidebarIconOnly, () => props.isSidebarHovering],
|
|
93
|
+
([isIconOnly, isHovering]) => {
|
|
94
|
+
if (!isIconOnly) {
|
|
95
|
+
showBadgeImmediately();
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (isHovering) {
|
|
100
|
+
showBadgeAfterDelay();
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
40
103
|
|
|
104
|
+
hideBadgeImmediately();
|
|
105
|
+
},
|
|
106
|
+
{ immediate: true }
|
|
107
|
+
);
|
|
41
108
|
|
|
42
109
|
</script>
|