mirror of
https://github.com/devcode-it/openstamanager.git
synced 2025-06-05 22:09:38 +02:00
feat: Migliorata gestione campi in RecordDialog
This commit is contained in:
@@ -6,7 +6,10 @@ import {
|
|||||||
VnodeCollection,
|
VnodeCollection,
|
||||||
VnodeCollectionItem
|
VnodeCollectionItem
|
||||||
} from '@osm/typings/jsx';
|
} from '@osm/typings/jsx';
|
||||||
import {isFormValid} from '@osm/utils/misc';
|
import {
|
||||||
|
isFormValid,
|
||||||
|
isVnode
|
||||||
|
} from '@osm/utils/misc';
|
||||||
import collect, {Collection} from 'collect.js';
|
import collect, {Collection} from 'collect.js';
|
||||||
import {
|
import {
|
||||||
Children,
|
Children,
|
||||||
@@ -69,17 +72,23 @@ export default abstract class AddEditRecordDialog<M extends Model<any, any>> ext
|
|||||||
formContents(): Children {
|
formContents(): Children {
|
||||||
return (
|
return (
|
||||||
<md-layout-grid>
|
<md-layout-grid>
|
||||||
{...this.fields().map((item, key: string) => {
|
{...this.formFields().values().all()}
|
||||||
// TODO: Remove this cast when new collection library is done
|
|
||||||
const field = item as Vnode<{name?: string, 'grid-span'?: number}>;
|
|
||||||
field.attrs.name ??= key;
|
|
||||||
field.attrs['grid-span'] ??= Math.floor(12 / this.numberOfColumns);
|
|
||||||
return item;
|
|
||||||
}).values().all()}
|
|
||||||
</md-layout-grid>
|
</md-layout-grid>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected formFields(): Collection<Children> {
|
||||||
|
return this.fields().map((field, key: string) => {
|
||||||
|
// TODO: Remove this cast when new collection library is done
|
||||||
|
if (isVnode<{name?: string, 'grid-span'?: number}>(field)) {
|
||||||
|
field.attrs.name ??= key;
|
||||||
|
field.attrs['grid-span'] ??= Math.floor(12 / this.numberOfColumns);
|
||||||
|
field.key = key;
|
||||||
|
}
|
||||||
|
return field;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
abstract fields(): Collection<Children>;
|
abstract fields(): Collection<Children>;
|
||||||
|
|
||||||
onCancelButtonClicked(): void {
|
onCancelButtonClicked(): void {
|
||||||
|
Reference in New Issue
Block a user