Commit 546683ce by NGUYEN HOANG SON

add jsdoc

parent eb57ef10
...@@ -5,7 +5,9 @@ ...@@ -5,7 +5,9 @@
*/ */
var DashboardSetting = {}; var DashboardSetting = {};
//setting html elements, map with json key from setting data API /**
* Html element array, 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 },
...@@ -15,6 +17,9 @@ DashboardSetting.elementItems = { ...@@ -15,6 +17,9 @@ DashboardSetting.elementItems = {
DashboardSetting.baseApiUrl = CONSTANT.URL.CMS.BASE + ClientData.userInfo_accountPath() + CONSTANT.URL.CMS.API.BASE + 'dashboardSetting/'; DashboardSetting.baseApiUrl = CONSTANT.URL.CMS.BASE + ClientData.userInfo_accountPath() + CONSTANT.URL.CMS.API.BASE + 'dashboardSetting/';
/**
* default setting JSON
*/
DashboardSetting.defaultSettingJson = { DashboardSetting.defaultSettingJson = {
newReport: 1, newReport: 1,
continousWork: 1, continousWork: 1,
...@@ -22,6 +27,10 @@ DashboardSetting.defaultSettingJson = { ...@@ -22,6 +27,10 @@ DashboardSetting.defaultSettingJson = {
dashboardHome: 0, dashboardHome: 0,
} }
/**
* get setting data from cms
* @param {function} callback
*/
DashboardSetting.getSettingData = function (callback) { DashboardSetting.getSettingData = function (callback) {
let param = { let param = {
sid: COMMON.getSid(), sid: COMMON.getSid(),
...@@ -39,6 +48,10 @@ DashboardSetting.getSettingData = function (callback) { ...@@ -39,6 +48,10 @@ DashboardSetting.getSettingData = function (callback) {
}); });
}; };
/**
* apply settings to screen
* @param {JSON} settings
*/
DashboardSetting.applySettings = function (settings) { DashboardSetting.applySettings = function (settings) {
for (const key in settings) { for (const key in settings) {
const enabled = settings[key]; const enabled = settings[key];
...@@ -58,6 +71,9 @@ DashboardSetting.applySettings = function (settings) { ...@@ -58,6 +71,9 @@ DashboardSetting.applySettings = function (settings) {
} }
}; };
/**
* post request to save setting to cms
*/
DashboardSetting.saveSetting = function () { DashboardSetting.saveSetting = function () {
let param = {}; let param = {};
param.sid = COMMON.getSid(); param.sid = COMMON.getSid();
...@@ -74,7 +90,9 @@ DashboardSetting.saveSetting = function () { ...@@ -74,7 +90,9 @@ DashboardSetting.saveSetting = function () {
}); });
}; };
//handle click on/off of setting item /**
* handle on/off setting
*/
DashboardSetting.bindToggleClick = function () { DashboardSetting.bindToggleClick = function () {
$('.toggle').on('click', function () { $('.toggle').on('click', function () {
$(this).toggleClass('checked'); $(this).toggleClass('checked');
...@@ -90,6 +108,9 @@ DashboardSetting.bindToggleClick = function () { ...@@ -90,6 +108,9 @@ DashboardSetting.bindToggleClick = function () {
}); });
}; };
/**
* init data, action when screen onload
*/
DashboardSetting.init = function () { DashboardSetting.init = function () {
DashboardSetting.getSettingData(function (settings) { DashboardSetting.getSettingData(function (settings) {
DashboardSetting.applySettings(settings); DashboardSetting.applySettings(settings);
...@@ -97,10 +118,16 @@ DashboardSetting.init = function () { ...@@ -97,10 +118,16 @@ DashboardSetting.init = function () {
DashboardSetting.bindToggleClick(); DashboardSetting.bindToggleClick();
}; };
/**
* handle click event of save button
*/
DashboardSetting.onClickSave = function () { DashboardSetting.onClickSave = function () {
DashboardSetting.saveSetting(); DashboardSetting.saveSetting();
}; };
/**
* close setting dialog
*/
DashboardSetting.closeModal = function () { DashboardSetting.closeModal = function () {
$('#dashboard-setting-modal .close').click(); $('#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