View.cshtml 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  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("DeleteCookiesSessionVariablesAndUserConfigs", "Global")',
  68. data: {
  69. cookies: ["deviationGridStateCookie"],
  70. sessionVariables: ["DeviationGridState", "DeviationGridViewState"],
  71. userConfigItemNames: ["DeviationGridLayoutState"]
  72. },
  73. success: function (response) {
  74. if (response == "success") {
  75. window.location = window.location;
  76. }
  77. }
  78. });
  79. }
  80. }
  81. function editDeviation(id) {
  82. if (!id) return;
  83. $.ajax({
  84. url: '@Url.Action("EditDeviation", "Deviation")',
  85. data: { Id: id },
  86. success: function (response) {
  87. setTimeout(function () {
  88. $(".deviationEditContainer").remove();
  89. $("body").append(response);
  90. }, 200);
  91. },
  92. error: function () {
  93. alert("error occured");
  94. }
  95. });
  96. }
  97. function confirmDelete(id) {
  98. if (!id) return;
  99. deleteId = id;
  100. $.ajax({
  101. type: "GET",
  102. url: '@Url.Action("GetDeviation", "Deviation")',
  103. data: { Id: id },
  104. success: function (response) {
  105. if (response == "notFound") return;
  106. var deviation = JSON.parse(response);
  107. var popupControl = MVCxClientPopupControl.Cast(devPopupControlDeleteDeviation);
  108. popupControl.SetHeaderText(popupControl.GetHeaderText().replace("{deviation}", deviation.CustomNumber));
  109. $(".dialogText").text($(".dialogText").text().replace("{deviation}", deviation.CustomNumber));
  110. popupControl.Show();
  111. }
  112. });
  113. }
  114. function deleteDeviation() {
  115. $.ajax({
  116. type: "POST",
  117. url: '@Url.Action("DeleteDeviation", "Deviation")',
  118. data: { Id: deleteId },
  119. success: function (response) {
  120. var popupControl = MVCxClientPopupControl.Cast(devPopupControlDeleteDeviation);
  121. popupControl.Hide();
  122. setTimeout(function () {
  123. devGridViewDeviation.PerformCallback();
  124. }, 200);
  125. },
  126. error: function () {
  127. alert("error occured");
  128. }
  129. });
  130. }
  131. </script>
  132. @Html.Partial("~/Views/Deviations/_DeviationGridPartial.cshtml", Model)
  133. @Html.Partial("~/Views/Shared/_PopupDialogYesNo.cshtml", new GreenTree.Nachtragsmanagement.Web.Models.Global.YesNoDialogModel
  134. {
  135. PopupName = "devPopupControlDeleteDeviation",
  136. Content = "<div class='dialogText' style='padding: 12px'>Sind Sie sicher, dass Sie die Vertragsabweichung \"{deviation}\" löschen möchten?</div>",
  137. HeaderText = "\"{deviation}\" löschen",
  138. YesFunction = "function (s, e) { deleteDeviation(); }"
  139. })