Manager.cshtml 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. @page "{id:int}"
  2. @model Admin.Pages.Forum.Board.ManagerModel
  3. @{
  4. ViewData["Title"] = "게시판 관리 - 관리자";
  5. ViewData["Sector"] = "Manager";
  6. ViewData["BoardID"] = Model.BoardID;
  7. ViewData["BoardList"] = Model.BoardList;
  8. ViewData["QueryString"] = Model.QueryString;
  9. }
  10. <div class="container">
  11. <partial name="_Header" />
  12. <partial name="_StatusMessage" />
  13. <partial name="/Pages/Forum/Board/_NavTabs.cshtml" />
  14. <form id="fAdminWrite" method="post" asp-page-handler="Create" accept-charset="utf-8" autocomplete="off">
  15. <div class="row g-2">
  16. <label class="col-lg-1 col-form-label">관리자</label>
  17. <div class="col-12 col-sm-auto">
  18. <input type="number" name="Input.MemberID" class="form-control" required placeholder="회원 ID" />
  19. </div>
  20. <div class="col-auto col-sm-auto col-form-label">
  21. <div class="form-check form-check-inline">
  22. <input type="checkbox" name="Input.CanEdit" id="CanEdit" class="form-check-input" checked value="true" />
  23. <label for="CanEdit" class="form-check-label">수정</label>
  24. </div>
  25. </div>
  26. <div class="col-auto col-sm-auto col-form-label">
  27. <div class="form-check form-check-inline">
  28. <input type="checkbox" name="Input.CanDelete" id="CanDelete" class="form-check-input" checked value="true" />
  29. <label for="CanDelete" class="form-check-label">삭제</label>
  30. </div>
  31. </div>
  32. <div class="col-12 col-sm-auto text-center">
  33. <button type="submit" class="btn btn-primary w-100">등록</button>
  34. </div>
  35. </div>
  36. </form>
  37. <hr/>
  38. <div class="row g-2 align-items-end">
  39. <div class="col">
  40. Total : @Model.Total.ToString("N0")
  41. </div>
  42. <div class="col text-end">
  43. <button type="button" id="btnFListDelete" class="btn btn-sm btn-danger" form="fAdminList" disabled>삭제</button>
  44. <button type="submit" id="btnFListSave" class="btn btn-sm btn-success" form="fAdminList" @(Model.Total <= 0 ? "disabled" : "")> 저장</button>
  45. </div>
  46. </div>
  47. <div class="table-responsive">
  48. <form id="fAdminList" method="post" asp-page-handler="Save" accept-charset="utf-8" autocomplete="off">
  49. <table class="table table-striped table-bordered table-hover mt-3">
  50. <caption>
  51. 게시판을 운영할 수 있는 관리자를 등록합니다.
  52. </caption>
  53. <colgroup>
  54. <col width="10%"/>
  55. <col width="*"/>
  56. <col width="12%"/>
  57. <col width="12%"/>
  58. <col width="15%"/>
  59. <col width="15%"/>
  60. </colgroup>
  61. <thead>
  62. <tr>
  63. <th>
  64. <div class="form-check form-check-inline">
  65. <input type="checkbox" id="checkedAll" class="form-check-input" value="1" />
  66. <label for="checkedAll" class="form-check-label">ID</label>
  67. </div>
  68. </th>
  69. <th>관리자</th>
  70. <th>수정 권한</th>
  71. <th>삭제 권한</th>
  72. <th>등록일시</th>
  73. <th>수정일시</th>
  74. </tr>
  75. </thead>
  76. <tbody>
  77. @if (Model.Data == null || !Model.Data.Any())
  78. {
  79. <tr>
  80. <td colspan="6">No Data.</td>
  81. </tr>
  82. }
  83. else
  84. {
  85. @foreach (var row in Model.Data)
  86. {
  87. var index = Model.Data.IndexOf(row);
  88. <tr>
  89. <td>
  90. <div class="form-check form-check-inline">
  91. <input type="checkbox" name="CheckList[]" id="CheckList_@index" class="form-check-input list-check-box" value="@row.ID" />
  92. <label for="CheckList_@index" class="form-check-label">@row.ID</label>
  93. </div>
  94. <input type="hidden" name="UpdateItems[@index].ID" value="@row.ID" />
  95. </td>
  96. <td>@row.MemberEmail</td>
  97. <td>
  98. <div class="form-check form-check-inline">
  99. <input type="checkbox" name="UpdateItems[@index].CanEdit" id="UpdateItems_@(index)_CanEdit" class="form-check-input" checked="@row.CanEdit" value="true" />
  100. <label for="UpdateItems_@(index)_CanEdit" class="form-check-label">수정</label>
  101. </div>
  102. </td>
  103. <td>
  104. <div class="form-check form-check-inline">
  105. <input type="checkbox" name="UpdateItems[@index].CanDelete" id="UpdateItems_@(index)_CanDelete" class="form-check-input" checked="@row.CanDelete" value="true" />
  106. <label for="UpdateItems_@(index)_CanDelete" class="form-check-label">삭제</label>
  107. </div>
  108. </td>
  109. <td>@row.CreatedAt</td>
  110. <td>@(row.UpdatedAt ?? "-")</td>
  111. </tr>
  112. }
  113. }
  114. </tbody>
  115. </table>
  116. </form>
  117. </div>
  118. </div>
  119. @section Scripts {
  120. <script>
  121. // 삭제
  122. $(document).on("click", "#btnFListDelete", function() {
  123. if (confirm("삭제 하시겠습니까?")) {
  124. let checked = document.querySelectorAll(".list-check-box:checked");
  125. if (checked.length === 0) return false;
  126. checked.forEach(function(el) {
  127. let form = document.createElement("form");
  128. form.method = "post";
  129. form.action = "?handler=Delete";
  130. let input = document.createElement("input");
  131. input.type = "hidden";
  132. input.name = "DeleteID";
  133. input.value = el.value;
  134. let token = document.querySelector('input[name="__RequestVerificationToken"]');
  135. if (token) {
  136. let tokenInput = document.createElement("input");
  137. tokenInput.type = "hidden";
  138. tokenInput.name = "__RequestVerificationToken";
  139. tokenInput.value = token.value;
  140. form.appendChild(tokenInput);
  141. }
  142. form.appendChild(input);
  143. document.body.appendChild(form);
  144. form.submit();
  145. });
  146. }
  147. return false;
  148. });
  149. // 저장
  150. $(document).on("click", "#btnFListSave", function() {
  151. if (confirm("저장 하시겠습니까?")) {
  152. let form = document.getElementById("fAdminList");
  153. if (form.checkValidity()) { // HTML5 폼 검증 수행
  154. form.submit();
  155. } else {
  156. form.reportValidity();
  157. }
  158. }
  159. return false;
  160. });
  161. </script>
  162. }