Skip to content

Commit 384fa20

Browse files
committed
Merge branch 'next' of github.com:devforth/adminforth into next
2 parents e879f8c + 8e76e8d commit 384fa20

File tree

14 files changed

+144
-21
lines changed

14 files changed

+144
-21
lines changed

adminforth/documentation/docs/tutorial/03-Customization/09-Actions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ import { admin } from '../index';
204204
//diff-add
205205
await stmt.run(...selectedIds);
206206
//diff-add
207-
return { ok: true, error: false, successMessage: `Marked ${selectedIds.length} apartments as listed` };
207+
return { ok: true, successMessage: `Marked ${selectedIds.length} apartments as listed` };
208208
//diff-add
209209
},
210210
//diff-add

adminforth/documentation/docs/tutorial/03-Customization/10-menuConfiguration.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ E.g. create group "Blog" with Items who link to resource "posts" and "categories
2323
```ts title='./index.ts'
2424
{
2525
...
26-
menu: {
26+
menu: [
2727
{
2828
label: 'Blog',
2929
icon: 'flowbite:brain-solid',
@@ -46,7 +46,7 @@ E.g. create group "Blog" with Items who link to resource "posts" and "categories
4646
icon: 'flowbite:folder-duplicate-outline',
4747
resourceId: 'adminuser',
4848
},
49-
},
49+
],
5050
...
5151
}
5252
```

