mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-24 02:58:43 +02:00
N°3617 collapsible components state saving : use user pref instead of localStorage
No migration from existing localStorage keys (introduced in 2.5.0 with N°1030) as the console UI has dramatically change in 3.0.0 : will be useful to show all the collapsible sections content once again ! Note that an iTop instance identifier was used in the localStorage key, it is no longer needed as we're getting the user pref directly from the current instance. Thanks @Molkobain for the help !
This commit is contained in:
28
js/utils.js
28
js/utils.js
@@ -346,17 +346,41 @@ function SetUserPreference(sPreferenceCode, sPrefValue, bPersistent) {
|
||||
|
||||
/**
|
||||
* Get user specific preferences
|
||||
* depends on a global variable oUserPreferences created/filled by the iTopWebPage
|
||||
* that acts as a local -write through- cache
|
||||
* @borrows global variable oUserPreferences created/filled by the iTopWebPage if login method was called
|
||||
*/
|
||||
function GetUserPreference(sPreferenceCode, sDefaultValue) {
|
||||
var value = sDefaultValue;
|
||||
if ((typeof(oUserPreferences) !== 'undefined') && (typeof(oUserPreferences[sPreferenceCode]) !== 'undefined')) {
|
||||
if ((typeof (oUserPreferences) !== 'undefined') && (typeof (oUserPreferences[sPreferenceCode]) !== 'undefined')) {
|
||||
value = oUserPreferences[sPreferenceCode];
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} sPreferenceCode
|
||||
* @param {boolean} bDefaultValue
|
||||
* @returns {boolean}
|
||||
* @since 3.0.0
|
||||
*/
|
||||
function GetUserPreferenceAsBoolean(sPreferenceCode, bDefaultValue) {
|
||||
let sVal = GetUserPreference(sPreferenceCode, bDefaultValue);
|
||||
try {
|
||||
sVal = sVal.toLowerCase();
|
||||
} catch (error) {
|
||||
// nothing : this may be the boolean default value !
|
||||
}
|
||||
|
||||
if (sVal === "true") {
|
||||
return true;
|
||||
}
|
||||
if (sVal === "false") {
|
||||
return false;
|
||||
}
|
||||
|
||||
return bDefaultValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check/uncheck a whole list of checkboxes
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user