define("EventTargetDetailV2", ["ServiceHelper", "ProcessModuleUtilities", "EventTargetDetailV2Resources"],
function (ServiceHelper, ProcessModuleUtilities, resources) {
return {
entitySchemaName: "EventTarget",
messages: {},
attributes: {
"IsEditResponseButtonVisible": {
dataValueType: Terrasoft.DataValueType.BOOLEAN,
type: Terrasoft.ViewModelColumnType.VIRTUAL_COLUMN,
value: false
},
"EventResponseModalBox": {
dataValueType: Terrasoft.DataValueType.LOOKUP,
isLookup: true,
referenceSchemaName: "EventResponse"
},
"NrbEventResponseList": {
dataValueType: Terrasoft.DataValueType.COLLECTION,
value: Ext.create("Terrasoft.Collection")
}
},
details: /**SCHEMA_DETAILS*/{}/**SCHEMA_DETAILS*/,
diff: /**SCHEMA_DIFF*/[
{
"operation": "insert",
"parentName": "Detail",
"propertyName": "tools",
"name": "EditResponseButton",
"values": {
"itemType": Terrasoft.ViewItemType.BUTTON,
"caption": { "bindTo": "Resources.Strings.EditResponseButtonCaption" },
"click": { "bindTo": "onEditResponseButtonClick" },
"enabled": { "bindTo": "isAnySelected" },
"style": Terrasoft.controls.ButtonEnums.style.TRANSPARENT
}
}
]/**SCHEMA_DIFF*/,
methods: {
/*
* Обработчик нажатия на кнопку Изменения отклика.
*/
onEditResponseButtonClick: function () {
this.askUserResponseResultMessage(this.callMassiveChangeResponseEventProcess);
},
/*
* Вызывает Бизнес-процесс обновления отклика в мероприяиях.
*/
callMassiveChangeResponseEventProcess: function (resultValueId) {
let selectedItems = this.getSelectedItems();
if (!Ext.isEmpty(resultValueId) && !Ext.isEmpty(selectedItems)) {
let selectedItemsJson = JSON.stringify(selectedItems);
let args = {
sysProcessName: "NrbMassiveChangeResponseEvent",
parameters: {
NrbRecordsId: selectedItemsJson,
NrbEventResponseId: resultValueId
},
callback: function () {
this.hideBodyMask();
this.reloadGridData();
},
scope: this
};
ProcessModuleUtilities.executeProcess(args);
};
},
/*
* Показывает диалоговое окно для выбора нового отклика.
*/
askUserResponseResultMessage: function (callback) {
let controlConfig = {
EventResponse: {
dataValueType: Terrasoft.DataValueType.ENUM,
caption: this.get("Resources.Strings.EventResponseComboBoxCaption"),
value: { bindTo: "EventResponseModalBox" },
contentType: Terrasoft.ContentType.ENUM,
customConfig: {
list: { "bindTo": "NrbEventResponseList" },
},
}
};
let inputBoxCaption = this.get("Resources.Strings.EventResponseInputBoxCaption");
Terrasoft.utils.inputBox(inputBoxCaption,
function (buttonCode, controlData) {
let resultValueId = this.getLookupValue("EventResponseModalBox");
this.set("EventResponseModalBox", null);
if (buttonCode !== "ok") {
return;
}
if (Ext.isEmpty(resultValueId)) {
let errorMessage = this.get("Resources.Strings.EventResponseInputBoxErrorCaption");
this.showInformationDialog(errorMessage, function () {
this.askUserResponseResultMessage();
});
return;
}
Ext.callback(callback, this, [resultValueId]);
},
["ok", "cancel"],
this,
controlConfig,
{ defaultButton: 0 }
);
//Подписка биндингов в диалоговом окне (самое важное)
Terrasoft.MessageBox.controlArray.forEach(function (item) {
item.control.bind(this);
}, this);
},
}
};
});