_UserSearchPartial.cshtml 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. @using GreenTree.Nachtragsmanagement.Web.Extensions
  2. @model IEnumerable<GreenTree.Nachtragsmanagement.Core.Authentication.ActiveDirectoryUser>
  3. <div class="userSearchContainer">
  4. <script>
  5. function selectUser() {
  6. var searchVal = CustomNumber.GetText();
  7. if (!searchVal) return;
  8. $.ajax({
  9. type: "POST",
  10. url: '@Url.Action("SelectUser", "Admin")',
  11. data: { accountName: devListBoxSearchUsers.GetValue() },
  12. success: function (response) {
  13. setTimeout(function () {
  14. if (!response) return;
  15. CustomNumber.SetText(response.AccountName);
  16. Forename.SetText(response.ForeName);
  17. Lastname.SetText(response.LastName);
  18. MailAddress.SetText(response.Mail);
  19. Password.SetEnabled(false);
  20. $(Password.GetMainElement()).css("background", "#efefef");
  21. $(Password.GetMainElement()).find("input").css("background", "#efefef");
  22. IsActiveDirectory.SetChecked(true);
  23. devPopupControlSearchUser.Hide();
  24. $("#imgPasswordInfo").css("display", "block");
  25. }, 200);
  26. },
  27. error: function () {
  28. alert("error occured");
  29. }
  30. });
  31. }
  32. </script>
  33. @Html.DevExpress().PopupControl(s =>
  34. {
  35. s.Name = "devPopupControlSearchUser";
  36. s.HeaderText = "Benutzersuche";
  37. s.Modal = true;
  38. s.Width = new Unit(280, UnitType.Pixel);
  39. s.CloseAction = CloseAction.CloseButton;
  40. s.PopupHorizontalAlign = PopupHorizontalAlign.WindowCenter;
  41. s.PopupVerticalAlign = PopupVerticalAlign.WindowCenter;
  42. s.AllowDragging = false;
  43. s.AllowResize = false;
  44. s.ShowFooter = false;
  45. s.ShowOnPageLoad = true;
  46. s.SetContent(() =>
  47. {
  48. using (Html.BeginForm("SelectUser", "Admin", FormMethod.Post, new { id = "userSelectForm" }))
  49. {
  50. ViewContext.Writer.Write("<div class='editFormWrapper'>");
  51. ViewContext.Writer.Write("Suchergebnis:");
  52. Html.DevExpress().ListBox(t =>
  53. {
  54. t.Name = "devListBoxSearchUsers";
  55. t.Width = new Unit(100, UnitType.Percentage);
  56. t.Height = new Unit(210, UnitType.Pixel);
  57. t.Properties.ValueField = "AccountName";
  58. t.Properties.TextField = "Name";
  59. }).BindList(Model).Render();
  60. ViewContext.Writer.Write("</div>");
  61. Html.RenderPartial(
  62. "~/Views/Shared/_PopupButtonPanel.cshtml",
  63. new GreenTree.Nachtragsmanagement.Web.Models.Global.PopupModel
  64. {
  65. PopupName = "devPopupControlSearchUser",
  66. AcceptFunction = "function (s, e) { selectUser(); }"
  67. }
  68. );
  69. }
  70. });
  71. s.Styles.Content.Paddings.Padding = new Unit(0);
  72. s.Styles.ModalBackground.Opacity = 0;
  73. }).GetHtml()
  74. </div>