Projet

Général

Profil

0001-gadjo-add-progressive-rendering-of-publik-menu-7996.patch

Frédéric Péters, 16 septembre 2015 18:58

Télécharger (4,24 ko)

Voir les différences:

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(-)
data/themes/gadjo/static/js/agent-portal.js
1 1
$(function() {
2 2
  $(document).on('publik:environment-loaded', function(event, services) {
3
    /* empty all apps cells */
4
    var service_ids = Array('authentic', 'wcs', 'combo', 'passerelle', 'hobo');
5
    $(service_ids).each(function(index, service_id) {
6
      $('#portal-agent-content div.services-' + service_id + ' ul.apps').empty();
7
    });
8
    $('#portal-agent-content div.services ul.apps').empty();
9
    /* and fill them with current services */
3 10
    $(services.services).each(function(index, element) {
4 11
      var $content = $('#portal-agent-content div.services-' + element.service_id);
5 12
      if ($content.length === 0) {
data/themes/gadjo/static/js/publik.js
3 3
$(function() {
4 4
  var all_done = false;
5 5

  
6
  function check_all_done() {
7
    var local_done = true;
8
    $(COMBO_KNOWN_SERVICES).each(function(index, service) {
9
      if (service.data === undefined) {
10
        local_done = false;
11
      }
12
    });
13
    all_done = local_done;
14
    if (all_done) {
15
      window.sessionStorage.hobo_environment = JSON.stringify(COMBO_KNOWN_SERVICES);
16
      window.sessionStorage.hobo_environment_timestamp = Date.now();
17
      create_menu_items();
18
      $(document).trigger('publik:environment-loaded', {services: COMBO_KNOWN_SERVICES});
19
    }
6
  function update_publik_menu() {
7
    window.sessionStorage.hobo_environment = JSON.stringify(COMBO_KNOWN_SERVICES);
8
    window.sessionStorage.hobo_environment_timestamp = Date.now();
9
    create_menu_items();
10
    $(document).trigger('publik:environment-loaded', {services: COMBO_KNOWN_SERVICES});
20 11
  }
21 12

  
22 13
  function create_menu_items() {
......
71 62
    $(COMBO_KNOWN_SERVICES).each(function(index, element) {
72 63
      if (element.backoffice_menu_url === null) {
73 64
        element.data = Array();
74
        check_all_done();
65
        update_publik_menu();
75 66
        return;
76 67
      }
77 68
      if (element.service_id === 'wcs' && element.uniq === false) {
......
82 73
        if (that_hostname != this_hostname) {
83 74
          look_for_wcs = true;
84 75
          element.data = Array();
85
          check_all_done();
76
          update_publik_menu();
86 77
          return;
87 78
        }
88 79
      }
......
96 87
            async: true,
97 88
            dataType: 'jsonp',
98 89
            crossDomain: true,
99
            success: function(data) { element.data = data; check_all_done(); },
100
            error: function(error) { console.log('bouh', error); element.data = Array(); check_all_done(); }
90
            success: function(data) { element.data = data; update_publik_menu(); },
91
            error: function(error) { console.log('bouh', error); element.data = Array(); update_publik_menu(); }
101 92
           }
102 93
       );
103 94
    });
......
129 120
                        async: true,
130 121
                        dataType: 'jsonp',
131 122
                        crossDomain: true,
132
                        success: function(data) { element.data = data; check_all_done(); },
133
                        error: function(error) { console.log('bouh', error); element.data = Array(); check_all_done(); }
123
                        success: function(data) { element.data = data; update_publik_menu(); },
124
                        error: function(error) { console.log('bouh', error); element.data = Array(); update_publik_menu(); }
134 125
                       }
135 126
                  );
136 127
                }
137
-