Notify.cshtml 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. @model Admin.ViewModels.Forum.Board.Meta.IndexViewModel
  2. @using Library.Constants
  3. @{
  4. ViewData["Title"] = "게시판 관리 - 알림";
  5. var notifyList = Model.NotifyList;
  6. }
  7. <div class="container">
  8. <partial name="~/Views/Forum/Board/Meta/_Header.cshtml" />
  9. <partial name="_StatusMessage" />
  10. <partial name="~/Views/Forum/Board/Meta/_Navbar.cshtml" />
  11. <form name="f_admin_write" id="fAdminWrite" method="post" accept-charset="utf-8" autocomplete="off" action="/Forum/Board/Meta/Update/Notify" enctype="multipart/form-data">
  12. <input type="hidden" name="BoardMeta.Board.Code" value="@Model.Board.Code" />
  13. <input type="hidden" asp-for="BoardMeta.ID" />
  14. <input type="hidden" asp-for="BoardMeta.BoardID" />
  15. <h5>이메일 알림</h5>
  16. <p class="text-muted form-text">이메일 알림이 양식에 맞추어 아래 대상자에게 발송됩니다.</p>
  17. <div class="row mb-3">
  18. <label class="col-md-2 col-form-label">게시글 작성 시</label>
  19. <div class="col-md-10 align-self-center">
  20. @if (notifyList is not null) {
  21. @foreach (var item in notifyList)
  22. {
  23. var notifyValue = (BoardConst.Notify)Enum.Parse(typeof(BoardConst.Notify), item.Value);
  24. <div class="form-check form-check-inline">
  25. <input type="checkbox" name="PostWriteNotify[]" value="@item.Value" id="postWriteNotify_@item.Value" class="form-check-input" checked="@Model.BoardMeta.Notify.PostWriteNotifyEnum.HasFlag(notifyValue)" />
  26. <label for="postWriteNotify_@item.Value" class="form-check-label">@item.Text</label>
  27. </div>
  28. }
  29. }
  30. </div>
  31. </div>
  32. <div class="row mb-3">
  33. <label class="col-md-2 col-form-label">댓글 작성 시</label>
  34. <div class="col-md-10 align-self-center">
  35. @if (notifyList is not null) {
  36. @foreach (var item in notifyList)
  37. {
  38. var notifyValue = (BoardConst.Notify)Enum.Parse(typeof(BoardConst.Notify), item.Value);
  39. <div class="form-check form-check-inline">
  40. <input type="checkbox" name="CommentWriteNotify[]" value="@item.Value" id="commentWriteNotify_@item.Value" class="form-check-input" checked="@Model.BoardMeta.Notify.CommentWriteNotifyEnum.HasFlag(notifyValue)" />
  41. <label for="commentWriteNotify_@item.Value" class="form-check-label">@item.Text</label>
  42. </div>
  43. }
  44. }
  45. </div>
  46. </div>
  47. <div class="row mb-3">
  48. <label for="Notify_ReplyWriteNotify" class="col-md-2 col-form-label">답글 작성 시</label>
  49. <div class="col-md-10 align-self-center">
  50. @if (notifyList is not null) {
  51. @foreach (var item in notifyList)
  52. {
  53. var notifyValue = (BoardConst.Notify)Enum.Parse(typeof(BoardConst.Notify), item.Value);
  54. <div class="form-check form-check-inline">
  55. <input type="checkbox" name="ReplyWriteNotify[]" value="@item.Value" id="replyWriteNotify_@item.Value" class="form-check-input" checked="@Model.BoardMeta.Notify.ReplyWriteNotifyEnum.HasFlag(notifyValue)" />
  56. <label for="replyWriteNotify_@item.Value" class="form-check-label">@item.Text</label>
  57. </div>
  58. }
  59. }
  60. </div>
  61. </div>
  62. <input type="hidden" name="BoardMeta.Notify.PostWriteNotify" id="PostWriteNotifyValue" />
  63. <input type="hidden" name="BoardMeta.Notify.CommentWriteNotify" id="CommentWriteNotifyValue" />
  64. <input type="hidden" name="BoardMeta.Notify.ReplyWriteNotify" id="ReplyWriteNotifyValue" />
  65. <hr/>
  66. <div class="d-grid gap-2 text-center d-md-block">
  67. <button type="submit" class="btn btn-sm btn-success">저장</button>
  68. <a href="/Forum/Board/List?@ViewBag.QueryString" class="btn btn-sm btn-secondary">취소</a>
  69. </div>
  70. </form>
  71. </div>
  72. @section Scripts {
  73. <script>
  74. document.addEventListener("DOMContentLoaded", function () {
  75. function calculateFlagValue(groupName) {
  76. let checkboxes = document.querySelectorAll(`input[name="${groupName}[]"]:checked`);
  77. let flagValue = 0;
  78. checkboxes.forEach(checkbox => {
  79. flagValue |= parseInt(checkbox.value, 10);
  80. });
  81. document.getElementById(`${groupName}Value`).value = flagValue;
  82. }
  83. function updateAllFlags() {
  84. calculateFlagValue("PostWriteNotify");
  85. calculateFlagValue("CommentWriteNotify");
  86. calculateFlagValue("ReplyWriteNotify");
  87. }
  88. document.querySelectorAll('input[type="checkbox"]').forEach(checkbox => {
  89. checkbox.addEventListener("change", updateAllFlags);
  90. });
  91. document.getElementById("fAdminWrite").addEventListener("submit", (e) => {
  92. updateAllFlags();
  93. });
  94. });
  95. </script>
  96. }