From 515a8dfd6bea317284814ae1dd14f6fb9f54b34c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Wed, 16 Sep 2015 18:52:15 +0200 Subject: [PATCH] gadjo: add progressive rendering of publik menu (#7996) --- data/themes/gadjo/static/js/agent-portal.js | 7 +++++++ data/themes/gadjo/static/js/publik.js | 31 ++++++++++------------------- 2 files changed, 18 insertions(+), 20 deletions(-) diff --git a/data/themes/gadjo/static/js/agent-portal.js b/data/themes/gadjo/static/js/agent-portal.js index 15610f7..132b5a2 100644 --- a/data/themes/gadjo/static/js/agent-portal.js +++ b/data/themes/gadjo/static/js/agent-portal.js @@ -1,5 +1,12 @@ $(function() { $(document).on('publik:environment-loaded', function(event, services) { + /* empty all apps cells */ + var service_ids = Array('authentic', 'wcs', 'combo', 'passerelle', 'hobo'); + $(service_ids).each(function(index, service_id) { + $('#portal-agent-content div.services-' + service_id + ' ul.apps').empty(); + }); + $('#portal-agent-content div.services ul.apps').empty(); + /* and fill them with current services */ $(services.services).each(function(index, element) { var $content = $('#portal-agent-content div.services-' + element.service_id); if ($content.length === 0) { diff --git a/data/themes/gadjo/static/js/publik.js b/data/themes/gadjo/static/js/publik.js index 46a29f8..6d888a7 100644 --- a/data/themes/gadjo/static/js/publik.js +++ b/data/themes/gadjo/static/js/publik.js @@ -3,20 +3,11 @@ GADJO_DEFAULT_SIDEPAGE_STATUS = 'expanded'; $(function() { var all_done = false; - function check_all_done() { - var local_done = true; - $(COMBO_KNOWN_SERVICES).each(function(index, service) { - if (service.data === undefined) { - local_done = false; - } - }); - all_done = local_done; - if (all_done) { - window.sessionStorage.hobo_environment = JSON.stringify(COMBO_KNOWN_SERVICES); - window.sessionStorage.hobo_environment_timestamp = Date.now(); - create_menu_items(); - $(document).trigger('publik:environment-loaded', {services: COMBO_KNOWN_SERVICES}); - } + function update_publik_menu() { + window.sessionStorage.hobo_environment = JSON.stringify(COMBO_KNOWN_SERVICES); + window.sessionStorage.hobo_environment_timestamp = Date.now(); + create_menu_items(); + $(document).trigger('publik:environment-loaded', {services: COMBO_KNOWN_SERVICES}); } function create_menu_items() { @@ -71,7 +62,7 @@ $(function() { $(COMBO_KNOWN_SERVICES).each(function(index, element) { if (element.backoffice_menu_url === null) { element.data = Array(); - check_all_done(); + update_publik_menu(); return; } if (element.service_id === 'wcs' && element.uniq === false) { @@ -82,7 +73,7 @@ $(function() { if (that_hostname != this_hostname) { look_for_wcs = true; element.data = Array(); - check_all_done(); + update_publik_menu(); return; } } @@ -96,8 +87,8 @@ $(function() { async: true, dataType: 'jsonp', crossDomain: true, - success: function(data) { element.data = data; check_all_done(); }, - error: function(error) { console.log('bouh', error); element.data = Array(); check_all_done(); } + success: function(data) { element.data = data; update_publik_menu(); }, + error: function(error) { console.log('bouh', error); element.data = Array(); update_publik_menu(); } } ); }); @@ -129,8 +120,8 @@ $(function() { async: true, dataType: 'jsonp', crossDomain: true, - success: function(data) { element.data = data; check_all_done(); }, - error: function(error) { console.log('bouh', error); element.data = Array(); check_all_done(); } + success: function(data) { element.data = data; update_publik_menu(); }, + error: function(error) { console.log('bouh', error); element.data = Array(); update_publik_menu(); } } ); } -- 2.5.1