loading messages
[unfold.git] / plugins / apply / static / js / apply.js
index a664ce5..236deaf 100644 (file)
                        bAutoWidth: true,
             });
             
-            //this.elmt('update').click(this, this.do_ok);
-            //this.elmt('refresh').click(this, this.do_cancel);
+            this.elmt('close').click(this, this.do_close);
+            //this.elmt('apply_cancel').click(this, this.do_cancel);
 
-            this.elmt('apply').on('shown.bs.modal', function() {
+            this.elmt('apply__window').on('shown.bs.modal', function() {
                 self.do_update();
             })
 
 
         clear: function()
         {
-
         },
 
-        find_row: function(key)
+        find_row: function(value)
         {
+            var KEY_POS, VALUE_POS, data, object_type, object_key;
+
+            TYPE_POS = 1;
             // key in third position, column id = 2
-            var KEY_POS = 2;
+            VALUE_POS = 2;
 
             var cols = $.grep(this.table.fnSettings().aoData, function(col) {
-                return (col._aData[KEY_POS] == key);
+                cur_value = col._aData[VALUE_POS];
+                object_type = col._aData[TYPE_POS];
+                object_key = manifold.metadata.get_key(object_type);
+
+                if (cur_value[0] == '{') {
+                    cur_value = JSON.parse(cur_value);
+                    return manifold._record_equals(cur_value, value, object_key);
+                } else {
+                    return (cur_value == value);
+                }
             } );
 
             if (cols.length == 0)
 
             var username = this.options.username;
 
-            this.spin();
             console.log("do_update in progress");
 
             manifold.raise_event(this.options.query_uuid, RUN_UPDATE);
 
         },
 
-        do_ok: function(e)
+        do_close: function(e)
         {
-            throw 'queryupdater.do_reset Not implemented';
+            var self = e.data;
+            self.table.fnClearTable();
         },
 
+        // Not used today
         do_cancel: function(e)
         {
             throw 'queryupdater.do_clear_annotations Not implemented';
 
         on_query_in_progress: function()
         {
-            this.spin();
         },
 
         on_query_done: function()
         {
             this.populate_table();
-            this.unspin();
         },
 
         // D : Data present
 
         on_clear_records: function()
         {
+                $('#applyloading').hide();
             this.clear();
         },
 
         on_query_done: function()
         {
-            this.unspin();
+            $('#applyloading').hide();
         },
 
         // PC : Pending changes
             // XXX how do we handle status reset ?
 
             // Jordan : I don't understand this. I added this test otherwise we have string = ""..."" double quoted twice.
-            if (typeof(data.value) !== "string")
-                data.value = JSON.stringify(data.value);
             data.selected_resources = this.selected_resources;
             row = this.find_row(data.value);
-            newline = [action, data.key, data.value, msg, button];
+            if (typeof(data.value) !== "string")
+                newline = [action, data.key, JSON.stringify(data.value), msg, button];
+            else
+                newline = [action, data.key, data.value, msg, button];
             if (!row) {
                 // XXX second parameter refresh = false can improve performance. todo in querytable also
                 this.table.fnAddData(newline);