Commit 280de0b5 by NGUYEN HOANG SON

refactor code : dashboard setting js

parent 4126f0f5
/**
* Dashboard Setting js in dashboard.html
*
* @since 1.0 check web
*/
var DashboardSetting = {};
DashboardSetting.elementItems = {
newReport: { id: 'settingNewReport', name: 'chk-new', enabled: true },
......@@ -7,8 +12,6 @@ DashboardSetting.elementItems = {
};
DashboardSetting.baseApiUrl = CONSTANT.URL.CMS.BASE + ClientData.userInfo_accountPath() + CONSTANT.URL.CMS.API.BASE + 'dashboardSetting/';
DashboardSetting.saveSettingApiUrl = DashboardSetting.baseApiUrl + 'saveSetting';
DashboardSetting.getSettingApiUrl = DashboardSetting.baseApiUrl + 'getAllSettingData';
DashboardSetting.defaultSettingJson = {
newReport: 1,
......@@ -21,7 +24,8 @@ DashboardSetting.getSettingData = function (callback) {
let param = {
sid: COMMON.getSid(),
};
COMMON.cmsAjax(DashboardSetting.getSettingApiUrl, param, false, function (json) {
const url = DashboardSetting.baseApiUrl + 'getAllSettingData';
COMMON.cmsAjax(url, param, false, function (json) {
if (callback) {
callback(json);
}
......@@ -37,7 +41,7 @@ DashboardSetting.applySettings = function (settings) {
for (const key in settings) {
const enabled = settings[key];
if (DashboardSetting.elementItems.hasOwnProperty(key)) {
const elementItem = DashboardSetting.elementItems[key];
let elementItem = DashboardSetting.elementItems[key];
elementItem.enabled = enabled;
let element = $('#' + elementItem.id);
if (element) {
......@@ -58,7 +62,8 @@ DashboardSetting.saveSetting = function () {
const element = DashboardSetting.elementItems[key];
param[key] = element.enabled;
}
COMMON.cmsAjax(DashboardSetting.saveSettingApiUrl, param, false, function (json) {
const url = DashboardSetting.baseApiUrl + 'saveSetting';
COMMON.cmsAjax(url, param, false, function (json) {
DashboardSetting.closeModal();
}, function() {
console.log('DashboardSetting.saveSetting error');
......@@ -66,7 +71,6 @@ DashboardSetting.saveSetting = function () {
});
};
//設定画面でクリックされてた時の処理
DashboardSetting.bindToggleClick = function () {
$('.toggle').on('click', function () {
$(this).toggleClass('checked');
......@@ -82,7 +86,6 @@ DashboardSetting.bindToggleClick = function () {
});
};
//設定画面の初期処理
DashboardSetting.init = function () {
DashboardSetting.getSettingData(function (settings) {
DashboardSetting.applySettings(settings);
......
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