From d0be19ef0a0c69a8b472df76bee02209b6acc895 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=8B=E1=85=A2=E1=84=91=E1=85=B3=E1=86=AF=20=E1=84=82?= =?UTF-8?q?=E1=85=A9=E1=84=90=E1=85=B3=E1=84=87=E1=85=AE=E1=86=A8?= Date: Sat, 28 Jul 2018 23:30:32 +0900 Subject: [PATCH] Fix: player list navigator refactoring --- src/web/js/maestro_main.js | 14 -- src/web/js/player_list.js | 4 - src/web/js/player_list_manager.js | 46 ++-- src/web/js/player_list_navigator.js | 106 +++++--- .../module/maestro_section_add_player.html | 187 +++++++------- src/web/module/maestro_section_main.html | 8 +- src/web/module/maestro_section_search.html | 229 +++++++++--------- 7 files changed, 296 insertions(+), 298 deletions(-) diff --git a/src/web/js/maestro_main.js b/src/web/js/maestro_main.js index c3950ab..6715517 100644 --- a/src/web/js/maestro_main.js +++ b/src/web/js/maestro_main.js @@ -5,17 +5,3 @@ let mouseAppList; let typingAppList; let accountValidator = new AccountValidator(); - -/* -function onClickPageNo(item, pageNo) { - let tagDiv = $(item).closest("div"); - // console.log(tagDiv); - let tagDivIDName = tagDiv.prop("id"); - // console.log(tagDivIDName); - - if(tagDivIDName === "add_player_list_navigator") - addPlayerListManager.onClickPageNo(pageNo); - else if(tagDivIDName === "search_player_list_navigator") - searchPlayerListManager.onClickPageNo(pageNo); -} -*/ \ No newline at end of file diff --git a/src/web/js/player_list.js b/src/web/js/player_list.js index 02a9b6d..53ef946 100644 --- a/src/web/js/player_list.js +++ b/src/web/js/player_list.js @@ -52,18 +52,14 @@ class PlayerList { disableItem(item) { $(item.playerID).empty(); $(item.playerName).prop("disabled", true); - // $(item.playerName).removeClass("bg-secondary"); $(item.enterCode).prop("disabled", true); - // $(item.enterCode).removeClass("bg-secondary"); $(item.editButton).prop("disabled", true); $(item.deleteButton).prop("disabled", true); } enableItem(item) { $(item.playerName).prop("disabled", false); - // $(item.playerName).addClass("bg-secondary"); $(item.enterCode).prop("disabled", false); - // $(item.enterCode).addClass("bg-secondary"); $(item.editButton).prop("disabled", false); $(item.deleteButton).prop("disabled", false); } diff --git a/src/web/js/player_list_manager.js b/src/web/js/player_list_manager.js index 2b298fc..1eb3d14 100644 --- a/src/web/js/player_list_manager.js +++ b/src/web/js/player_list_manager.js @@ -8,7 +8,6 @@ this.list = new PlayerList(this.docList, this); this.list.updatePlayerList(null); - // this.listNavigator = new PlayerListNavigator(this, this.list, this.docNav); this.listNavigator = new PlayerListNavigator(this.docNav, this); this.playerCount = 0; @@ -36,9 +35,7 @@ }, (errorMessage, errorCode) => { - if($("#error_message").length) { - $("#error_message").text(errorMessage); - } + showErrorMessage(errorMessage, "error"); } ); @@ -62,9 +59,7 @@ }, (errorMessage, errorCode) => { - if($("#error_message").length) { - $("#error_message").text(errorMessage); - } + showErrorMessage(errorMessage, "error"); } ); @@ -90,9 +85,7 @@ }, (errorMessage, errorCode) => { - if($("#error_message").length) { - $("#error_message").text(errorMessage); - } + showErrorMessage(errorMessage, "error"); } ); @@ -114,12 +107,13 @@ self.activePageNo = 1; self.updateSearchPlayerListPage(this.searchPlayerName, 1); + + if(self.playerCount === 0) + showErrorMessage(this.searchPlayerName + " : 검색 결과가 없습니다.", "info"); }, (errorMessage, errorCode) => { - if($("#error_message").length) { - $("#error_message").text(errorMessage); - } + showErrorMessage(errorMessage, "error"); } ); @@ -144,9 +138,7 @@ }, (errorMessage, errorCode) => { - if($("#error_message").length) { - $("#error_message").text(errorMessage); - } + showErrorMessage(errorMessage, "error"); } ); @@ -163,35 +155,32 @@ let id = $(inputButton).siblings(".player_id"); let playerID = id.text(); - console.log(playerID); + // console.log(playerID); let name = $(inputButton).siblings(".player_name"); let playerName = name.val(); - console.log(playerName); + // console.log(playerName); let enterCode = $(inputButton).siblings(".player_entercode"); let playerEnterCode = enterCode.val(); - console.log(playerEnterCode); + // console.log(playerEnterCode); sendRequestServer( //url, sendParams, onSuccess, onFail, isDebugMode); "./../server/player/edit_player.php", "maestro_id=" + maestroID + "&player_id=" + playerID + "&player_name=" + playerName + "&enter_code=" + playerEnterCode, (jsonData) => { - console.log(jsonData); + // console.log(jsonData); if(this.playerListID === "add_player_list") { self.setupAddPlayerList(); } else if(this.playerListID === "search_player_list") { - // let playerName = $("#search_name").val(); self.setupSearchPlayerList(this.searchPlayerName); } showErrorMessage("학생 데이터가 [ " + playerName + " / " + playerEnterCode + " ] 으로 변경되었습니다.", "success"); }, (errorMessage, errorCode) => { - if($("#error_message").length) { - $("#error_message").text(errorMessage); - } + showErrorMessage(errorMessage, "error"); } ); @@ -205,7 +194,7 @@ let name = $(inputButton).siblings(".player_name"); let playerName = name.val(); - console.log(playerName); + // console.log(playerName); // let clickedObjectID = this.getClickedObjectID(inputButton); @@ -220,8 +209,7 @@ if(this.playerListID === "add_player_list") { self.setupAddPlayerList(); } else if(this.playerListID === "search_player_list") { - // let searchPlayerName = $("#search_name").val(); - self.setupSearchPlayerList(searchPlayerName); + self.setupSearchPlayerList(this.searchPlayerName); } showErrorMessage("[ " + playerName + "] 학생 데이터가 삭제되었습니다.", "success"); @@ -229,9 +217,7 @@ }, (errorMessage, errorCode) => { - if($("#error_message").length) { - $("#error_message").text(errorMessage); - } + showErrorMessage(errorMessage, "error"); } ); diff --git a/src/web/js/player_list_navigator.js b/src/web/js/player_list_navigator.js index 5bb67f1..7e5fbbd 100644 --- a/src/web/js/player_list_navigator.js +++ b/src/web/js/player_list_navigator.js @@ -11,60 +11,67 @@ } updateNavigator(activePageNo, lastPageNo) { - let self = this; - this.activePageNo = activePageNo; this.lastPageNo = lastPageNo; // this.lastPageNo = Math.ceil( (playerCount + 1) / 10 ); $(this.pagination).empty(); + this.makePagination(); + this.applyClickEvent(); + this.disableNavButtons(); + } + makePagination() { + // left arrows let paginationLeftArrows = '\ -
  • \ - \ - \ - First\ - \ -
  • \ +
  • \ + \ + \ + First\ + \ +
  • \ \ -
  • \ - \ - \ - Previous\ - \ -
  • \ +
  • \ + \ + \ + Previous\ + \ +
  • \ \ -
  •  
  • \ -\ '; - +
  •  
  • \ +\ '; $(this.pagination).append(paginationLeftArrows); + // numbers for(let pageNo = 1; pageNo < this.lastPageNo + 1; pageNo++) { $(this.pagination).append( - // " " + pageNo + " " '
  • ' + pageNo + '
  • ' ); } + // right arrows let paginationRightArrows = '\ -
  •  
  • \ +
  •  
  • \ \ -
  • \ - \ - \ - Next\ - \ -
  • \ +
  • \ + \ + \ + Next\ + \ +
  • \ \ -
  • \ - \ - \ - Last\ - \ -
  • \ +
  • \ + \ + \ + Last\ + \ +
  • \ '; - $(this.pagination).append(paginationRightArrows); + $(this.pagination).append(paginationRightArrows); + } + applyClickEvent() { + let self = this; $("[aria-label='First']").click(function() { self.onClickPageNo("first"); @@ -89,6 +96,41 @@ }); } + disableNavButtons() { + /* + console.log(this.activePageNo); + console.log(this.lastPageNo); + console.log($("[aria-label='First']").parent()); + + if(this.activePageNo === 1 || this.lastPageNo === 1) + $("[aria-label='First']").parent().prop("disabled", true); + else + $("[aria-label='First']").parent().prop("disabled", false); + + if(this.activePageNo === 1 || this.lastPageNo === 1) + $("[aria-label='Previous']").parent().prop("disabled", true); + else + $("[aria-label='Previous']").parent().prop("disabled", false); + + for(let pageNo = 1; pageNo < this.lastPageNo + 1; pageNo++) { + if(this.activePageNo === pageNo) + $("[aria-label='" + pageNo + "']").parent().prop("disabled", true); + else + $("[aria-label='" + pageNo + "']").parent().prop("disabled", false); + } + + if(this.activePageNo === this.lastPageNo) + $("[aria-label='Next']").parent().prop("disabled", true); + else + $("[aria-label='Next']").parent().prop("disabled", false); + + if(this.activePageNo === this.lastPageNo) + $("[aria-label='Last']").parent().prop("disabled", true); + else + $("[aria-label='Last']").parent().prop("disabled", false); + */ + } + onClickPageNo(pageNo) { console.log(pageNo); switch(pageNo) { diff --git a/src/web/module/maestro_section_add_player.html b/src/web/module/maestro_section_add_player.html index aa51d38..032dc50 100644 --- a/src/web/module/maestro_section_add_player.html +++ b/src/web/module/maestro_section_add_player.html @@ -3,8 +3,8 @@ $(document).ready(function() { addPlayerListManager = new PlayerListManager( $("#add_player_list"), - // $("#add_player_list_navigator > #page_no_area") - $(".pagination") + // $(".pagination") + $("[aria-label='add_player_list'] > .pagination") ); addPlayerListManager.setupAddPlayerList(); @@ -43,6 +43,7 @@ function addPlayer() { "maestro_id=" + maestroID + "&player_name=" + playerName + "&enter_code=" + enterCode, (jsonData) => { + showErrorMessage(playerName + " : 학생 데이터가 추가되었습니다", "success"); addPlayerListManager.updateAddPlayerListPage(1); onChangePlayerCount(); @@ -74,13 +75,6 @@ function onErrorPlayerPW(message) { -
    -
    -
    -
    -
    - -
    @@ -146,102 +140,98 @@ function onErrorPlayerPW(message) {
    학생 목록
    -
    +
    +
    + + + + + +
    - -
    - - - - - -
    +
    + + + + + +
    -
    - - - - - -
    +
    + + + + + +
    -
    - - - - - -
    +
    + + + + + +
    -
    - - - - - -
    +
    + + + + + +
    -
    - - - - - -
    +
    + + + + + +
    -
    - - - - - -
    +
    + + + + + +
    -
    - - - - - -
    +
    + + + + + +
    -
    - - - - - -
    +
    + + + + + +
    -
    - - - - - -
    +
    + + + + + +
    -
    - - - - - -
    +
    + + + + + +
    -
    - - - - - -
    +
    - -
    - - -
    +
    -
    \ No newline at end of file + \ No newline at end of file diff --git a/src/web/module/maestro_section_main.html b/src/web/module/maestro_section_main.html index 0c1b7ec..54add07 100644 --- a/src/web/module/maestro_section_main.html +++ b/src/web/module/maestro_section_main.html @@ -38,6 +38,11 @@ function onChangePlayerCount() {
    계정 정보 수정 버튼
    +
    +
    +
    +
    +
    -
    @@ -76,4 +80,6 @@ function onChangePlayerCount() {
    +
    + \ No newline at end of file diff --git a/src/web/module/maestro_section_search.html b/src/web/module/maestro_section_search.html index 30533d6..f30c254 100644 --- a/src/web/module/maestro_section_search.html +++ b/src/web/module/maestro_section_search.html @@ -3,8 +3,8 @@ $(document).ready(function() { searchPlayerListManager = new PlayerListManager( $("#search_player_list"), - // $("#search_player_list_navigator > #page_no_area") - $(".pagination") + // $(".pagination") + $("[aria-label='search_player_list'] > .pagination") ); }); @@ -25,119 +25,125 @@ function searchPlayer() {
    -
    -
    -
    -
    +
    +
    학생 검색
    - -

    검색

    - - 학생 이름 -
    -
    - -
    - - - 검색 결과 -
    - - -
    -
    - - - - - + +
    + +
    + +
    +
    -
    - - - - - +
    +
    +
    +
    -
    - - - - - -
    + -
    - - - - - -
    - -
    - - - - - -
    - -
    - - - - - -
    - -
    - - - - - -
    - -
    - - - - - -
    - -
    - - - - - -
    - -
    - - - - - -
    - -
    - - - - - -
    - - +
    -
    \ No newline at end of file