|
@@ -1,37 +1,55 @@
|
|
|
-/*
|
|
|
-
|
|
|
-Dynaform Service, exposing 8 public methods
|
|
|
-===========================================
|
|
|
-
|
|
|
-build(model, meta) - takes a model and (lazy)metadata and returns an object { form: FormGroup, meta: ModeledMetaData }
|
|
|
-autoBuildFormGroupAndMeta(model, meta) - synonym for build
|
|
|
-autoBuildModeledMeta(model, meta) - takes a model and (lazy)metadata and returns expanded metadata
|
|
|
-
|
|
|
-buildFormGroup(metadata) - builds FormGroups from modelled metdata, recursively if necessary
|
|
|
-buildFieldSpecificMeta(metadata) - use field metadta models to fill out metadata
|
|
|
-combineModelWithMeta(model, extraMeta) - automatically generated metadata for model then combines extra metadata
|
|
|
-combineExtraMeta(metadata, extraMeta) - combine extra metadata into metatdata, lazyly and recursively
|
|
|
-autoMeta(model) - generate basic metadata from a raw or mapped model, recursively if necessary
|
|
|
-
|
|
|
-
|
|
|
-NOTES
|
|
|
------
|
|
|
-This class acts as an injectable wraper around the exports of meta-utils.ts,
|
|
|
-as well as creating a buildFormGroup function using the injected FormBuilder singleton
|
|
|
-
|
|
|
-
|
|
|
-USAGE
|
|
|
------
|
|
|
-
|
|
|
-TO ADD ...
|
|
|
-
|
|
|
-
|
|
|
-EXAMPLES
|
|
|
---------
|
|
|
-
|
|
|
-TO ADD ...
|
|
|
-
|
|
|
-*/
|
|
|
+/* ***************************************************************************************************************************************
|
|
|
+ * Dynaform Service, exposing 8 public methods
|
|
|
+ * ***************************************************************************************************************************************
|
|
|
+ *
|
|
|
+ * build(model, meta = {}, createFromMeta = false)
|
|
|
+ *
|
|
|
+ * Takes a model and (lazy)metadata and returns an object containing a FormGroup and Modeled MetaData :
|
|
|
+ * {
|
|
|
+ * form: FormGroup,
|
|
|
+ * meta: ModeledMetaData
|
|
|
+ * }
|
|
|
+ *
|
|
|
+ * meta is optional, and if not supplied all the model fields will become Text inputs in the FormGroup,
|
|
|
+ * with their labels set to the un-camel-cased property name
|
|
|
+ *
|
|
|
+ * createFromMeta is optional. If true it will create new fields in the FormGroup when they don't already exist in the model.
|
|
|
+ * If defaults to false, except when a completly empty model {} is supplied.
|
|
|
+ *
|
|
|
+ * USAGE
|
|
|
+ * -----
|
|
|
+ *
|
|
|
+ * build(model)
|
|
|
+ * build({}, meta)
|
|
|
+ * build(model, meta)
|
|
|
+ * build(model, meta, true)
|
|
|
+ *
|
|
|
+ *
|
|
|
+ * LOWER-LEVEL METHODS
|
|
|
+ * -------------------
|
|
|
+ *
|
|
|
+ * autoBuildFormGroupAndMeta(model, meta, createFromMeta) - synonym for build
|
|
|
+ * autoBuildModeledMeta(model, meta, createFromMeta) - takes a model and (lazy)metadata and returns expanded metadata
|
|
|
+ *
|
|
|
+ * buildFormGroup(metadata) - builds FormGroups from modelled metdata, recursively if necessary
|
|
|
+ * buildFieldSpecificMeta(metadata) - use field metadta models to fill out metadata
|
|
|
+ * combineModelWithMeta(model, extraMeta) - automatically generated metadata for model then combines extra metadata
|
|
|
+ * combineExtraMeta(metadata, extraMeta) - combine extra metadata into metatdata, lazyly and recursively
|
|
|
+ * autoMeta(model) - generate basic metadata from a raw or mapped model, recursively if necessary
|
|
|
+ *
|
|
|
+ *
|
|
|
+ * NOTES
|
|
|
+ * -----
|
|
|
+ * This class acts as an injectable wraper around the exports of meta-utils.ts,
|
|
|
+ * as well as creating a buildFormGroup function using the injected FormBuilder singleton
|
|
|
+ *
|
|
|
+ *
|
|
|
+ * EXAMPLES
|
|
|
+ * --------
|
|
|
+ *
|
|
|
+ * TO ADD ...
|
|
|
+ *
|
|
|
+ */
|
|
|
|
|
|
import { Injectable } from '@angular/core';
|
|
|
import { FormBuilder, FormGroup } from '@angular/forms';
|