summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPavel Vomacka <pvomacka@redhat.com>2016-08-11 15:56:01 +0200
committerMartin Babinsky <mbabinsk@redhat.com>2017-03-08 14:54:56 +0100
commitf78cc8932626de667c6e3a4461141a10a5d9c2e6 (patch)
treeb1547f5e4be1c2cc064ea07087f2c2ae0547b941
parent7b699105a52d4d8c26a73044ba182d752b4a9833 (diff)
downloadfreeipa-f78cc8932626de667c6e3a4461141a10a5d9c2e6.tar.gz
freeipa-f78cc8932626de667c6e3a4461141a10a5d9c2e6.tar.xz
freeipa-f78cc8932626de667c6e3a4461141a10a5d9c2e6.zip
Make singleton from config module
Also added general setter and getter for attributes of config. Part of: https://fedorahosted.org/freeipa/ticket/5742 Reviewed-By: Petr Vobornik <pvoborni@redhat.com>
-rw-r--r--install/ui/src/freeipa/config.js51
1 files changed, 45 insertions, 6 deletions
diff --git a/install/ui/src/freeipa/config.js b/install/ui/src/freeipa/config.js
index 61922d454..3bf017bdc 100644
--- a/install/ui/src/freeipa/config.js
+++ b/install/ui/src/freeipa/config.js
@@ -20,14 +20,18 @@
-define([], function() {
+define([
+ 'dojo/_base/declare',
+ 'dojo/topic'
+ ],
+ function(declare, topic) {
/**
* Application configuration
* @class config
* @singleton
*/
- var config = {
+ var config = declare([], {
/**
* Selector for application container node
@@ -82,8 +86,43 @@ define([], function() {
* Hide sections without any visible widget
* @property {boolean}
*/
- hide_empty_sections: true
- };
+ hide_empty_sections: true,
- return config;
-}); \ No newline at end of file
+ /**
+ * Number of lines in table on table_facets
+ * @property {Integer}
+ */
+ table_page_size: 20,
+
+ /**
+ * Genereal setter for config values.
+ * @param item_name {string}
+ * @param value
+ * @param store {Boolean} sets whether the value will be stored into
+ * local storage
+ */
+ set: function(item_name, value, store) {
+ if (!item_name) return;
+ this[item_name] = value;
+
+ if (store) {
+ window.localStorage.setItem(item_name, value);
+ }
+ },
+
+ /**
+ * Genereal setter for config values.
+ * @param item_name {string}
+ */
+ get: function(item_name) {
+ return this[item_name];
+ },
+
+ constructor: function() {
+ var user_limit = window.localStorage.getItem('table_page_size');
+ if (user_limit) this.table_page_size = user_limit;
+ }
+ });
+
+ return new config();
+});