_ConfigItemEditPartial.cshtml 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. @using GreenTree.Nachtragsmanagement.Web.Extensions
  2. @model GreenTree.Nachtragsmanagement.Web.Models.Config.ConfigItemDataModel
  3. <div class="configItemEditContainer">
  4. <script>
  5. function saveConfigItem() {
  6. var form = $("#configItemEditForm");
  7. $(form).submit(function (e) {
  8. $.ajax({
  9. type: "POST",
  10. url: '@Url.Action("EditConfigItem", "Misc")',
  11. data: form.serialize(),
  12. success: function (response) {
  13. setTimeout(function () {
  14. $(".configItemEditContainer").remove();
  15. if (response == "success") {
  16. parent.callCustomEventListener('ConfigItemDataCallbackEventReceiver');
  17. } else {
  18. $("body").append(response);
  19. }
  20. }, 200);
  21. }
  22. });
  23. e.preventDefault();
  24. });
  25. form.submit();
  26. }
  27. function getValueTypePartialEdit() {
  28. $.ajax({
  29. type: "GET",
  30. url: '@Url.Action("GetValueTypePartialEdit", "Misc")',
  31. data: { typeFullName: TypeFullName.GetValue() },
  32. success: function (response) {
  33. $(".configItemValueEdit").replaceWith(response);
  34. }
  35. });
  36. }
  37. </script>
  38. @Html.DevExpress().PopupControl(s =>
  39. {
  40. s.Name = "devPopupControlEditConfigItem";
  41. if (Model.Id == -1)
  42. s.HeaderText = "Neue Einstellung erstellen";
  43. else
  44. {
  45. if (Model.Name.Length > 40)
  46. s.HeaderText = "\"" + Model.Name.Substring(0, 15) + " ... " + Model.Name.Substring(Model.Name.Length - 15, 15) + "\" bearbeiten";
  47. }
  48. s.Modal = true;
  49. s.Width = new Unit(500, UnitType.Pixel);
  50. s.CloseAction = CloseAction.CloseButton;
  51. s.PopupHorizontalAlign = PopupHorizontalAlign.WindowCenter;
  52. s.PopupVerticalAlign = PopupVerticalAlign.TopSides;
  53. s.PopupVerticalOffset = 20;
  54. s.AllowDragging = false;
  55. s.AllowResize = false;
  56. s.ShowFooter = false;
  57. s.ShowOnPageLoad = true;
  58. s.SetContent(() =>
  59. {
  60. using (Html.BeginForm("EditConfigItem", "Deviation", FormMethod.Post, new { id = "configItemEditForm" }))
  61. {
  62. ViewContext.Writer.Write("<div class='editFormWrapper'>");
  63. ViewContext.Writer.Write("<input type=\"hidden\" value=\"" + Model.Id + "\" id=\"Id\" name=\"Id\" />");
  64. ViewContext.Writer.Write(Html.CustomLabelFor(m => m.Name, "Name:"));
  65. ViewContext.Writer.Write(Html.ValidationMessageFor(m => m.Name).ToHtmlString());
  66. Html.DevExpress().TextBoxFor(m => m.Name, t =>
  67. {
  68. t.Width = new Unit(100, UnitType.Percentage);
  69. }).Render();
  70. ViewContext.Writer.Write(Html.CustomLabelFor(m => m.TypeFullName, "Datentyp:"));
  71. ViewContext.Writer.Write(Html.ValidationMessageFor(m => m.TypeFullName).ToHtmlString());
  72. Html.DevExpress().ComboBoxFor(m => m.TypeFullName, t =>
  73. {
  74. t.Width = new Unit(60, UnitType.Percentage);
  75. t.Properties.Items.AddRange(
  76. GreenTree.Nachtragsmanagement.Web.Models.Config.ConfigItemDataModel.FullTypeTranslations
  77. .Select(f => new ListEditItem(f.Value, f.Key))
  78. .ToList());
  79. t.Properties.ClientSideEvents.SelectedIndexChanged = "function (s, e) { getValueTypePartialEdit(); }";
  80. }).Render();
  81. ViewContext.Writer.Write("<div class=\"configItemEditContainerPlaceholder\">");
  82. {
  83. ViewContext.Writer.Write(Html.CustomLabelFor(m => m.Value, "Wert:"));
  84. ViewContext.Writer.Write(Html.ValidationMessageFor(m => m.Value).ToHtmlString());
  85. Html.RenderPartial("~/Views/Config/_ConfigItemValueEditPartial.cshtml", Model);
  86. }
  87. ViewContext.Writer.Write("</div>");
  88. ViewContext.Writer.Write(Html.CustomLabelFor(m => m.Description, "Beschreibung:"));
  89. ViewContext.Writer.Write(Html.ValidationMessageFor(m => m.Description).ToHtmlString());
  90. Html.DevExpress().MemoFor(m => m.Description, t =>
  91. {
  92. t.Width = new Unit(100, UnitType.Percentage);
  93. t.Height = new Unit(80, UnitType.Pixel);
  94. }).Render();
  95. ViewContext.Writer.Write("</div>");
  96. Html.RenderPartial(
  97. "~/Views/Shared/_PopupButtonPanel.cshtml",
  98. new GreenTree.Nachtragsmanagement.Web.Models.Global.PopupModel
  99. {
  100. PopupName = "devPopupControlEditConfigItem",
  101. AcceptFunction = "function (s, e) { saveConfigItem(); }"
  102. }
  103. );
  104. }
  105. });
  106. s.Styles.Content.Paddings.Padding = new Unit(0);
  107. s.Styles.ModalBackground.Opacity = 0;
  108. }).GetHtml()
  109. </div>