Commit 6b6540e2 by Kang Donghun

Merge branch 'feature/1.0_check_web_dev' into feature/1.0_check_web_dev_kdh_2

parents 08c8c9c9 8e848331
<button type="button" id="showConfirmModalButton" class="btn btn-sm btn-tertiary d-none" data-toggle="modal" data-target="#confirm-modal"></button>
<div class="modal fade" id="confirm-modal" tabindex="-1" role="dialog">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
......
......@@ -71,6 +71,97 @@ COMMON.closeLoading = function () {
};
/**
* show confirm modal with yes, no buttons
* @param {Object} data - Object with {title, message, confirmYes, confirmNo}
* @param {callback} confirmCallback - The callback that handles the confirm button clicked
*/
COMMON.showConfirmModal = function (data, confirmCallback) {
if (data) {
let title = '';
if (data.title) {
title = data.title;
}
$('#confirm-modal .modal-title').text(title);
let message = '';
if (data.message) {
message = data.message;
}
$('#confirm-modal #msgModel').text(message);
if (data.confirmYes) {
$('#confirm-modal #confirmYes').text(data.confirmYes);
$('#confirm-modal #confirmYes').removeClass('d-none');
$('#confirm-modal #confirmYes').off('click');//remove all old click handlers
$('#confirm-modal #confirmYes').click(function() {
$('#confirm-modal .close').click();
if (confirmCallback) {
confirmCallback();
}
});
} else {
$('#confirm-modal #confirmYes').addClass('d-none');
}
if (data.confirmNo) {
$('#confirm-modal #confirmNo').text(data.confirmNo);
$('#confirm-modal #confirmNo').removeClass('d-none');
} else {
$('#confirm-modal #confirmNo').addClass('d-none');
}
}
$('#showConfirmModalButton').click();
};
/**
* Show confirm modal with defaults: title, yes, no
* @param {string} messageCode
* @param {callback} confirmCallback - The callback that handles the confirm button clicked
* @param {Object} options - Object with {title, message, confirmYes, confirmNo}
*/
COMMON.showConfirm = function (messageCode, confirmCallback, options = {}) {
const defaultParams = {
titleCode: 'confirmation',
confirmYesCode: 'confirmYes',
confirmNoCode: 'confirmNo'
}
const params = Object.assign(options, defaultParams);
let message = '';
if (messageCode) {
message = I18N.i18nText(messageCode);
} else if (params.message) {
message = params.message;
}
COMMON.showConfirmModal({
message: message,
title: I18N.i18nText(params.titleCode),
confirmYes: I18N.i18nText(params.confirmYesCode),
confirmNo: I18N.i18nText(params.confirmNoCode)
}, confirmCallback);
};
/**
* show alert message by confirm modal html
* @param {String} messageCode
* @param {Object} options - Data Options {message, titleCode, confirmNoCode}
*/
COMMON.showAlert = function (messageCode, options = {}) {
const defaultParams = {
titleCode: 'error',
confirmNoCode: 'close'
}
const params = Object.assign(options, defaultParams);
let message = '';
if (messageCode) {
message = I18N.i18nText(messageCode);
} else if (params.message) {
message = params.message;
}
COMMON.showConfirmModal({
message: message,
title: I18N.i18nText(params.titleCode),
confirmNo: I18N.i18nText(params.confirmNoCode)
});
};
/**
* show alert
*
* @param {String} msgCode
......
......@@ -117,5 +117,7 @@
"reportForm": "Report",
"periodicInspectionPeriod": "Periodic Inspection Period",
"msgSendPushMessageSuccess":"we sent a push message",
"error": "Error"
"error": "Error",
"msgSendPushMessageConfirm": "Do you want to send message?",
"close":"Close"
}
\ No newline at end of file
......@@ -87,10 +87,10 @@
"txtMessageContent":"メッセージ",
"buttonTemplateSelection":"テンプレート選択",
"buttonSend":"送信",
"msgContentRequired":"Content is required",
"msgContentInvalidLength":"The content length exceeds the maximum of {0} characters",
"msgOperationRequired":"Operation is required",
"msgSendTypeRequired":"Send type is required",
"msgContentRequired":"メッセージを入力してください。",
"msgContentInvalidLength":"メッセージの長さが最大文字数({0})を超えています。",
"msgOperationRequired":"作業を選択してください。",
"msgSendTypeRequired":"送信先を選択してください。",
"operationSelection":"作業選択",
"selection":"選択",
"templateSelection":"テンプレート選択",
......@@ -115,5 +115,7 @@
"reportForm": "報告",
"periodicInspectionPeriod": "定期点検期間",
"msgSendPushMessageSuccess":"プッシュメッセージ送信しました。",
"error": "エラー"
"error": "エラー",
"msgSendPushMessageConfirm": "プッシュメッセージを送信しますか?",
"close":"閉じる"
}
\ No newline at end of file
......@@ -114,5 +114,7 @@
"reportForm": "보고서",
"periodicInspectionPeriod": "정기점검기간",
"msgSendPushMessageSuccess":"푸시메시지를 보냈습니다.",
"error": "에러"
"error": "에러",
"msgSendPushMessageConfirm": "Do you want to send message?",
"close":"Close"
}
\ No newline at end of file
......@@ -33,9 +33,13 @@
<!-- header -->
<div id="includedHeader"></div>
<!-- report list -->
<div id="includedMainTitle"></div>
<div class="quickReportBtn" id="quickReportBtn" onclick="submitForm();">
<img src="../common/img/icon_pdf.svg" alt="pdf出力" class="p-1 w-40px" data-toggle="tooltip" data-placement="bottom"
title="pdfPrint">
</div>
<!-- report list -->
<div class="mb-5" id="report-form"></div>
<!-- confirm -->
......
......@@ -91,6 +91,7 @@
<!-- select template modal -->
<div id="includeTemplateModal"></div>
<div id="includeConfirmModal"></div>
<script type="text/javascript" src="../common/js/app.js"></script>
<script src="../common/js/event.js?__UPDATEID__"></script>
</body>
......
......@@ -301,18 +301,18 @@ OL.createCategoryList = function () {
//Create a side menu category structure
var categoryListElement = $('#categoryListMenu');
categoryListElement.empty();
//sort group master list by level low to hight
OL.operationGroupMaster.sort(function (a, b) {
if (a.operationGroupMasterLevel < b.operationGroupMasterLevel) return -1;
if (a.operationGroupMasterLevel > b.operationGroupMasterLevel) return 1;
return 1;
});
let allChecked = '';
if (typeof OL.operationGroupMasterId === 'undefined' || OL.operationGroupMasterId == 0) {
allChecked = ' checked';
}
const allCategory = $(
'<ul><li><label><input type="radio" name="category" value="0"' + allChecked + '><span class="lang" lang="categoryAll">' + I18N.i18nText('categoryAll') + '</span></label></li></ul>',
'<ul><li><label><input type="radio" name="category" value="0"' + allChecked + '> <span>' + I18N.i18nText('categoryAll') + '</span></label></li></ul>',
);
categoryListElement.append(allCategory);
//create category(operationGroupMaster) structure
......@@ -327,12 +327,22 @@ OL.createCategoryList = function () {
}
let groupSpan = $('<span>' + item.operationGroupMasterName + '</span>');
inputLabel.append(inputRadio);
inputLabel.append(' ');
inputLabel.append(groupSpan);
if (item.operationGroupMasterLevel == 0) {
const isParent = OL.operationGroupMaster.find(function(child) {
return item.operationGroupMasterId == child.parentOperationGroupMasterId;
});
let parentElement = categoryListElement;
if (item.parentOperationGroupMasterId != 0) {
parentElement = $('#collapse' + item.parentOperationGroupMasterId + ' > ul');
}
if (isParent) {
//accordion
const accordionId = 'accordion' + item.operationGroupMasterId;
const headingId = 'heading' + item.operationGroupMasterId;
const collapseId = 'collapse' + item.operationGroupMasterId;
let categoryParentElm = $('<li class="accordion" id="' + accordionId + '" />');
let accordionElm = $('<li class="accordion" id="' + accordionId + '" />');
//heading
let headingDiv = $('<div id="' + headingId + '" />');
let linkA = $('<a class="list-menu-link" />');
let collapseButton = $('<button type="button" class="collapsed" data-toggle="collapse" aria-expanded="true" />');
......@@ -342,26 +352,19 @@ OL.createCategoryList = function () {
linkA.append(collapseButton);
linkA.append(inputLabel);
headingDiv.append(linkA);
categoryParentElm.append(headingDiv);
categoryListElement.append(categoryParentElm);
//collapse
let collapseElm = $('<div id="' + collapseId + '" class="collapse">');
collapseElm.attr('data-parent', '#' + accordionId);
collapseElm.attr('aria-labelledby', headingId);
let ul = $('<ul>');
collapseElm.append(ul);
accordionElm.append(headingDiv);
accordionElm.append(collapseElm);
parentElement.append(accordionElm);
} else {
let li = $('<li>');
li.append(inputLabel);
let parentElm = $('#collapse' + item.parentOperationGroupMasterId + ' > ul');
if (typeof parentElm === 'undefined' || !parentElm || parentElm.length < 1) {
const accordionParentId = 'accordion' + item.parentOperationGroupMasterId;
const headingParentId = 'heading' + item.parentOperationGroupMasterId;
const collapseParentId = 'collapse' + item.parentOperationGroupMasterId;
parentElm = $('<div id="' + collapseParentId + '" class="collapse">');
parentElm.attr('data-parent', '#' + accordionParentId);
parentElm.attr('aria-labelledby', headingParentId);
let ul = $('<ul>');
ul.append(li);
parentElm.append(ul);
$('#' + accordionParentId).append(parentElm);
} else {
parentElm.append(li);
}
parentElement.append(li);
}
}
};
......
......@@ -18,7 +18,7 @@ PushMessageList.init = function () {
href: 'dashboard.html',
},
{
titleLang: 'messageListTitle',
titleLang: 'pushMessageList',
},
];
TEMPLATE.loadMainNavsTitle('#includedMainTitle', 'pushMessageList', navs, null);
......@@ -71,6 +71,12 @@ PushMessageList.generateMessageListHtml = function (messageList) {
$('#messageList .not-found').removeClass('d-none');
return;
}
//sort message list by send date
messageList.sort(function (a, b) {
if (a.pushSendDate > b.pushSendDate) return -1;
if (a.pushSendDate < b.pushSendDate) return 1;
return 0;
});
$('#messageList .not-found').addClass('d-none');
for (var i = 0; i < messageList.length; i++) {
let message = messageList[i];
......
......@@ -132,7 +132,7 @@ RF.initFormView = function () {
if (replyNo) params.replyNo = replyNo;
if (processKey) params.processKey = processKey;
if (phaseNo) params.phaseNo = phaseNo;
if (reportStartDate) prarams.reportStartDate = reportStartDate;
if (reportStartDate) params.reportStartDate = reportStartDate;
const url = COMMON.format(ClientData.conf_checkApiUrl(), ClientData.userInfo_accountPath()) + CONSTANT.URL.CMS.HTML.BASE + CONSTANT.URL.CMS.HTML.LIST_REPORT_FORM;
$('#report-form').load(url, params, function () {
......
......@@ -39,21 +39,21 @@ SendMessage.getCurrentSendType = function () {
SendMessage.checkValidation = function () {
const message = SendMessage.getCurrentMessageContent();
if (!ValidationUtil.CheckRequiredForText(message)) {
alert(I18N.i18nText('msgContentRequired'));
COMMON.showAlert('msgContentRequired');
return false;
}
if (!ValidationUtil.CheckMaxLengthForByte(message, SendMessage.contentMaxLength)) {
alert(COMMON.format(I18N.i18nText('msgContentInvalidLength'), SendMessage.contentMaxLength));
COMMON.showAlert(null, {message: COMMON.format(I18N.i18nText('msgContentInvalidLength'), SendMessage.contentMaxLength)});
return false;
}
const operationId = SendMessage.getCurrentOperationId();
if (!ValidationUtil.IsNumber(operationId)) {
alert(I18N.i18nText('msgOperationRequired'));
COMMON.showAlert('msgOperationRequired');
return false;
}
const sendType = SendMessage.getCurrentSendType();
if (!ValidationUtil.IsNumber(sendType)) {
alert(I18N.i18nText('msgSendTypeRequired'));
COMMON.showAlert('msgSendTypeRequired');
return false;
}
return true;
......@@ -69,7 +69,9 @@ SendMessage.onClickSend = function () {
const message = SendMessage.getCurrentMessageContent();
const operationId = SendMessage.getCurrentOperationId();
const sendType = SendMessage.getCurrentSendType();
SendMessage.postMessage(message, operationId, sendType);
COMMON.showConfirm('msgSendPushMessageConfirm', function() {
SendMessage.postMessage(message, operationId, sendType);
});
};
/**
......@@ -92,7 +94,7 @@ SendMessage.postMessage = function (message, operationId, sendType) {
false,
function (json) {
COMMON.closeLoading();
alert(I18N.i18nText('msgSendPushMessageSuccess'));
COMMON.showAlert('msgSendPushMessageSuccess');
},
function () {
console.log('SendMessage.postMessage error');
......@@ -126,13 +128,14 @@ SendMessage.init = function () {
//Check if user is logged in
COMMON.checkAuth(false);
TEMPLATE.loadHeader('#includedHeader');
TEMPLATE.loadConfirmModal('#includeConfirmModal');
const navs = [
{
titleLang: 'dashboard',
href: 'dashboard.html',
},
{
titleLang: 'sendMessageTitle',
titleLang: 'sendMessage',
},
];
TEMPLATE.loadMainNavsTitle('#includedMainTitle', 'sendMessage', navs, null);
......
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