Fix: player list navigator refactoring
This commit is contained in:
@@ -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);
|
||||
}
|
||||
*/
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
);
|
||||
|
||||
@@ -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 = '\
|
||||
<li class="page-item">\
|
||||
<a class="page-link" href="javascript:void(0);" aria-label="First">\
|
||||
<span aria-hidden="true">«</span>\
|
||||
<span class="sr-only">First</span>\
|
||||
</a>\
|
||||
</li>\
|
||||
<li class="page-item">\
|
||||
<a class="page-link" href="javascript:void(0);" aria-label="First">\
|
||||
<span aria-hidden="true">«</span>\
|
||||
<span class="sr-only">First</span>\
|
||||
</a>\
|
||||
</li>\
|
||||
\
|
||||
<li class="page-item">\
|
||||
<a class="page-link" href="javascript:void(0);" aria-label="Previous">\
|
||||
<span aria-hidden="true"><</span>\
|
||||
<span class="sr-only">Previous</span>\
|
||||
</a>\
|
||||
</li>\
|
||||
<li class="page-item">\
|
||||
<a class="page-link" href="javascript:void(0);" aria-label="Previous">\
|
||||
<span aria-hidden="true"><</span>\
|
||||
<span class="sr-only">Previous</span>\
|
||||
</a>\
|
||||
</li>\
|
||||
\
|
||||
<li> </li>\
|
||||
\ ';
|
||||
|
||||
<li> </li>\
|
||||
\ ';
|
||||
$(this.pagination).append(paginationLeftArrows);
|
||||
|
||||
// numbers
|
||||
for(let pageNo = 1; pageNo < this.lastPageNo + 1; pageNo++) {
|
||||
$(this.pagination).append(
|
||||
// "<a onClick='onClickPageNo(this, " + pageNo + ")'> " + pageNo + " </a>"
|
||||
'<li class="page-item"><a class="page-link" href="javascript:void(0);" aria-label="' + pageNo + '">' + pageNo + '</a></li>'
|
||||
);
|
||||
}
|
||||
|
||||
// right arrows
|
||||
let paginationRightArrows = '\
|
||||
<li> </li>\
|
||||
<li> </li>\
|
||||
\
|
||||
<li class="page-item">\
|
||||
<a class="page-link" href="javascript:void(0);" aria-label="Next">\
|
||||
<span aria-hidden="true">></span>\
|
||||
<span class="sr-only">Next</span>\
|
||||
</a>\
|
||||
</li>\
|
||||
<li class="page-item">\
|
||||
<a class="page-link" href="javascript:void(0);" aria-label="Next">\
|
||||
<span aria-hidden="true">></span>\
|
||||
<span class="sr-only">Next</span>\
|
||||
</a>\
|
||||
</li>\
|
||||
\
|
||||
<li class="page-item">\
|
||||
<a class="page-link" href="javascript:void(0);" aria-label="Last">\
|
||||
<span aria-hidden="true">»</span>\
|
||||
<span class="sr-only">Last</span>\
|
||||
</a>\
|
||||
</li>\
|
||||
<li class="page-item">\
|
||||
<a class="page-link" href="javascript:void(0);" aria-label="Last">\
|
||||
<span aria-hidden="true">»</span>\
|
||||
<span class="sr-only">Last</span>\
|
||||
</a>\
|
||||
</li>\
|
||||
';
|
||||
$(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) {
|
||||
|
||||
Reference in New Issue
Block a user