summaryrefslogtreecommitdiffstats
path: root/aconf/model/init.lua
diff options
context:
space:
mode:
Diffstat (limited to 'aconf/model/init.lua')
-rw-r--r--aconf/model/init.lua55
1 files changed, 47 insertions, 8 deletions
diff --git a/aconf/model/init.lua b/aconf/model/init.lua
index aaf6ad0..02bbb83 100644
--- a/aconf/model/init.lua
+++ b/aconf/model/init.lua
@@ -18,9 +18,15 @@ M.Range = combination.Range
local fld = require('aconf.model.field')
local Field = fld.Field
+--- boolean field.
+-- @fclass Boolean
M.Boolean = fld.Boolean
+--- integer field.
+-- @fclass Integer
M.Integer = fld.Integer
M.Number = fld.Number
+--- string field.
+-- @fclass String
M.String = fld.String
local model = require('aconf.model.model')
@@ -203,14 +209,24 @@ function M.Reference:deleted(context, addr)
end
+--- model field. The value of this field is a [model
+-- object](#Model_objects) conforming to the specified model. A model
+-- field with default parameters is implicitly created when a model is
+-- used in lieu of a field.
+-- @fclass Model
+-- @param model (<i>[&lt;Model&gt;](#new)</i>) model describing the
+-- structure of the model objects
M.Model = fld.Model
--- collection field.
--- @fcons Collection
--- @param type (<i>[&lt;Field&gt;](#Field_constructors)</i> or
--- <i>[&lt;Model&gt;](#new)</i>) field constructor, field instance, or
--- model specifying the type of the members.
+-- @fclass Collection
+-- @param key (optional
+-- <i>[&lt;Field&gt;](#Overview_of_field_classes)</i>) primitive field
+-- class or instance used to validate the collection keys.
+-- @param type (<i>[&lt;Field&gt;](#Overview_of_field_classes)</i> or
+-- <i>[&lt;Model&gt;](#new)</i>) field class, field instance, or model
+-- specifying the type of the members.
-- @tparam ?string ui_member user-friendly noun for a member of this
-- collection
M.Collection = class(fld.TreeNode)
@@ -251,14 +267,14 @@ end
--- list field, inherits @{Collection}. The value of this field is an
-- instance of @{node.List}.
--- @fcons List
+-- @fclass List
M.List = class(M.Collection)
function M.List:init(params) super(self, M.List):init(params, node.List) end
--- set field, inherits @{Collection}. The value of this field is an
-- instance of @{node.Set}.
--- @fcons Set
+-- @fclass Set
M.Set = class(M.Collection)
function M.Set:init(params)
if not params.widget and isinstance(params.type, M.Reference) then
@@ -297,8 +313,9 @@ function M.defer(addr) def_store:defer(addr) end
--- Field constructor parameters. All field constructors accept one
-- table argument containing field parameters as key&ndash;value
--- pairs. The parameters listed below are valid for all
--- subclasses. Subclasses may define additional parameters.
+-- pairs. The parameters listed below are valid for all field
+-- classes. Depending on the class, there may be additional
+-- parameters.
-- @section Field
--- back-end address for the field. This can be an
@@ -339,9 +356,31 @@ function M.defer(addr) def_store:defer(addr) end
-- @field compute (optional <i><b>function(@{node.TreeNode})</b></i>
-- or <i>**string**</i>)
+--- indicates this field is relevant only when other fields of the
+-- model have specific values. The keys of the table define the
+-- condition fields, and the corresponding values define required
+-- field values. If a value is a table, the condition field can have
+-- any of the value given in the table for this field to be considered
+-- relevant.
+-- @field condition (optional <i>**{[string]=string**</i> or
+-- <i>**{string,...},...}**</i>)
+
--- default value for the field.
-- @tfield ?primitive default
+--- boolean or function specifying whether the value of the field can
+-- be changed. If defined as a function, the return value determines
+-- the behavior. The function gets a reference to the field's parent
+-- as an argument. If defined as a string, a method with the given
+-- name is invoked. When this parameter is not defined, the behavior
+-- depends on the other parameters as follows: If *visible* is set to
+-- false, the field is not editable. Otherwise, if *store* is defined
+-- or *compute* is not, the field is editable. Otherwise, if the
+-- *compute* function yields a value, the field is not
+-- editable. Otherwise, the field is editable.
+-- @field editable (optional <i>**boolean**</i>,
+-- <i><b>function(@{node.TreeNode})</b></i> or <i>**string**</i>)
+
--- required field must be assigned a value if set. Defaults to false.
-- @tfield ?boolean required