module:nmodule/webEditors/rc/wb/mgr/model/columns/MixinPropMgrColumn

module:nmodule/webEditors/rc/wb/mgr/model/columns/MixinPropMgrColumn

API Status: Development

MgrColumn that allows you to edit a property on a baja:IMixIn installed
on a component.

The property may also be several levels deep relative to the row's subject
component's mixin.

Constructor

new (require("nmodule/webEditors/rc/wb/mgr/model/columns/MixinPropMgrColumn"))(name, mixinType, path, paramsopt)

Source:
Extends:
Parameters:
Name Type Attributes Description
name string

column name (if omitted, one will be generated). This
was added in Niagara 4.13, but may be omitted (you may still use mixinType
as the first parameter).

mixinType Type

the BIMixIn Type whose property you wish to edit

path String | baja.Slot

the property or property path (as a
'/'-delimited string) you wish to edit.

params Object <optional>
Properties
Name Type Attributes Description
displayName String <optional>

the display name for the column;
if omitted, will use the slot display name from the Type

Throws:

if Type or prop are missing

Type
Error

Extends

Methods

buildCell(row, dom) → {Promise}

Description:
  • Creates the cell's contents by calling toString on the row's proposed value
    or the current value if there is no proposal. HTML will be safely escaped.

Source:
Overrides:
Parameters:
Name Type Description
row module:nmodule/webEditors/rc/wb/table/model/Row
dom JQuery
Returns:
Type
Promise

coalesceRows(rows) → {*}

Description:
  • Given the set of rows to be edited, coalesce their values into one single
    value to load into an editor.

    By default, this will simply read the proposed value from the first row.
    This is appropriate for a use case where one value will be entered and
    written back to all edited components.

    If editing one value for all the given rows is not a use case supported by
    your column (a good example is a Name column, because no two components can
    share the same name), throw an error.

Source:
Overrides:
Parameters:
Name Type Description
rows Array.<module:nmodule/webEditors/rc/wb/table/model/Row>
Throws:

if rows array not given, or values from rows are not all
of the same type

Type
Error
Returns:

value coalesced from the given rows

Type
*

commit(value, row, params) → {Promise}

Description:
  • Sets the value to the mixin instance on the row's component. If the
    component does not have an instance of the mixin, a new one will be
    created.

    This method may be safely overridden while maintaining the assurance that
    the mixin instance exists.

Source:
Overrides:
Parameters:
Name Type Description
value baja.Value
row module:nmodule/webEditors/rc/wb/table/model/Row
params Object
Returns:
Type
Promise

destroyCell(row, dom) → {Promise|*}

Description:
  • Called when the table is destroying the DOM element built for a cell in this column. This
    gives a Column implementation the chance to clean up any resources that might have been
    created during the earlier call to #buildCell, perhaps destroying a widget in the cell,
    for example. As with #buildCell, if this completes synchronously and doesn't return a
    Promise, the caller must wrap this in a call to Promise.resolve().

Source:
Overrides:
Parameters:
Name Type Description
row module:nmodule/webEditors/rc/wb/table/model/Row
dom JQuery
Returns:
Type
Promise | *

getColumnIcon() → {String}

Description:
  • Returns a URI for an icon representing this column. Returns null by
    default; override as needed in subclasses.

Source:
Overrides:
Returns:

a URI for an icon to be shown for this column.

Type
String

getComplexFromPath(row) → {baja.Complex}

Description:
  • Get the complex this property is on. Utilize the existing mixin instance or
    create a new instance of the mixIn if it does not exist yet.

Source:
Parameters:
Name Type Description
row module:nmodule/webEditors/rc/wb/table/model/Row
Returns:
Type
baja.Complex

getConfigFor(rows) → {Object}

Description:
  • After coalescing the selected rows into a single value, calculate a
    config object to be given to fe.makeFor that will determine how the
    editor will be built to edit that value.

    This function will typically not be called directly but serves as an
    override point. By default, it will simply get the coalesced value from
    those rows and have fe.makeFor build the default editor for that value.
    Note that this means if the coalesced value is a non-Baja value, like an
    array, this function must be overridden.

Source:
Overrides:
Parameters:
Name Type Description
rows Array.<module:nmodule/webEditors/rc/wb/table/model/Row>
Returns:

configuration object to be given to fe.makeFor

Type
Object

getFlags() → {Number}

Description:
  • Get the flags set on this column.

Source:
Overrides:
Returns:
Type
Number

getMixinContainer(row) → {baja.Complex}

Description:
  • Get the container where the mixin is located or will be located once it is added.

Source:
Since:
  • Niagara 4.13
Parameters:
Name Type Description
row module:nmodule/webEditors/rc/wb/table/model/Row
Returns:
Type
baja.Complex

getMixinInstance(row) → {baja.Value|null}

Description:
  • Get the existing mixin instance that already belongs to the component
    loaded into the row. If called from commit(), the instance is
    guaranteed to have been added if it did not already exist.

Source:
Parameters:
Name Type Description
row module:nmodule/webEditors/rc/wb/table/model/Row
Returns:
Type
baja.Value | null

getName() → {String}

Description:
  • Get the column name or null if none was given.

Source:
Overrides:
Returns:
Type
String

getProposedValueFor(row) → {*}

Description:
  • Get the currently proposed value for the given row. If no value proposed
    yet, will return the actual column value (getValueFor).

Source:
Overrides:
Parameters:
Name Type Description
row module:nmodule/webEditors/rc/wb/table/model/Row
Returns:
Type
*

getValueFor(row) → {baja.Value}

Description:
  • Get the property from the mixin instance on this row's component. If
    the component does not have an instance of that mixin (e.g. it is an
    unmounted component created browser-side), the default value from an
    instance of that mixin will be returned.