adminforth/documentation/docs/tutorial/03-Customization/13-standardPagesTuning.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export default {
6363
}
6464
```
6565

66-
You can also specify on which page you want to create or delete groups. If you assign null, the groups will disappear from this page.
66+
You can also specify on which page you want to create groups.
6767

6868
```typescript title="./resources/apartments.ts"
6969
export default {
@@ -89,10 +89,6 @@ export default {
8989
}
9090
//diff-add
9191
],
92-
//diff-add
93-
editFieldGroups: null,
94-
//diff-add
95-
showFieldGroups: null,
9692
}
9793
}
9894
```

adminforth/modules/restApi.ts

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
HttpExtra,
1313
IAdminForthAndOrFilter,
1414
BackendOnlyInput,
15+
Filters,
1516
} from "../types/Back.js";
1617

1718
import { ADMINFORTH_VERSION, listify, md5hash, getLoginPromptHTML } from './utils.js';
@@ -363,7 +364,13 @@ export default class AdminForthRestAPI implements IAdminForthRestAPI {
363364

364365
const announcementBadge: AnnouncementBadgeResponse = this.adminforth.config.customization.announcementBadge?.(adminUser);
365366

366-
367+
const settingPages = []
368+
for ( const settingPage of this.adminforth.config.auth.userMenuSettingsPages || [] ) {
369+
if ( settingPage.isVisible ) {
370+
const isVisible = await settingPage.isVisible( adminUser );
371+
settingPages.push( { ...settingPage, isVisible } );
372+
}
373+
}
367374

368375
const publicPart = {
369376
brandName: this.adminforth.config.customization.brandName,
@@ -378,7 +385,6 @@ export default class AdminForthRestAPI implements IAdminForthRestAPI {
378385
singleTheme: this.adminforth.config.customization.singleTheme,
379386
customHeadItems: this.adminforth.config.customization.customHeadItems,
380387
}
381-
382388
const loggedInPart = {
383389
showBrandNameInSidebar: this.adminforth.config.customization.showBrandNameInSidebar,
384390
showBrandLogoInSidebar: this.adminforth.config.customization.showBrandLogoInSidebar,
@@ -393,7 +399,7 @@ export default class AdminForthRestAPI implements IAdminForthRestAPI {
393399
announcementBadge,
394400
globalInjections: this.adminforth.config.customization.globalInjections,
395401
userFullnameField: this.adminforth.config.auth.userFullNameField,
396-
settingPages: this.adminforth.config.auth.userMenuSettingsPages,
402+
settingPages: settingPages,
397403
}
398404

399405
// translate menu labels
@@ -1175,6 +1181,14 @@ export default class AdminForthRestAPI implements IAdminForthRestAPI {
11751181
}
11761182
}
11771183

1184+
const primaryKeyColumn = resource.columns.find((col) => col.primaryKey);
1185+
if (record[primaryKeyColumn.name] !== undefined) {
1186+
const existingRecord = await this.adminforth.resource(resource.resourceId).get([Filters.EQ(primaryKeyColumn.name, record[primaryKeyColumn.name])]);
1187+
if (existingRecord) {
1188+
return { error: `Record with ${primaryKeyColumn.name} '${record[primaryKeyColumn.name]}' already exists`, ok: false };
1189+
}
1190+
}
1191+
11781192
const ctxCreate = {
11791193
adminUser,
11801194
resource,
@@ -1291,6 +1305,14 @@ export default class AdminForthRestAPI implements IAdminForthRestAPI {
12911305
return { error: allowedError };
12921306
}
12931307

1308+
const primaryKeyColumn = resource.columns.find((col) => col.primaryKey);
1309+
if (record[primaryKeyColumn.name] !== undefined) {
1310+
const existingRecord = await this.adminforth.resource(resource.resourceId).get([Filters.EQ(primaryKeyColumn.name, record[primaryKeyColumn.name])]);
1311+
if (existingRecord) {
1312+
return { error: `Record with ${primaryKeyColumn.name} '${record[primaryKeyColumn.name]}' already exists`, ok: false };
1313+
}
1314+
}
1315+
12941316
const ctxEdit = {
12951317
adminUser,
12961318
resource,

adminforth/spa/src/App.vue

Lines changed: 68 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,10 +202,77 @@ const expandedWidth = computed(() => coreStore.config?.iconOnlySidebar?.expanded
202202
const theme = ref('light');
203203
204204
const userMenuComponents = computed(() => {
205-
console.log('🪲🆕 userMenuComponents recomputed', coreStore?.config?.globalInjections?.userMenu);
205+
console.log('🪲🆕 userMenuComponents recomputed', JSON.parse(JSON.stringify(coreStore?.config?.globalInjections?.userMenu)));
206206
return coreStore?.config?.globalInjections?.userMenu || [];
207207
})
208208
209+
watch(
210+
() => coreStore.config?.globalInjections?.userMenu,
211+
(newVal, oldVal) => {
212+
// Only log when it becomes undefined (you can relax this if needed)
213+
if (newVal === undefined) {
214+
const err = new Error('🔍 userMenu changed to undefined');
215+
console.groupCollapsed(
216+
'%c[TRACE] userMenu changed to undefined',
217+
'color: red; font-weight: bold;'
218+
);
219+
console.log('old value:', oldVal);
220+
console.log('new value:', newVal);
221+
console.log('coreStore.config.globalInjections:', coreStore.config?.globalInjections);
222+
console.log('Stack trace:');
223+
console.log(err.stack);
224+
console.groupEnd();
225+
} else {
226+
// Optional: log ALL changes for debugging
227+
console.groupCollapsed(
228+
'%c[DEBUG] userMenu changed',
229+
'color: orange; font-weight: bold;'
230+
);
231+
console.log('old value:', oldVal);
232+
console.log('new value:', newVal);
233+
console.log('coreStore.config.globalInjections:', coreStore.config?.globalInjections);
234+
console.groupEnd();
235+
}
236+
},
237+
{
238+
deep: false,
239+
immediate: false,
240+
}
241+
);
242+
243+
watch(() => coreStore.config?.globalInjections, (v) => {
244+
console.log("🔧 globalInjections replaced:", v);
245+
}, { deep: false });
246+
247+
watch(
248+
() => coreStore.config?.globalInjections?.userMenu,
249+
(newVal, oldVal) => {
250+
if (newVal === undefined) {
251+
const err = new Error('🔍 userMenu changed to undefined');
252+
console.groupCollapsed(
253+
'%c[TRACE] userMenu changed to undefined',
254+
'color: red; font-weight: bold;'
255+
);
256+
console.log('old value:', oldVal);
257+
console.log('new value:', newVal);
258+
console.log('coreStore.config.globalInjections:', coreStore.config?.globalInjections);
259+
console.log('Stack trace:');
260+
console.log(err.stack);
261+
console.groupEnd();
262+
} else {
263+
console.groupCollapsed(
264+
'%c[DEBUG] userMenu changed',
265+
'color: orange; font-weight: bold;'
266+
);
267+
console.log('old value:', oldVal);
268+
console.log('new value:', newVal);
269+
console.log('coreStore.config.globalInjections:', coreStore.config?.globalInjections);
270+
console.groupEnd();
271+
}
272+
},
273+
{ deep: false, immediate: false }
274+
);
275+
209276
function hideSidebar(): void {
210277
sideBarOpen.value = false;
211278
}

adminforth/spa/src/afcl/VerticalTabs.vue

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
<ul class="ps-6 flex-column space-y space-y-4 text-sm font-medium text-lightVerticalTabsText dark:text-darkVerticalTabsText md:me-4 mb-4 md:mb-0 md:mr-0 mr-6">
44
<li v-for="tab in tabs" :key="`${tab}-tab-controll`">
55
<a
6+
v-if="!props.hideTabesWhenSingle || tabs.length > 1"
67
href="#"
78
@click="setActiveTab(tab)"
89
class="inline-flex items-center px-4 py-3 rounded-lg w-full"
@@ -26,6 +27,10 @@ import { onMounted, useSlots, ref, type Ref } from 'vue';
2627
const props = defineProps({
2728
activeTab: {
2829
type: String
30+
},
31+
hideTabesWhenSingle: {
32+
type: Boolean,
33+
default: false
2934
}
3035
});
3136
const emites = defineEmits([

adminforth/spa/src/components/GroupsTable.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
@update:emptiness="customComponentsEmptiness[$event.name] = $event.value"
5656
:readonly="readonlyColumns?.includes(column.name)"
5757
/>
58-
<div v-if="columnError(column) && validating" class="mt-1 text-xs text-lightInputErrorColor dark:text-darkInputErrorColor">{{ columnError(column) }}</div>
58+
<div v-if="columnError(column) && validating" class="af-invalid-field-message mt-1 text-xs text-lightInputErrorColor dark:text-darkInputErrorColor">{{ columnError(column) }}</div>
5959
<div v-if="column.editingNote && column.editingNote[mode]" class="mt-1 text-xs text-lightFormFieldTextColor dark:text-darkFormFieldTextColor">{{ column.editingNote[mode] }}</div>
6060
</td>
6161
</tr>

adminforth/spa/src/components/ResourceForm.vue

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,4 +377,9 @@ watch(() => isValid.value, (value) => {
377377
emit('update:isValid', value);
378378
});
379379
380+
defineExpose({
381+
columnError,
382+
editableColumns,
383+
})
384+
380385
</script>

adminforth/spa/src/components/UserMenuSettingsButton.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<div class="min-w-40">
2+
<div v-if="options && options.length" class="min-w-40">
33
<div class="cursor-pointer flex items-center justify-between gap-1 block px-4 py-2 text-sm
44
bg-lightUserMenuItemBackground hover:bg-lightUserMenuItemBackgroundHover text-lightUserMenuItemText
55
hover:text-lightUserMenuItemText dark:bg-darkUserMenuItemBackground dark:hover:bg-darkUserMenuItemBackgroundHover
@@ -50,7 +50,7 @@ const showDropdown = ref(false);
5050
const props = defineProps(['meta', 'resource']);
5151
5252
const options = computed(() => {
53-
return coreStore.config?.settingPages?.map((page) => {
53+
return coreStore.config?.settingPages?.filter(page => page.isVisible).map((page) => {
5454
return {
5555
pageLabel: page.pageLabel,
5656
slug: page.slug || null,

adminforth/spa/src/stores/core.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ export const useCoreStore = defineStore('core', () => {
198198
path: '/get_public_config',
199199
method: 'GET',
200200
});
201+
console.log('📦 getPublicConfig', res);
201202
config.value = {...config.value, ...res};
202203
}
203204

@@ -206,6 +207,7 @@ export const useCoreStore = defineStore('core', () => {
206207
path: '/get_login_form_config',
207208
method: 'GET',
208209
});
210+
console.log('📦 getLoginFormConfig', res);
209211
config.value = {...config.value, ...res};
210212
}
211213

0 commit comments

Comments
 (0)