View.cshtml 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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 = 240;
  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("DeleteCookiesAndSessionVariables", "Global")',
  55. data: { cookies: [ "appendixGridStateCookie" ], sessionVariables: [ "AppendixGridState", "AppendixGridViewState" ] },
  56. success: function (response) {
  57. if (response == "success") {
  58. window.location = window.location;
  59. }
  60. }
  61. });
  62. }
  63. }
  64. function viewAppendix(id) {
  65. if (!id) return;
  66. $.ajax({
  67. url: '@Url.Action("ViewAppendix", "Appendix")',
  68. data: { Id: id },
  69. success: function (response) {
  70. setTimeout(function () {
  71. $(".appendixViewContainer").remove();
  72. $("body").append(response);
  73. }, 200);
  74. },
  75. error: function () {
  76. alert("error occured");
  77. }
  78. });
  79. }
  80. function editAppendix(id) {
  81. if (!id) return;
  82. $.ajax({
  83. url: '@Url.Action("EditAppendix", "Appendix")',
  84. data: { Id: id },
  85. success: function (response) {
  86. setTimeout(function () {
  87. $(".appendixEditContainer").remove();
  88. $("body").append(response);
  89. }, 200);
  90. },
  91. error: function () {
  92. alert("error occured");
  93. }
  94. });
  95. }
  96. function confirmDelete(id) {
  97. if (!id) return;
  98. deleteId = id;
  99. $.ajax({
  100. type: "GET",
  101. url: '@Url.Action("GetAppendix", "Appendix")',
  102. data: { Id: id },
  103. success: function (response) {
  104. if (response == "notFound") return;
  105. var appendix = JSON.parse(response);
  106. var popupControl = MVCxClientPopupControl.Cast(devPopupControlDeleteAppendix);
  107. popupControl.SetHeaderText(popupControl.GetHeaderText().replace("{appendix}", appendix.CustomNumber));
  108. $(".dialogText").text($(".dialogText").text().replace("{appendix}", appendix.CustomNumber));
  109. popupControl.Show();
  110. }
  111. });
  112. }
  113. function deleteAppendix() {
  114. $.ajax({
  115. type: "POST",
  116. url: '@Url.Action("DeleteAppendix", "Appendix")',
  117. data: { Id: deleteId },
  118. success: function (response) {
  119. var popupControl = MVCxClientPopupControl.Cast(devPopupControlDeleteAppendix);
  120. popupControl.Hide();
  121. setTimeout(function () {
  122. devGridViewAppendix.PerformCallback();
  123. }, 200);
  124. },
  125. error: function () {
  126. alert("error occured");
  127. }
  128. });
  129. }
  130. function editOrderInvoiceCreated(id, callback) {
  131. if (!id) return;
  132. editOrderInvoiceCreatedCallback = callback;
  133. $.ajax({
  134. url: '@Url.Action("EditOrderInvoiceCreated", "Appendix")',
  135. data: { id: id },
  136. success: function (response) {
  137. $(".editOrderInvoiceCreatedContainer").remove();
  138. $("body").append(response);
  139. }
  140. });
  141. }
  142. </script>
  143. @Html.Partial("~/Views/Appendices/_AppendixGridPartial.cshtml", Model)
  144. @Html.Partial("~/Views/Shared/_PopupDialogYesNo.cshtml", new GreenTree.Nachtragsmanagement.Web.Models.Global.YesNoDialogModel
  145. {
  146. PopupName = "devPopupControlDeleteAppendix",
  147. Content = "<div class='dialogText' style='padding: 12px'>Sind Sie sicher, dass Sie den Nachtrag \"{appendix}\" löschen möchten?</div>",
  148. HeaderText = "\"{appendix}\" löschen",
  149. YesFunction = "function (s, e) { deleteAppendix(); }"
  150. })