Commit fc0a3347 by NGUYEN HOANG SON

add comment code fiel dashboad-setting js

parent 23d38ca7
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
* @since 1.0 check web * @since 1.0 check web
*/ */
var DashboardSetting = {}; var DashboardSetting = {};
//setting html elements, map with json key from setting data API
DashboardSetting.elementItems = { DashboardSetting.elementItems = {
newReport: { id: 'settingNewReport', name: 'chk-new', enabled: true }, newReport: { id: 'settingNewReport', name: 'chk-new', enabled: true },
continousWork: { id: 'settingContinousWork', name: 'chk-proccess', enabled: true }, continousWork: { id: 'settingContinousWork', name: 'chk-proccess', enabled: true },
...@@ -41,6 +43,7 @@ DashboardSetting.applySettings = function (settings) { ...@@ -41,6 +43,7 @@ DashboardSetting.applySettings = function (settings) {
for (const key in settings) { for (const key in settings) {
const enabled = settings[key]; const enabled = settings[key];
if (DashboardSetting.elementItems.hasOwnProperty(key)) { if (DashboardSetting.elementItems.hasOwnProperty(key)) {
//apply enabled, disabled setting
let elementItem = DashboardSetting.elementItems[key]; let elementItem = DashboardSetting.elementItems[key];
elementItem.enabled = enabled; elementItem.enabled = enabled;
let element = $('#' + elementItem.id); let element = $('#' + elementItem.id);
...@@ -71,16 +74,17 @@ DashboardSetting.saveSetting = function () { ...@@ -71,16 +74,17 @@ DashboardSetting.saveSetting = function () {
}); });
}; };
//handle click on/off of setting item
DashboardSetting.bindToggleClick = function () { DashboardSetting.bindToggleClick = function () {
$('.toggle').on('click', function () { $('.toggle').on('click', function () {
$(this).toggleClass('checked'); $(this).toggleClass('checked');
const key = $(this).attr('data-key'); const key = $(this).attr('data-key');
var enabled = false; let enabled = false;
if ($(this).hasClass('checked')) { if ($(this).hasClass('checked')) {
enabled = true; enabled = true;
} }
if (DashboardSetting.elementItems.hasOwnProperty(key)) { if (DashboardSetting.elementItems.hasOwnProperty(key)) {
const elementItem = DashboardSetting.elementItems[key]; let elementItem = DashboardSetting.elementItems[key];
elementItem.enabled = enabled; elementItem.enabled = enabled;
} }
}); });
......
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