Source:
Overrides:
Parameters:
Name Type Description
row module:nmodule/webEditors/rc/wb/table/model/Row
Returns:
Type
baja.Value

hasFlags(flags) → {Boolean}

Description:
  • Return true if the column has all of the given flags.

Source:
Overrides:
Parameters:
Name Type Description
flags Number

flags to check for

Returns:
Type
Boolean

isEditable() → {Boolean}

Description:
  • Return true if the column is editable.

Source:
Overrides:
Returns:
Type
Boolean

isEditorSuitable(editor, rows) → {Boolean}

Description:
  • If an editor has already been built, it may be possible to reuse it,
    simply loading in a new coalesced value rather than destroying and
    rebuilding the existing editor.

    This function should return true if the editor is suitable to be reused
    for the given rows. By default, will always return true.

Source:
Overrides:
Parameters:
Name Type Description
editor module:nmodule/webEditors/rc/fe/baja/BaseEditor
rows Array.<module:nmodule/webEditors/rc/wb/table/model/Row>
Returns:
Type
Boolean

isExportable() → {Boolean}

Description:
  • Return true if the column should show up in export operations, e.g. to CSV.

Source:
Since:
  • Niagara 4.8
Overrides:
Returns:
Type
Boolean

isHidable() → {Boolean}

Description:
  • Return true if the column should available in the table's show/hide context menu.
    Defaults to true.

Source:
Overrides:
Returns:
Type
Boolean

isReadonly() → {Boolean}

Description:
  • Return true if the column is readonly.

Source:
Overrides:
Returns:
Type
Boolean

isSortable() → {Boolean}

Description:
  • Returns a boolean indicating whether the column should not be sortable via the table headings.
    Defaults to true.

Source:
Overrides:
Returns:
Type
Boolean

isUnseen() → {Boolean}

Description:
  • Return true if the column is unseen.

Source:
Overrides:
Returns:
Type
Boolean

mgrValidate(model, data, paramsopt) → {Promise}

Description:
  • Allows this column to validate proposed changes.

Source:
Overrides:
Example

Validating this column may require that I examine the changes I'm about to make to other columns as well.

MyMgrColumn.prototype.mgrValidate = function (model, data, params) {
  var that = this,
      rows = model.getRows(),
      otherColumn = model.getColumn('otherColumn');

  //search through all MgrModel rows, and check to see that my proposed
  //change is compatible with the proposed change to another column.
  //say, i'm a "password" column, and the other column is a "password
  //scheme" column - i need to make sure that the proposed password is
  //considered valid by the proposed password scheme.

  for (var i = 0; i < rows.length; i++) {
    var row = rows[i],
        myValue = data[i],
        otherValue = otherColumn.getProposedValueFor(row);

    if (myValue === null) {
      //no changes proposed for this row, so nothing to validate.
    }

    if (!isCompatible(myValue, otherValue)) {
      return Promise.reject(new Error('incompatible values'));
    }
  }
};
Parameters:
Name Type Attributes Description
model module:nmodule/webEditors/rc/wb/mgr/model/MgrModel

the model to which we're about to apply changes.

data Array

an array of proposed changes to this column, one per
row in the MgrModel. If a value in this array is null, no change has
been proposed for that row.

params Object <optional>
Properties
Name Type Attributes Description
editor module:nmodule/webEditors/rc/fe/baja/BaseEditor <optional>

the editor from which the proposed values were read. Note that the editor
may have been used to edit other rows, so the editor's current value may
not match the proposed new values.

Returns:

promise that resolves by default

Type
Promise

propose(value, row) → {Promise}

Description:
  • Should read the value and "tentatively" apply it to the
    selected row. In most cases this will be setting some temporary data
    for display-only purposes.

    By default, will set some temporary data on the row using the column's
    name as a key.

Source:
Overrides:
Parameters:
Name Type Description
value *
row module:nmodule/webEditors/rc/wb/table/model/Row
Returns:
Type
Promise

setEditable(editable)

Description:
  • Set or unset the column's EDITABLE flag. Emits a flagsChanged event.

Source:
Overrides:
Parameters:
Name Type Description
editable boolean

setExportable(exportable)

Description:
  • Set or unset whether the column should show up in export operations.

Source:
Since:
  • Niagara 4.8
Overrides:
Parameters:
Name Type Description
exportable boolean

setFlags(flags)

Description:
  • Set the column's flags.

Source:
Overrides:
Parameters:
Name Type Description
flags Number
Throws:

if a non-Number given

Type
Error

setHidable(hidable)

Description:
  • Set or unset whether the column should be allowed to be hidden or shown by the table's
    show/hide context menu.

Source:
Overrides:
Parameters:
Name Type Description
hidable boolean

setReadonly(readonly)

Description:
  • Set or unset the column's READONLY flag. Emits a flagsChanged event.

Source:
Overrides:
Parameters:
Name Type Description
readonly boolean

setSortable(sortable)

Description:
  • Set or unset whether the column should be allowed to be sorted by the table heading.

Source:
Overrides:
Parameters:
Name Type Description
sortable boolean

setUnseen(unseen)

Description:
  • Set or unset the column's UNSEEN flag. Emits a flagsChanged event.

Source:
Overrides:
Parameters:
Name Type Description
unseen boolean

toDisplayName() → {Promise|*}

Description:
  • Resolves a display name for this column.

Source:
Overrides:
Returns:

promise to be resolved when the element's display name
has been fully built. It's also acceptable for overrides of this function
to complete synchronously without returning a promise, so be sure to wrap
calls to this function in Promise.resolve() when appropriate.

Type
Promise | *