block-obj-builder
Version:
Block object builder
56 lines (55 loc) • 1.8 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var helpers_1 = require("../../helpers/helpers");
var ChoiceBuilder = /** @class */ (function () {
function ChoiceBuilder(action, session, profile, functionArgs) {
this.action = action;
this.session = session;
this.profile = profile;
this.functionArgs = functionArgs;
this.obj = {};
this.obj = {
action: action
};
}
ChoiceBuilder.prototype.addTitle = function (lang, text) {
this.obj.title = this.obj.title || {};
this.obj.title[lang] = text;
return this;
};
ChoiceBuilder.prototype.setTitle = function (polylang) {
this.obj.title = polylang;
return this;
};
ChoiceBuilder.prototype.selectedTitle = function (text) {
this.obj.selectedTitle = text;
return this;
};
ChoiceBuilder.prototype.persistentMenu = function (isPersistentMenu) {
this.obj.persistentMenu = isPersistentMenu;
return this;
};
ChoiceBuilder.prototype.userStatus = function (userStatus) {
this.obj.userStatus = userStatus;
return this;
};
ChoiceBuilder.prototype.formField = function (formField) {
this.obj.formField = formField;
return this;
};
ChoiceBuilder.prototype.build = function () {
if (this.session) {
this.obj.session = this.session;
}
if (this.profile) {
this.obj.profile = this.profile;
}
if (this.functionArgs) {
this.obj.functionArgs = this.functionArgs;
}
// Clone here so we an use the same builder twice
return helpers_1.clone(this.obj);
};
return ChoiceBuilder;
}());
exports.default = ChoiceBuilder;