Fix: maestro search bug

This commit is contained in:
2018-09-16 19:57:15 +09:00
parent 14a3665a95
commit cbde6256d6
2 changed files with 41 additions and 53 deletions
+40 -52
View File
@@ -1,5 +1,4 @@
function PlayerListManager(docList, docNav) { function PlayerListManager(docList, docNav) {
var self = this;
this.docList = docList; this.docList = docList;
this.docNav = docNav; this.docNav = docNav;
this.playerListID = $(docList).attr("id"); this.playerListID = $(docList).attr("id");
@@ -17,20 +16,18 @@
PlayerListManager.prototype.setupAddPlayerList = function() { PlayerListManager.prototype.setupAddPlayerList = function() {
var self = this;
sendRequestServer( //url, sendParams, onSuccess, onFail, isDebugMode); sendRequestServer( //url, sendParams, onSuccess, onFail, isDebugMode);
"./../server/player/registered_player_count.php", "./../server/player/registered_player_count.php",
"maestro_id=" + maestroID, "maestro_id=" + maestroID,
function(jsonData) { (function(jsonData) {
self.playerCount = jsonData["playerCount"]; this.playerCount = jsonData["playerCount"];
self.lastPageNo = Math.ceil( (self.playerCount + 1) / 10 ); this.lastPageNo = Math.ceil( (this.playerCount + 1) / 10 );
self.activePageNo = 1; this.activePageNo = 1;
self.loadAddPlayerListPage(self.activePageNo); this.loadAddPlayerListPage(this.activePageNo);
self.listNavigator.updateNavigator(self.activePageNo, self.lastPageNo); this.listNavigator.updateNavigator(this.activePageNo, this.lastPageNo);
}, }).bind(this),
function(errorMessage, errorCode) { function(errorMessage, errorCode) {
showErrorMessage(errorMessage, "error"); showErrorMessage(errorMessage, "error");
@@ -40,7 +37,6 @@ PlayerListManager.prototype.setupAddPlayerList = function() {
} }
PlayerListManager.prototype.loadAddPlayerListPage = function(pageNo) { PlayerListManager.prototype.loadAddPlayerListPage = function(pageNo) {
var self = this;
this.activePageNo = pageNo; this.activePageNo = pageNo;
var pageIndex = pageNo - 1; var pageIndex = pageNo - 1;
@@ -51,10 +47,10 @@ PlayerListManager.prototype.loadAddPlayerListPage = function(pageNo) {
"./../server/player/registered_player_list.php", "./../server/player/registered_player_list.php",
"maestro_id=" + maestroID + "&start_no=" + startNo + "&end_no=" + endNo, "maestro_id=" + maestroID + "&start_no=" + startNo + "&end_no=" + endNo,
function(jsonData) { (function(jsonData) {
self.playerCount = jsonData["playerList"].length; this.playerCount = jsonData["playerList"].length;
self.list.updatePlayerList(jsonData["playerList"]); this.list.updatePlayerList(jsonData["playerList"]);
}, }).bind(this),
function(errorMessage, errorCode) { function(errorMessage, errorCode) {
showErrorMessage(errorMessage, "error"); showErrorMessage(errorMessage, "error");
@@ -65,7 +61,6 @@ PlayerListManager.prototype.loadAddPlayerListPage = function(pageNo) {
PlayerListManager.prototype.updateAddPlayerListPage = function(pageNo) { PlayerListManager.prototype.updateAddPlayerListPage = function(pageNo) {
var self = this;
this.playerListPage = pageNo; this.playerListPage = pageNo;
var pageIndex = pageNo - 1; var pageIndex = pageNo - 1;
@@ -76,11 +71,11 @@ PlayerListManager.prototype.updateAddPlayerListPage = function(pageNo) {
"./../server/player/registered_player_list.php", "./../server/player/registered_player_list.php",
"maestro_id=" + maestroID + "&start_no=" + startNo + "&end_no=" + endNo, "maestro_id=" + maestroID + "&start_no=" + startNo + "&end_no=" + endNo,
function(jsonData) { (function(jsonData) {
self.playerCount = jsonData["playerList"].length; this.playerCount = jsonData["playerList"].length;
self.list.updatePlayerList(jsonData["playerList"]); this.list.updatePlayerList(jsonData["playerList"]);
self.listNavigator.updateNavigator(self.activePageNo, self.lastPageNo); this.listNavigator.updateNavigator(this.activePageNo, this.lastPageNo);
}, }).bind(this),
function(errorMessage, errorCode) { function(errorMessage, errorCode) {
showErrorMessage(errorMessage, "error"); showErrorMessage(errorMessage, "error");
@@ -92,23 +87,22 @@ PlayerListManager.prototype.updateAddPlayerListPage = function(pageNo) {
PlayerListManager.prototype.setupSearchPlayerList = function(playerName) { PlayerListManager.prototype.setupSearchPlayerList = function(playerName) {
var self = this;
this.searchPlayerName = playerName; this.searchPlayerName = playerName;
sendRequestServer( //url, sendParams, onSuccess, onFail, isDebugMode); sendRequestServer( //url, sendParams, onSuccess, onFail, isDebugMode);
"./../server/player/search_player_count.php", "./../server/player/search_player_count.php",
"maestro_id=" + maestroID + "&player_name=" + this.searchPlayerName, "maestro_id=" + maestroID + "&player_name=" + this.searchPlayerName,
function(jsonData) { (function(jsonData) {
self.playerCount = jsonData["playerCount"]; this.playerCount = jsonData["playerCount"];
self.lastPageNo = Math.ceil( (self.playerCount + 1) / 10 ); this.lastPageNo = Math.ceil( (this.playerCount + 1) / 10 );
self.activePageNo = 1; this.activePageNo = 1;
self.updateSearchPlayerListPage(this.searchPlayerName, 1); this.updateSearchPlayerListPage(this.searchPlayerName, 1);
if(self.playerCount === 0) if(this.playerCount === 0)
showErrorMessage(this.searchPlayerName + " : 검색 결과가 없습니다.", "info"); showErrorMessage(this.searchPlayerName + " : 검색 결과가 없습니다.", "info");
}, }).bind(this),
function(errorMessage, errorCode) { function(errorMessage, errorCode) {
showErrorMessage(errorMessage, "error"); showErrorMessage(errorMessage, "error");
@@ -118,7 +112,6 @@ PlayerListManager.prototype.setupSearchPlayerList = function(playerName) {
} }
PlayerListManager.prototype.updateSearchPlayerListPage = function(playerName, pageNo) { PlayerListManager.prototype.updateSearchPlayerListPage = function(playerName, pageNo) {
var self = this;
this.playerListPage = pageNo; this.playerListPage = pageNo;
var pageIndex = pageNo - 1; var pageIndex = pageNo - 1;
@@ -129,11 +122,11 @@ PlayerListManager.prototype.updateSearchPlayerListPage = function(playerName, pa
"./../server/player/search_player_list.php", "./../server/player/search_player_list.php",
"maestro_id=" + maestroID + "&player_name=" + playerName + "&start_no=" + startNo + "&end_no=" + endNo, "maestro_id=" + maestroID + "&player_name=" + playerName + "&start_no=" + startNo + "&end_no=" + endNo,
function(jsonData) { (function(jsonData) {
self.playerCount = jsonData["playerList"].length; this.playerCount = jsonData["playerList"].length;
self.list.updatePlayerList(jsonData["playerList"]); this.list.updatePlayerList(jsonData["playerList"]);
self.listNavigator.updateNavigator(self.activePageNo, self.lastPageNo); this.listNavigator.updateNavigator(this.activePageNo, this.lastPageNo);
}, }).bind(this),
function(errorMessage, errorCode) { function(errorMessage, errorCode) {
showErrorMessage(errorMessage, "error"); showErrorMessage(errorMessage, "error");
@@ -146,8 +139,7 @@ PlayerListManager.prototype.updateSearchPlayerListPage = function(playerName, pa
PlayerListManager.prototype.editPlayer = function(inputButton) { PlayerListManager.prototype.editPlayer = function(inputButton) {
var self = this; // console.log(inputButton);
console.log(inputButton);
// var clickedObjectID = this.getClickedObjectID(inputButton); // var clickedObjectID = this.getClickedObjectID(inputButton);
@@ -167,15 +159,15 @@ PlayerListManager.prototype.editPlayer = function(inputButton) {
"./../server/player/edit_player.php", "./../server/player/edit_player.php",
"maestro_id=" + maestroID + "&player_id=" + playerID + "&player_name=" + playerName + "&enter_code=" + playerEnterCode, "maestro_id=" + maestroID + "&player_id=" + playerID + "&player_name=" + playerName + "&enter_code=" + playerEnterCode,
function(jsonData) { (function(jsonData) {
// console.log(jsonData); // console.log(jsonData);
if(this.playerListID === "add_player_list") { if(this.playerListID === "add_player_list") {
self.setupAddPlayerList(); this.setupAddPlayerList();
} else if(this.playerListID === "search_player_list") { } else if(this.playerListID === "search_player_list") {
self.setupSearchPlayerList(this.searchPlayerName); this.setupSearchPlayerList(this.searchPlayerName);
} }
showErrorMessage("학생 데이터가 [ " + playerName + " / " + playerEnterCode + " ] 으로 변경되었습니다.", "success"); showErrorMessage("학생 데이터가 [ " + playerName + " / " + playerEnterCode + " ] 으로 변경되었습니다.", "success");
}, }).bind(this),
function(errorMessage, errorCode) { function(errorMessage, errorCode) {
showErrorMessage(errorMessage, "error"); showErrorMessage(errorMessage, "error");
@@ -185,8 +177,6 @@ PlayerListManager.prototype.editPlayer = function(inputButton) {
} }
PlayerListManager.prototype.deletePlayer = function(inputButton) { PlayerListManager.prototype.deletePlayer = function(inputButton) {
var self = this;
var id = $(inputButton).siblings(".player_id"); var id = $(inputButton).siblings(".player_id");
var playerID = id.text(); var playerID = id.text();
@@ -203,16 +193,16 @@ PlayerListManager.prototype.deletePlayer = function(inputButton) {
"./../server/player/delete_player.php", "./../server/player/delete_player.php",
"maestro_id=" + maestroID + "&player_id=" + playerID, "maestro_id=" + maestroID + "&player_id=" + playerID,
function(jsonData) { (function(jsonData) {
if(this.playerListID === "add_player_list") { if(this.playerListID === "add_player_list") {
self.setupAddPlayerList(); this.setupAddPlayerList();
} else if(this.playerListID === "search_player_list") { } else if(this.playerListID === "search_player_list") {
self.setupSearchPlayerList(this.searchPlayerName); this.setupSearchPlayerList(this.searchPlayerName);
} }
showErrorMessage("[ " + playerName + "] 학생 데이터가 삭제되었습니다.", "success"); showErrorMessage("[ " + playerName + "] 학생 데이터가 삭제되었습니다.", "success");
onChangePlayerCount(); onChangePlayerCount();
}, }).bind(this),
function(errorMessage, errorCode) { function(errorMessage, errorCode) {
showErrorMessage(errorMessage, "error"); showErrorMessage(errorMessage, "error");
@@ -222,13 +212,11 @@ PlayerListManager.prototype.deletePlayer = function(inputButton) {
} }
PlayerListManager.prototype.onClickPageNo = function(pageNo) { PlayerListManager.prototype.onClickPageNo = function(pageNo) {
var self = this; this.activePageNo = pageNo;
self.activePageNo = pageNo;
if(this.playerListID === "add_player_list") { if(this.playerListID === "add_player_list") {
self.updateAddPlayerListPage(self.activePageNo); this.updateAddPlayerListPage(this.activePageNo);
} else if(this.playerListID === "search_player_list") { } else if(this.playerListID === "search_player_list") {
self.updateSearchPlayerListPage(this.searchPlayerName, self.activePageNo); this.updateSearchPlayerListPage(this.searchPlayerName, this.activePageNo);
} }
} }
+1 -1
View File
@@ -49,7 +49,7 @@ function searchPlayer() {
</div> <!-- 학생 검색 --> </div> <!-- 학생 검색 -->
<div class="col-7 rounded " style="background-color: #ffce54"> <div class="col-7 border border-warning rounded" style="background-color: #ffeab6">
<h5 class="my-3">검색 결과</h5> <h5 class="my-3">검색 결과</h5>
<form id="search_player_list"> <form id="search_player_list">