Skip to content

Commit dea0e12

Browse files
committed
docs: various tutorial fixes
1 parent 2157cf7 commit dea0e12

File tree

6 files changed

+23
-17
lines changed

6 files changed

+23
-17
lines changed

adminforth/documentation/docs/tutorial/001-gettingStarted.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ export default {
207207
{
208208
name: 'title',
209209
required: true,
210-
showIn: { all: false }, // all available options
210+
showIn: { all: true }, // all available options
211211
type: AdminForthDataTypes.STRING,
212212
maxLength: 255, // you can set max length for string fields
213213
minLength: 3, // you can set min length for string fields

adminforth/documentation/docs/tutorial/03-Customization/02-customFieldRendering.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,11 +216,13 @@ Now you can use this component in the configuration of the resource:
216216
...
217217
{
218218
name: 'country',
219+
//diff-add
219220
components: {
220221
//diff-add
221222
edit: '@@/CountryDropdown.vue',
222223
//diff-add
223224
create: '@@/CountryDropdown.vue',
225+
//diff-add
224226
},
225227
...
226228
},
@@ -236,7 +238,7 @@ Custom componets can emit `update:inValidity` event to parent to say that the fi
236238
237239
You can define this emit as:
238240
239-
```ts
241+
```ts title='./custom/<AnyYourComponent>.vue'
240242
const emit = defineEmits([
241243
"update:value",
242244
//diff-add

adminforth/documentation/docs/tutorial/03-Customization/03-virtualColumns.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ For doing this you can use `virtual` columns.
88

99
```ts title='./resources/apartments.ts'
1010

11+
//diff-add
12+
import { AdminForthResourcePages } from 'adminforth';
13+
1114
...
1215
resourceId: 'aparts',
1316
columns: [
@@ -109,18 +112,18 @@ columns: [
109112
Now to handle virtual `password` field we use hooks:
110113
111114
112-
```ts title="./index.ts"
115+
```ts title="./resources/adminuser.ts"
113116
hooks: {
114117
create: {
115118
beforeSave: async ({ record, adminUser, resource }: { record: any, adminUser: AdminUser, resource: AdminForthResource }) => {
116-
record.passwordHash = await AdminForth.Utils.generatePasswordHash(record.password);
119+
record.password_hash = await AdminForth.Utils.generatePasswordHash(record.password);
117120
return { ok: true };
118121
}
119122
},
120123
edit: {
121124
beforeSave: async ({ updates, adminUser, resource }: { updates: any, adminUser: AdminUser, resource: AdminForthResource }) => {
122125
if (updates.password) {
123-
updates.passwordHash = await AdminForth.Utils.generatePasswordHash(updates.password);
126+
updates.password_hash = await AdminForth.Utils.generatePasswordHash(updates.password);
124127
}
125128
return { ok: true }
126129
},

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,11 @@ import type { AdminUser } from 'adminforth';
9696
//diff-add
9797
create: {
9898
//diff-add
99-
beforeSave: async ({ adminUser, record }: { adminUser: AdminUser, updates: any }) => {
99+
beforeSave: async ({ adminUser, updates }: { adminUser: AdminUser, updates: any }) => {
100100
//diff-add
101101
updates.realtor_id = adminUser.dbUser.id;
102102
//diff-add
103-
return { ok: true, record };
103+
return { ok: true };
104104
//diff-add
105105
}
106106
//diff-add

adminforth/documentation/docs/tutorial/03-Customization/06-customPages.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ app.get(`${ADMIN_BASE_URL}/api/dashboard/`,
312312
admin.express.authorize(
313313
async (req, res) => {
314314
const days = req.body.days || 7;
315-
const apartsByDays = await db.prepare(
315+
const apartsByDays = await admin.resource('aparts').client.prepare(
316316
`SELECT
317317
strftime('%Y-%m-%d', created_at) as day,
318318
COUNT(*) as count
@@ -326,7 +326,7 @@ app.get(`${ADMIN_BASE_URL}/api/dashboard/`,
326326
const totalAparts = apartsByDays.reduce((acc: number, { count }: { count:number }) => acc + count, 0);
327327
328328
// add listed, unlisted, listedPrice, unlistedPrice
329-
const listedVsUnlistedByDays = await db.prepare(
329+
const listedVsUnlistedByDays = await admin.resource('aparts').client.prepare(
330330
`SELECT
331331
strftime('%Y-%m-%d', created_at) as day,
332332
SUM(listed) as listed,
@@ -340,7 +340,7 @@ app.get(`${ADMIN_BASE_URL}/api/dashboard/`,
340340
`
341341
).all(days);
342342
343-
const apartsCountsByRooms = await db.prepare(
343+
const apartsCountsByRooms = await admin.resource('aparts').client.prepare(
344344
`SELECT
345345
number_of_rooms,
346346
COUNT(*) as count
@@ -350,7 +350,7 @@ app.get(`${ADMIN_BASE_URL}/api/dashboard/`,
350350
`
351351
).all();
352352
353-
const topCountries = await db.prepare(
353+
const topCountries = await admin.resource('aparts').client.prepare(
354354
`SELECT
355355
country,
356356
COUNT(*) as count
@@ -361,14 +361,14 @@ app.get(`${ADMIN_BASE_URL}/api/dashboard/`,
361361
`
362362
).all();
363363
364-
const totalSquare = await db.prepare(
364+
const totalSquare = await admin.resource('aparts').client.prepare(
365365
`SELECT
366366
SUM(square_meter) as totalSquare
367367
FROM apartments;
368368
`
369369
).get();
370370
371-
const listedVsUnlistedPriceByDays = await db.prepare(
371+
const listedVsUnlistedPriceByDays = await admin.resource('aparts').client.prepare(
372372
`SELECT
373373
strftime('%Y-%m-%d', created_at) as day,
374374
SUM(listed * price) as listedPrice,

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,20 +36,20 @@ const isConfirmed = await adminforth.confirm({message: 'Are you sure?', yes: 'Ye
3636

3737
## Ussage example
3838

39-
Create a Vue component in the custom directory of your project, e.g. Alerts.vue:
39+
Create a Vue component in the custom directory of your project, e.g. `Alerts.vue`:
4040

4141
```html title="./custom/Alerts.vue"
4242
<template>
4343
<div class="ml-3 mt-16">
44-
<Button @click="successAlert($t('Example success alert'))" >
44+
<Button @click="successAlert($t('Example success alert'))" class="bg-green-700 hover:bg-green-800 focus:ring-green-300 dark:bg-green-600 dark:hover:bg-green-700 dark:focus:ring-green-800" >
4545
{{$t('Call success alert')}}
4646
</Button>
4747

48-
<Button @click="warningAlert($t('Example danger alert'))" >
48+
<Button @click="warningAlert($t('Example danger alert'))" class="bg-orange-500 hover:bg-orange-400 focus:ring-orange-100 dark:bg-orange-600 dark:hover:bg-orange-700 dark:focus:ring-orange-900" >
4949
{{$t('Call warning alert')}}
5050
</Button>
5151

52-
<Button @click="doConfirm" >
52+
<Button @click="doConfirm" class="bg-red-700 hover:bg-red-800 focus:ring-red-300 dark:bg-red-600 dark:hover:bg-red-700 dark:focus:ring-red-900" >
5353
{{$t('Call confirm dialog')}}
5454
</Button>
5555
</div>
@@ -97,6 +97,7 @@ menu: [
9797
//diff-add
9898
}
9999
```
100+
100101
Here is how alert looks:
101102
![alt text](image-12.png)
102103

0 commit comments

Comments
 (0)