From 31cc945eda5880557485ca4c78f2c23ad991faf4 Mon Sep 17 00:00:00 2001 From: Loic Baron Date: Fri, 17 Jan 2014 16:10:54 +0100 Subject: [PATCH] SliceList display No Result if the user has no slices --- plugins/lists/static/js/simplelist.js | 62 +++++++++++++++------------ portal/dashboardview.py | 2 +- 2 files changed, 36 insertions(+), 28 deletions(-) diff --git a/plugins/lists/static/js/simplelist.js b/plugins/lists/static/js/simplelist.js index 254fb226..f3476c07 100644 --- a/plugins/lists/static/js/simplelist.js +++ b/plugins/lists/static/js/simplelist.js @@ -24,8 +24,11 @@ }, on_query_done: function() { - this._display_table(); + this._display_table(); this.unspin(); + console.log("query simple list done"); + console.log(this); + console.log(this.buffered_records); }, on_new_record: function(record) { @@ -36,40 +39,45 @@ _display_table: function() { var self=this; - var $plugindiv = this.elmt(); - var options = this.options; - // locate the element; with datatables in the way, - // this might not be a direct son of the div-plugin - var $table = $plugindiv.find("table."+this.classname).first(); - // also we may or may not have a header - var $tbody = $table.find("tbody."+this.classname).first(); - var use_datatables = $table.hasClass("with-datatables"); + var $plugindiv = this.elmt(); + var options = this.options; + // locate the
element; with datatables in the way, + // this might not be a direct son of the div-plugin + var $table = $plugindiv.find("table."+this.classname).first(); + // also we may or may not have a header + var $tbody = $table.find("tbody."+this.classname).first(); + var use_datatables = $table.hasClass("with-datatables"); var rows=self.buffered_records; self.buffered_records=[]; - if (debug) - messages.debug($plugindiv.attr('id') + " udt= " + use_datatables + " rows="+rows.length); - - if (rows.length == 0) { - if (use_datatables) - this._datatables_set_message ($table, $tbody, unfold.warning("No result")); - else + if (debug){ + messages.debug($plugindiv.attr('id') + " udt= " + use_datatables + " rows="+rows.length); + } + // check if rows contains results related to the object key + object_key = this.options.key.split('.'); + if (rows.length == 0 || rows[0][object_key[0]].length == 0) { + if (use_datatables){ + this._datatables_set_message ($table, $tbody, unfold.warning("No result")); + }else{ this._regular_set_message ($table, $tbody, unfold.warning("No result")); - return; } + return; + } - if (typeof rows[0].error != 'undefined') { - var error="ERROR: " + rows[0].error; - if (use_datatables) - this._datatables_set_message ($table, $tbody, unfold.error(error)); - else + if (typeof rows[0].error != 'undefined') { + var error="ERROR: " + rows[0].error; + if (use_datatables){ + this._datatables_set_message ($table, $tbody, unfold.error(error)); + }else{ this._regular_set_message ($table, $tbody, unfold.error(error)); - return; } + return; + } - if (use_datatables) - this._datatables_update_table($table, $tbody, rows, options.key); - else - this._regular_update_table($table, $tbody, rows, options.key, this.classname); + if (use_datatables){ + this._datatables_update_table($table, $tbody, rows, options.key); + }else{ + this._regular_update_table($table, $tbody, rows, options.key, this.classname); + } }, _regular_set_message: function ($table, $tbody, message) { diff --git a/portal/dashboardview.py b/portal/dashboardview.py index 2f04a40a..17e3a5ce 100644 --- a/portal/dashboardview.py +++ b/portal/dashboardview.py @@ -46,7 +46,7 @@ class DashboardView (LoginRequiredAutoLogoutView): # root_authority = sub_authority[0] # slice_query = Query().get(root_authority+':user').filter_by('user_hrn', '==', '$user_hrn').select('user_hrn', 'slice.slice_hrn') # else: - slice_query = Query().get('user').filter_by('user_hrn', '==', '$user_hrn').select('user_hrn', 'slice.slice_hrn') + slice_query = Query().get('user').filter_by('user_hrn', '==', '$user_hrn').select('slice.slice_hrn') page.enqueue_query(slice_query) page.enqueue_query(testbed_query) -- 2.43.0