From d4d9e8ba02faaaed14777dd46230908e8b32c3c8 Mon Sep 17 00:00:00 2001 From: Loic Baron Date: Tue, 16 Jun 2015 17:45:31 +0200 Subject: [PATCH] Manifold.js fixed exception cases --- manifoldapi/static/js/manifold.js | 48 ++++++++++++++++--------------- 1 file changed, 25 insertions(+), 23 deletions(-) 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); + } } }, -- 2.43.0