X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=plugins%2Fresources_selected%2Fstatic%2Fjs%2Fresources_selected.js;h=0e710a492a2ecabc325e515c6824ae85321cd5f4;hb=c025814eadebf386f556f9af571d3f04e2124a80;hp=5659670da23e5c5cd629c4d4fa4f87a62bb1d35f;hpb=08d7894cc080789686f4b6301626ce54c444d1ff;p=unfold.git
diff --git a/plugins/resources_selected/static/js/resources_selected.js b/plugins/resources_selected/static/js/resources_selected.js
index 5659670d..0e710a49 100644
--- a/plugins/resources_selected/static/js/resources_selected.js
+++ b/plugins/resources_selected/static/js/resources_selected.js
@@ -30,28 +30,33 @@
this._super(options, element);
var self = this;
- this.table = this.el('table').dataTable({
- //sPaginationType: 'full_numbers', // Use pagination
- sPaginationType: 'bootstrap',
- //bJQueryUI : true,
- //bRetrieve : true,
- sScrollX : '100%', // Horizontal scrolling
- bSortClasses : false, // Disable style for the sorted column
- aaSorting : [[ 0, 'asc' ]], // Default sorting on URN
- fnDrawCallback: function() { // Reassociate close click every time the table is redrawn
- /* Prevent to loop on click while redrawing table */
- $('.ResourceSelectedClose').unbind('click');
- /* Handle clicks on close span */
- /* Reassociate close click every time the table is redrawn */
- $('.ResourceSelectedClose').bind('click', self, self._close_click);
- }
+ this.table = this.elmt('table').dataTable({
+// the original querytable layout was
+// sDom: "<'row'<'col-xs-5'l><'col-xs-1'r><'col-xs-6'f>>t<'row'<'col-xs-5'i><'col-xs-7'p>>",
+// however the bottom line with 'showing blabla...' and the navigation widget are not really helpful
+ sDom: "<'row'<'col-xs-5'l><'col-xs-1'r><'col-xs-6'f>>t>",
+// so this does not matter anymore now that the pagination area is turned off
+// sPaginationType: 'bootstrap',
+ bAutoWidth: true,
+// bJQueryUI : true,
+// bRetrieve : true,
+// sScrollX : '100%', // Horizontal scrolling
+// bSortClasses : false, // Disable style for the sorted column
+// aaSorting : [[ 0, 'asc' ]], // Default sorting on URN
+// fnDrawCallback: function() { // Reassociate close click every time the table is redrawn
+// /* Prevent to loop on click while redrawing table */
+// $('.ResourceSelectedClose').unbind('click');
+// /* Handle clicks on close span */
+// /* Reassociate close click every time the table is redrawn */
+// $('.ResourceSelectedClose').bind('click', self, self._close_click);
+// }
});
// XXX This should not be done at init...
- this.el('update').click(this, this.do_update);
- this.el('refresh').click(this, this.do_refresh);
- this.el('reset').click(this, this.do_reset);
- this.el('clear_annotations').click(this, this.do_clear_annotations);
+ this.elmt('update').click(this, this.do_update);
+ this.elmt('refresh').click(this, this.do_refresh);
+ this.elmt('reset').click(this, this.do_reset);
+ this.elmt('clear_annotations').click(this, this.do_clear_annotations);
this.listen_query(options.query_uuid);
},
@@ -67,19 +72,20 @@
manifold.raise_event(self.options.query_uuid, RUN_UPDATE);
},
+ // related buttons are also disabled in the html template
do_refresh: function(e)
{
- throw 'Not implemented';
+ throw 'resource_selected.do_refresh Not implemented';
},
do_reset: function(e)
{
- throw 'Not implemented';
+ throw 'resources_selected.do_reset Not implemented';
},
do_clear_annotations: function(e)
{
- throw 'Not implemented';
+ throw 'resources_selected.do_clear_annotations Not implemented';
},
/************************** GUI MANIPULATION **************************/
@@ -87,7 +93,7 @@
set_button_state: function(name, state)
{
- this.el(name).attr('disabled', state ? false : 'disabled');
+ this.elmt(name).attr('disabled', state ? false : 'disabled');
},
clear: function()
@@ -119,13 +125,20 @@
var button = '';
var row;
-
- if (data.request == FIELD_REQUEST_RESET) {
- // find line
- // delete it
- }
-
+
+ // make sure the change is visible : toggle on the whole plugin
+ // this might hae 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();
+
switch(data.request) {
+ case FIELD_REQUEST_ADD_RESET:
+ case FIELD_REQUEST_REMOVE_RESET:
+ // find line and delete it
+ row = this.find_row(data.value);
+ if (row)
+ this.table.fnDeleteRow(row.nTr);
+ return;
case FIELD_REQUEST_CHANGE:
action = 'UPDATE';
break;
@@ -140,7 +153,7 @@
switch(data.status) {
case FIELD_REQUEST_PENDING:
msg = 'PENDING';
- button = "";
+ button = "";
break;
case FIELD_REQUEST_SUCCESS:
msg = 'SUCCESS';
@@ -165,7 +178,7 @@
button
];
if (!row) {
- // XXX second parameter refresh = false can improve performance. todo in hazelnut also
+ // XXX second parameter refresh = false can improve performance. todo in querytable also
this.table.fnAddData(newline);
row = this.find_row(data.value);
} else {
@@ -301,9 +314,11 @@
// - Key and confirmation could be sufficient, or key and record state
// XXX move record state to the manifold plugin API
- on_field_state_changed: function(request, key, value, status)
+ on_field_state_changed: function(result)
{
- this.set_state(request, key, value, status);
+ console.log(result)
+ /* this.set_state(result.request, result.key, result.value, result.status); */
+ this.set_state(result);
},
// XXX we will have the requests for change
@@ -327,7 +342,7 @@
var remove_urn = this.id;
var current_resources = event.data.instance.current_resources;
var list_resources = $.grep(current_resources, function(x) {return x.urn != remove_urn});
- //jQuery.publish('selected', 'cancel/'+this.id+'/'+get_value(firstCellVal));
+ //jQuery.publish('selected', 'cancel/'+this.id+'/'+unfold.get_value(firstCellVal));
$.publish('/update-set/' + event.data.instance.options.resource_query_uuid, [list_resources, true]);
},
@@ -381,7 +396,7 @@
var urn = r.urn;
time = r.timeslot;
- var SPAN = "";
+ var SPAN = "";
var slot = "" + time + ""; //ioi
// ioi
var newline=Array();
@@ -398,7 +413,7 @@
var node = r.urn;
time = r.timeslot;
- var SPAN = "";
+ var SPAN = "";
var slot = "" + time + ""; //ioi
// ioi
var newline=Array();
@@ -413,7 +428,7 @@
var node = r.urn;
var time = r.timeslot;
- var SPAN = "";
+ var SPAN = "";
var slot = "" + time + "";
// ioi
var newline=Array();