Manager.cshtml 7.1 KB

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