Claims.cshtml 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. @using GreenTree.Nachtragsmanagement.Web.Models.Global
  2. @{
  3. Layout = "~/Views/Shared/_FunctionLayout.cshtml";
  4. }
  5. <script>
  6. var deleteId;
  7. var deleteReplaceId;
  8. var deleteClaimType;
  9. var claimTypeTranslation = {
  10. state: "NT-Status",
  11. category: "Kategorie"
  12. };
  13. $(document).ready(setListBoxHeights);
  14. $(window).resize(setListBoxHeights);
  15. function setListBoxHeights() {
  16. var windowHeight = $(window).height();
  17. devListBoxStates.SetHeight(windowHeight - 40);
  18. devListBoxCategories.SetHeight(windowHeight - 40);
  19. }
  20. function editClaim(claimType, id) {
  21. if (!id) return;
  22. $.ajax({
  23. url: '@Url.Action("EditClaim", "Appendix")',
  24. data: { claimType: claimType, Id: id },
  25. success: function (response) {
  26. setTimeout(function () {
  27. $(".claimEditContainer").remove();
  28. $("body").append(response);
  29. if (claimType == "state") {
  30. parent.addCustomEventListener('StateDataCallbackEventReceiver', function () {
  31. devListBoxStates.PerformCallback();
  32. });
  33. } else if (claimType == "category") {
  34. parent.addCustomEventListener('CategoryDataCallbackEventReceiver', function () {
  35. devListBoxCategories.PerformCallback();
  36. });
  37. }
  38. }, 200);
  39. },
  40. error: function () {
  41. alert("error occured");
  42. }
  43. });
  44. }
  45. function confirmDelete(claimType, id) {
  46. if (!id) return;
  47. deleteId = id;
  48. deleteClaimType = claimType;
  49. $.ajax({
  50. type: "GET",
  51. url: '@Url.Action("GetClaim", "Appendix")',
  52. data: { claimType: deleteClaimType, Id: id },
  53. success: function (response) {
  54. if (response == "notFound") return;
  55. var claim = JSON.parse(response);
  56. $(".deleteValidation").hide();
  57. var popupControl = MVCxClientPopupControl.Cast(devPopupControlDeleteClaim);
  58. popupControl.SetHeaderText(popupControl.GetHeaderText().replace("{claim}", claim.Description));
  59. $(".dialogText").text($(".dialogText").text().replace("{claim}", claim.Description));
  60. $(".dialogText").text($(".dialogText").text().replace("{claim}", claim.Description));
  61. $(".dialogText").text($(".dialogText").text().replace("{claimType}", claimTypeTranslation[claimType]));
  62. devRadioButtonDeleteReplaceClaim
  63. .SetText(devRadioButtonDeleteReplaceClaim.GetText().replace("{claimType}", claimTypeTranslation[claimType]));
  64. devComboBoxClaimDeleteReplaceState.SetVisible(false);
  65. devComboBoxClaimDeleteReplaceCategory.SetVisible(false);
  66. var comboBox = null;
  67. if (deleteClaimType == "state") {
  68. devComboBoxClaimDeleteReplaceState.SetVisible(true);
  69. comboBox = MVCxClientComboBox.Cast(devComboBoxClaimDeleteReplaceState);
  70. } else if (deleteClaimType == "category") {
  71. devComboBoxClaimDeleteReplaceCategory.SetVisible(true);
  72. comboBox = MVCxClientComboBox.Cast(devComboBoxClaimDeleteReplaceCategory);
  73. }
  74. comboBox.PerformCallback();
  75. popupControl.Show();
  76. }
  77. });
  78. }
  79. function deleteClaim() {
  80. if (deleteClaimType == "state") {
  81. deleteReplaceId = devComboBoxClaimDeleteReplaceState.GetValue();
  82. } else if (deleteClaimType == "category") {
  83. deleteReplaceId = devComboBoxClaimDeleteReplaceCategory.GetValue();
  84. }
  85. if (deleteReplaceId == 0) {
  86. $(".deleteValidation").text("Es muss ein Ersatz ausgewählt werden.");
  87. $(".deleteValidation").show();
  88. return;
  89. }
  90. if (deleteId == deleteReplaceId) {
  91. $(".deleteValidation").text("Der Ersatz darf nicht gleich dem zu löschenden Element sein.");
  92. $(".deleteValidation").show();
  93. return;
  94. }
  95. $.ajax({
  96. type: "POST",
  97. url: '@Url.Action("DeleteClaim", "Appendix")',
  98. data: { claimType: deleteClaimType, Id: deleteId, replaceId: deleteReplaceId },
  99. success: function (response) {
  100. var popupControl = MVCxClientPopupControl.Cast(devPopupControlDeleteClaim);
  101. popupControl.Hide();
  102. setTimeout(function () {
  103. if (deleteClaimType == "state") {
  104. devListBoxStates.PerformCallback();
  105. } else if (deleteClaimType == "category") {
  106. devListBoxCategories.PerformCallback();
  107. }
  108. }, 200);
  109. },
  110. error: function () {
  111. alert("error occured");
  112. }
  113. });
  114. }
  115. </script>
  116. <table style="width: 100%">
  117. <tbody>
  118. <tr>
  119. <td style="width: 50%; padding-right: 8px">
  120. <div class="listHeader">
  121. <span>NT-Stati</span>
  122. <img src='@Url.Content("~/Content/Images/add-24-contrast.png")' onclick='editClaim("state", -1)' title="Neuer NT-Status" />
  123. </div>
  124. @Html.Partial("~/Views/Appendices/_StateListPartial.cshtml", ViewData["AllStates"])
  125. </td>
  126. <td style="width: 50%; padding-left: 8px">
  127. <div class="listHeader">
  128. <span>Kategorien</span>
  129. <img src='@Url.Content("~/Content/Images/add-24-contrast.png")' onclick='editClaim("category", -1)' title="Neue NT-Kategorie" />
  130. </div>
  131. @Html.Partial("~/Views/Appendices/_CategoryListPartial.cshtml", ViewData["AllCategories"])
  132. </td>
  133. </tr>
  134. </tbody>
  135. </table>
  136. @Html.DevExpress().PopupControl(s =>
  137. {
  138. s.Name = "devPopupControlDeleteClaim";
  139. s.HeaderText = "\"{claim}\" löschen";
  140. s.Modal = false;
  141. s.Width = new Unit(350, UnitType.Pixel);
  142. s.CloseAction = CloseAction.CloseButton;
  143. s.PopupHorizontalAlign = PopupHorizontalAlign.WindowCenter;
  144. s.PopupVerticalAlign = PopupVerticalAlign.WindowCenter;
  145. s.AllowDragging = false;
  146. s.AllowResize = false;
  147. s.ShowFooter = false;
  148. s.SetContent(() =>
  149. {
  150. ViewContext.Writer.Write("<div class='dialogText' style='padding: 12px'>");
  151. ViewContext.Writer.Write("Falls Sie \"{claim}\" löschen möchten, was soll mit den Nachträgen geschehen, die bereits \"{claim}\" zugeordnet sind?");
  152. ViewContext.Writer.Write("</div>");
  153. ViewContext.Writer.Write("<div style='padding: 0 12px 12px 12px'>");
  154. Html.DevExpress().RadioButton(rb =>
  155. {
  156. rb.Name = "devRadioButtonDeleteReplaceClaim";
  157. rb.Text = "Eine neue(n) {claimType} zuweisen";
  158. rb.GroupName = "claimDelete";
  159. rb.Checked = true;
  160. }).Render();
  161. Session.Add("StatesDeleteComboBoxSettings", new Action<ComboBoxSettings>(a =>
  162. {
  163. a.Name = "devComboBoxClaimDeleteReplaceState";
  164. a.Width = new Unit(100, UnitType.Percentage);
  165. a.Properties.ValueType = typeof(int);
  166. a.Properties.ValueField = "Id";
  167. a.Properties.TextField = "Description";
  168. a.Properties.ClientSideEvents.BeginCallback = "function (s, e) { e.customArgs['excludedIds'] = [ deleteId ]; }";
  169. a.Properties.ClientSideEvents.EndCallback = "function (s, e) { s.SetSelectedIndex(0); }";
  170. a.SelectedIndex = 0;
  171. a.ClientVisible = false;
  172. a.CallbackRouteValues = new
  173. {
  174. Controller = "DataCallback",
  175. Action = "StatesComboBoxExcluded",
  176. SettingsKey = "StatesDeleteComboBoxSettings"
  177. };
  178. }));
  179. ViewData.Add("StatesComboBoxSettings", "StatesDeleteComboBoxSettings");
  180. Html.RenderPartial("~/Views/Shared/DataEditorTemplates/_StatesComboBox.cshtml", null, ViewData);
  181. Session.Add("CategoriesDeleteComboBoxSettings", new Action<ComboBoxSettings>(a =>
  182. {
  183. a.Name = "devComboBoxClaimDeleteReplaceCategory";
  184. a.Width = new Unit(100, UnitType.Percentage);
  185. a.Properties.ValueType = typeof(int);
  186. a.Properties.ValueField = "Id";
  187. a.Properties.TextField = "Description";
  188. a.Properties.ClientSideEvents.BeginCallback = "function (s, e) { e.customArgs['excludedIds'] = [ deleteId ]; }";
  189. a.Properties.ClientSideEvents.EndCallback = "function (s, e) { s.SetSelectedIndex(0); }";
  190. a.SelectedIndex = 0;
  191. a.ClientVisible = false;
  192. a.CallbackRouteValues = new
  193. {
  194. Controller = "DataCallback",
  195. Action = "CategoriesComboBoxExcluded",
  196. SettingsKey = "CategoriesDeleteComboBoxSettings"
  197. };
  198. }));
  199. ViewData.Add("CategoriesComboBoxSettings", "CategoriesDeleteComboBoxSettings");
  200. Html.RenderPartial("~/Views/Shared/DataEditorTemplates/_CategoriesComboBox.cshtml", null, ViewData);
  201. ViewContext.Writer.Write("<div class=\"deleteValidation\" style=\"display: none\"></div>");
  202. ViewContext.Writer.Write("</div>");
  203. Html.RenderPartial(
  204. "~/Views/Shared/_PopupButtonPanelYesNo.cshtml",
  205. new YesNoDialogModel
  206. {
  207. PopupName = "devPopupControlDeleteClaim",
  208. YesFunction = "function (s, e) { deleteClaim(); }"
  209. }
  210. );
  211. });
  212. s.Styles.Content.Paddings.Padding = new Unit(0, UnitType.Pixel);
  213. }).GetHtml()