Commit 77868961 by Lee Munkyeong

検索機能のJavascript化

parent 6000dac6
......@@ -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="4" onclick="CHK.changeSortType(this);">閲覧日が新しい順</a>
</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>
<span class="d-none d-md-inline text-dark fs-10">
リセット
......
......@@ -392,10 +392,8 @@ CHK.initReportApp = function (callback) {
// 作業一覧JSONデータ
CHK.loadJson(CHK.jsonPath.operationList, function (json) {
CHK.operation = json;
if (CHK.isAndroid || CHK.isIOS) {
$('#operationTable').empty();
CHK.operation.searchOperationList = json.operationList;
}
$('#operationTable').empty();
CHK.operation.searchOperationList = json.operationList;
//作業一覧描画
CHK.createOperationList(CHK.operation.operationList);
});
......@@ -409,7 +407,7 @@ CHK.initReportApp = function (callback) {
// 作業・カテゴリー関係JSONデータ
CHK.loadJson(CHK.jsonPath.operationGroupMasterRelationList, function (json) {
CHK.operationGroupMasterRelation = json;
});
// コミュニケーションデータJSONデータ
......@@ -2744,21 +2742,19 @@ CHK.showWhiteFrame = function() {
*/
CHK.createCategory = function(operationGroupMasterList) {
if (CHK.isAndroid || CHK.isIOS) {
$('.group-category-list').remove();
$("#groupMasterPath").empty();
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>');
} else {
var groupMaster = operationGroupMasterList.filter(it => it.operationGroupMasterId == CHK.operationGroupMasterId)[0];
var groupMasterPathIdlist = groupMaster.treePath.split('/');
groupMasterPathIdlist.forEach( function (parentId){
var pathOperationGroupMaster = operationGroupMasterList.filter(it => it.operationGroupMasterId == parentId)[0];
$("#groupMasterPath").append('<li class="breadcrumb-item"><a onclick="CHK.changeOperationGroupMaster('
+ pathOperationGroupMaster.operationGroupMasterId + ');" class="text-decoration-none text-dark">'
+ pathOperationGroupMaster.operationGroupMasterName + '</a></li>');
});
}
$('.group-category-list').remove();
$("#groupMasterPath").empty();
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>');
} else {
var groupMaster = operationGroupMasterList.filter(it => it.operationGroupMasterId == CHK.operationGroupMasterId)[0];
var groupMasterPathIdlist = groupMaster.treePath.split('/');
groupMasterPathIdlist.forEach( function (parentId){
var pathOperationGroupMaster = operationGroupMasterList.filter(it => it.operationGroupMasterId == parentId)[0];
$("#groupMasterPath").append('<li class="breadcrumb-item"><a onclick="CHK.changeOperationGroupMaster('
+ pathOperationGroupMaster.operationGroupMasterId + ');" class="text-decoration-none text-dark">'
+ pathOperationGroupMaster.operationGroupMasterName + '</a></li>');
});
}
//サイドメニューカテゴリー構造作成
......@@ -2835,23 +2831,18 @@ CHK.createOperationList = function(operationList, isSearched = false) {
}
switch(sortType) {
case CHK_CONSTANT.SORT_TYPE.NAME:
console.log(sortType);
operationList.sort((a, b) => (a.operationName > b.operationName) ? 1 : -1);
break;
case CHK_CONSTANT.SORT_TYPE.START_DATE_DESC:
console.log(sortType);
operationList.sort((a, b) => (setOperationDate(a.operationStartDate) < setOperationDate(b.operationStartDate)) ? 1 : -1);
break;
case CHK_CONSTANT.SORT_TYPE.START_DATE_ASC:
console.log(sortType);
operationList.sort((a, b) => (setOperationDate(a.operationStartDate) > setOperationDate(b.operationStartDate)) ? 1 : -1);
break;
case CHK_CONSTANT.SORT_TYPE.TYPE:
console.log(sortType);
operationList.sort((a, b) => (a.operationType < b.operationType) ? 1 : -1);
break;
case CHK_CONSTANT.SORT_TYPE.LAST_EDIT_DATE:
console.log(sortType);
operationList.sort((a, b) => (a.lastEditDate < b.lastEditDate) ? 1 : -1);
break;
}
......@@ -2905,24 +2896,33 @@ CHK.search = function() {
var searchKeyword = $("#searchTaskName").val();
var searchStartDate = $("#searchStartDate").val();
var searchEndDate = $("#searchEndDate").val();
var operationGroupMasterId = CHK.operationGroupMasterId;
var searchResult;
if (CHK.isAndroid) {
searchResult = JSON.parse(android.searchOperationList(searchKeyword, searchStartDate, searchEndDate, CHK.operationGroupMasterId));
CHK.isSearched = true;
CHK.operation.searchOperationList = searchResult.operationList;
CHK.createOperationList(searchResult.operationList);
// TODO: カテゴリの保存
} else if (CHK.isIOS) {
searchResult = CHK_iOS.searchOperationList(searchKeyword, searchStartDate, searchEndDate, CHK.operationGroupMasterId);
CHK.isSearched = true;
CHK.operation.searchOperationList = searchResult.operationList;
CHK.createOperationList(searchResult.operationList);
webkit.messageHandlers.saveOperationGroupMaster.postMessage(CHK.operationGroupMasterId);
let searchButtonTaped = searchKeyword != "" || searchStartDate != "" || searchEndDate != "";
if (searchButtonTaped) {
webkit.messageHandlers.showSearchResultToast.postMessage(searchResult.operationList.length);
}
}
searchResult = CHK.operation.operationList.filter(function(operation) {
var result = true;
if (searchKeyword.length) {
result = result * operation.operationName.includes(searchKeyword);
}
if (searchStartDate.length) {
result = result * (operation.operationEndDate >= searchStartDate);
}
if (searchEndDate.length) {
result = result * (operation.operationStartDate <= searchEndDate);
}
if (operationGroupMasterId != 0) {
var operationGroupMasterIdList = CHK.operationGroupMasterRelation.operationGroupMasterRelationList.filter(function(operationGroupMasterRelation) {
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) {
$("#alertMsg").html(getMsg(msgCode));
$(".alert-overlay").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