(function( $ ){
+ var debug=false;
+ debug=true;
+
// XXX record selected (multiple selection ?)
// XXX record disabled ?
// XXX out of sync plugin ?
var QueryUpdater = Plugin.extend({
- init: function(options, element)
- {
+ init: function(options, element) {
+ this.classname="queryupdater";
this._super(options, element);
var self = this;
/***************************** GUI EVENTS *****************************/
- do_update: function(e)
- {
+ do_update: function(e) {
var self = e.data;
// XXX check that the query is not disabled
manifold.raise_event(self.options.query_uuid, RUN_UPDATE);
// make sure the change is visible : toggle on the whole plugin
// this might have to be made an 'auto-toggle' option of this plugin..
// also it might be needed to be a little finer-grained here
- this.toggle_on();
+
+ // XXX we don't want to show automaticaly the pending when a checkbox is checked
+ //this.toggle_on();
switch(data.request) {
case FIELD_REQUEST_ADD_RESET:
row = this.find_row(data.value);
if (row)
this.table.fnDeleteRow(row.nTr);
+ $("#badge-pending").data('number', $("#badge-pending").data('number') - 1 );
+ $("#badge-pending").text($("#badge-pending").data('number'));
return;
case FIELD_REQUEST_CHANGE:
action = 'UPDATE';
var status = msg + status;
+
+
// find line
// if no, create it, else replace it
// XXX it's not just about adding lines, but sometimes removing some
// XXX how do we handle status reset ?
+ data.value = JSON.stringify(data.value);
row = this.find_row(data.value);
newline = [
action,
// XXX second parameter refresh = false can improve performance. todo in querytable also
this.table.fnAddData(newline);
row = this.find_row(data.value);
+ $("#badge-pending").data('number', $("#badge-pending").data('number') + 1 );
+ $("#badge-pending").text($("#badge-pending").data('number'));
} else {
// Update row text...
this.table.fnUpdate(newline, row.nTr);
on_query_in_progress: function()
{
+ messages.debug("queryupdater.on_query_in_progress");
this.spin();
},
on_added_record: function(record)
{
this.set_record_state(record, RECORD_STATE_ADDED);
+ // update pending number
},
on_removed_record: function(record_key)
on_field_state_changed: function(result)
{
- console.log(result)
+ messages.debug(result)
/* this.set_state(result.request, result.key, result.value, result.status); */
this.set_state(result);
},
update_resources: function(resources, change)
{
- console.log("update_resources");
+ messages.debug("update_resources");
var my_oTable = this.table.dataTable();
var prev_resources = this.current_resources;