oops
[myslice.git] / plugins / updater / updater.js
index 26390a8..ae349f7 100644 (file)
        // implementation wouldn't fly
        // we keep this for a later improvement
        var query=manifold.find_query (options.query_uuid);
-       console.log("retrieved query " + query.__repr());
+       messages.info("retrieved query " + query.__repr());
        // very rough way of filling this for now
        this.update_query = 
            new ManifoldQuery ("update", query.subject, null, query.filters, 
                               {}, // params
                               query.fields, 
                               undefined, /* unique */ 
-                              query.query_uuid, /* tmp */
+                              Math.uuid(32,16), 
                               undefined, undefined /* maybe some day I'll get that one */);
+       manifold.insert_query (this.update_query);
        // arm button once document is loaded
        (function(updater) {$(document).ready(function(){updater.arm_button()})})(this);
 
        this.arm_button = function () {
-           console.log("arm_button");
            $('#updater-' + this.options.plugin_uuid).click(this, this.submit_update_request);
        },
        this.submit_update_request = function (e) {
-           console.log("submit_update_request");
+           messages.debug("submit_update_request");
            var query_uuid = e.data.options.query_uuid;
            var update_query = e.data.update_query;
            $.publish("/messages/debug","Updater.submit_update_request " + update_query.__repr());
-           // publish results as if coming from the original query
-           manifold.asynchroneous_exec ( [ {'query_uuid': query_uuid, 'publish_uuid' : update_query.query_uuid} ]);
+           // actually send the Update query, but publish results as if coming from the original query
+           manifold.asynchroneous_exec ( [ {'query_uuid': update_query.query_uuid, 'publish_uuid' : query_uuid} ]);
            // looks like a previous attempt to disable the button while the query is flying
             //$('#updateslice-' + options.plugin_uuid).prop('disabled', true);
         },
@@ -93,7 +93,9 @@
        },
   
        update_slice = function (e, rows, query) {
+
            /* This function is called twice : get and update */
+
       
            var data = e.data.instance.data().Slices;