FormsUnit

flitter-forms/FormsUnit~ FormsUnit

Unit that loads form validator definitions and makes available flitter-forms' service helpers.


Constructor

new FormsUnit(base_directoryopt)

Instantiate the unit.

Parameters:
Name Type Attributes Default Description
base_directory string <optional>
'./app/forms'

the base directory to search for form definitions

Extends

Members

(static) name

Get the name of the service provided by this unit: 'forms'

(static) services

Defines the services required by this unit.

(private) _di_allow_defer :boolean

If true, the injector will defer the class if the class requests any services that the container is missing. These services are filled in later and added to the prototype and any instances. True by default.

Type:
  • boolean

(private) _di_deferred_instances :Array.<module:flitter-di/src/Injectable~Injectable>

Collection of instances of this class that need to have the deferred service instances injected into them when the deferred services are finally provided.

(private) _di_deferred_services :Array.<string>

List of services that were deferred and not provided at the time of injection.

Type:
  • Array.<string>

canonical_item :string

Name of the canonical item provided by this unit: 'form'

Type:
  • string

canonical_items :object

Mapping of canonical names to instances for this item.

Type:
  • object

directory :Promise.<void>|Promise.<string>

The root directory for this canonical resource's files.

Type:
  • Promise.<void> | Promise.<string>

suffix :string

File extension of the canonical item provided by this unit: '.form.js'

Type:
  • string

Methods

(async) cleanup(app) → {Promise.<void>}

Cleans up the unit's resources before Flitter closes.

Parameters:
Name Type Description
app module:libflitter/app/FlitterApp~FlitterApp

the Flitter app

Returns:
Type
Promise.<void>

(async) deploy() → {Promise.<void>}

Deploy the sample files provided by this unit. Creates the "app/validators" directory and an example validator schema.

Returns:
Type
Promise.<void>

directories() → {object}

Get the directories provided by this unit.

Returns:
Type
object

get(name) → {object}

Resolve an unqualified canonical name to a registered canonical item.

Parameters:
Name Type Description
name string
Returns:
Type
object

(async) go(app) → {Promise.<void>}

Initializes the unit. Loads the form validator definitions from the configured directory.

Parameters:
Name Type Description
app module:libflitter/app/FlitterApp~FlitterApp

the Flitter app

Returns:
Type
Promise.<void>

init(validator, request)

Initialize a form for the specified validator into the request's session.

Parameters:
Name Type Description
validator module:flitter-forms/Validator~Validator
request express/request

(async) init_canonical_file(info, instance) → {Promise.<module:flitter-forms/Validator~Validator>}

Init a single instance of the validator from the canonical info.

Parameters:
Name Type Description
info object
Properties
Name Type Description
app module:libflitter/app/FlitterApp~FlitterApp

the Flitter app

name string

the unqualified canonical name of the file

instance object

validator schema definition

name() → {String}

Get the name of the unit. Should be a lowercase, alphanum/dash/underscore string.

Returns:
Type
String

status(setopt) → {string}

Get or set the unit's current status.

Parameters:
Name Type Attributes Description
set string <optional>

if provided, set the status of the unit

Returns:
  • current status of the unit
Type
string

templates() → {Object}

Get the templates provided by this unit.

Returns:
Type
Object