Commit 77868961 by Lee Munkyeong

検索機能のJavascript化

parent 6000dac6
...@@ -113,7 +113,7 @@ ...@@ -113,7 +113,7 @@
<a class="dropdown-item sort-type" data-sort="3" onclick="CHK.changeSortType(this);">報告タイプ順</a> <a class="dropdown-item sort-type" data-sort="3" onclick="CHK.changeSortType(this);">報告タイプ順</a>
<a class="dropdown-item sort-type" data-sort="4" onclick="CHK.changeSortType(this);">閲覧日が新しい順</a> <a class="dropdown-item sort-type" data-sort="4" onclick="CHK.changeSortType(this);">閲覧日が新しい順</a>
</div> </div>
<a href="javascript:CHK_L.sendAppCommand('resetSearch');" class="text-decoration-none py-2 lht-0 d-inline-block ml-3"> <a href="javascript:CHK.resetSearch();" class="text-decoration-none py-2 lht-0 d-inline-block ml-3">
<i class="fa fa-times text-dark"></i> <i class="fa fa-times text-dark"></i>
<span class="d-none d-md-inline text-dark fs-10"> <span class="d-none d-md-inline text-dark fs-10">
リセット リセット
......
...@@ -392,10 +392,8 @@ CHK.initReportApp = function (callback) { ...@@ -392,10 +392,8 @@ CHK.initReportApp = function (callback) {
// 作業一覧JSONデータ // 作業一覧JSONデータ
CHK.loadJson(CHK.jsonPath.operationList, function (json) { CHK.loadJson(CHK.jsonPath.operationList, function (json) {
CHK.operation = json; CHK.operation = json;
if (CHK.isAndroid || CHK.isIOS) { $('#operationTable').empty();
$('#operationTable').empty(); CHK.operation.searchOperationList = json.operationList;
CHK.operation.searchOperationList = json.operationList;
}
//作業一覧描画 //作業一覧描画
CHK.createOperationList(CHK.operation.operationList); CHK.createOperationList(CHK.operation.operationList);
}); });
...@@ -409,7 +407,7 @@ CHK.initReportApp = function (callback) { ...@@ -409,7 +407,7 @@ CHK.initReportApp = function (callback) {
// 作業・カテゴリー関係JSONデータ // 作業・カテゴリー関係JSONデータ
CHK.loadJson(CHK.jsonPath.operationGroupMasterRelationList, function (json) { CHK.loadJson(CHK.jsonPath.operationGroupMasterRelationList, function (json) {
CHK.operationGroupMasterRelation = json;
}); });
// コミュニケーションデータJSONデータ // コミュニケーションデータJSONデータ
...@@ -2744,21 +2742,19 @@ CHK.showWhiteFrame = function() { ...@@ -2744,21 +2742,19 @@ CHK.showWhiteFrame = function() {
*/ */
CHK.createCategory = function(operationGroupMasterList) { CHK.createCategory = function(operationGroupMasterList) {
if (CHK.isAndroid || CHK.isIOS) { $('.group-category-list').remove();
$('.group-category-list').remove(); $("#groupMasterPath").empty();
$("#groupMasterPath").empty(); if (typeof CHK.operationGroupMasterId == 'undefined' || CHK.operationGroupMasterId == 0) {
if (typeof CHK.operationGroupMasterId == 'undefined' || CHK.operationGroupMasterId == 0) { $("#groupMasterPath").append('<li class="breadcrumb-item"><a href="#" class="text-decoration-none text-dark">' + getMsg("all") + '</a></li>');
$("#groupMasterPath").append('<li class="breadcrumb-item"><a href="#" class="text-decoration-none text-dark">' + getMsg("all") + '</a></li>'); } else {
} else { var groupMaster = operationGroupMasterList.filter(it => it.operationGroupMasterId == CHK.operationGroupMasterId)[0];
var groupMaster = operationGroupMasterList.filter(it => it.operationGroupMasterId == CHK.operationGroupMasterId)[0]; var groupMasterPathIdlist = groupMaster.treePath.split('/');
var groupMasterPathIdlist = groupMaster.treePath.split('/'); groupMasterPathIdlist.forEach( function (parentId){
groupMasterPathIdlist.forEach( function (parentId){ var pathOperationGroupMaster = operationGroupMasterList.filter(it => it.operationGroupMasterId == parentId)[0];
var pathOperationGroupMaster = operationGroupMasterList.filter(it => it.operationGroupMasterId == parentId)[0]; $("#groupMasterPath").append('<li class="breadcrumb-item"><a onclick="CHK.changeOperationGroupMaster('
$("#groupMasterPath").append('<li class="breadcrumb-item"><a onclick="CHK.changeOperationGroupMaster(' + pathOperationGroupMaster.operationGroupMasterId + ');" class="text-decoration-none text-dark">'
+ pathOperationGroupMaster.operationGroupMasterId + ');" class="text-decoration-none text-dark">' + pathOperationGroupMaster.operationGroupMasterName + '</a></li>');
+ pathOperationGroupMaster.operationGroupMasterName + '</a></li>'); });
});
}
} }
//サイドメニューカテゴリー構造作成 //サイドメニューカテゴリー構造作成
...@@ -2835,23 +2831,18 @@ CHK.createOperationList = function(operationList, isSearched = false) { ...@@ -2835,23 +2831,18 @@ CHK.createOperationList = function(operationList, isSearched = false) {
} }
switch(sortType) { switch(sortType) {
case CHK_CONSTANT.SORT_TYPE.NAME: case CHK_CONSTANT.SORT_TYPE.NAME:
console.log(sortType);
operationList.sort((a, b) => (a.operationName > b.operationName) ? 1 : -1); operationList.sort((a, b) => (a.operationName > b.operationName) ? 1 : -1);
break; break;
case CHK_CONSTANT.SORT_TYPE.START_DATE_DESC: case CHK_CONSTANT.SORT_TYPE.START_DATE_DESC:
console.log(sortType);
operationList.sort((a, b) => (setOperationDate(a.operationStartDate) < setOperationDate(b.operationStartDate)) ? 1 : -1); operationList.sort((a, b) => (setOperationDate(a.operationStartDate) < setOperationDate(b.operationStartDate)) ? 1 : -1);
break; break;
case CHK_CONSTANT.SORT_TYPE.START_DATE_ASC: case CHK_CONSTANT.SORT_TYPE.START_DATE_ASC:
console.log(sortType);
operationList.sort((a, b) => (setOperationDate(a.operationStartDate) > setOperationDate(b.operationStartDate)) ? 1 : -1); operationList.sort((a, b) => (setOperationDate(a.operationStartDate) > setOperationDate(b.operationStartDate)) ? 1 : -1);
break; break;
case CHK_CONSTANT.SORT_TYPE.TYPE: case CHK_CONSTANT.SORT_TYPE.TYPE:
console.log(sortType);
operationList.sort((a, b) => (a.operationType < b.operationType) ? 1 : -1); operationList.sort((a, b) => (a.operationType < b.operationType) ? 1 : -1);
break; break;
case CHK_CONSTANT.SORT_TYPE.LAST_EDIT_DATE: case CHK_CONSTANT.SORT_TYPE.LAST_EDIT_DATE:
console.log(sortType);
operationList.sort((a, b) => (a.lastEditDate < b.lastEditDate) ? 1 : -1); operationList.sort((a, b) => (a.lastEditDate < b.lastEditDate) ? 1 : -1);
break; break;
} }
...@@ -2905,24 +2896,33 @@ CHK.search = function() { ...@@ -2905,24 +2896,33 @@ CHK.search = function() {
var searchKeyword = $("#searchTaskName").val(); var searchKeyword = $("#searchTaskName").val();
var searchStartDate = $("#searchStartDate").val(); var searchStartDate = $("#searchStartDate").val();
var searchEndDate = $("#searchEndDate").val(); var searchEndDate = $("#searchEndDate").val();
var operationGroupMasterId = CHK.operationGroupMasterId;
var searchResult; var searchResult;
if (CHK.isAndroid) {
searchResult = JSON.parse(android.searchOperationList(searchKeyword, searchStartDate, searchEndDate, CHK.operationGroupMasterId)); searchResult = CHK.operation.operationList.filter(function(operation) {
CHK.isSearched = true; var result = true;
CHK.operation.searchOperationList = searchResult.operationList; if (searchKeyword.length) {
CHK.createOperationList(searchResult.operationList); result = result * operation.operationName.includes(searchKeyword);
// TODO: カテゴリの保存 }
} else if (CHK.isIOS) { if (searchStartDate.length) {
searchResult = CHK_iOS.searchOperationList(searchKeyword, searchStartDate, searchEndDate, CHK.operationGroupMasterId); result = result * (operation.operationEndDate >= searchStartDate);
CHK.isSearched = true; }
CHK.operation.searchOperationList = searchResult.operationList; if (searchEndDate.length) {
CHK.createOperationList(searchResult.operationList); result = result * (operation.operationStartDate <= searchEndDate);
webkit.messageHandlers.saveOperationGroupMaster.postMessage(CHK.operationGroupMasterId); }
let searchButtonTaped = searchKeyword != "" || searchStartDate != "" || searchEndDate != ""; if (operationGroupMasterId != 0) {
if (searchButtonTaped) { var operationGroupMasterIdList = CHK.operationGroupMasterRelation.operationGroupMasterRelationList.filter(function(operationGroupMasterRelation) {
webkit.messageHandlers.showSearchResultToast.postMessage(searchResult.operationList.length); return operationGroupMasterRelation.operationId == operation.operationId;
} })
} result = result * operationGroupMasterIdList.filter(function(operationGroupMaster){
return operationGroupMaster.operationGroupMasterId == operationGroupMasterId;
}).length;
}
return result;
})
CHK.isSearched = true;
CHK.operation.searchOperationList = searchResult;
CHK.createOperationList(searchResult, CHK.isSearched);
}; };
/** /**
...@@ -3009,4 +3009,11 @@ CHK.displayAlert = function(msgCode) { ...@@ -3009,4 +3009,11 @@ CHK.displayAlert = function(msgCode) {
$("#alertMsg").html(getMsg(msgCode)); $("#alertMsg").html(getMsg(msgCode));
$(".alert-overlay").removeClass("d-none"); $(".alert-overlay").removeClass("d-none");
$(".alert-area").removeClass("d-none"); $(".alert-area").removeClass("d-none");
}
CHK.resetSearch = function() {
$('#searchTaskName').val('');
$('#searchStartDate').val('');
$('#searchEndDate').val('');
CHK.changeSortType($('#defaultSort'));
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment