fixed naming for facility_name and testbed_name in QueryTable plugin
[unfold.git] / plugins / querytable / static / js / querytable.js
index 623a1e1..7ddf300 100644 (file)
@@ -12,7 +12,8 @@ QUERYTABLE_BGCOLOR_REMOVED = 2;
 
     
     var QUERYTABLE_MAP = {
-        'Testbed': 'network_hrn',
+        'Facility': 'facility_name',
+        'Testbed': 'testbed_name',
         'Resource name': 'hostname',
         'Type': 'type',
     };
@@ -97,7 +98,7 @@ QUERYTABLE_BGCOLOR_REMOVED = 2;
                 sPaginationType: 'bootstrap',
                 // Handle the null values & the error : Datatables warning Requested unknown parameter
                 // http://datatables.net/forums/discussion/5331/datatables-warning-...-requested-unknown-parameter/p2
-                aoColumnDefs: [{sDefaultContent: '',aTargets: [ '_all' ]}],
+                aoColumnDefs: [{sDefaultContent: '', aTargets: [ '_all' ]}],
                 // WARNING: this one causes tables in a 'tabs' that are not exposed at the time this is run to show up empty
                 // sScrollX: '100%',       /* Horizontal scrolling */
                 bProcessing: true,      /* Loading */
@@ -450,10 +451,12 @@ QUERYTABLE_BGCOLOR_REMOVED = 2;
         
         on_field_state_changed: function(data)
         {
-            var state = manifold.query_store.get_record_state(this.options.query_uuid, data.value, data.status);
-            switch(data.status) {
+            // XXX We could get this from data.value
+            // var state = manifold.query_store.get_record_state(this.options.query_uuid, data.value, data.state);
+
+            switch(data.state) {
                 case STATE_SET:
-                    switch(state) {
+                    switch(data.op) {
                         case STATE_SET_IN:
                         case STATE_SET_IN_SUCCESS:
                         case STATE_SET_OUT_FAILURE:
@@ -467,18 +470,18 @@ QUERYTABLE_BGCOLOR_REMOVED = 2;
                             this.set_bgcolor(data.value, QUERYTABLE_BGCOLOR_RESET);
                             break;
                         case STATE_SET_IN_PENDING:
-                            this.set_checkbox_from_data(data.value, true);
+                            this.set_checkbox_from_data(data.key, true);
                             this.set_bgcolor(data.value, QUERYTABLE_BGCOLOR_ADDED);
                             break;  
                         case STATE_SET_OUT_PENDING:
-                            this.set_checkbox_from_data(data.value, false);
+                            this.set_checkbox_from_data(data.key, false);
                             this.set_bgcolor(data.value, QUERYTABLE_BGCOLOR_REMOVED);
                             break;
                     }
                     break;
 
                 case STATE_WARNINGS:
-                    this.change_status(data.value, state);
+                    this.change_status(data.key, data.value);
                     break;
             }
         },
@@ -551,14 +554,18 @@ QUERYTABLE_BGCOLOR_REMOVED = 2;
 
         _check_click: function(e) 
         {
-            e.stopPropagation();
-
+            var data;
             var self = e.data;
-        var id=this.id;
 
-            // this.id = key of object to be added... what about multiple keys ?
-        if (debug) messages.debug("querytable._check_click key="+this.canonical_key+"->"+id+" checked="+this.checked);
-            manifold.raise_event(self.options.query_uuid, this.checked?SET_ADD:SET_REMOVED, id);
+            e.stopPropagation();
+
+            data = {
+                state: STATE_SET,
+                key  : null,
+                op   : this.checked ? STATE_SET_ADD : STATE_SET_REMOVE,
+                value: this.id
+            }
+            manifold.raise_event(self.options.query_uuid, FIELD_STATE_CHANGED, data);
             //return false; // prevent checkbox to be checked, waiting response from manifold plugin api
             
         },