From: Loic Baron Date: Tue, 16 Jun 2015 15:45:31 +0000 (+0200) Subject: Manifold.js fixed exception cases X-Git-Tag: myslice-1.5~11 X-Git-Url: http://git.onelab.eu/?p=unfold.git;a=commitdiff_plain;h=d4d9e8ba02faaaed14777dd46230908e8b32c3c8 Manifold.js fixed exception cases --- diff --git a/manifoldapi/static/js/manifold.js b/manifoldapi/static/js/manifold.js index d6f09320..f75ae208 100644 --- a/manifoldapi/static/js/manifold.js +++ b/manifoldapi/static/js/manifold.js @@ -1085,7 +1085,7 @@ var manifold = { * \param array results results corresponding to query */ publish_result: function(query, result) { - if (typeof result === 'undefined') + if (result == null || typeof result === 'undefined') result = []; // NEW PLUGIN API @@ -1116,29 +1116,31 @@ var manifold = { }, store_records: function(query, records) { - // Store records - var query_ext = manifold.query_store.find_analyzed_query_ext(query.query_uuid); - if (query_ext.set_query_ext) { - // We have a domain query - // The results are stored in the corresponding set_query - manifold.query_store.set_records(query_ext.set_query_ext.query.query_uuid, records); - - } else if (query_ext.domain_query_ext) { - // We have a set query, it is only used to determine which objects are in the set, we should only retrieve the key - // Has it a domain query, and has it completed ? - $.each(records, function(i, record) { - var key = manifold.metadata.get_key(query.object); - if ( typeof record === "string" ){ - var record_key = record; - }else{ - var record_key = manifold.record_get_value(record, key); - } - manifold.query_store.set_record_state(query.query_uuid, record_key, STATE_SET, STATE_SET_IN); - }); + if(records != null && records.length != 0){ + // Store records + var query_ext = manifold.query_store.find_analyzed_query_ext(query.query_uuid); + if (query_ext.set_query_ext) { + // We have a domain query + // The results are stored in the corresponding set_query + manifold.query_store.set_records(query_ext.set_query_ext.query.query_uuid, records); + + } else if (query_ext.domain_query_ext) { + // We have a set query, it is only used to determine which objects are in the set, we should only retrieve the key + // Has it a domain query, and has it completed ? + $.each(records, function(i, record) { + var key = manifold.metadata.get_key(query.object); + if ( typeof record === "string" ){ + var record_key = record; + }else{ + var record_key = manifold.record_get_value(record, key); + } + manifold.query_store.set_record_state(query.query_uuid, record_key, STATE_SET, STATE_SET_IN); + }); - } else { - // We have a normal query - manifold.query_store.set_records(query.query_uuid, records, STATE_SET_IN); + } else { + // We have a normal query + manifold.query_store.set_records(query.query_uuid, records, STATE_SET_IN); + } } },