View.cshtml 4.7 KB

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