Commit 8112496c by NGUYEN HOANG SON

#50278 implement dashboard setting js

parent 18699cb8
......@@ -18,13 +18,13 @@
<script src="/abvw/common/js/constant.js?__UPDATEID__"></script>
<script src="/abvw/common/js/common.js?__UPDATEID__"></script>
<script src="/abvw/common/js/footer.js"></script>
<script src="/abvw/js/dashboardSetting/check-dashboard-setting.js"></script>
<script src="/abvw/js/dashboardSetting/dashboard-setting.js"></script>
</head>
<body id="dashboard" onload="CHK_DashboardSetting.init();">
<body id="dashboard" onload="DashboardSetting.init();">
<header>
<nav class="navbar navbar-dark bg-primary position-fixed fixed-top w-100">
<a href="javascript:CHK_DashboardSetting.goBack();" class="navbar-brand category-btn lht-0">
<a href="javascript:DashboardSetting.goBack();" class="navbar-brand category-btn lht-0">
<i class="fas fa-chevron-left fs-12 p-1"></i>
<span class="d-none d-md-inline fs-10">
戻る
......
var CHK_DashboardSetting = {};
CHK_DashboardSetting.displayItems = [
{ id: 'newReport', name: 'chk-new', enabled: true, title: '新規報告', msg: 'dashboardSettingNewRegistrationTitle' },
{ id: 'continousWork', name: 'chk-proccess', enabled: true, title: '工程作業', msg: 'dashboardSettingContinousWorkTitle' },
{ id: 'reportWarning', name: 'chk-alert', enabled: true, title: '警告を含む作業', msg: 'dashboardSettingReportWarningTitle' },
{ id: 'dashboardHome', name: 'chk-home', enabled: false, title: 'ダッシュボードをホーム画面にする', msg: 'dashboardSettingDashboardHomeTitle' },
var DashboardSetting = {};
DashboardSetting.displayItems = [
{ id: 'newReport', name: 'newReport', enabled: true, title: '新規報告', msg: 'dashboardSettingNewRegistrationTitle' },
{ id: 'continousWork', name: 'continousWork', enabled: true, title: '工程作業', msg: 'dashboardSettingContinousWorkTitle' },
{ id: 'reportWarning', name: 'reportWarning', enabled: true, title: '警告を含む作業', msg: 'dashboardSettingReportWarningTitle' },
{ id: 'dashboardHome', name: 'dashboardHome', enabled: false, title: 'ダッシュボードをホーム画面にする', msg: 'dashboardSettingDashboardHomeTitle' },
];
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.dummySettingJson = {
newReport: 1,
continousWork: 1,
reportWarning: 1,
dashboardHome: 0,
}
DashboardSetting.getSettingData = function (callback) {
let param = {
sid: COMMON.getSid(),
};
COMMON.cmsAjax(DashboardSetting.getSettingApiUrl, param, false, function (json) {
if (callback) {
callback(json);
}
}, function() {
console.log('DashboardSetting.getSettingData error');
});
};
//CHK_DashboardSetting.displayItemsに設定されている情報から✓されている項目をhtml上に設定する
CHK_DashboardSetting.loadSettings = function () {
CHK_DashboardSetting.displayItems.forEach(function (item) {
let enabled = CHK.dashboardSetting[item.id];
DashboardSetting.loadSettings = function (settings) {
DashboardSetting.displayItems.forEach(function (item) {
let enabled = settings[item.id];
if (typeof enabled !== 'undefined') {
item.enabled = enabled;
let itemElement = $('#' + item.id);
......@@ -23,26 +47,31 @@ CHK_DashboardSetting.loadSettings = function () {
};
//CHK_DashboardSetting.displayItemsに設定を書き込む
CHK_DashboardSetting.saveSetting = function (key, enabled) {
CHK_DashboardSetting.displayItems.forEach(function (item) {
DashboardSetting.saveSetting = function (key, enabled) {
DashboardSetting.displayItems.forEach(function (item) {
if (item.id == key) {
item.enabled = enabled;
}
});
CHK.saveDashboardSetting(key, enabled);
let param = {};
param.sid = COMMON.getSid();
param[key] = enabled;
COMMON.cmsAjax(DashboardSetting.saveSettingApiUrl, param, false, function (json) {
});
};
//CHK_DashboardSetting.displayItemsからhtmlに設定画面を表示する
CHK_DashboardSetting.initDisplays = function () {
DashboardSetting.initDisplays = function () {
$('#displayItems tbody').empty();
CHK_DashboardSetting.displayItems.forEach(function (item) {
var html = CHK_DashboardSetting.initHtmlItem(item);
DashboardSetting.displayItems.forEach(function (item) {
var html = DashboardSetting.initHtmlItem(item);
$('#displayItems tbody').append(html);
});
};
//設定画面に表示するhtmlを生成する
CHK_DashboardSetting.initHtmlItem = function (item) {
DashboardSetting.initHtmlItem = function (item) {
var titleDiv = '<div class="font-weight-normal text-dark multi-lang" data-msg="' + item.msg + '">' + item.title + '</div>';
var toggleClass = 'toggle';
if (item.enabled) {
......@@ -55,7 +84,7 @@ CHK_DashboardSetting.initHtmlItem = function (item) {
//設定画面でクリックされてた時の処理
//
CHK_DashboardSetting.bindToggleClick = function () {
DashboardSetting.bindToggleClick = function () {
$('.toggle').on('click', function () {
$(this).toggleClass('checked');
var id = $(this).attr('id');
......@@ -63,24 +92,21 @@ CHK_DashboardSetting.bindToggleClick = function () {
if ($(this).hasClass('checked')) {
enabled = true;
}
CHK_DashboardSetting.saveSetting(id, enabled);
DashboardSetting.saveSetting(id, enabled);
});
};
//設定画面の初期処理
CHK_DashboardSetting.init = function () {
CHK.initCommon();
$('#footer').load('main-footer.html', function () {
FOOTER.activeDashboardBottomNav();
});
CHK.loadDashboardSetting(function () {
CHK_DashboardSetting.loadSettings();
CHK_DashboardSetting.initDisplays();
CHK_DashboardSetting.bindToggleClick();
DashboardSetting.init = function () {
FOOTER.initFooter();
DashboardSetting.getSettingData(function (settings) {
DashboardSetting.loadSettings(settings);
DashboardSetting.initDisplays();
DashboardSetting.bindToggleClick();
});
};
//戻るボタン
CHK_DashboardSetting.goBack = function () {
DashboardSetting.goBack = function () {
FOOTER.goDashboard();
};
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