X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=plugins%2Fquerytable%2Fstatic%2Fjs%2Fquerytable.js;h=935c08784390d4a48392786e7b9cdde1a84cdecb;hb=f01153e83e648390596f0343294912560165bc49;hp=12232c8e372fc70e6e540a96125005ce29e67369;hpb=bbfc7014301e80090bf60082cbb11bc2a4e3ed7f;p=myslice.git diff --git a/plugins/querytable/static/js/querytable.js b/plugins/querytable/static/js/querytable.js index 12232c8e..935c0878 100644 --- a/plugins/querytable/static/js/querytable.js +++ b/plugins/querytable/static/js/querytable.js @@ -7,7 +7,7 @@ (function($){ var debug=false; -// debug=true + debug=true var QueryTable = Plugin.extend({ @@ -39,19 +39,25 @@ // $(window).unbind('QueryTable'); var query = manifold.query_store.find_analyzed_query(this.options.query_uuid); - this.method = query.object; - - var keys = manifold.metadata.get_key(this.method); - this.key = (keys && keys.length == 1) ? keys[0] : null; - - // xxx temporary hack - // as of nov. 28 2013 we have here this.key='urn', but in any place where - // the code tries to access record[this.key] the records only have - // keys=type,hrn,network_hrn,hostname - // so for now we force using hrn instead - // as soon as record have their primary key set this line can be removed - // see also same hack in googlemap - this.key= (this.key == 'urn') ? 'hrn' : this.key; + this.object = query.object; + + //// we need 2 different keys + // * canonical_key is the primary key as derived from metadata (typically: urn) + // and is used to communicate about a given record with the other plugins + // * init_key is a key that both kinds of records + // (i.e. records returned by both queries) must have (typically: hrn or hostname) + // in general query_all will return well populated records, but query + // returns records with only the fields displayed on startup + var keys = manifold.metadata.get_key(this.object); + this.canonical_key = (keys && keys.length == 1) ? keys[0] : undefined; + // + this.init_key = this.options.init_key; + // have init_key default to canonical_key + this.init_key = this.init_key || this.canonical_key; + // sanity check + if ( ! this.init_key ) messages.warning ("QueryTable : cannot find init_key"); + if ( ! this.canonical_key ) messages.warning ("QueryTable : cannot find canonical_key"); + if (debug) messages.debug("querytable: canonical_key="+this.canonical_key+" init_key="+this.init_key); /* Setup query and record handlers */ this.listen_query(options.query_uuid); @@ -160,22 +166,28 @@ return (tabIndex.length > 0) ? tabIndex[0] : -1; }, // getColIndex - checkbox_html : function (key, value) - { -// if (debug) messages.debug("checkbox_html, value="+value); + // create a checkbox tag + // computes 'id' attribute from canonical_key + // computes 'init_id' from init_key for initialization phase + // no need to used convoluted ids with plugin-uuid or others, since + // we search using table.$ which looks only in this table + checkbox_html : function (record) { var result=""; // Prefix id with plugin_uuid result += ""+id+" checked="+this.checked); + manifold.raise_event(self.options.query_uuid, this.checked?SET_ADD:SET_REMOVED, id); //return false; // prevent checkbox to be checked, waiting response from manifold plugin api },