Notify.cshtml 5.2 KB

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