Skip to content

Commit

Permalink
chore: refactor admin component
Browse files Browse the repository at this point in the history
  • Loading branch information
DavideIadeluca committed Oct 27, 2024
1 parent 3590a7b commit a5d5571
Showing 1 changed file with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
import Button from 'flarum/common/components/Button';
import FieldEdit from './FieldEdit';

import type { Vnode } from 'mithril';
import type Field from '../../lib/models/Field';

interface FieldListAttrs {
existing: Field[];
new: Field;
loading: boolean;
onUpdate: () => void;
}

export default class FieldList {
view(vnode) {
view(vnode: Vnode<FieldListAttrs>) {
const { existing, new: newField, loading, onUpdate } = vnode.attrs;

return m(
'form.js-sortable-fields',
existing.map((field) => {
existing.map((field: Field) => {
return m(FieldEdit, { field, loading, onUpdate });
}),
m(FieldEdit, { field: newField, loading, onUpdate })
Expand Down

0 comments on commit a5d5571

Please sign in to comment.