공지사항 검색, 페이징 추가.
This commit is contained in:
@@ -5,11 +5,19 @@
|
|||||||
* @param {string} sort
|
* @param {string} sort
|
||||||
*/
|
*/
|
||||||
function goPageable(page, size, sort) {
|
function goPageable(page, size, sort) {
|
||||||
|
if (typeof formControl === 'object' && typeof formControl.init === 'function') {
|
||||||
|
setTimeout(() => {
|
||||||
|
formControl.goPageable(page, size, sort);
|
||||||
|
}, 200)
|
||||||
|
} else {
|
||||||
|
|
||||||
let uri = new Uri(location.href);
|
let uri = new Uri(location.href);
|
||||||
uri.replaceQueryParam('page', page).replaceQueryParam('size', size)
|
uri.replaceQueryParam('page', page).replaceQueryParam('size', size)
|
||||||
.replaceQueryParam('sort', convertToPageableSortValue(sort));
|
.replaceQueryParam('sort', convertToPageableSortValue(sort));
|
||||||
|
|
||||||
location.href = uri.toString();
|
location.href = uri.toString();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -24,8 +24,15 @@
|
|||||||
|
|
||||||
<if test="cmd.searchField != null and cmd.searchField != ''">
|
<if test="cmd.searchField != null and cmd.searchField != ''">
|
||||||
<choose>
|
<choose>
|
||||||
|
<when test="cmd.searchField eq 'titleContent'">
|
||||||
|
AND ( a.title ILIKE '%' || #{cmd.searchValue} || '%' OR a.content ILIKE '%' || #{cmd.searchValue} || '%' )
|
||||||
|
</when>
|
||||||
|
|
||||||
<when test="cmd.searchField eq 'title'">
|
<when test="cmd.searchField eq 'title'">
|
||||||
AND a.title ILIKE '%' || #{cmd.searchValue} || '%'
|
AND a.title ILIKE '%' || #{cmd.searchValue} || '%'
|
||||||
|
</when>
|
||||||
|
<when test="cmd.searchField eq 'content'">
|
||||||
|
AND a.content ILIKE '%' || #{cmd.searchValue} || '%'
|
||||||
</when>
|
</when>
|
||||||
<when test="cmd.searchField eq 'updatedBy'">
|
<when test="cmd.searchField eq 'updatedBy'">
|
||||||
AND a.updated_by ILIKE '%' || #{cmd.searchValue} || '%'
|
AND a.updated_by ILIKE '%' || #{cmd.searchValue} || '%'
|
||||||
|
|||||||
@@ -26,7 +26,8 @@ class GetNoticesUIController {
|
|||||||
private final GetNoticesPortIn getNoticesPortIn;
|
private final GetNoticesPortIn getNoticesPortIn;
|
||||||
|
|
||||||
@GetMapping(path = "/info/notice")
|
@GetMapping(path = "/info/notice")
|
||||||
String operate(Model model, @PageableDefault(sort = "createdAt", direction = Sort.Direction.DESC, page = 0, size = 5) Pageable pageable, GetNoticesReqVO reqVO) {
|
String operate(Model model, @PageableDefault(sort = "createdAt", direction = Sort.Direction.DESC, page = 0, size = 5) Pageable pageable
|
||||||
|
, GetNoticesReqVO reqVO) {
|
||||||
reqVO.setSearchOpen("true");
|
reqVO.setSearchOpen("true");
|
||||||
|
|
||||||
Page<GetNotices> notices =
|
Page<GetNotices> notices =
|
||||||
@@ -35,6 +36,7 @@ class GetNoticesUIController {
|
|||||||
new GetNoticesCmd(
|
new GetNoticesCmd(
|
||||||
reqVO.getSearchField(), reqVO.getSearchValue(), reqVO.getSearchOpen()));
|
reqVO.getSearchField(), reqVO.getSearchValue(), reqVO.getSearchOpen()));
|
||||||
|
|
||||||
|
model.addAttribute("reqVO", reqVO);
|
||||||
model.addAttribute("notices", notices);
|
model.addAttribute("notices", notices);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -39,10 +39,10 @@
|
|||||||
|
|
||||||
<div th:fragment="paginationCommon(items)">
|
<div th:fragment="paginationCommon(items)">
|
||||||
<nav class="component-pagination" aria-label="페이지네이션">
|
<nav class="component-pagination" aria-label="페이지네이션">
|
||||||
|
<th:block th:if="${items.totalPages != 1}">
|
||||||
<a th:href="|javascript:goPageable(0, ${items.pageable.pageSize}, '${items.pageable.sort}')|" class="pagination-item first"><span class="hide-txt">첫 페이지로 이동</span></a>
|
<a th:href="|javascript:goPageable(0, ${items.pageable.pageSize}, '${items.pageable.sort}')|" class="pagination-item first"><span class="hide-txt">첫 페이지로 이동</span></a>
|
||||||
<a th:href="|javascript:goPageable(${items.pageable.pageNumber - 1}, ${items.pageable.pageSize}, '${items.pageable.sort}')|" class="pagination-item prev"><span class="hide-txt">이전 페이지로 이동</span></a>
|
<a th:href="|javascript:goPageable(${items.pageable.pageNumber - 1}, ${items.pageable.pageSize}, '${items.pageable.sort}')|" class="pagination-item prev"><span class="hide-txt">이전 페이지로 이동</span></a>
|
||||||
|
</th:block>
|
||||||
|
|
||||||
<th:block th:each="idx : ${#numbers.sequence(0, items.totalPages == 0 ? 0 : items.totalPages - 1)}">
|
<th:block th:each="idx : ${#numbers.sequence(0, items.totalPages == 0 ? 0 : items.totalPages - 1)}">
|
||||||
<th:block th:if="${idx == items.pageable.pageNumber}">
|
<th:block th:if="${idx == items.pageable.pageNumber}">
|
||||||
@@ -52,9 +52,10 @@
|
|||||||
<a th:href="|javascript:goPageable(${idx}, ${items.pageable.pageSize}, '${items.pageable.sort}')|" class="pagination-item" th:text="${idx+1}"></a>
|
<a th:href="|javascript:goPageable(${idx}, ${items.pageable.pageSize}, '${items.pageable.sort}')|" class="pagination-item" th:text="${idx+1}"></a>
|
||||||
</th:block>
|
</th:block>
|
||||||
</th:block>
|
</th:block>
|
||||||
|
<th:block th:if="${items.totalPages != 1}">
|
||||||
<a th:href="|javascript:goPageable(${items.pageable.pageNumber + 1}, ${items.pageable.pageSize}, '${items.pageable.sort}')|" class="pagination-item next"><span class="hide-txt">다음 페이지로 이동</span></a>
|
<a th:href="|javascript:goPageable(${items.pageable.pageNumber + 1}, ${items.pageable.pageSize}, '${items.pageable.sort}')|" class="pagination-item next"><span class="hide-txt">다음 페이지로 이동</span></a>
|
||||||
<a th:href="|javascript:goPageable(${items.pageable.pageNumber-1}, ${items.pageable.pageSize}, '${items.pageable.sort}')|" class="pagination-item last"><span class="hide-txt">마지막 페이지로 이동</span></a>
|
<a th:href="|javascript:goPageable(${items.pageable.pageNumber-1}, ${items.pageable.pageSize}, '${items.pageable.sort}')|" class="pagination-item last"><span class="hide-txt">마지막 페이지로 이동</span></a>
|
||||||
|
</th:block>
|
||||||
</nav>
|
</nav>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,14 @@
|
|||||||
<main id="content" role="main">
|
<main id="content" role="main">
|
||||||
<div class="inner">
|
<div class="inner">
|
||||||
<section class="search-area">
|
<section class="search-area">
|
||||||
<div id="select3" class="component-select bottom-sheet" data-props-default="제목 + 내용" data-props-type="bottomSheet">
|
<form autocomplete="off" method="get" name="reqForm" action="/info/notice" onsubmit="formControl.goSearch()"
|
||||||
|
th:object="${reqVO}"
|
||||||
|
>
|
||||||
|
<input type="hidden" name="sort" id="sort" value="createdAt,DESC"/>
|
||||||
|
<input type="hidden" name="page" id="page" th:value="${notices != null} ? ${notices.number} : 0"/>
|
||||||
|
|
||||||
|
<div id="searchFieldId" class="component-select bottom-sheet" data-props-default="제목 + 내용" data-props-type="bottomSheet">
|
||||||
|
<input type="hidden" name="searchField"/>
|
||||||
<button type="button" class="select-box">
|
<button type="button" class="select-box">
|
||||||
<span class="select-txt">제목 + 내용</span>
|
<span class="select-txt">제목 + 내용</span>
|
||||||
</button>
|
</button>
|
||||||
@@ -19,19 +26,20 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="select-scroll">
|
<div class="select-scroll">
|
||||||
<ul class="">
|
<ul class="">
|
||||||
<li class="option current" data-value="option1">제목 + 내용</li>
|
<li class="option" th:classappend="*{searchField == null or searchField == 'titleContent'} ? ' current' : ''" data-value="titleContent">제목 + 내용</li>
|
||||||
<li class="option" data-value="option2">제목</li>
|
<li class="option" th:classappend="*{searchField == 'title'} ? ' current' : ''" data-value="title">제목</li>
|
||||||
<li class="option" data-value="option3">내용</li>
|
<li class="option" th:classappend="*{searchField == 'content'} ? ' current' : ''" data-value="content">내용</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="component-input">
|
<div class="component-input">
|
||||||
<div class="input-field">
|
<div class="input-field">
|
||||||
<input type="text" id="temp_input_ico_id_0001" placeholder="검색어를 입력해 주세요">
|
<input type="text" id="temp_input_ico_id_0001" placeholder="검색어를 입력해 주세요" name="searchValue" th:field="*{searchValue}"/>
|
||||||
<i class="input-field-ico ico-search" aria-hidden="true"></i>
|
<i class="input-field-ico ico-search" aria-hidden="true" onclick="formControl.goSearch()"></i>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</form>
|
||||||
</section>
|
</section>
|
||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
@@ -84,6 +92,27 @@
|
|||||||
},
|
},
|
||||||
submitted: false,
|
submitted: false,
|
||||||
};
|
};
|
||||||
|
let formControl = {
|
||||||
|
init(){
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO 검색할때 각 페이지에 함수 구현 필요.
|
||||||
|
* TODO 일단 뒤로가기에 대한 부분 정의가 없기에 페이지 이동으로 처리해둠...
|
||||||
|
*/
|
||||||
|
goSearch(){
|
||||||
|
const f = document.reqForm;
|
||||||
|
|
||||||
|
f.searchField.value = document.getElementById('searchFieldId').value;
|
||||||
|
f.submit();
|
||||||
|
},
|
||||||
|
goPageable(page, size, sort){
|
||||||
|
const f = document.reqForm;
|
||||||
|
f.page.value = page;
|
||||||
|
f.submit();
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
</section>
|
</section>
|
||||||
|
|||||||
Reference in New Issue
Block a user