Built files from Bizgaze WebServer
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

actions.propertychange.js 37KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443
  1. var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
  2. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  3. return new (P || (P = Promise))(function (resolve, reject) {
  4. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  5. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  6. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  7. step((generator = generator.apply(thisArg, _arguments || [])).next());
  8. });
  9. };
  10. var Unibase;
  11. (function (Unibase) {
  12. let Platform;
  13. (function (Platform) {
  14. let Automation;
  15. (function (Automation) {
  16. let Components;
  17. (function (Components) {
  18. class PropertyChange extends Platform.Core.BaseComponent {
  19. constructor() {
  20. super(...arguments);
  21. this.RowIndex = 0;
  22. this.RuleProviderId = 0;
  23. this.AutomationMode = 0;
  24. }
  25. jsFiles() {
  26. var jsfiles = ["platform/automation/managers/rulemanager.js",
  27. "platform/automation/enums/automationmode.js",
  28. "platform/automation/components/conditions.js",
  29. "platform/automation/components/contactselection.js",
  30. "platform/automation/requests/ruleaction.js",
  31. "platform/automation/requests/rulecondition.js",
  32. "platform/forms/components/formviewer/formviewer.js",
  33. "libs/parsley/parsley.min.js",
  34. "libs/querybuilder/query-builder.min.js",
  35. "libs/querybuilder/query-builder.standalone.min.js",
  36. "libs/querybuilder/query-builder.standalone.js",
  37. "libs/querybuilder/sql-parser.min.js", "libs/notificationbuilder/notificationbuilder.js", "platform/automation/components/rulebuilder/notificationgroup.js", "platform/automation/managers/notificationgroupmanager.js"
  38. ];
  39. return jsfiles;
  40. }
  41. cssFiles() {
  42. return [];
  43. }
  44. html(id, containerid) {
  45. let html = `<form id="frmUnibase_PropertyChange" data-validate="parsley" data-isdynamic="false">
  46. <div class="card bg-light">
  47. <div class="b-b bg-white card-header header">
  48. <strong class="text-dark title" id="Spn_PropertyChange">Create PropertyChange</strong>
  49. </div>
  50. <div class="card-body scrollable" style="overflow-y: scroll;">
  51. <div class="bg-white card" id="divPropertyChange">
  52. <div id="Validate_PropertyChnageAction" class="clear"></div>
  53. <div class="card-body">
  54. <div class="row">
  55. <div class="col-sm-12">
  56. <div class="floating-label-form-group">
  57. <label for="lbl" id="lbl_RuleActionName">Action<span class="text-danger required" id="spnIsRequired_RuleActionName"> *</span></label>
  58. <input type="text" id="txtPropertyChange_RuleActionName" class="form-control value-control required floating-label-control" placeholder="Action *" data-placeholder="Enter Action" data-label="Action *">
  59. <input type="hidden" id="hf_RuleActionName" />
  60. </div>
  61. </div>
  62. </div>
  63. <div class="row">
  64. <div class="col-sm-6">
  65. <div class="input-group">
  66. <label for="InstalledApps" class="font-bold">InstalledApps<span class="text-danger">*</span></label>
  67. <select id="txtAutoComplete_InstalledApps" class="form-control text-control required" style="width:100%;" placeholder="InstalledApps" data-placeholder="InstalledApps" data-label="" data-istagselect="true"></select>
  68. <input type="hidden" id="hf_Autocomplete_InstalledApps" class="form-control value-control" data-isdynamic="true" />
  69. </div>
  70. </div>
  71. <div class="col-sm-6">
  72. <div class="input-group">
  73. <label for="AppDoctypes" class="font-bold">AppDoctypes<span class="text-danger">*</span></label>
  74. <select id="txtAutoComplete_AppDoctypes" class="form-control text-control required" style="width:100%;" placeholder="AppDoctypes" data-placeholder="AppDoctypes" data-label="" data-istagselect="true"></select>
  75. <input type="hidden" id="hf_Autocomplete_AppDoctypes" class="form-control value-control" data-isdynamic="true" />
  76. </div>
  77. </div>
  78. </div>
  79. <div class="row">
  80. <div class="col-sm-6">
  81. <div class="input-group">
  82. <label for="DocProperties" class="font-bold">DocProperties<span class="text-danger">*</span></label>
  83. <select id="txtAutoComplete_DocProperties" class="form-control text-control required" style="width:100%;" placeholder="DocProperties" data-placeholder="DocProperties" data-label="" data-istagselect="true"></select>
  84. <input type="hidden" id="hf_Autocomplete_DocProperties" class="form-control value-control" data-isdynamic="true" />
  85. </div>
  86. </div>
  87. <div class="col-sm-6">
  88. <div class="floating-label-form-group">
  89. <label for="txt_Property" id="lbl_Property">Property Name<span class="text-danger">*</span></label>
  90. <input type="text" id="txt_Property" class="form-control required value-control floating-label-control" data-isdynamic="false" placeholder="Property Name*" data-placeholder="Enter Property Name" data-label="Property Name*" />
  91. <input type="hidden" id="hf_Property" />
  92. <label for="Validation" id="lblValidation_Property"></label>
  93. </div>
  94. </div>
  95. </div>
  96. <div class="row">
  97. <div class="col-sm-12">
  98. <div id="div_Parameter" class="floating-label-form-group">
  99. <label for="lbl_ApiParameter" id="lbl_ApiParameter">Parameter<span class="text-danger"> *</span></label>
  100. <div class="input-group">
  101. <input type="text" id="txtPropertyChange_Parameter" class="col-sm-9 form-control value-control required floating-label-control" data-placeholder="Enter Parameter" placeholder="Parameter *" data-label="Parameter *">
  102. <select id="ddl_PropertyChangeParameters" class="col-sm-3 form-control value-control">
  103. <option value="0">Select Token</option>
  104. </select>
  105. </div>
  106. </div>
  107. </div>
  108. </div>
  109. <div class="row">
  110. <div id="div_NotificationGrp" class="floating-label-form-group col-sm-6 floating-label-form-group-with-value">
  111. <label for="lbl_NotificationGrp" id="lbl_NotificationGroup">Notification Group<span class="text-danger"> *</span></label>
  112. <select id="ddl_NotificationGrp" class="form-control"><option value="0">Select Group</option></select>
  113. </div><div class="col-sm-6 createbtn_grp"><button class="badge badge-primary mt-30 ml-15" id="creategrp_btn">Create Group</button></div></div>
  114. <div class="row">
  115. <div class="ResultActions col-sm-6 hidden">
  116. <div id="div_ResultAction" class=" floating-label-form-group floating-label-form-group-with-value">
  117. <label for="lbl" id="lbl_ResultAction">Result Action</label>
  118. <select id="ddl_ResultAction" class="form-control">
  119. <option value="0">Select</option>
  120. </select>
  121. <label for="Validation" id="lblValidation_ResultAction"></label><input type="hidden" id="hfFormPropertyId" value="0" />
  122. </div>
  123. </div>
  124. <div class="col-sm-6">
  125. <div class="custom-control custom-checkbox divEnablePieces checkbox-primary mt-20">
  126. <input type="checkbox" class="custom-control-input" id="chkAutoApprovedPropertyChange" checked>
  127. <label class="custom-control-label" for="chkAutoApprovedPropertyChange">Perform this Action</label>&nbsp
  128. </div>
  129. </div>
  130. </div>
  131. </div>
  132. </div>
  133. <div class="bg-white card col-sm-3" id="btn_ActionConditions">
  134. <button type="button" class="btn btn-primary" onclick="Unibase.Platform.Automation.Components.PropertyChange.Instance().TogglePropertyChangeConditions();">Conditions</button>
  135. </div>
  136. <div class="bg-white card hidden" id="ActionConditionsDiv">
  137. <div class="card-header">Condition Details</div>
  138. <div class="card-body">
  139. <div class="ActionConditions">
  140. <!--For Action Conditions-->
  141. </div>
  142. </div>
  143. </div>
  144. </div>
  145. <div class="bg-white card-footer footer" id="CreatePropertyChangeFooter">
  146. <a href="javascript:;" id="btnClosePropertyChange" class="btn btn-light btn-sm mr-auto "> Close</a>
  147. <a href="javascript:;" id="btnSavePropertyChange" class="btn btn-primary btn-sm"> Save</a>
  148. </div>
  149. </div>
  150. </form>`;
  151. return html;
  152. }
  153. load(id, containerid, callback) {
  154. return __awaiter(this, void 0, void 0, function* () {
  155. var instance = this;
  156. Unibase.Platform.Automation.Components.PropertyChange.Instance().ActionId = instance.ActionId;
  157. Unibase.Platform.Automation.Components.PropertyChange.Instance().RuleActionData = instance.RuleActionData;
  158. Unibase.Platform.Automation.Components.PropertyChange.Instance().RowIndex = instance.RowIndex;
  159. Unibase.Platform.Automation.Components.PropertyChange.Instance().AutomationMode = instance.AutomationMode;
  160. Unibase.Platform.Automation.Components.PropertyChange.Instance().RuleProviderId = instance.RuleProviderId;
  161. Unibase.Platform.Automation.Components.PropertyChange.Instance().ParentActionId = instance.ParentActionId;
  162. Unibase.Platform.Automation.Components.PropertyChange.Instance().IsAutomationMode = instance.IsAutomationMode;
  163. yield Unibase.Platform.Automation.Components.NotificationGroup.Instance().LoadNotificationGroups();
  164. $("#btnClosePropertyChange").click(function () {
  165. $('#' + containerid).modal('hide');
  166. $('#' + containerid).remove();
  167. if (Unibase.Platform.Automation.Components.PropertyChange.Instance().AutomationMode == Unibase.Platform.Automation.Enums.AutomationMode.NormalMode) {
  168. if (Unibase.Platform.Automation.Components.PropertyChange.Instance().AutomationMode) {
  169. if (Unibase.Platform.Automation.Components.PropertyChange.Instance().IsAutomationMode) {
  170. Unibase.Platform.Automation.Components.Rule.Instance().ChangeAction(instance.RowIndex, id);
  171. }
  172. }
  173. }
  174. Unibase.Platform.Automation.Components.Conditions.conditionArray = [];
  175. });
  176. $("#btnSavePropertyChange").click(function () {
  177. let appcontrolid = "frmUnibase_PropertyChange";
  178. let result = Unibase.Platform.Forms.Components.FormViewer.Instance().requiredFieldValidation(appcontrolid);
  179. if (result == false) {
  180. MessageHelper.Instance().showError("Mandatory fields are missing", "Validate_PropertyChnageAction");
  181. return false;
  182. }
  183. else {
  184. Unibase.Platform.Automation.Components.PropertyChange.Instance().SavePropertyChange(id, containerid);
  185. }
  186. });
  187. $("#ddl_PropertyChangeParameters").change(function () {
  188. var textAreaTxt = $("#txtPropertyChange_Parameter").val();
  189. var txtToAdd = '{{' + $("#ddl_PropertyChangeParameters option:selected").text() + '}}';
  190. $("#txtPropertyChange_Parameter").val(textAreaTxt + txtToAdd);
  191. $("#ddl_PropertyChangeParameters").val(0);
  192. });
  193. if (id != "") {
  194. Unibase.Platform.Automation.Components.PropertyChange.Instance().EditPropertyChange(id);
  195. }
  196. let rpid = instance.RuleProviderId;
  197. if (rpid != 0) {
  198. Unibase.Platform.Automation.Components.PropertyChange.Instance().LoadPropertyChangeParameters(rpid);
  199. Unibase.Platform.Automation.Components.ContactSelection.Instance().loadQueryBuilder(rpid, null);
  200. }
  201. if (instance.RuleActionData.length != 0) {
  202. Unibase.Platform.Automation.Components.PropertyChange.Instance().LoadPropertyChangeData(instance.RuleActionData);
  203. }
  204. $('#creategrp_btn').click(function () {
  205. Unibase.Platform.Automation.Components.NotificationGroup.Instance().init(0, null, true);
  206. });
  207. if (instance.ParentActionId != 0) {
  208. Unibase.Platform.Automation.Components.ContactSelection.Instance().getResultActions(instance.ParentActionId);
  209. yield Unibase.Platform.Automation.Components.PropertyChange.Instance().GetRuleActionInfo(Number(instance.ParentActionId));
  210. $('#ddl_NotificationGrp').prop("disabled", true);
  211. $('#creategrp_btn').addClass('d-none');
  212. }
  213. var url = _appsettings.server_url() + '/apis/v4/unibase/platform/apps/installedappautocomplete';
  214. AutoCompleteHelper.getHelper().Create("#txtAutoComplete_InstalledApps", "#hf_Autocomplete_InstalledApps", url, function (response) {
  215. var data = response;
  216. });
  217. $("#txtAutoComplete_InstalledApps").change(function () {
  218. Unibase.Platform.Automation.Components.PropertyChange.Instance().OnChangeInstalledApp();
  219. });
  220. $("#txtAutoComplete_AppDoctypes").change(function () {
  221. Unibase.Platform.Automation.Components.PropertyChange.Instance().OnChangeDoctype();
  222. });
  223. });
  224. }
  225. OnChangeInstalledApp() {
  226. return __awaiter(this, void 0, void 0, function* () {
  227. $("#txtAutoComplete_AppDoctypes").val(0);
  228. var url = _appsettings.server_url() + '/apis/v4/unibase/platform/doctypes/appdoctypesautocomplete/installedappid/' + Number($("#txtAutoComplete_InstalledApps option:selected").val());
  229. return yield AutoCompleteHelper.getHelper().Create("#txtAutoComplete_AppDoctypes", "#hf_Autocomplete_AppDoctypes", url, function (response) {
  230. var data = response;
  231. });
  232. });
  233. }
  234. OnChangeDoctype() {
  235. return __awaiter(this, void 0, void 0, function* () {
  236. $("#txtAutoComplete_DocProperties").val(0);
  237. var url = _appsettings.server_url() + '/apis/v4/unibase/platform/doctypes/docpropertiesautocomplete/doctypeid/' + Number($("#txtAutoComplete_AppDoctypes option:selected").val());
  238. return yield AutoCompleteHelper.getHelper().Create("#txtAutoComplete_DocProperties", "#hf_Autocomplete_DocProperties", url, function (response) {
  239. var data = response;
  240. });
  241. });
  242. }
  243. TogglePropertyChangeConditions() {
  244. $("#ActionConditionsDiv").toggle(function () {
  245. $("#btn_ActionConditions").addClass("hidden");
  246. $("#ActionConditionsDiv").removeClass("hidden");
  247. Unibase.Platform.Automation.Components.ContactSelection.Instance().loadQueryBuilder(Unibase.Platform.Automation.Components.PropertyChange.Instance().RuleProviderId, null);
  248. });
  249. }
  250. LoadPropertyChangeData(Data) {
  251. for (var i = 0; i < Data.length; i++) {
  252. $("#txtPropertyChange_RuleActionName").val(Data[i].RuleActionName);
  253. $("#txt_Property").val(Data[i].BString1);
  254. $("#txtPropertyChange_Parameter").val(Data[i].BString2);
  255. $("#txtAutoComplete_InstalledApps").append(Data[i].String1);
  256. $("#txtAutoComplete_AppDoctypes").append(Data[i].String2);
  257. $("#txtAutoComplete_DocProperties").append(Data[i].String3);
  258. let id = Number(Data[i].String1);
  259. Unibase.Platform.Apps.Managers.AppManager.Instance().getInstallApp(id).then(function (res) {
  260. var selectedappoption = new Option(res.result.AppTitle, res.result.InstalledAppId.toString(), true);
  261. $("#txtAutoComplete_InstalledApps").append(selectedappoption);
  262. });
  263. let docid = Number(Data[i].String2);
  264. Unibase.Platform.DataSources.Managers.DocTypeManager.Instance().getDoctype(docid).then(function (docres) {
  265. var selecteddoctypeoption = new Option(docres.result.DocTypeName, docres.result.DocTypeId.toString(), true);
  266. $("#txtAutoComplete_AppDoctypes").append(selecteddoctypeoption);
  267. });
  268. let docpropid = Number(Data[i].String3);
  269. Unibase.Platform.DataSources.Managers.DocTypeManager.Instance().getDocProperty(docpropid).then(function (docpropres) {
  270. var selecteddocpropoption = new Option(docpropres.result.DocPropertyName, docpropres.result.DocPropertyId.toString(), true);
  271. $("#txtAutoComplete_DocProperties").append(selecteddocpropoption);
  272. });
  273. if (Data[i].ExecuteStatusId != Number(Unibase.Platform.Automation.Enums.ExecuteActionStatus.Approved))
  274. $("#chkAutoApprovedPropertyChange").prop("checked", false);
  275. else
  276. $("#chkAutoApprovedPropertyChange").prop("checked", true);
  277. if (Data[i].SqlWhere != "" && Data[i].SqlWhere != null) {
  278. Unibase.Platform.Automation.Components.ContactSelection.Instance().loadQueryBuilder(Unibase.Platform.Automation.Components.PropertyChange.Instance().RuleProviderId, Data[i].SqlWhere);
  279. $("#btn_ActionConditions").addClass("hidden");
  280. $("#ActionConditionsDiv").removeClass("hidden");
  281. }
  282. $("#div_Parameter").addClass('floating-label-form-group-with-value');
  283. eval('_floatingLabelHelper.init();');
  284. }
  285. }
  286. LoadPropertyChangeParameters(ruleproviderid) {
  287. Unibase.Platform.Automation.Managers.RuleManager.Instance().getTokens(ruleproviderid).then(function (response) {
  288. let ApiParameters = document.getElementById('ddl_PropertyChangeParameters');
  289. $('#ddl_PropertyChangeParameters').empty();
  290. var defaultOpt1 = document.createElement("option");
  291. defaultOpt1.text = "Select Token";
  292. defaultOpt1.value = "0";
  293. ApiParameters.appendChild(defaultOpt1);
  294. for (let i = 0; i <= response.length - 1; i++) {
  295. var opt = document.createElement("option");
  296. opt.text = response[i];
  297. opt.value = (i + 1).toString();
  298. ApiParameters.appendChild(opt);
  299. }
  300. });
  301. }
  302. EditPropertyChange(id) {
  303. let actionid = Number(id);
  304. $("#Spn_PropertyChange").text("Edit PropertyChange");
  305. Unibase.Platform.Automation.Managers.RuleManager.Instance().getRuleAction(actionid).then(function (response) {
  306. $("#txtPropertyChange_RuleActionName").val(response.RuleActionName);
  307. $("#txtPropertyChange_Parameter").val(response.BString2);
  308. $("#txt_Property").val(response.BString1);
  309. $('#ddl_NotificationGrp option[value=' + response.NotificationGroupId + ']').prop('selected', true);
  310. if (!Unibase.Platform.Automation.Components.PropertyChange.Instance().IsAutomationMode) {
  311. Unibase.Platform.Automation.Components.PropertyChange.Instance().RuleId = response.RuleId;
  312. Unibase.Platform.Automation.Components.PropertyChange.Instance().RuleEventId = response.RuleEventId;
  313. Unibase.Platform.Automation.Components.PropertyChange.Instance().EventGroupId = response.EventGroupId;
  314. Unibase.Platform.Automation.Components.PropertyChange.Instance().ActionId = response.ActionId;
  315. Unibase.Platform.Automation.Components.PropertyChange.Instance().ParentActionId = response.ParentActionId;
  316. }
  317. if (response.ExecuteStatusId != Number(Unibase.Platform.Automation.Enums.ExecuteActionStatus.Approved))
  318. $("#chkAutoApprovedPropertyChange").prop("checked", false);
  319. else
  320. $("#chkAutoApprovedPropertyChange").prop("checked", true);
  321. let id = Number(response.String1);
  322. Unibase.Platform.Apps.Managers.AppManager.Instance().getInstallApp(id).then(function (res) {
  323. var selectedappoption = new Option(res.result.AppTitle, res.result.InstalledAppId.toString(), true);
  324. $("#txtAutoComplete_InstalledApps").append(selectedappoption);
  325. });
  326. let docid = Number(response.String2);
  327. Unibase.Platform.DataSources.Managers.DocTypeManager.Instance().getDoctype(docid).then(function (docres) {
  328. var selecteddoctypeoption = new Option(docres.result.DocTypeName, docres.result.DocTypeId.toString(), true);
  329. $("#txtAutoComplete_AppDoctypes").append(selecteddoctypeoption);
  330. });
  331. let docpropid = Number(response.String3);
  332. Unibase.Platform.DataSources.Managers.DocTypeManager.Instance().getDocProperty(docpropid).then(function (docpropres) {
  333. var selecteddocpropoption = new Option(docpropres.result.DocPropertyName, docpropres.result.DocPropertyId.toString(), true);
  334. $("#txtAutoComplete_DocProperties").append(selecteddocpropoption);
  335. });
  336. Unibase.Platform.Automation.Components.ContactSelection.Instance().loadQueryBuilder(response.RuleProviderId, response.SqlWhere);
  337. $("#btn_ActionConditions").addClass("hidden");
  338. $("#ActionConditionsDiv").removeClass("hidden");
  339. $("#div_Parameter").addClass('floating-label-form-group-with-value');
  340. eval('_floatingLabelHelper.init();');
  341. });
  342. }
  343. GetRuleActionInfo(parentactionid) {
  344. return __awaiter(this, void 0, void 0, function* () {
  345. yield Unibase.Platform.Automation.Managers.RuleManager.Instance().getRuleAction(parentactionid).then(function (response) {
  346. if (response != null) {
  347. var html = '<option value=' + response.NotificationGroupId + ' selected>' + response.NotificationGroupName + '</option>';
  348. $('#ddl_NotificationGrp').html('').html(html);
  349. }
  350. });
  351. });
  352. }
  353. SavePropertyChange(PropertyChangeid, containerid) {
  354. let ruleactionid = Number(PropertyChangeid);
  355. let queryelmnt = $("#builder");
  356. let model = new Unibase.Platform.Automation.Requests.RuleAction();
  357. model.RuleActionId = ruleactionid;
  358. model.RuleActionName = $("#txtPropertyChange_RuleActionName").val().toString();
  359. model.String1 = $("#txtAutoComplete_InstalledApps option:selected").val().toString();
  360. model.String2 = $("#txtAutoComplete_AppDoctypes option:selected").val().toString();
  361. model.String3 = $("#txtAutoComplete_DocProperties option:selected").val().toString();
  362. model.BString1 = $("#txt_Property").val().toString();
  363. model.BString2 = $("#txtPropertyChange_Parameter").val().toString();
  364. model.ActionId = Unibase.Platform.Automation.Components.PropertyChange.Instance().ActionId;
  365. model.RuleId = 0;
  366. model.Users = "";
  367. model.NotificationGroupId = $('#ddl_NotificationGrp').val() == undefined ? 0 : Number($('#ddl_NotificationGrp').val());
  368. if (model.NotificationGroupId == 0) {
  369. MessageHelper.Instance().showError("Please Select Notification Group", "Validate_NotificationAction");
  370. return;
  371. }
  372. let query = queryelmnt.queryBuilder('getSQL', false, true);
  373. if (query != null) {
  374. model.SqlWhere = queryelmnt.queryBuilder('getSQL', false, true).sql.replace(/\n/g, " ").replace(/LIKE/g, "ILIKE");
  375. ;
  376. model.SqlWhereJson = JSON.stringify(queryelmnt.queryBuilder('getSQL', false, true));
  377. }
  378. model.ResultActionId = Number($("#ddl_ResultAction option:selected").val());
  379. if (model.ResultActionId != 0) {
  380. model.ResultActionName = $("#ddl_ResultAction option:selected").text();
  381. }
  382. else {
  383. model.ResultActionName = "";
  384. }
  385. model.DelayTime = 0;
  386. model.ParentActionId = Unibase.Platform.Automation.Components.PropertyChange.Instance().ParentActionId;
  387. model.AutoApproved = $('#chkAutoApprovedPropertyChange').is(':checked');
  388. model.RowIndex = Unibase.Platform.Automation.Components.PropertyChange.Instance().RowIndex;
  389. if (Unibase.Platform.Automation.Components.PropertyChange.Instance().IsAutomationMode) {
  390. if (Unibase.Platform.Automation.Components.PropertyChange.Instance().AutomationMode == Unibase.Platform.Automation.Enums.AutomationMode.NormalMode) {
  391. Unibase.Platform.Automation.Components.Rule.Instance().RuleActionsArray(model);
  392. $('#' + containerid).modal('hide');
  393. $('#' + containerid).remove();
  394. Unibase.Platform.Automation.Components.Conditions.conditionArray = [];
  395. }
  396. else {
  397. model.RuleId = eval("bizgaze_automation_flow_main.getruleid()");
  398. Automation.Managers.RuleManager.Instance().saveRuleAction(model).then(function (response) {
  399. if (response.status == Unibase.Data.Status.Error) {
  400. MessageHelper.Instance().showError(response.message, "Validate_PropertyChnageAction");
  401. }
  402. else {
  403. MessageHelper.Instance().showSuccess(response.message, "Validate_PropertyChnageAction");
  404. $('#' + containerid).modal('hide');
  405. $('#' + containerid).remove();
  406. Unibase.Platform.Automation.Components.Conditions.conditionArray = [];
  407. var actionname = response.result.RuleActionName;
  408. eval("bizgaze_automation_flow_main.savePropertyChangeblock('" + response.result.RuleActionId + "','" + actionname + "')");
  409. }
  410. });
  411. }
  412. }
  413. else {
  414. model.RuleId = Unibase.Platform.Automation.Components.PropertyChange.Instance().RuleId;
  415. model.EventGroupId = Unibase.Platform.Automation.Components.PropertyChange.Instance().EventGroupId;
  416. model.RuleEventId = Unibase.Platform.Automation.Components.PropertyChange.Instance().RuleEventId;
  417. model.ActionId = Unibase.Platform.Automation.Components.PropertyChange.Instance().ActionId;
  418. model.ParentActionId = Unibase.Platform.Automation.Components.PropertyChange.Instance().ParentActionId;
  419. Automation.Managers.RuleManager.Instance().saveRuleAction(model).then(function (response) {
  420. if (response.status == Unibase.Data.Status.Error) {
  421. MessageHelper.Instance().showError(response.message, "Validate_PropertyChnageAction");
  422. }
  423. else {
  424. MessageHelper.Instance().showSuccess(response.message, "Validate_PropertyChnageAction");
  425. $('#' + containerid).modal('hide');
  426. $('#' + containerid).remove();
  427. Unibase.Platform.Automation.Components.Conditions.conditionArray = [];
  428. }
  429. });
  430. }
  431. }
  432. static Instance() {
  433. if (this.instance === undefined) {
  434. this.instance = new PropertyChange();
  435. }
  436. return this.instance;
  437. }
  438. }
  439. Components.PropertyChange = PropertyChange;
  440. })(Components = Automation.Components || (Automation.Components = {}));
  441. })(Automation = Platform.Automation || (Platform.Automation = {}));
  442. })(Platform = Unibase.Platform || (Unibase.Platform = {}));
  443. })(Unibase || (Unibase = {}));