Testbeds list plugin with filters: key, included, [x,y,z]
[myslice.git] / plugins / querytable / static / js / querytable.js
index 19ecd6c..8637e72 100644 (file)
                     else
                         line.push(record['hostname']);
 
-                } else if (colnames[j] == 'hrn' && typeof(record) != 'undefined') {
-                    line.push('<a href="../resource/'+record['urn']+'"><span class="glyphicon glyphicon-search"></span></a> '+record['hrn']);
+                } else if (colnames[j] == this.init_key && typeof(record) != 'undefined') {
+                    obj = this.object
+                    o = obj.split(':');
+                    if(o.length>1){
+                        obj = o[1];
+                    }else{
+                        obj = o[0];
+                    }
+                    /* XXX TODO: Remove this and have something consistant */
+                    if(obj=='resource'){
+                        line.push('<a href="../'+obj+'/'+record['urn']+'"><span class="glyphicon glyphicon-search"></span></a> '+record[this.init_key]);
+                    }else{
+                        line.push('<a href="../'+obj+'/'+record[this.init_key]+'"><span class="glyphicon glyphicon-search"></span></a> '+record[this.init_key]);
+                    }
                 } else {
                     if (record[colnames[j]])
                         line.push(record[colnames[j]]);
         {
             // Remove corresponding filters
             this.filters = $.grep(this.filters, function(x) {
-                return x != filter;
+                return x == filter;
             });
             this.redraw_table();
         },
             switch(data.request) {
                 case FIELD_REQUEST_ADD:
                 case FIELD_REQUEST_ADD_RESET:
-                    this.set_checkboxfrom_data(data.value, true);
+                    this.set_checkbox_from_data(data.value, true);
                     break;
                 case FIELD_REQUEST_REMOVE:
                 case FIELD_REQUEST_REMOVE_RESET:
                 if (op == '=' || op == '==') {
                     if ( col_value != value || col_value==null || col_value=="" || col_value=="n/a")
                         ret = false;
+                }else if (op == 'included') {
+                    $.each(value, function(i,x) {
+                      if(x == col_value){
+                          ret = true;
+                          return false;
+                      }else{
+                          ret = false;
+                      }
+                    });
                 }else if (op == '!=') {
                     if ( col_value == value || col_value==null || col_value=="" || col_value=="n/a")
                         ret = false;