Skip to main content

dialog.state.method

DialogStateMethod : d2/sdk/controls/dialogs/generic/dialog.state.method

DialogStateMethod. Base class for implementing D2SV generic dialog state transition logic. All derived classes should override the asynchronous execute() method to actually implement the transition logic.

Also see DialogStateMethods

Extends: Marionette.Object
Example (A sample method implementation module that constructs state metadata by literal definition for a certain given state name)

import StateMethod from 'd2/sdk/controls/dialogs/generic/dialog.state.method';

class LiteralGetMethod extends StateMethod {
async execute(options, result) {
if(options.formName === 'MyFormName') {
result['page-content'] = {
dialog: {
id: 'user_dialog',
label: 'Name Form',
content: {
text: {
order: 1,
control: true,
id: 'full_name',
label: 'Full name',
value: 'John Doe'
}
},
buttons: {
button: [
{id: 'buttonOk', action: 'validDialog()', label: 'OK', order: 1}
]
}
}
};
return false; //So that no other succeeeding state method applies
}
return true;
}
}

export default LiteralGetMethod;

dialogStateMethod.execute(options, result) ⇒ Promise.<boolean>

Implement state transition logic for D2SV generic dialog

Kind: instance method of DialogStateMethod
Returns: Promise.<boolean> - Resolve with false to stop executing any other matching state methods that are supposed to execute after it.

ParamTypeDescription
optionsMethodMetadata

holder for various current state related metadata

resultOutputFormData

Output parameter, should be filled in with metadata pertaining to next possible state of the dialog.

DialogStateMethod~MethodMetadata : Object

Metadata related to current state of the dialog

Kind: inner typedef of DialogStateMethod
Properties

NameTypeDescription
methodstring

Name of the transition method which is getting applied

formNamestring

Form name of the current dialog state.

nodesNodeCollection

The object selection set on which this method is being applied.

actionParamsObject

If the dialog was invoked through a menu, all the parameters associated with the menu are collection in this part of options.

[formData]Object

Data collected from currently visible screen of the dialog.

DialogStateMethod~OutputFormData : Object

Type of form data to be populated by the state method. The overall structure should match response structure returned by D2-REST 'property-page' endpoint.

Kind: inner typedef of DialogStateMethod
Properties

NameTypeDescription
"page-content"Object

wrapper for the form data

["page-content".dialog]DialogMetadata

Actual form data

DialogStateMethod~DialogMetadata : Object

Metadata for a single screen in a dialog.

Kind: inner typedef of DialogStateMethod
Properties

NameTypeDescription
idstring

unique identifier of the form

labelstring

Displayable title of the form

[buttons]ButtonWrapper

Interaction buttons for the form

[content]*

Structure of the form.

DialogStateMethod~ButtonWrapper : Object

Wrapper for buttons

Kind: inner typedef of DialogStateMethod
Properties

NameTypeDescription
buttonArray.<ButtonMetadata>

collection of buttons

DialogStateMethod~ButtonMetadata : Object

Metadata definition of a button

Kind: inner typedef of DialogStateMethod
Properties

NameTypeDescription
idstring

Uniqueue identifier of the button

labelstring

Display text for the button

ordernumber

Sequential position of the button.

actionstring

The action this button represents

[isPrimary]boolean

Whether to visually indicate this button as primary button for the current form.