Fix: player list navigator

This commit is contained in:
2018-07-28 17:09:45 +09:00
parent 5ef974206e
commit 7c9439133d
7 changed files with 115 additions and 116 deletions
+37 -51
View File
@@ -4,14 +4,17 @@
let self = this;
this.docList = docList;
this.docNav = docNav;
this.playerListID = $(docList).attr("id");
this.list = new PlayerList(this.docList, this);
this.list.updatePlayerList(null);
this.listNavigator = new PlayerListNavigator(this.docNav);
this.listNavigator = new PlayerListNavigator(this, this.list, this.docNav);
this.playerCount = 0;
this.activePageNo = 1;
this.lastPageNo = 0;
this.searchPlayerName = "";
}
@@ -98,17 +101,18 @@
setupSearchPlayerList(playerName) {
let self = this;
this.searchPlayerName = playerName;
sendRequestServer( //url, sendParams, onSuccess, onFail, isDebugMode);
"./../server/player/search_player_count.php",
"maestro_id=" + maestroID + "&player_name=" + playerName,
"maestro_id=" + maestroID + "&player_name=" + this.searchPlayerName,
(jsonData) => {
self.playerCount = jsonData["playerCount"];
self.lastPageNo = Math.ceil( (self.playerCount + 1) / 10 );
self.activePageNo = 1;
self.updateSearchPlayerListPage(playerName, 1);
self.updateSearchPlayerListPage(this.searchPlayerName, 1);
},
(errorMessage, errorCode) => {
@@ -148,66 +152,39 @@
}
onClickPlayerListPage(pageNo) {
let self = this;
switch(pageNo) {
case "first":
this.activePageNo = 1;
self.loadAddPlayerListPage(self.activePageNo);
return;
case "prev":
if(this.activePageNo > 1)
this.activePageNo -= 1;
self.loadAddPlayerListPage(self.activePageNo);
return;
case "next":
if(this.activePageNo < this.lastPageNo)
this.activePageNo += 1;
self.loadAddPlayerListPage(self.activePageNo);
return;
case "last":
this.loadAddPlayerListPage(this.lastPageNo);
return;
}
this.activePageNo = pageNo;
self.loadAddPlayerListPage(self.activePageNo);
}
editPlayer(inputButton) {
let self = this;
// console.log(inputButton);
let clickedObjectID = this.getClickedObjectID(inputButton);
console.log(inputButton);
// let clickedObjectID = this.getClickedObjectID(inputButton);
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) => {
if(clickedObjectID === "add_player_list") {
console.log(jsonData);
if(this.playerListID === "add_player_list") {
self.setupAddPlayerList();
} else if(clickedObjectID === "search_player_list") {
let playerName = $("#search_name").val();
self.setupSearchPlayerList(playerName);
} else if(this.playerListID === "search_player_list") {
// let playerName = $("#search_name").val();
self.setupSearchPlayerList(this.searchPlayerName);
}
showErrorMessage("학생 데이터가 [ " + playerName + " / " + playerEnterCode + " ] 으로 변경되었습니다.", "success");
},
(errorMessage, errorCode) => {
@@ -225,7 +202,11 @@
let id = $(inputButton).siblings(".player_id");
let playerID = id.text();
let clickedObjectID = this.getClickedObjectID(inputButton);
let name = $(inputButton).siblings(".player_name");
let playerName = name.val();
console.log(playerName);
// let clickedObjectID = this.getClickedObjectID(inputButton);
if(playerID === null || playerID === "")
return;
@@ -235,12 +216,13 @@
"maestro_id=" + maestroID + "&player_id=" + playerID,
(jsonData) => {
if(clickedObjectID === "add_player_list") {
if(this.playerListID === "add_player_list") {
self.setupAddPlayerList();
} else if(clickedObjectID === "search_player_list") {
let playerName = $("#search_name").val();
self.setupSearchPlayerList(playerName);
} else if(this.playerListID === "search_player_list") {
// let searchPlayerName = $("#search_name").val();
self.setupSearchPlayerList(searchPlayerName);
}
showErrorMessage("[ " + playerName + "] 학생 데이터가 삭제되었습니다.", "success");
onChangePlayerCount();
},
@@ -254,11 +236,15 @@
);
}
getClickedObjectID(clickedObject) {
let tagDiv = $(clickedObject).closest(".player_list");
let tagDivID = tagDiv.prop("id");
// console.log(tagDivIDName);
onClickPageNo(pageNo) {
let self = this;
self.activePageNo = pageNo;
if(this.playerListID === "add_player_list") {
self.updateAddPlayerListPage(self.activePageNo);
} else if(this.playerListID === "search_player_list") {
self.updateSearchPlayerListPage(this.searchPlayerName, self.activePageNo);
}
return tagDivID;
}
}