Commit 93ec237f by NGO THI HONG

Fix bug operation select , template

parent eddb2861
......@@ -13,7 +13,7 @@
</ul>
</div>
<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>
</div>
</div>
......
......@@ -4,6 +4,7 @@
* @since 1.0 check web
*/
var NotificationSelect = {};
NotificationSelect.changeSelectCallback = function() {};
NotificationSelect.nameSelected="";
NotificationSelect.valueSelected="";
......@@ -48,24 +49,26 @@ NotificationSelect.selectOperationClick = function () {
/**
* init data, action when screen onload
*/
NotificationSelect.init = function () {
NotificationSelect.init = function (selectedCallback) {
NotificationSelect.getNotificationSelectData(function (data) {
NotificationSelect.createNotificationSelectList(data);
if (typeof data === 'undefined' || data == null) return;
NotificationSelect.createNotificationSelectList(data.pushMessageTemplate);
});
NotificationSelect.selectOperationClick();
NotificationSelect.changeSelectCallback = selectedCallback;
};
/**
* Implement notification select html
* @returns
*/
NotificationSelect.createNotificationSelectList = function(data) {
NotificationSelect.createNotificationSelectList = function(pushMessageTemplate) {
$("#notificationSelectList").empty();
if (typeof data === 'undefined' || data.length < 1) return;
if (typeof pushMessageTemplate === 'undefined' || pushMessageTemplate.length < 1) return;
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'>"
+ "<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>"
......@@ -76,7 +79,7 @@ NotificationSelect.init = function () {
classSelected = "";
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>");
......@@ -86,7 +89,40 @@ NotificationSelect.init = function () {
divValue.append(divBodyValue);
messageli.append(divParentName);
messageli.append(divValue);
if(i == 0)
{
NotificationSelect.nameSelected = pushMessageTemplate[i].name;
NotificationSelect.valueSelected = pushMessageTemplate[i].value;
}
$("#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 () {
*/
OperationSelect.init = function (selectedCallback) {
OperationSelect.getOperationSelectData(function (data) {
OperationSelect.createOperationSelectList(data);
if (typeof data === 'undefined' || data == null) return;
OperationSelect.createOperationSelectList(data.operationList);
});
OperationSelect.selectOperationClick();
OperationSelect.changeSelectCallback = selectedCallback;
......@@ -62,14 +63,14 @@ OperationSelect.init = function (selectedCallback) {
* Implement operation select html
* @returns
*/
OperationSelect.createOperationSelectList = function(data) {
OperationSelect.createOperationSelectList = function(operationList) {
$("#operationSelectList").empty();
if (typeof data === 'undefined' || data.length < 1) return;
for (let i = 0; i < data.length; i++) {
if (typeof operationList === 'undefined' || operationList.length < 1) return;
for (let i = 0; i < operationList.length; i++) {
let messageli = $("<li class='card mb-2' name = 'operationId_" + data[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 divText = $("<div class='fs-12 text-truncate d-block'>"+ data[i].operationName + "</div>");
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='" + operationList[i].operationId + "' data-name='" + operationList[i].operationName + "' ></a>");
let divText = $("<div class='fs-12 text-truncate d-block'>"+ operationList[i].operationName + "</div>");
ahrefRequiredFlg.append(divText);
messageli.append(ahrefRequiredFlg);
......@@ -97,7 +98,7 @@ OperationSelect.init = function (selectedCallback) {
param.operationNameSelected = OperationSelect.operationNameSelected;
OperationSelect.closeModal();
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