Claims.cshtml 8.0 KB

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