StackpressGitHub

API reference

Fieldset

Fieldset represents a reusable group of columns and attributes. Model extends this class, so fieldset behavior also applies to models.

Import

import { Fieldset } from 'stackpress/schema';

Instantiation

Use Fieldset.make(...) when building from Idea tokens. The constructor accepts already-built Attributes and Columns instances or arrays of Attribute and Column.

const fieldset = Fieldset.make('Address');
fieldset.addColumn('street', 'String');
fieldset.addAttribute('label', [ 'Address' ]);

This example creates a fieldset and adds one column plus one attribute. The methods return the fieldset, so they can also be chained.

Properties

PropertyTypeDescription
assertionFieldsetAssertionAssertion metadata helper.
attributesAttributesAttribute collection.
columnsColumnsColumn collection.
componentFieldsetComponentComponent metadata helper.
documentFieldsetDocumentDocumentation metadata helper.
nameFieldsetNameName formatting helper.
typeFieldsetTypeType metadata helper.
valueFieldsetValueValue metadata helper.
hasSchemabooleanWhether this fieldset is attached to a schema.
schemaSchemaParent schema. Throws if read before one is set.

Static Methods

Fieldset.make(name, attributes?, columns?, schema?)

Builds a fieldset from Idea-style tokens.

Returns a Fieldset.

Instance Methods

addAttribute(attribute)

Adds an existing Attribute object.

Returns the fieldset instance for chaining.

addAttribute(name, value)

Creates and adds an attribute.

ParameterTypeDescription
namestringAttribute name.
value`Data[] \boolean`Attribute args or boolean flag.

Returns the fieldset instance for chaining.

addColumn(column)

Adds an existing Column object.

Returns the fieldset instance for chaining.

addColumn(name, type, attributes?)

Creates and adds a column.

ParameterTypeDescription
namestringColumn name.
typeColumnTypeTokenIdea column type token.
attributesAttributesTokenOptional column attributes.

Returns the fieldset instance for chaining.

attribute(name)

Finds an attribute by name.

Returns an Attribute when found, otherwise undefined.

column(name, format?)

Finds a column by name. The optional format argument supports name formatting used by Stackpress schema helpers.

Returns a Column when found, otherwise undefined.