Skip to content

Commit eae865c

Browse files
committed
Merge branch 'next' of github.com:devforth/adminforth into next
2 parents e65aa5d + a5a24ad commit eae865c

File tree

8 files changed

+70
-2
lines changed

8 files changed

+70
-2
lines changed

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/documentation/docs/tutorial/07-Plugins/17-bulk-ai-flow.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,3 +332,53 @@ If you want to compare a generated image with an image stored in your storage, y
332332
After generation, you’ll see a button labeled "old image". Clicking it will open a pop-up where you can compare the generated image with the stored one:
333333
334334
![alt text](Bulk-vision-4.png)
335+
336+
## Extra data fields
337+
338+
When creating default prompts, you can use Handlebars to pass data from the record into the prompt:
339+
340+
```ts
341+
...
342+
fillPlainFields: {
343+
description: 'Create a description based on the apartment name: {{title}}.'
344+
},
345+
...
346+
```
347+
348+
Each record will receive a unique prompt based on its own title.
349+
350+
If you want to add extra data fields for use in your prompt, implement the `provideAdditionalContextForRecord` callback:
351+
352+
```ts
353+
provideAdditionalContextForRecord({ record, adminUser, resource }) {
354+
const extraData: any = {};
355+
if (record.country === 'Spain') {
356+
// Your logic
357+
// e.g. extraData.discount = '10%';
358+
} else {
359+
// Your logic
360+
}
361+
return extraData;
362+
},
363+
fillPlainFields: {
364+
description: 'Create a description based on the apartment name: {{title}}. Also include the fact that the apartment has a discount of {{extraData.discount}}.'
365+
},
366+
```
367+
368+
## Allow users to edit generation prompts
369+
370+
If you want to let users adjust generation prompts for their unique cases, add this to the plugin setup:
371+
372+
```ts
373+
...
374+
//diff-add
375+
askConfirmationBeforeGenerating: true,
376+
...
377+
```
378+
379+
The user will now see a popup with a "Start generation" button and an "Edit prompts" button, allowing them to modify the prompt before running it.
380+
381+
![alt text](Bulk-vision-5.png)
382+
![alt text](Bulk-vision-6.png)
383+
384+
> ☝️ Updated prompts are stored in the user's local storage. Changes are local to that browser and do not affect other users or devices.
66.9 KB
Loading
133 KB
Loading

adminforth/spa/src/afcl/Table.vue

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
'afcl-table-body odd:bg-lightTableOddBackground odd:dark:bg-darkTableOddBackground even:bg-lightTableEvenBackground even:dark:bg-darkTableEvenBackground': evenHighlights,
5858
'border-b border-lightTableBorder dark:border-darkTableBorder': index !== dataPage.length - 1 || totalPages > 1,
5959
}"
60+
@click="tableRowClick(item)"
6061
>
6162
<td class="px-6 py-4" :key="`cell-${index}-${column.fieldName}`"
6263
v-for="column in props.columns"
@@ -242,6 +243,7 @@
242243
'update:sortField',
243244
'update:sortDirection',
244245
'sort-change',
246+
'clickTableRow'
245247
]);
246248
247249
function onPageInput(event: any) {
@@ -349,4 +351,8 @@ function sortArrayData(data:any[], sortField?:string, dir:'asc'|'desc'='asc') {
349351
return dir === 'asc' ? cmp : -cmp;
350352
});
351353
}
354+
355+
function tableRowClick(row) {
356+
emit("clickTableRow", row)
357+
}
352358
</script>

0 commit comments

Comments
 (0)