View.cshtml 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. @{
  2. Layout = "~/Views/Shared/_FunctionLayout.cshtml";
  3. }
  4. @model IEnumerable<GreenTree.Nachtragsmanagement.Web.Models.Appendix.AppendixDataModel>
  5. <script>
  6. var deleteId;
  7. var gridScrollHeight;
  8. var gridScrollOffset = 185;
  9. var resizeFinished;
  10. var editOrderInvoiceCreatedCallback;
  11. $(document).ready(function () {
  12. gridScrollHeight = calculateGridScrollHeight();
  13. setTimeout(function () {
  14. devGridViewAppendix.PerformCallback();
  15. }, 500);
  16. });
  17. $(window).resize(function () {
  18. clearTimeout(window.resizedFinished);
  19. window.resizedFinished = setTimeout(function () {
  20. setGridScrollHeight();
  21. }, 250);
  22. });
  23. function calculateGridScrollHeight() {
  24. var windowHeight = $(window).height();
  25. var gridHeaderHeight = $("#devGridViewAppendix_DXHeadersRow0").height();
  26. var gridFooterHeight = $("#devGridViewAppendix_DXFooterRow").height();
  27. return windowHeight - gridHeaderHeight - gridFooterHeight - gridScrollOffset;
  28. }
  29. function setGridScrollHeight() {
  30. gridScrollHeight = calculateGridScrollHeight();
  31. devGridViewAppendix.PerformCallback();
  32. }
  33. function onToolbarItemClick(s, e) {
  34. if (!s || !e) return;
  35. if (e.item.name == "Print") {
  36. parent.$(".printPopupContainer").remove();
  37. $.ajax({
  38. type: "POST",
  39. url: '@Url.Action("ExportPartialAppendices", "Appendix")',
  40. data: { displayMode: "popup", exportFormat: "" },
  41. success: function (response) {
  42. parent.$("body").append(response);
  43. parent.exportFormat = "pdf";
  44. }
  45. });
  46. } else if (e.item.name == "ToggleColumnChooser") {
  47. if (devGridViewAppendix.IsCustomizationWindowVisible())
  48. devGridViewAppendix.HideCustomizationWindow();
  49. else
  50. devGridViewAppendix.ShowCustomizationWindow();
  51. } else if (e.item.name == "ResetSettings") {
  52. $.ajax({
  53. type: "POST",
  54. url: '@Url.Action("DeleteCookiesSessionVariablesAndUserConfigs", "Global")',
  55. data: {
  56. cookies: ["appendixGridStateCookie"],
  57. sessionVariables: ["AppendixGridState", "AppendixGridViewState"],
  58. userConfigItemNames: ["AppendixGridLayoutState"]
  59. },
  60. success: function (response) {
  61. if (response == "success") {
  62. window.location = window.location;
  63. }
  64. }
  65. });
  66. }
  67. }
  68. function viewAppendix(id) {
  69. if (!id) return;
  70. $.ajax({
  71. url: '@Url.Action("ViewAppendix", "Appendix")',
  72. data: { Id: id },
  73. success: function (response) {
  74. setTimeout(function () {
  75. $(".appendixViewContainer").remove();
  76. $("body").append(response);
  77. }, 200);
  78. },
  79. error: function () {
  80. alert("error occured");
  81. }
  82. });
  83. }
  84. function editAppendix(id) {
  85. if (!id) return;
  86. $.ajax({
  87. url: '@Url.Action("EditAppendix", "Appendix")',
  88. data: { Id: id },
  89. success: function (response) {
  90. setTimeout(function () {
  91. $(".appendixEditContainer").remove();
  92. $("body").append(response);
  93. }, 200);
  94. },
  95. error: function () {
  96. alert("error occured");
  97. }
  98. });
  99. }
  100. function confirmDelete(id) {
  101. if (!id) return;
  102. deleteId = id;
  103. $.ajax({
  104. type: "GET",
  105. url: '@Url.Action("GetAppendix", "Appendix")',
  106. data: { Id: id },
  107. success: function (response) {
  108. if (response == "notFound") return;
  109. var appendix = JSON.parse(response);
  110. var popupControl = MVCxClientPopupControl.Cast(devPopupControlDeleteAppendix);
  111. popupControl.SetHeaderText(popupControl.GetHeaderText().replace("{appendix}", appendix.CustomNumber));
  112. $(".dialogText").text($(".dialogText").text().replace("{appendix}", appendix.CustomNumber));
  113. popupControl.Show();
  114. }
  115. });
  116. }
  117. function deleteAppendix() {
  118. $.ajax({
  119. type: "POST",
  120. url: '@Url.Action("DeleteAppendix", "Appendix")',
  121. data: { Id: deleteId },
  122. success: function (response) {
  123. var popupControl = MVCxClientPopupControl.Cast(devPopupControlDeleteAppendix);
  124. popupControl.Hide();
  125. setTimeout(function () {
  126. devGridViewAppendix.PerformCallback();
  127. }, 200);
  128. },
  129. error: function () {
  130. alert("error occured");
  131. }
  132. });
  133. }
  134. function editOrderInvoiceCreated(id, callback) {
  135. if (!id) return;
  136. editOrderInvoiceCreatedCallback = callback;
  137. $.ajax({
  138. url: '@Url.Action("EditOrderInvoiceCreated", "Appendix")',
  139. data: { id: id },
  140. success: function (response) {
  141. $(".editOrderInvoiceCreatedContainer").remove();
  142. $("body").append(response);
  143. }
  144. });
  145. }
  146. </script>
  147. @Html.Partial("~/Views/Appendices/_AppendixGridPartial.cshtml", Model)
  148. @Html.Partial("~/Views/Shared/_PopupDialogYesNo.cshtml", new GreenTree.Nachtragsmanagement.Web.Models.Global.YesNoDialogModel
  149. {
  150. PopupName = "devPopupControlDeleteAppendix",
  151. Content = "<div class='dialogText' style='padding: 12px'>Sind Sie sicher, dass Sie den Nachtrag \"{appendix}\" löschen möchten?</div>",
  152. HeaderText = "\"{appendix}\" löschen",
  153. YesFunction = "function (s, e) { deleteAppendix(); }"
  154. })