Commit 761f1355 by NGUYEN HOANG SON

implement save dashboard setting

parent 52572808
......@@ -51,16 +51,18 @@ DashboardSetting.applySettings = function (settings) {
}
};
DashboardSetting.saveSetting = function (key, enabled) {
if (DashboardSetting.elementItems.hasOwnProperty(key)) {
const elementItem = DashboardSetting.elementItems[key];
elementItem.enabled = enabled;
}
DashboardSetting.saveSetting = function () {
let param = {};
param.sid = COMMON.getSid();
param[key] = enabled;
for (const key in DashboardSetting.elementItems) {
const element = DashboardSetting.elementItems[key];
param[key] = element.enabled;
}
COMMON.cmsAjax(DashboardSetting.saveSettingApiUrl, param, false, function (json) {
DashboardSetting.closeModal();
}, function() {
console.log('DashboardSetting.saveSetting error');
DashboardSetting.closeModal();
});
};
......@@ -73,7 +75,10 @@ DashboardSetting.bindToggleClick = function () {
if ($(this).hasClass('checked')) {
enabled = true;
}
DashboardSetting.saveSetting(key, enabled);
if (DashboardSetting.elementItems.hasOwnProperty(key)) {
const elementItem = DashboardSetting.elementItems[key];
elementItem.enabled = enabled;
}
});
};
......@@ -86,5 +91,9 @@ DashboardSetting.init = function () {
};
DashboardSetting.onClickSave = function () {
console.log("DashboardSetting.save");
DashboardSetting.saveSetting();
};
DashboardSetting.closeModal = function () {
$('#dashboard-setting-modal .close').click();
};
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