summaryrefslogtreecommitdiffstats
path: root/install/static/entity.js
diff options
context:
space:
mode:
authorEndi S. Dewata <edewata@redhat.com>2010-09-30 15:37:33 -0500
committerAdam Young <ayoung@redhat.com>2010-10-01 09:06:47 -0400
commitc53831037cbe388d961420e87b036b1caf6cf723 (patch)
tree1d43f011ffaabad7307e5181b715659c41676815 /install/static/entity.js
parent4f2d2fda93b1a118869579efa70d800a28b97a8b (diff)
downloadfreeipa-c53831037cbe388d961420e87b036b1caf6cf723.tar.gz
freeipa-c53831037cbe388d961420e87b036b1caf6cf723.tar.xz
freeipa-c53831037cbe388d961420e87b036b1caf6cf723.zip
Refactoring navigation.js.
The navigation.js has been modified to make it more abstract, i.e. unaware of entity facets. The nav_update_tabs() has been modified such that it activates and updates the tabs based on the current state stored in the URL. The facets are now handled in entity.js. The ipa_entity_setup() has been modified to update the facets based on the current state and cached state. The navigation.js also has been modified to be more class-like. The nav_create() has been modified to store the tab configuration and the tab container in internal variables nav_tabs_lists and nav_container. The nav_update_tabs() now can be called without any parameters. Functions nav_push_state(), nav_get_state(), and nav_remove_state() have been added to wrap BBQ API. This is to allow unit tests to replace them with mockup functions to remove dependency on BBQ.
Diffstat (limited to 'install/static/entity.js')
-rw-r--r--install/static/entity.js47
1 files changed, 45 insertions, 2 deletions
diff --git a/install/static/entity.js b/install/static/entity.js
index 7b82c06e..39836fe3 100644
--- a/install/static/entity.js
+++ b/install/static/entity.js
@@ -24,6 +24,9 @@ var ipa_entity_search_list = {};
var ipa_entity_add_list = {};
var ipa_entity_details_list = {};
+/* use this to track individual changes between two hashchange events */
+var window_hash_cache = {};
+
function ipa_entity_set_search_definition(obj_name, data)
{
ipa_entity_search_list[obj_name] = data;
@@ -39,8 +42,49 @@ function ipa_entity_set_details_definition(obj_name, data)
ipa_entity_details_list[obj_name] = data;
}
-function ipa_entity_setup(jobj)
+function ipa_entity_setup(container)
{
+ var id = container.attr('id');
+
+ var state = id + '-facet';
+ var facet = $.bbq.getState(state, true) || 'search';
+ var last_facet = window_hash_cache[state];
+
+ if (facet != last_facet) {
+ _ipa_entity_setup(container);
+ window_hash_cache[state] = facet;
+
+ } else if (facet == 'search') {
+ state = id + '-filter';
+ var filter = $.bbq.getState(state, true);
+ var last_filter = window_hash_cache[state];
+ if (filter == last_filter) return;
+
+ _ipa_entity_setup(container);
+ window_hash_cache[state] = filter;
+
+ } else if (facet == 'details') {
+ state = id + '-pkey';
+ var pkey = $.bbq.getState(state, true);
+ var last_pkey = window_hash_cache[state];
+ if (pkey == last_pkey) return;
+
+ _ipa_entity_setup(container);
+ window_hash_cache[state] = pkey;
+
+ } else if (facet == 'associate') {
+ state = id + '-enroll';
+ var enroll = $.bbq.getState(state, true);
+ var last_enroll = window_hash_cache[state];
+ if (enroll == last_enroll) return;
+
+ _ipa_entity_setup(container);
+ window_hash_cache[state] = enroll;
+ }
+}
+
+function _ipa_entity_setup(jobj) {
+
var obj_name = jobj.attr('id');
function reset_on_click() {
@@ -158,4 +202,3 @@ function ipa_entity_generate_views(obj_name, container, switch_view)
container.append(ul);
}
-