Commit f13e027d by NGUYEN HOANG SON

#49153 implement save, load dashboard setting json

parent 98e46f5f
......@@ -218,7 +218,7 @@
} else if (location.hash === '#operationList') {
CHK_Footer.goOperationList();
} else {
if (CHK_DashboardSetting.isSettingEnabled(CHK_Dashboard.settingKey.dashboardHome)) {
if (CHK.dashboardSetting.dashboardHome) {
CHK_Footer.goDashboard();
} else {
CHK_Footer.goOperationList();
......
var CHK_DashboardSetting = {};
CHK_DashboardSetting.displayItems = [
{ id:'dashboardSettingNewReport', name: 'chk-new', enabled: true, title:'新規報告', msg: 'dashboardSettingNewRegistrationTitle'},
{ id:'dashboardSettingContinousWork', name: 'chk-proccess', enabled: true, title:'工程作業', msg: 'dashboardSettingContinousWorkTitle'},
{ id:'dashboardSettingReportWarning', name: 'chk-alert', enabled: true, title:'警告を含む作業', msg: 'dashboardSettingReportWarningTitle'},
{ id:'dashboardSettingDashboardHome', name: 'chk-home', enabled: false, title:'ダッシュボードをホーム画面にする', msg: 'dashboardSettingDashboardHomeTitle'},
{ 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'},
];
CHK_DashboardSetting.loadLocalSettings = function() {
CHK_DashboardSetting.loadSettings = function() {
CHK_DashboardSetting.displayItems.forEach(function(item) {
let enabled = CHK_DashboardSetting.isSettingEnabled(item.id);
if (enabled == true || enabled == false) {
let enabled = CHK.dashboardSetting[item.id];
if (typeof enabled !== 'undefined') {
item.enabled = enabled;
}
});
}
CHK_DashboardSetting.saveLocalSetting = function(key, value) {
localStorage.setItem(key, value);
}
CHK_DashboardSetting.isSettingEnabled = function(key) {
var setting = localStorage.getItem(key);
if (setting == '1') {
return true;
} else if (setting == '0') {
return false;
}
return setting;
CHK_DashboardSetting.saveSetting = function(key, enabled) {
CHK_DashboardSetting.displayItems.forEach(function(item) {
if (item.id == key) {
item.enabled = enabled;
}
});
CHK.saveDashboardSetting(key, enabled);
}
CHK_DashboardSetting.initDisplays = function() {
......@@ -55,16 +50,18 @@ CHK_DashboardSetting.bindToggleClick = function() {
$(".toggle").on("click", function() {
$(this).toggleClass("checked");
var id = $(this).attr('id');
var enabled = false;
if ($(this).hasClass('checked')) {
CHK_DashboardSetting.saveLocalSetting(id, '1');
} else {
CHK_DashboardSetting.saveLocalSetting(id, '0');
enabled = true;
}
CHK_DashboardSetting.saveSetting(id, enabled);
});
}
CHK_DashboardSetting.init = function() {
CHK_DashboardSetting.loadLocalSettings();
CHK.initCommon();
CHK.loadDashboardSetting();
CHK_DashboardSetting.loadSettings();
CHK_DashboardSetting.initDisplays();
$("#footer").load("main-footer.html", function() {
CHK_Footer.activeDashboardBottomNav();
......
......@@ -12,13 +12,6 @@ CHK_Dashboard.communicationItems = [
{id: 'chat', href: "javascript:CHK_L.sendAppCommand('goChat');", count: 0, enabled: false, img: {src: 'img/icon_chat.svg'}, msg: 'chatTitle'},
];
CHK_Dashboard.settingKey = {
newReport: "dashboardSettingNewReport",
continousWork: "dashboardSettingContinousWork",
reportWarning: "dashboardSettingReportWarning",
dashboardHome: "dashboardSettingDashboardHome",
}
CHK_Dashboard.initPickups = function() {
$("#pickupItems").empty();
CHK_Dashboard.pickupItems.forEach(function(item) {
......@@ -68,7 +61,7 @@ CHK_Dashboard.init = function() {
CHK_Dashboard.updateDataPickups = function() {
CHK_Dashboard.pickupItems.forEach(function(item) {
let enabled = CHK_DashboardSetting.isSettingEnabled(CHK_Dashboard.settingKey[item.id]);
let enabled = CHK.dashboardSetting[item.id];
if (enabled == true || enabled == false) {
item.enabled = enabled;
}
......
......@@ -46,6 +46,12 @@ CHK.pushMessageList;
CHK.scanResultCode; //スキャンしたRFID,バーコード
CHK.scanType; //スキャン種別(0:バーコード、1:RFID)
CHK.isChat;
CHK.dashboardSetting = {
newReport: true,
continousWork: true,
reportWarning: true,
dashboardHome: false,
};
var pageLang; // ページ設定言語
var CATEGORY_HEIGHT; //カテゴリー描画用固定値(高さ)
......@@ -186,7 +192,8 @@ CHK.jsonPath = {
operationList: "operationList.json", // 作業一覧JSONデータ
operationGroupMasterList: "operationGroupMasterList.json", // カテゴリーJSONデータ
operationGroupMasterRelationList: "operationGroupMasterRelationList.json", // 作業・カテゴリー関係JSONデータ
pushMessageList: "pushMessageList.json" // コミュニケーションデータJSONデータ
pushMessageList: "pushMessageList.json", // コミュニケーションデータJSONデータ
dashboardSetting: "dashboardSetting.json"
};
//アプリ送信用コマンド
CHK.apiCmd = {
......@@ -216,7 +223,8 @@ CHK.apiCmd = {
getGroupTreeInfo: "getGroupTreeInfo", //担当グループ参照用 ログインユーザーが所属しているグループ取得
deleteProcess: "deleteProcess",
changeOperationGroupMaster: "changeOperationGroupMaster",
actionPushMessage: "actionPushMessage"
actionPushMessage: "actionPushMessage",
saveJson: "saveJson"
};
//CMS送信用コマンド
CHK.actCmd = {
......@@ -435,7 +443,7 @@ CHK.initCommon = function() {
CHK.init = function() {
//共通処理
CHK.initCommon();
CHK.loadDashboardSetting();
//VR設定
krpano.call("set(content[def].useVr, false);");
......@@ -552,6 +560,27 @@ CHK.initPushMessageList = function() {
});
}
CHK.loadDashboardSetting = function() {
CHK.loadJson(CHK.jsonPath.dashboardSetting, function(json) {
if (json) {
CHK.dashboardSetting = json;
}
});
// ios clear localStorage when reopen index page
// var setting = localStorage.getItem('dashboardSetting');
// if (setting) {
// CHK.dashboardSetting = JSON.parse(setting);
// }
}
CHK.saveDashboardSetting = function(key, enabled) {
if (key) {
CHK.dashboardSetting[key] = enabled;
}
CHK.saveJson(CHK.jsonPath.dashboardSetting, CHK.dashboardSetting);
//localStorage.setItem('dashboardSetting' , JSON.stringify(CHK.dashboardSetting));
}
/**
* 作業一覧を描画
*/
......@@ -3356,6 +3385,15 @@ CHK.openCategory = function() {
}
}
//save, load json
CHK.saveJson = function(jsonFileName, jsonData) {
var param = {};
param.cmd = CHK.getCommand("saveJson");
param.jsonName = jsonFileName;
param.jsonData = JSON.stringify(jsonData);
CHK.sendABookCheckApi(param);
}
$(document).ready(function () {
var urlParam = CHK.getUrlParameter();
if (typeof urlParam !== 'undefined' && typeof urlParam.lang !== 'undefined') {
......
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