summaryrefslogtreecommitdiffstats
path: root/install/static/search.js
diff options
context:
space:
mode:
authorAdam Young <ayoung@redhat.com>2010-09-07 10:08:19 -0400
committerAdam Young <ayoung@redhat.com>2010-09-07 10:08:19 -0400
commitdde15772700da41ec931bb55087fbec6f30fab55 (patch)
tree890bd7ecd8bb4d906c4b670b772b2a960c50f3c1 /install/static/search.js
parente93932b3235fc27b31a59c0cb77250acf15d3f31 (diff)
downloadfreeipa-dde15772700da41ec931bb55087fbec6f30fab55.tar.gz
freeipa-dde15772700da41ec931bb55087fbec6f30fab55.tar.xz
freeipa-dde15772700da41ec931bb55087fbec6f30fab55.zip
associations
-Refactored the associations code into a set of objects that are configured by the entities -Added support for associations that can be done in a single rpc -hostgroup to host and group to user associations working -Restructed sampledata so that the file is matched automatically by the RPC method name -The new ipa_cmd/sampledata scheme insists on there being sample data for any commands or the ipa_command fails. -Added sampledata files for all the calls we make -renamed several of the sampledata files to match their rpc calls -Started a pattern of refactoring where all the forms for the entity fall under a single object
Diffstat (limited to 'install/static/search.js')
-rw-r--r--install/static/search.js110
1 files changed, 53 insertions, 57 deletions
diff --git a/install/static/search.js b/install/static/search.js
index 95ac482d..c1f99bab 100644
--- a/install/static/search.js
+++ b/install/static/search.js
@@ -1,6 +1,3 @@
-//useSampleData is defined in index.xhtml. Work around for development
-var sampleData;
-
//Columns is an array of items in the form
// {title, column, render}
@@ -25,13 +22,19 @@ function renderUnknownColumn(current,cell){
}
-function renderPkeyColumn(form,current,cell){
+function renderPkeyColumn2(obj,pkeyCol,current,cell){
$("<a/>",{
- href:"#tab="+form.obj+"&facet=details&pkey="+current[form.pkeyCol],
- html: "" + current[form.pkeyCol],
+ href:"#tab="+obj+"&facet=details&pkey="+current[pkeyCol],
+ html: "" + current[pkeyCol],
}).appendTo(cell);
}
+function renderPkeyColumn(form,current,cell){
+ renderPkeyColumn2(form.obj, form.pkeyCol,current, cell);
+}
+
+
+
function renderDetailColumn(current,cell,pkey,obj){
$("<a/>",{
@@ -42,7 +45,7 @@ function renderDetailColumn(current,cell,pkey,obj){
-function SearchForm(obj, method, cols, searchSampleData){
+function SearchForm(obj, method, cols){
this.buildColumnHeaders = function (){
var columnHeaders = document.createElement("tr");
@@ -66,67 +69,60 @@ function SearchForm(obj, method, cols, searchSampleData){
}
this.searchSuccess = function (json){
- if (json.result.truncated){
- $("#searchResultsTable tfoot").html("More than "+sizelimit+" results returned. First "+ sizelimit+" results shown." );
- }else{
- $("#searchResultsTable tfoot").html(json.result.summary);
- }
- $("#searchResultsTable tbody").find("tr").remove();
- for (var index = 0; index != json.result.result.length; index++){
- var current = json.result.result[index];
- $('#searchResultsTable tbody:last').append(this.renderResultRow(current));
- }
+ if (json.result.truncated){
+ $("#searchResultsTable tfoot").html("More than "+sizelimit+" results returned. First "+ sizelimit+" results shown." );
+ }else{
+ $("#searchResultsTable tfoot").html(json.result.summary);
+ }
+ $("#searchResultsTable tbody").find("tr").remove();
+ for (var index = 0; index != json.result.result.length; index++){
+ var current = json.result.result[index];
+ $('#searchResultsTable tbody:last').append(this.renderResultRow(current));
+ }
}
this.searchWithFilter = function(queryFilter){
- var form = this;
-
- $('#searchResultsTable tbody').html("");
- $('#searchResultsTable tbody').html("");
- $('#searchResultsTable tfoot').html("");
-
- ipa_cmd(this.method,
- [queryFilter],
- {"all":"true"},
- function(json){
- form.searchSuccess(json);
- },
- function(json){
- alert("Search Failed");
- },form.obj, form.searchSampleData);
-
+ var form = this;
+
+ $('#searchResultsTable tbody').html("");
+ $('#searchResultsTable tbody').html("");
+ $('#searchResultsTable tfoot').html("");
+
+ ipa_cmd(this.method,
+ [queryFilter],
+ {"all":"true"},
+ function(json){
+ form.searchSuccess(json);
+ },
+ function(json){
+ alert("Search Failed");
+ },
+ form.obj);
}
this.setup = function(){
- showSearch();
-
- $('#searchResultsTable thead').html("");
- $('#searchResultsTable tbody').html("");
- $('#searchResultsTable tfoot').html("");
-
- $("#new").click(function(){
- location.hash="tab="+obj+"&facet=add";
- });
-
- $("#query").click(executeSearch);
-
- this.buildColumnHeaders();
-
- var params = ipa_parse_qs();
-
- qs = location.hash.substring(1);
- //TODO fix this hack. since parse returns an object, I don't know how to see if that object has a"critia" property if criteria is null.
- if (qs.indexOf("criteria") > 0)
- {
- this.searchWithFilter(params["criteria"]);
- }
+ showSearch();
+
+ $('#searchResultsTable thead').html("");
+ $('#searchResultsTable tbody').html("");
+ $('#searchResultsTable tfoot').html("");
+ $("#new").click(function(){
+ location.hash="tab="+obj+"&facet=add";
+ });
+ $("#query").click(executeSearch);
+ this.buildColumnHeaders();
+ var params = ipa_parse_qs();
+ qs = location.hash.substring(1);
+ //TODO fix this hack. since parse returns an object, I don't know how to see if that object has a"critia" property if criteria is null.
+ if (qs.indexOf("criteria") > 0)
+ {
+ this.searchWithFilter(params["criteria"]);
+ }
}
this.obj = obj;
this.method = method;
this.columns = cols;
- this.searchSampleData = searchSampleData;
-
this.setup();
}
executeSearch = function(){