View.cshtml 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. @{
  2. Layout = "~/Views/Shared/_FunctionLayout.cshtml";
  3. }
  4. @model IEnumerable<GreenTree.Nachtragsmanagement.Web.Models.Deviation.DeviationDataModel>
  5. <script>
  6. var deleteId;
  7. var gridScrollHeight;
  8. var gridScrollOffset = 240;
  9. var resizeFinished;
  10. var customFilters = {};
  11. var customFilterDelay = 800;
  12. var timer;
  13. var setFilterTimer = function (timeout, func) {
  14. if (timer != null) {
  15. clearTimeout(timer);
  16. timer = null;
  17. }
  18. if (timer == null) {
  19. timer = setTimeout(function () {
  20. func();
  21. }, timeout);
  22. }
  23. }
  24. $(document).ready(function () {
  25. gridScrollHeight = calculateGridScrollHeight();
  26. setTimeout(function () {
  27. devGridViewDeviation.PerformCallback();
  28. }, 500);
  29. });
  30. $(window).resize(function () {
  31. clearTimeout(window.resizedFinished);
  32. window.resizedFinished = setTimeout(function () {
  33. setGridScrollHeight();
  34. }, 250);
  35. });
  36. function calculateGridScrollHeight() {
  37. var windowHeight = $(window).height();
  38. var gridHeaderHeight = $("#devGridViewDeviation_DXHeadersRow0").height();
  39. var gridFooterHeight = $("#devGridViewDeviation_DXFooterRow").height();
  40. return windowHeight - gridHeaderHeight - gridFooterHeight - gridScrollOffset;
  41. }
  42. function setGridScrollHeight() {
  43. gridScrollHeight = calculateGridScrollHeight();
  44. devGridViewDeviation.PerformCallback();
  45. }
  46. function onToolbarItemClick(s, e) {
  47. if (!s || !e) return;
  48. if (e.item.name == "Print") {
  49. parent.$(".printPopupContainer").remove();
  50. $.ajax({
  51. type: "POST",
  52. url: '@Url.Action("ExportPartialDeviations", "Deviation")',
  53. data: { customFilters: JSON.stringify(customFilters), displayMode: "popup", exportFormat: "" },
  54. success: function (response) {
  55. parent.$("body").append(response);
  56. parent.exportFormat = "pdf";
  57. }
  58. });
  59. } else if (e.item.name == "ToggleColumnChooser") {
  60. if (devGridViewDeviation.IsCustomizationWindowVisible())
  61. devGridViewDeviation.HideCustomizationWindow();
  62. else
  63. devGridViewDeviation.ShowCustomizationWindow();
  64. } else if (e.item.name == "ResetSettings") {
  65. $.ajax({
  66. type: "POST",
  67. url: '@Url.Action("DeleteCookiesAndSessionVariables", "Global")',
  68. data: { cookies: [ "deviationGridStateCookie" ], sessionVariables: [ "DeviationGridState", "DeviationGridViewState" ] },
  69. success: function (response) {
  70. if (response == "success") {
  71. window.location = window.location;
  72. }
  73. }
  74. });
  75. }
  76. }
  77. function editDeviation(id) {
  78. if (!id) return;
  79. $.ajax({
  80. url: '@Url.Action("EditDeviation", "Deviation")',
  81. data: { Id: id },
  82. success: function (response) {
  83. setTimeout(function () {
  84. $(".deviationEditContainer").remove();
  85. $("body").append(response);
  86. }, 200);
  87. },
  88. error: function () {
  89. alert("error occured");
  90. }
  91. });
  92. }
  93. function confirmDelete(id) {
  94. if (!id) return;
  95. deleteId = id;
  96. $.ajax({
  97. type: "GET",
  98. url: '@Url.Action("GetDeviation", "Deviation")',
  99. data: { Id: id },
  100. success: function (response) {
  101. if (response == "notFound") return;
  102. var deviation = JSON.parse(response);
  103. var popupControl = MVCxClientPopupControl.Cast(devPopupControlDeleteDeviation);
  104. popupControl.SetHeaderText(popupControl.GetHeaderText().replace("{deviation}", deviation.CustomNumber));
  105. $(".dialogText").text($(".dialogText").text().replace("{deviation}", deviation.CustomNumber));
  106. popupControl.Show();
  107. }
  108. });
  109. }
  110. function deleteDeviation() {
  111. $.ajax({
  112. type: "POST",
  113. url: '@Url.Action("DeleteDeviation", "Deviation")',
  114. data: { Id: deleteId },
  115. success: function (response) {
  116. var popupControl = MVCxClientPopupControl.Cast(devPopupControlDeleteDeviation);
  117. popupControl.Hide();
  118. setTimeout(function () {
  119. devGridViewDeviation.PerformCallback();
  120. }, 200);
  121. },
  122. error: function () {
  123. alert("error occured");
  124. }
  125. });
  126. }
  127. </script>
  128. @Html.Partial("~/Views/Deviations/_DeviationGridPartial.cshtml", Model)
  129. @Html.Partial("~/Views/Shared/_PopupDialogYesNo.cshtml", new GreenTree.Nachtragsmanagement.Web.Models.Global.YesNoDialogModel
  130. {
  131. PopupName = "devPopupControlDeleteDeviation",
  132. Content = "<div class='dialogText' style='padding: 12px'>Sind Sie sicher, dass Sie die Vertragsabweichung \"{deviation}\" löschen möchten?</div>",
  133. HeaderText = "\"{deviation}\" löschen",
  134. YesFunction = "function (s, e) { deleteDeviation(); }"
  135. })