Prefix.cshtml 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. @model Admin.ViewModels.Forum.Board.Prefix.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-7 col-sm-auto">
  18. <div class="input-group">
  19. <div class="input-group-text">
  20. <input type="color" name="color" class="h-100" maxlength="10" required />
  21. </div>
  22. <input type="text" name="name" class="form-control" maxlength="20" required placeholder="이름" />
  23. </div>
  24. </div>
  25. <div class="col col-lg-auto">
  26. <input type="number" name="order" class="form-control" min="-999" max="999" required placeholder="순서" />
  27. </div>
  28. <div class="col-12 col-sm-auto text-center">
  29. <button type="submit" class="btn btn-primary w-100">등록</button>
  30. </div>
  31. </div>
  32. </form>
  33. <hr/>
  34. <div class="row g-2 align-items-end">
  35. <div class="col">
  36. Total : @Model.Total.ToString("N0")
  37. </div>
  38. <div class="col text-end">
  39. <button type="button" id="btnListDelete" class="btn btn-sm btn-danger" form="fAdminList" data-action="/Forum/Board/Prefix/@Model.BoardID/Delete" disabled>삭제</button>
  40. <button type="submit" id="btnListSave" class="btn btn-sm btn-success" form="fAdminList" @(Model.Total <= 0 ? "disabled" : "")> 저장</button>
  41. </div>
  42. </div>
  43. <div class="table-responsive">
  44. <form id="fAdminList" asp-action="Update" method="post" accept-charset="utf-8" autocomplete="off">
  45. <input type="hidden" name="boardID" value="@Model.BoardID" />
  46. <table class="table table-striped table-bordered table-hover mt-3">
  47. <caption>
  48. 게시글 제목에 특정 단어를 넣는 기능입니다. 최대 10개를 추가할 수 있습니다.
  49. </caption>
  50. <colgroup>
  51. <col width="5%"/>
  52. <col width="*"/>
  53. <col width="*"/>
  54. <col width="*"/>
  55. <col width="*"/>
  56. <col width="12%" />
  57. <col width="12%"/>
  58. </colgroup>
  59. <thead>
  60. <tr>
  61. <th>
  62. <div class="form-check form-check-inline">
  63. <input type="checkbox" id="checkedAll" class="form-check-input" value="1" />
  64. <label for="checkedAll" class="form-check-label">ID</label>
  65. </div>
  66. </th>
  67. <th>말머리</th>
  68. <th>순서</th>
  69. <th>사용 횟수</th>
  70. <th>사용 여부</th>
  71. <th>등록일시</th>
  72. <th>수정일시</th>
  73. </tr>
  74. </thead>
  75. <tbody>
  76. @if (Model.Data == null || !Model.Data.Any())
  77. {
  78. <tr>
  79. <td colspan="7">No Data.</td>
  80. </tr>
  81. }
  82. else
  83. {
  84. @foreach (var row in Model.Data)
  85. {
  86. var index = Model.Data.IndexOf(row);
  87. <tr>
  88. <td>
  89. <div class="form-check form-check-inline">
  90. <input type="checkbox" name="CheckList[]" id="CheckList_@index" class="form-check-input list-check-box" value="@row.ID" />
  91. <label for="CheckList_@index" class="form-check-label">@row.ID</label>
  92. </div>
  93. <input type="hidden" name="Items[@index].ID" class="form-control-plaintext text-center" value="@row.ID" />
  94. </td>
  95. <td>
  96. <div class="input-group">
  97. <div class="input-group-text">
  98. <input type="color" name="Items[@index].Color" class="h-100" maxlength="10" value="@row.Color" required />
  99. </div>
  100. <input type="text" name="Items[@index].Name" class="form-control" maxlength="20" value="@row.Name" required />
  101. </div>
  102. </td>
  103. <td>
  104. <input type="number" name="Items[@index].Order" class="form-control" min="-999" max="999" value="@row.Order" required />
  105. </td>
  106. <td>@row.Posts</td>
  107. <td>
  108. <div class="form-check form-check-inline">
  109. <input type="checkbox" name="Items[@index].IsActive" id="Items_@(index)_IsActive" class="form-check-input" checked="@row.IsActive" value="true" />
  110. <label for="Items_@(index)_IsActive" class="form-check-label">사용</label>
  111. </div>
  112. </td>
  113. <td>@row.CreatedAt.GetDateAt()</td>
  114. <td>@(row.UpdatedAt.GetDateAt() ?? "-")</td>
  115. </tr>
  116. }
  117. }
  118. </tbody>
  119. </table>
  120. </form>
  121. </div>
  122. </div>
  123. @section Scripts {
  124. <script>
  125. // 저장
  126. $(document).on("click", "#btnListSave", function() {
  127. if (confirm("저장 하시겠습니까?")) {
  128. let form = document.getElementById("fAdminList");
  129. if (form.checkValidity()) { // HTML5 폼 검증 수행
  130. form.submit();
  131. } else {
  132. form.reportValidity();
  133. }
  134. }
  135. return false;
  136. });
  137. </script>
  138. }