Skip to content

Commit 3b5ed22

Browse files
committed
Merge remote-tracking branch 'refs/remotes/origin/main'
2 parents 8bfd908 + 2672b12 commit 3b5ed22

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+2328
-414
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ npm run install-plugins
8282
npm run install-adapters
8383

8484
npm ci
85+
86+
./run_inventory.sh
87+
8588
npm run migrate:local
8689
npm start
8790
```

adminforth/commands/createApp/templates/package.json.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,6 @@
3131
"@types/express": "latest",
3232
"@types/node": "latest",
3333
"@prisma/client": "latest",
34-
"prisma": "latest"
34+
"prisma": "^7.0.0"
3535
}
3636
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import 'dotenv/config'
2+
import { defineConfig, env } from 'prisma/config'
3+
4+
export default defineConfig({
5+
datasource: {
6+
url: env('PRISMA_DATABASE_URL'),
7+
},
8+
})

adminforth/commands/createApp/templates/schema.prisma.hbs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ generator client {
44

55
datasource db {
66
provider = "{{provider}}"
7-
url = env("PRISMA_DATABASE_URL")
87
}
98

109
model adminuser {

adminforth/commands/createApp/utils.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,11 @@ async function writeTemplateFiles(dirname, cwd, options) {
222222
data: { provider },
223223
condition: Boolean(prismaDbUrl), // only create if prismaDbUrl is truthy
224224
},
225+
{
226+
src: 'prisma.config.ts.hbs',
227+
dest: 'prisma.config.ts',
228+
data: {},
229+
},
225230
{
226231
src: 'package.json.hbs',
227232
dest: 'package.json',

adminforth/dataConnectors/baseConnector.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,13 +253,13 @@ export default class AdminForthBaseConnector implements IAdminForthDataSourceCon
253253
resource: AdminForthResource; record: any; adminUser: any;
254254
}): Promise<{ error?: string; ok: boolean; createdRecord?: any; }> {
255255
// transform value using setFieldValue and call createRecordOriginalValues
256-
256+
257257
const filledRecord = {...record};
258258
const recordWithOriginalValues = {...record};
259259

260260
for (const col of resource.dataSourceColumns) {
261261
if (col.fillOnCreate) {
262-
if (filledRecord[col.name] === undefined) {
262+
if (filledRecord[col.name] === undefined || (Array.isArray(filledRecord[col.name]) && filledRecord[col.name].length === 0)) {
263263
filledRecord[col.name] = col.fillOnCreate({
264264
initialRecord: record,
265265
adminUser

adminforth/documentation/docs/tutorial/03-Customization/01-branding.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,8 @@ const admin = new AdminForth({
141141
enabled: true, // Optional: Enable the collapsible icon-only sidebar feature
142142
//diff-add
143143
logo: '@@/logo.svg', // Optional: Custom logo to display in icon-only mode
144+
//diff-add
145+
expandedSidebarWidth: '18.5rem', // Optional: sets the expanded sidebar width, defaults to 16.5rem
144146
//diff-add
145147
},
146148
},

adminforth/documentation/docs/tutorial/03-Customization/04-hooks.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ For example we can prevent the user to see Apartments created by other users. Su
137137
}
138138

139139
// this function will skip existing realtor_id filter if it supplied already from UI or previous hook, and will add new one for realtor_id
140-
query.filterTools.replaceOrAddTopFilter(Filters.EQ('realtor_id', adminUser.dbUser.id).
140+
query.filterTools.replaceOrAddTopFilter(Filters.EQ('realtor_id', adminUser.dbUser.id)
141141

142142
return { ok: true };
143143
},

adminforth/documentation/docs/tutorial/03-Customization/07-alert.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ Next variants are supported:
2424
* `warning`
2525
* `info`
2626

27-
// ...existing code...
2827
### Making alert responsive
2928
You can pass buttons in the alert method and receive a response like:
3029

adminforth/documentation/docs/tutorial/03-Customization/08-pageInjections.md

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,79 @@ cd custom
396396
npm i @iconify-prerendered/vue-mdi
397397
```
398398
399+
## List table row replace injection
400+
401+
`tableRowReplace` lets you fully control how each list table row is rendered. Instead of the default table `<tr></tr>` markup, AdminForth will mount your Vue component per record and use its returned DOM to display the row. Use this when you need custom row layouts, extra controls, or conditional styling that goes beyond column-level customization.
402+
403+
Supported forms:
404+
- Single component: `pageInjections.list.tableRowReplace = '@@/MyRowRenderer.vue'`
405+
- Object form with meta: `pageInjections.list.tableRowReplace = { file: '@@/MyRowRenderer.vue', meta: { /* optional */ } }`
406+
- If an array is provided, the first element is used.
407+
408+
Example configuration:
409+
410+
```ts title="/resources/apartments.ts"
411+
{
412+
resourceId: 'aparts',
413+
...
414+
options: {
415+
pageInjections: {
416+
list: {
417+
tableRowReplace: {
418+
file: '@@/ApartRowRenderer.vue',
419+
meta: {
420+
// You can pass any meta your component may read
421+
}
422+
}
423+
}
424+
}
425+
}
426+
}
427+
```
428+
429+
Minimal component example (decorate default row with a border):
430+
431+
```vue title="/custom/ApartRowRenderer.vue"
432+
<template>
433+
<tr class="border border-gray-200 dark:border-gray-700 rounded-sm">
434+
<slot />
435+
</tr>
436+
437+
</template>
438+
439+
<script setup lang="ts">
440+
import { computed } from 'vue';
441+
const props = defineProps<{
442+
record: any
443+
resource: any
444+
meta: any
445+
adminUser: any
446+
}>();
447+
</script>
448+
```
449+
450+
Component contract:
451+
- Inputs
452+
- `record`: the current record object
453+
- `resource`: the resource config object
454+
- `meta`: the meta object passed in the injection config
455+
- Slots
456+
- Default slot: the table’s standard row content (cells) will be projected here. Your component can wrap or style it.
457+
- Output
458+
- Render a full `<tr></tr>` fragment. For example, to replace the standard set of cells with a single full‑width cell, render:
459+
460+
```vue
461+
<tr>
462+
<td :colspan="columnsCount">
463+
<slot />
464+
</td>
465+
</tr>
466+
```
467+
468+
Notes and tips:
469+
- Requirements:
470+
- Required `<tr></tr>` structure around `<slot />`
471+
399472
## List table beforeActionButtons
400473
401474
`beforeActionButtons` allows injecting one or more compact components into the header bar of the list page, directly to the left of the default action buttons (`Create`, `Filter`, bulk actions, three‑dots menu). Use it for small inputs (quick search, toggle, status chip) rather than large panels.

0 commit comments

Comments
 (0)