summaryrefslogtreecommitdiffstats
path: root/install/static/navigation.js
diff options
context:
space:
mode:
authorEndi S. Dewata <edewata@redhat.com>2010-09-29 00:52:56 -0500
committerAdam Young <ayoung@redhat.com>2010-09-29 15:43:23 -0400
commit4b4ecef4a32319932f31413feaf60e0dbfa96973 (patch)
treed1aec20a48073b23719efe81d0b5263e830a4bcc /install/static/navigation.js
parent09555fae17dcd142c4b39643e3f7d376ed8d4841 (diff)
downloadfreeipa.git-4b4ecef4a32319932f31413feaf60e0dbfa96973.tar.gz
freeipa.git-4b4ecef4a32319932f31413feaf60e0dbfa96973.tar.xz
freeipa.git-4b4ecef4a32319932f31413feaf60e0dbfa96973.zip
Added error handler for ipa_cmd().
The ipa_cmd() has been modified such that when an error occurs a dialog box will appear showing the error message with 2 buttons: Retry and Cancel. If Retry is clicked, it will attempt to execute the same operation again. If Cancel is clicked, the operation will be canceled and the control is returned to the caller. New unit tests have been added to test ipa_cmd() on successfull and unsuccessfull cases. The associate.js, details.js, entity.js, search.js, and webui.js have been modified to display the error message inside the page. This behavior can be changed in the future (e.g. redirect to error page). The navigation.js and webui.js have been modified to render only the visible tabs. This improves the performance and reduce hidden errors. The navigation unit test has been modified to reflect this behavior. Some variables/functions also have been renamed for consistency.
Diffstat (limited to 'install/static/navigation.js')
-rw-r--r--install/static/navigation.js64
1 files changed, 61 insertions, 3 deletions
diff --git a/install/static/navigation.js b/install/static/navigation.js
index 169729ba..3aa49fe2 100644
--- a/install/static/navigation.js
+++ b/install/static/navigation.js
@@ -18,6 +18,8 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+/* use this to track individual changes between two hashchange events */
+var window_hash_cache = {};
function nav_create(nls, container, tabclass)
{
@@ -38,6 +40,8 @@ function nav_create(nls, container, tabclass)
return true;
}
});
+
+ nav_update_tabs(nls, container);
}
function nav_generate_tabs(nls, container, tabclass, depth)
@@ -62,9 +66,7 @@ function nav_generate_tabs(nls, container, tabclass, depth)
var div = nav_create_tab_div(n.name);
container.append(div);
- if (n.setup) {
- n.setup(div);
- } else if (n.children) {
+ if (n.children) {
nav_generate_tabs(n.children, div, tabclass, depth +1 );
}
}
@@ -103,3 +105,59 @@ function nav_select_tabs(nls, container)
}
}
}
+
+function nav_update_tabs(nls, container)
+{
+ nav_select_tabs(nls, container);
+
+ var index1 = container.tabs('option', 'selected');
+ if (index1 >= nls.length) return;
+
+ var tab1 = nls[index1];
+ if (!tab1.children) return;
+
+ var div1 = $('#' + tab1.name);
+ var index2 = div1.tabs('option', 'selected');
+ if (index2 >= tab1.children.length) return;
+
+ var tab2 = tab1.children[index2];
+ var obj_name = tab2.name;
+ var entity_setup = tab2.setup;
+ var div2 = $('#' + tab2.name);
+
+ var state = obj_name + '-facet';
+ var facet = $.bbq.getState(state, true) || 'search';
+ var last_facet = window_hash_cache[state];
+
+ if (facet != last_facet) {
+ entity_setup(div2);
+ window_hash_cache[state] = facet;
+
+ } else if (facet == 'search') {
+ state = obj_name + '-filter';
+ var filter = $.bbq.getState(state, true);
+ var last_filter = window_hash_cache[state];
+ if (filter == last_filter) return;
+
+ entity_setup(div2);
+ window_hash_cache[state] = filter;
+
+ } else if (facet == 'details') {
+ state = obj_name + '-pkey';
+ var pkey = $.bbq.getState(state, true);
+ var last_pkey = window_hash_cache[state];
+ if (pkey == last_pkey) return;
+
+ entity_setup(div2);
+ window_hash_cache[state] = pkey;
+
+ } else if (facet == 'associate') {
+ state = obj_name + '-enroll';
+ var enroll = $.bbq.getState(state, true);
+ var last_enroll = window_hash_cache[state];
+ if (enroll == last_enroll) return;
+
+ entity_setup(div2);
+ window_hash_cache[state] = enroll;
+ }
+}