Module: nmodule/webEditors/rc/fe/baja/BaseEditor


new (require("nmodule/webEditors/rc/fe/baja/BaseEditor"))( [params])

Base class for all webEditors editors for Baja values. This editor
incorporates all the Widget sugar from BaseWidget and adds more
Baja-specific features on top. Most Niagara field editors should extend
from this class.

Extends:
Parameters:
Name Type Argument Description
params Object <optional>

Same parameters as
BaseWidget

Properties
Name Type Argument Description
facets baja.Facets | Object <optional>

(Deprecated - use properties)
facets to use to customize this editor instance. These facets will
typically come from the slot facets of a Baja value being loaded into this
BaseEditor. They will be converted into transient bajaux Properties and
will override any other specified Properties with the same name. This can
be either a Facets instance or an object literal.

Methods


<static> typeToClass(type)

Convert a BajaScript Type to a corresponding CSS class.

Parameters:
Name Type Description
type String | Type

spec

Returns:
Type
String
Example
expect(BaseEditor.typeToClass('baja:String')).toBe('type-baja-String');

destroy()

Removes all classes added during a call to #load. Emits a
destroyed tinyevent.

Overrides:
Returns:

call to module:bajaux/Widget#destroy

Type
Promise

getChildEditors( [params])

Same as getChildWidgets, but is limited to instances of BaseEditor.

Parameters:
Name Type Argument Description
params Object <optional>
Deprecated:
  • use `getChildWidgets` instead.

initialize(dom)

Every BaseWidget will add the editor class to the element and emit an
initialized tinyevent when initialized.

Parameters:
Name Type Description
dom JQuery
Inherited From:
Returns:

call to module:bajaux/Widget#initialize

Type
Promise

load(value [, params])

Every BaseEditor will apply a number of CSS classes to a DOM element
when a value is loaded into it:

  • editor
  • If the loaded value is a Baja value, a number of CSS classes
    corresponding to the value's Type and all superTypes. Classes will be
    determined using typeToClass().

It will also emit a loaded tinyevent.

Parameters:
Name Type Argument Description
value baja.Value | *
params Object <optional>
Returns:

call to module:bajaux/Widget#load

Type
Promise

setFacets(facets)

Convert the given Facets into hidden, transient bajaux Properties and
apply them to this editor. In most cases you'll want to use
properties().setValue() directly, but this method is useful when
applying Complex slot facets.

Parameters:
Name Type Description
facets baja.Facets | Object

(a baja.Facets instance or an object
literal to be converted to baja.Facets)


shouldValidate( [flag])

This provides an extra hook for an editor to declare itself as needing to
be validated before saving or not. The default behavior is to return true
if this editor is modified, or if a shouldValidate bajaux Property
is present and truthy. If neither of these conditions is true, it will
check all known child editors, and return true if it has a child editor
that should validate.

If flag is given, then the check against the shouldValidate
Property will return true only if the value bitwise matches the
parameter. See BaseWidget.SHOULD_VALIDATE_ON_SAVE, etc.

Parameters:
Name Type Argument Description
flag Number <optional>
Inherited From:
Returns:
Type
Boolean