summaryrefslogtreecommitdiffstats
path: root/install/static/search.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/search.js
parent09555fae17dcd142c4b39643e3f7d376ed8d4841 (diff)
downloadfreeipa-4b4ecef4a32319932f31413feaf60e0dbfa96973.tar.gz
freeipa-4b4ecef4a32319932f31413feaf60e0dbfa96973.tar.xz
freeipa-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/search.js')
-rw-r--r--install/static/search.js38
1 files changed, 25 insertions, 13 deletions
diff --git a/install/static/search.js b/install/static/search.js
index 5e5be8fa0..59caf71f0 100644
--- a/install/static/search.js
+++ b/install/static/search.js
@@ -52,13 +52,19 @@ function search_create(obj_name, scl, container)
jobj.children().last().click(find_on_click);
div.append('<span class="search-buttons"></span>');
- container.append('<table class="search-table"></table>');
- jobj = container.children().last();
- jobj.append('<thead><tr></tr></thead>');
- jobj.append('<tbody></tbody>');
- jobj.append('<tfoot></tfoot>');
+ var search_results = $('<div/>', {
+ class: 'search-results'
+ }).appendTo(container);
- var tr = jobj.find('tr');
+ var search_table = $('<table/>', {
+ class: 'search-table'
+ }).appendTo(search_results);
+
+ search_table.append('<thead><tr></tr></thead>');
+ search_table.append('<tbody></tbody>');
+ search_table.append('<tfoot></tfoot>');
+
+ var tr = search_table.find('tr');
for (var i = 0; i < scl.length; ++i) {
var c = scl[i];
search_insert_th(tr, obj_name, c[0], c[1], c[2]);
@@ -85,23 +91,29 @@ function search_insert_th(jobj, obj_name, attr, name, render_call)
jobj.append(th);
}
-function search_load(obj_name, criteria, on_win, on_fail)
+function search_load(jobj, criteria, on_win, on_fail)
{
- function load_on_win(data, text_status, xhr) {
+ var obj_name = jobj.attr('id');
+
+ function search_on_success(data, text_status, xhr) {
+ if (on_win)
+ on_win(data, text_status, xhr);
if (data.error)
return;
search_display(obj_name, data);
- if (on_win)
- on_win(data, text_status, xhr);
};
- function load_on_fail(xhr, text_status, error_thrown) {
+ function search_on_error(xhr, text_status, error_thrown) {
if (on_fail)
on_fail(xhr, text_status, error_thrown);
- };
+
+ var search_results = $('.search-results', jobj);
+ search_results.append('<p>Error: '+error_thrown.name+'</p>');
+ search_results.append('<p>'+error_thrown.message+'</p>');
+ }
ipa_cmd(
- 'find', [criteria], {all: true}, load_on_win, load_on_fail, obj_name
+ 'find', [criteria], {all: true}, search_on_success, search_on_error, obj_name
);
}