Вопрос
Где посмотреть реализацию сообщений между деталями через песочницу (sandbox)?
Ответ
Примеры реализации обмена сообщениями между деталями через sandbox:
1) AccountBillingInfoDetailV2:
define("AccountBillingInfoDetailV2", [], function() {
return {
entitySchemaName: "AccountBillingInfo",
details: /**SCHEMA_DETAILS*/{
}/**SCHEMA_DETAILS*/,
diff: /**SCHEMA_DIFF*/[
{
"operation": "merge",
"name": "DataGrid",
"values": {
"selectRow": {
"bindTo": "rowSelected"
}
}
}
]/**SCHEMA_DIFF*/,
methods: {
rowSelected: function() {
this.sandbox.publish("RowSelectedInFirstDetail", { test: "param anything" }, [this.sandbox.id]);
console.log("rowSelected in first detail...");
}
},
messages: {
"RowSelectedInFirstDetail": {
mode: Terrasoft.MessageMode.PTP,
direction: Terrasoft.MessageDirectionType.PUBLISH
}
}
};
});
2) AccountAddressDetailV2:
define("AccountAddressDetailV2", [], function() {
return {
entitySchemaName: "AccountAddress",
details: /**SCHEMA_DETAILS*/{
}/**SCHEMA_DETAILS*/,
diff: /**SCHEMA_DIFF*/[]/**SCHEMA_DIFF*/,
methods: {
init: function() {
this.sandbox.subscribe("RowSelectedInFirstDetail", function(arg) {
console.log("test " + arg.test);
}, this, [this.getSenderSandboxId()]);
},
getSenderSandboxId: function() {
return this.sandbox.id.replace("_AccountAddress", "_AccountBillingInfo");
}
},
messages: {
"RowSelectedInFirstDetail": {
mode: Terrasoft.MessageMode.PTP,
direction: Terrasoft.MessageDirectionType.SUBSCRIBE
}
}
};
});