Commit 93ec237f by NGO THI HONG

Fix bug operation select , template

parent eddb2861
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
</ul> </ul>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button type="button" class="btn btn-primary lang" lang="selection"></button> <button type="button" class="btn btn-primary lang" lang="selection" onclick="NotificationSelect.onClickTempalte();"></button>
<button type="button" class="btn btn-tertiary lang" lang="dspCancel" data-dismiss="modal"></button> <button type="button" class="btn btn-tertiary lang" lang="dspCancel" data-dismiss="modal"></button>
</div> </div>
</div> </div>
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
* @since 1.0 check web * @since 1.0 check web
*/ */
var NotificationSelect = {}; var NotificationSelect = {};
NotificationSelect.changeSelectCallback = function() {};
NotificationSelect.nameSelected=""; NotificationSelect.nameSelected="";
NotificationSelect.valueSelected=""; NotificationSelect.valueSelected="";
...@@ -48,24 +49,26 @@ NotificationSelect.selectOperationClick = function () { ...@@ -48,24 +49,26 @@ NotificationSelect.selectOperationClick = function () {
/** /**
* init data, action when screen onload * init data, action when screen onload
*/ */
NotificationSelect.init = function () { NotificationSelect.init = function (selectedCallback) {
NotificationSelect.getNotificationSelectData(function (data) { NotificationSelect.getNotificationSelectData(function (data) {
NotificationSelect.createNotificationSelectList(data); if (typeof data === 'undefined' || data == null) return;
NotificationSelect.createNotificationSelectList(data.pushMessageTemplate);
}); });
NotificationSelect.selectOperationClick(); NotificationSelect.selectOperationClick();
NotificationSelect.changeSelectCallback = selectedCallback;
}; };
/** /**
* Implement notification select html * Implement notification select html
* @returns * @returns
*/ */
NotificationSelect.createNotificationSelectList = function(data) { NotificationSelect.createNotificationSelectList = function(pushMessageTemplate) {
$("#notificationSelectList").empty(); $("#notificationSelectList").empty();
if (typeof data === 'undefined' || data.length < 1) return; if (typeof pushMessageTemplate === 'undefined' || pushMessageTemplate.length < 1) return;
let classSelected = "selected"; let classSelected = "selected";
for (let i = 0; i < data.length; i++) { for (let i = 0; i < pushMessageTemplate.length; i++) {
let divName = $("<div class='pl-5 py-3 h-100 w-100 align-self-center select-label'>" + data[i].name + "</div>"); let divName = $("<div class='pl-5 py-3 h-100 w-100 align-self-center select-label'>" + pushMessageTemplate[i].name + "</div>");
let divIcon = $("<div class='flex-shrink-1 mx-3 align-self-center'>" let divIcon = $("<div class='flex-shrink-1 mx-3 align-self-center'>"
+ "<button class='btn btn-link border collapsed' type='button' data-toggle='collapse' data-target='#collapse" + i + "' aria-expanded='true' aria-controls='collapse" + i + "'>" + "<button class='btn btn-link border collapsed' type='button' data-toggle='collapse' data-target='#collapse" + i + "' aria-expanded='true' aria-controls='collapse" + i + "'>"
+ "<div class='arrow-icon'></div>" + "<div class='arrow-icon'></div>"
...@@ -76,7 +79,7 @@ NotificationSelect.init = function () { ...@@ -76,7 +79,7 @@ NotificationSelect.init = function () {
classSelected = ""; classSelected = "";
let divValue = $("<div id='collapse" + i + "' class='collapse' aria-labelledby='heading" + i + "' data-parent='#accordion" + i + "'></div>"); let divValue = $("<div id='collapse" + i + "' class='collapse' aria-labelledby='heading" + i + "' data-parent='#accordion" + i + "'></div>");
let divBodyValue = $("<div class='card-body'>" + data[i].value + "</div>"); let divBodyValue = $("<div class='card-body'>" + pushMessageTemplate[i].value + "</div>");
let messageli = $("<li class='accordion' id='accordion" + i + "'></li>"); let messageli = $("<li class='accordion' id='accordion" + i + "'></li>");
...@@ -86,7 +89,40 @@ NotificationSelect.init = function () { ...@@ -86,7 +89,40 @@ NotificationSelect.init = function () {
divValue.append(divBodyValue); divValue.append(divBodyValue);
messageli.append(divParentName); messageli.append(divParentName);
messageli.append(divValue); messageli.append(divValue);
if(i == 0)
{
NotificationSelect.nameSelected = pushMessageTemplate[i].name;
NotificationSelect.valueSelected = pushMessageTemplate[i].value;
}
$("#notificationSelectList").append(messageli); $("#notificationSelectList").append(messageli);
} }
} }
/**
* handle click event of select button
*/
NotificationSelect.onClickTempalte = function () {
NotificationSelect.chooseTemplate();
};
/**
* Get operation select and call back function in main page
*/
NotificationSelect.chooseTemplate = function () {
let param = {};
param.nameSelected = NotificationSelect.nameSelected;
param.valueSelected = NotificationSelect.valueSelected;
NotificationSelect.closeModal();
if (NotificationSelect.changeSelectCallback && typeof NotificationSelect.changeSelectCallback === 'function') {
NotificationSelect.changeSelectCallback(param.valueSelected);
}
};
/**
* close setting dialog
*/
NotificationSelect.closeModal = function () {
$('#select-template-modal .close').click();
};
\ No newline at end of file
...@@ -52,7 +52,8 @@ OperationSelect.selectOperationClick = function () { ...@@ -52,7 +52,8 @@ OperationSelect.selectOperationClick = function () {
*/ */
OperationSelect.init = function (selectedCallback) { OperationSelect.init = function (selectedCallback) {
OperationSelect.getOperationSelectData(function (data) { OperationSelect.getOperationSelectData(function (data) {
OperationSelect.createOperationSelectList(data); if (typeof data === 'undefined' || data == null) return;
OperationSelect.createOperationSelectList(data.operationList);
}); });
OperationSelect.selectOperationClick(); OperationSelect.selectOperationClick();
OperationSelect.changeSelectCallback = selectedCallback; OperationSelect.changeSelectCallback = selectedCallback;
...@@ -62,14 +63,14 @@ OperationSelect.init = function (selectedCallback) { ...@@ -62,14 +63,14 @@ OperationSelect.init = function (selectedCallback) {
* Implement operation select html * Implement operation select html
* @returns * @returns
*/ */
OperationSelect.createOperationSelectList = function(data) { OperationSelect.createOperationSelectList = function(operationList) {
$("#operationSelectList").empty(); $("#operationSelectList").empty();
if (typeof data === 'undefined' || data.length < 1) return; if (typeof operationList === 'undefined' || operationList.length < 1) return;
for (let i = 0; i < data.length; i++) { for (let i = 0; i < operationList.length; i++) {
let messageli = $("<li class='card mb-2' name = 'operationId_" + data[i].operationId + "' ></li>"); let messageli = $("<li class='card mb-2' name = 'operationId_" + operationList[i].operationId + "' ></li>");
let ahrefRequiredFlg = $("<a href='#' class='d-block px-5 py-3 text-decoration-none select-label' data-key='" + data[i].operationId + "' data-name='" + data[i].operationName + "' ></a>"); let ahrefRequiredFlg = $("<a href='#' class='d-block px-5 py-3 text-decoration-none select-label' data-key='" + operationList[i].operationId + "' data-name='" + operationList[i].operationName + "' ></a>");
let divText = $("<div class='fs-12 text-truncate d-block'>"+ data[i].operationName + "</div>"); let divText = $("<div class='fs-12 text-truncate d-block'>"+ operationList[i].operationName + "</div>");
ahrefRequiredFlg.append(divText); ahrefRequiredFlg.append(divText);
messageli.append(ahrefRequiredFlg); messageli.append(ahrefRequiredFlg);
...@@ -97,7 +98,7 @@ OperationSelect.init = function (selectedCallback) { ...@@ -97,7 +98,7 @@ OperationSelect.init = function (selectedCallback) {
param.operationNameSelected = OperationSelect.operationNameSelected; param.operationNameSelected = OperationSelect.operationNameSelected;
OperationSelect.closeModal(); OperationSelect.closeModal();
if (OperationSelect.changeSelectCallback && typeof OperationSelect.changeSelectCallback === 'function') { if (OperationSelect.changeSelectCallback && typeof OperationSelect.changeSelectCallback === 'function') {
OperationSelect.changeSelectCallback(param); OperationSelect.changeSelectCallback(param.operationIdSelected,param.operationNameSelected );
} }
}; };
......
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