Question

Sandbox dependencies

Help with Sandbox, you need the button to be Enabled = false if it's a woman. How to make it so that the code is written correctly and the attribute in ContactPageV2 works



 

define("ContactSectionV2", [], function() {
	return {
		entitySchemaName: "Contact",
		messages: {
			"MessageOnPageClick": {
				mode: Terrasoft.MessageMode.PTP,
				direction: Terrasoft.MessageDirectionType.PUBLISH
			},
			"MessageIsButtonEnabledSubscribe": {
				mode: Terrasoft.MessageMode.BROADCAST,
				direction: Terrasoft.MessageDirectionType.PUBLISH
			},
		attributes: {
			"ButtonEnabled11": {
				"dataValueType": Terrasoft.DataValueType.BOOLEAN,
				"type": Terrasoft.ViewModelColumnType.VIRTUAL_COLUMN,
				dependencies: [
					{
						columns: ["ButtonEnabled"],
						methodName: "getButtonEnabled"
					}
				]
			}
		},
		},
		methods: {
			onEntityInitialized: function() {
				this.callParent(arguments);
				this.getButtonEnabled();
			},
			onSectionClick: function() {
				this.sandbox.publish("MessageOnPageClick", null, ["SectionModuleV2_ContactSectionV2"]);
			},
			getButtonEnabled: function() {
				this.set("ButtonEnabled11", this.sandbox.publish("MessageIsButtonEnabledSubscribe", null, ["SectionModuleV2_ContactSectionV2"]));
			},
		},
		diff: /**SCHEMA_DIFF*/[
			{
				"operation": "insert",
				"parentName": "CombinedModeActionButtonsCardLeftContainer",
				"propertyName": "items",
				"name": "NewButton",
				"values": {
					"itemType": Terrasoft.ViewItemType.BUTTON,
                    "caption": {bindTo: "Resources.Strings.NewButtonCaption"},
                    "classes": {"textClass": "actions-button-margin-right"},
					"click": {bindTo: "onSectionClick"},
					"style": Terrasoft.controls.ButtonEnums.style.RED,
					"enabled": {bindTo: "ButtonEnabled11"}
				}
			}
		]/**SCHEMA_DIFF*/
	};
});
 
define("ContactPageV2", [], function() {
	return {
		entitySchemaName: "Contact",
		attributes: {
			"ButtonEnabled": {
				"dataValueType": Terrasoft.DataValueType.BOOLEAN,
				"type": Terrasoft.ViewModelColumnType.VIRTUAL_COLUMN,
				dependencies: [
					{
						columns: ["Gender"],
						methodName: "setButtonEnabled"
					}
				]
			}
		},
		messages: {
			"MessageOnPageClick": {
				mode: Terrasoft.MessageMode.PTP,
				direction: Terrasoft.MessageDirectionType.SUBSCRIBE
			},
			"MessageIsButtonEnabledSubscribe": {
				mode: Terrasoft.MessageMode.BROADCAST,
				direction: Terrasoft.MessageDirectionType.SUBSCRIBE
			},
		},
		methods: {
			onEntityInitialized: function() {
				this.callParent(arguments);
				this.setButtonEnabled();
				this.sandbox.subscribe("MessageOnPageClick", function() {
					return this.onPageClick();
				}, this, ["SectionModuleV2_ContactSectionV2"]);
			},
			onPageClick: function() {
				this.showInformationDialog(";;;;;;");
			},
			setButtonEnabled: function() {
				var value;
				if (this.get("Gender") != null && this.get("Gender").value == "eeac42ee-65b6-df11-831a-001d60e938c6")  {
					value = true;
					this.set("ButtonEnabled", value);
					this.sandbox.subscribe("MessageIsButtonEnabledSubscribe", value, ["Answer"]);
				}
				else {
                    value = false;
					this.set("ButtonEnabled", value);
					this.sandbox.subscribe("MessageIsButtonEnabledSubscribe", value, ["Answer"]);
				}
			},		
		},
		diff: [{
			"operation": "insert",
			"parentName": "LeftContainer",
			"propertyName": "items",
			"name": "NewButton",
			"values": {
				"itemType": Terrasoft.ViewItemType.BUTTON,
				"caption": { bindTo: "Resources.Strings.CaptionButton" },
				"classes": { "textClass": "actions-button-margin-right" },
				"style": Terrasoft.controls.ButtonEnums.style.BLUE,
				"enabled": {bindTo: "ButtonEnabled"},
				"click": {bindTo: "ButtonEnabled"}
			}
		}] /**SCHEMA_DIFF*/
	};
});

 

Like 0

Like

1 comments

Hi Erlan,

 

Please clarify what exactly in the approach discussed here yesterday doesn't work. Why do you still need sandbox messages in this scenario?

Show all comments