Widget Definitions
class NGSWidget {
static get type() {
return "NGSWidget"
}
/* Html template that will generate before class gets created
All id's and css classes name will be suffixed by the uniqueId
provided during creation of the widget */
static get template() {}
/* Html template is used during design time of the form
If null the actual widget template will be rendered */
static get designTimeTemplate() {}
/* Html template is when form is shown to be printed */
static get printTemplate() {}
/* Inline css style that will be added to the page
note that style classes names will be scoped
to the widget unique id
*/
static get style() {}
/* Inline javascript code that will be added to
the page as long as the widget */
static get script() {}
static get selectionWidget() {
return true;
}
/* Does this widget support label, the label is the text a form
admin can enter using the form design and which will be displayed
before the widget template */
static get hasLabel() {
return true;
}
/* Displays the ngsurvey native error message box
under the control
*/
static get displayErrorMessage() {
return true;
}
/* Will prefix all CSS classes from the widget style
with a unique value to avoid conflicts if other components
have registered these classes under the same name.
Note that it wont parse external CSS dependencies.
0 : No encapsulation
1 : Shadow CSS - native ngSurvey prefix processor
*/
static get encapsulationMode() {
return 1;
}
/* Allows the answer to be set required or not
from the answer settings page to make
the widget answer required during survey
*/
static get required() {
return false;
}
/* Properties that can be set in from the form designer for each
answer using this widget as an answer type in the answer settings */
static get propertiesDef() {}
/* External javascript code dependencies that will be loaded
before the widget gets created */
static get jsDependencies() {}
/* External css code dependencies that will be loaded
before the widget gets created */
static get cssDependencies() {}
/*
setAnswer; // callback furnction to post a value from the widget eg: answerPosted(widgetAnswerValue)
valueChanges$; // Observable that returns the value of the widget
containerElement;
labelElement;
respondentAnswers = [];
uniqueId;
answerContext;
formContext;
sectionIndex;
properties;
initialValue;
label;
*/
/* containerElement : DOM element holding the template
labelElement: DOM element holding the label
answerContext: Answer context that provides helper methods to interact with the answer
formContext: Form context that provides helper methods to interact with the form
uniqueId: must be used to query as suffix the template element id's or css classes
properties : instance specific property values
setAnswer: function that will set the given text value of the widget setAnswer(textVal)
valueChanges: monitor any value changes of the widget
*/
constructor(containerElement, labelElement, answerContext, formContext,
sectionIndex, uniqueId, properties, setAnswerCallback, valueChanges$) {
}
/* Widget has been template has not yet been added to the DOM
but its properties have been already been set
*/
build() {}
/* Widget has been template has added to the DOM
and its properties have been set
*/
init() {}
/* Subscribe to the observable and keeps
a reference to automatically unsubscribe
it when the widget gets disposed
*/
safeSubscribe(obs, next, error, complete);
// Beta Not for production
remoteValidate();
// Beta Not for production
remoteValidateProd();
getValidationParam(name, value);
/*
returns the properties of the widget
in the callback
*/
getProperties$(propsCallback);
getLabel$(labelCallback);
getValue$(valueCallback);
isDisabled$(stateCallback);
isSelected$(selectionCallback);
getRenderMode$(renderModeCallback);
getLanguage$(languageCallback);
getRespondentAnswers$(respondentAnswersCallBack);
getAnswers$(answersCallBack);
getQuestions$(questionsCallBack);
/* Will be called by the form to see if the value is valid
If not valid must return '' (no error message shown) or the error message to show
If its valid return null */
isValid();
/* Returns the html element from the dom that has been generated
from the widget template will match the suffixed ids of the
widget template
*/
getWidgetElementById(id);
/*
Queryselector only on the container of the widget.
Adds the widget unique id to ids (#) to match to
the suffixed local ids of the widget template
*/
widgetQuerySelector(selector);
/*
QueryselectorAll only on the container of the widget.
Adds the widget unique id to ids (#) to match to
the suffixed local ids of the widget template
*/
widgetQuerySelectorAll(selector);
}
submitForm();
nextPage();
previousPage();
nextQuestion();
previousQuestion();
saveProgress(silent);
/* Cleans up all things that needs to be cleaned
up before the widget gets destroyed from the dom */
dispose() {}
_disposeSubscribers() {
if (this._subscribers) {
this._subscribers.forEach(subscriber => {
if (subscriber) {
subscriber.unsubscribe();
}
})
this._subscribers = [];
}
}
/* Hooks the widget events to keep their
state in sync */
_hookEvents() {}
/* Internal method should not be overriden */
_dispose() {}
/* _value;
_subscribers = [];*/
}
class NGSSelectionWidget extends NGSWidget {
static get type() {
return "NGSSelectionWidget"
}
/* containerElement : DOM element holding the template
labelElement: DOM element holding the label
answerContext: Answer context that provides helper methods to interact with the answer
formContext: Form context that provides helper methods to interact with the form
uniqueId: must be used to query as suffix the template element id's or css classes
selectionId: is the unique id of the group of selection
selectAnswerCallback: function that will be called when an answer must be selected from widget
selected$: observable that returns true / false when answer is selected or unselected
properties : instance specific property values
setAnswer: function that will set the given text value of the widget setAnswer(textVal) */
constructor(containerElement, labelElement, answerContext, formContext,
sectionIndex, uniqueId, selectionId, selected, selectedAnswerCallback,
selected$, properties, setAnswerCallback, valueChanges$) {
super(containerElement, labelElement, answerContext,
formContext, sectionIndex, uniqueId, properties, setAnswerCallback, valueChanges$)
}Last updated
Was this helpful?