Skip to content

Commit d519d3f

Browse files
committed
fix: changes object from col to inCol for editingNote in configValidator, add documentation for editingNote
1 parent b16b7ae commit d519d3f

File tree

2 files changed

+26
-4
lines changed

2 files changed

+26
-4
lines changed

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,25 @@ export default {
370370

371371
> `validation` checks are enforced both on frontend and backend.
372372
373+
### Editing note
374+
375+
You can add `editingNote` to a column to show a note below the input field.
376+
377+
```typescript title="./resources/users.ts"
378+
export default {
379+
name: 'users',
380+
columns: [
381+
...
382+
{
383+
name: "password",
384+
editingNote: { edit: "Leave empty to keep password unchanged" },
385+
},
386+
],
387+
},
388+
...
389+
],
390+
```
391+
373392
### Foreign resources
374393

375394
[Documentation in progress]

adminforth/modules/configValidator.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -352,17 +352,20 @@ export default class ConfigValidator implements IConfigValidator {
352352
// force required to be object
353353
col.required = typeof inCol.required === 'boolean' ? { create: inCol.required, edit: inCol.required } : inCol.required;
354354

355+
355356
// same for editingNote
356-
if (col.editingNote && !((typeof col.editingNote === 'string') || (typeof col.editingNote === 'object'))) {
357+
if (inCol.editingNote && !((typeof inCol.editingNote === 'string') || (typeof inCol.editingNote === 'object'))) {
357358
errors.push(`Resource "${res.resourceId}" column "${col.name}" editingNote must be a string or object`);
358359
}
359-
if (typeof col.editingNote === 'object') {
360-
const wrongEditingNoteOn = Object.keys(col.editingNote).find((c) => !['create', 'edit'].includes(c));
360+
if (typeof inCol.editingNote === 'object') {
361+
const wrongEditingNoteOn = Object.keys(inCol.editingNote).find((c) => !['create', 'edit'].includes(c));
361362
if (wrongEditingNoteOn) {
362-
errors.push(`Resource "${res.resourceId}" column "${col.name}" has invalid editingNote value "${wrongEditingNoteOn}", allowed keys are 'create', 'edit']`);
363+
errors.push(`Resource "${res.resourceId}" column "${inCol.name}" has invalid editingNote value "${wrongEditingNoteOn}", allowed keys are 'create', 'edit']`);
363364
}
364365
}
365366

367+
col.editingNote = typeof inCol.editingNote === 'string' ? { create: inCol.editingNote, edit: inCol.editingNote } : inCol.editingNote;
368+
366369
const wrongShowIn = col.showIn && col.showIn.find((c) => AdminForthResourcePages[c] === undefined);
367370
if (wrongShowIn) {
368371
errors.push(`Resource "${res.resourceId}" column "${col.name}" has invalid showIn value "${wrongShowIn}", allowed values are ${Object.keys(AdminForthResourcePages).join(', ')}`);

0 commit comments

Comments
 (0)