X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=plugins%2Fqueryupdater%2Fstatic%2Fjs%2Fqueryupdater.js;h=ac7fc0aeccf3e70f473371fa4db69c8037c6553d;hb=c99f1bd98ff355bd3f63b4929739ea5bd92cd6a3;hp=e4b3f9cef9d0c8b1f032331eb321ff64ab3ae94a;hpb=c9bda06ba879bace5ed82bd188ac562c35163acf;p=unfold.git diff --git a/plugins/queryupdater/static/js/queryupdater.js b/plugins/queryupdater/static/js/queryupdater.js index e4b3f9ce..ac7fc0ae 100644 --- a/plugins/queryupdater/static/js/queryupdater.js +++ b/plugins/queryupdater/static/js/queryupdater.js @@ -70,8 +70,51 @@ do_update: function(e) { var self = e.data; + var username = e.data.options.username; + var urn = data.value; // XXX check that the query is not disabled - manifold.raise_event(self.options.query_uuid, RUN_UPDATE); + + console.log("DATA VALUE: " + data.value); + + if (data.value.toLowerCase().indexOf("iminds") >= 0){ + + $('#sla_dialog').show(); + $('#slamodal').modal('show'); + + $(document).ready(function() { + $("#accept_sla").click(function(){ + console.log("SLA ACCEPTED"); + console.log("With username: " + username); + if(urn.toLowerCase().indexOf("wall2") >= 0){ + $.post("/sla/agreements/simplecreate", + { "template_id": "iMindsServiceVirtualwall", + "user": username, + "expiration_time": new Date() // jgarcia: FIXME + }); + } else if(urn.toLowerCase().indexOf("wilab2") >= 0){ + $.post("/sla/agreements/simplecreate", + { "template_id":"iMindsServiceWiLab2", + "user":username, + "expiration_time": new Date() // jgarcia: FIXME + }); + } + $('#slamodal').modal('hide'); + console.log("Executing raise_event after sending SLA"); + // manifold.raise_event(self.options.query_uuid, RUN_UPDATE); + }); + }); + + $(document).ready(function() { + $("#dismiss_sla").click(function(){ + console.log("SLA NOT ACCEPTED"); + $('#slamodal').modal('hide'); + }); + }); + + } else { + console.log("Executing raise_event"); + manifold.raise_event(self.options.query_uuid, RUN_UPDATE); + } }, // related buttons are also disabled in the html template @@ -142,6 +185,8 @@ 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'; @@ -188,6 +233,8 @@ // 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); @@ -305,6 +352,7 @@ on_added_record: function(record) { this.set_record_state(record, RECORD_STATE_ADDED); + // update pending number }, on_removed_record: function(record_key)