Projet

Général

Profil

0001-backoffice-don-t-let-map-popups-block-filter-changes.patch

Frédéric Péters, 11 décembre 2018 18:21

Télécharger (4,51 ko)

Voir les différences:

Subject: [PATCH] backoffice: don't let map popups block filter changes
 (#28913)

 wcs/qommon/static/js/qommon.map.js  |  9 ++++++---
 wcs/qommon/static/js/wcs.listing.js | 18 ++++++++++++------
 2 files changed, 18 insertions(+), 9 deletions(-)
wcs/qommon/static/js/qommon.map.js
118 118
     }
119 119

  
120 120
    $(document).on('backoffice-filter-change', function(event, listing_settings) {
121
      if ($('.leaflet-popup').length > 0) return;
121
      if ($('.leaflet-popup').length > 0 && listing_settings.auto == true) {
122
        /* disable autorefresh when a popup is open */
123
        return;
124
      }
122 125
      $('.qommon-map').each(function() {
123 126
         var base_url = $(this).data('geojson-url').split('?')[0];
124 127
         map.eachLayer(function(layer) {
......
126 129
             map.removeLayer(layer);
127 130
           }
128 131
         });
129
         $.getJSON(base_url + '?' + listing_settings, function(data) {
132
         $.getJSON(base_url + '?' + listing_settings.qs, function(data) {
130 133
           var geo_json = L.geoJson(data, {
131 134
             onEachFeature: function(feature, layer) {
132 135
               if (feature.properties.display_fields.length > 0) {
......
163 166
      });
164 167
    });
165 168
    if ($(this).data('geojson-url')) {
166
        $(document).trigger('backoffice-filter-change', $('form#listing-settings').serialize());
169
        $(document).trigger('backoffice-filter-change', {qs: $('form#listing-settings').serialize()});
167 170
    }
168 171
  });
169 172
  $(document).trigger('wcs:maps-ready');
wcs/qommon/static/js/wcs.listing.js
60 60
  });
61 61
}
62 62

  
63
function autorefresh_table() {
64
  $(document).trigger('backoffice-filter-change',
65
      {qs: $('form#listing-settings').serialize(), auto: true});
66
}
67

  
63 68
function refresh_table() {
64
  $(document).trigger('backoffice-filter-change', $('form#listing-settings').serialize());
69
  $(document).trigger('backoffice-filter-change',
70
      {qs: $('form#listing-settings').serialize(), auto: false});
65 71
}
66 72

  
67 73
$(document).on('backoffice-filter-change', function(event, listing_settings) {
......
69 75
  var pathname = window.location.pathname.replace(/^\/+/, '/');
70 76

  
71 77
  $.ajax({
72
    url: pathname + '?ajax=true&' + listing_settings,
78
    url: pathname + '?ajax=true&' + listing_settings.qs,
73 79
    beforeSend: function() { $('#more-user-links, #listing, #statistics').addClass('activity'); },
74 80
    complete: function() { $('#more-user-links, #listing, #statistics').removeClass('activity'); },
75 81
    success: function(html) {
......
83 89
      prepare_row_links();
84 90
      prepare_column_headers();
85 91
      $('a[data-base-href]').each(function(idx, elem) {
86
        $(elem).attr('href', $(elem).data('base-href') + '?' + listing_settings);
92
        $(elem).attr('href', $(elem).data('base-href') + '?' + listing_settings.qs);
87 93
      });
88 94
      if (window.history) {
89
        window.history.replaceState(null, null, pathname + '?' + listing_settings);
95
        window.history.replaceState(null, null, pathname + '?' + listing_settings.qs);
90 96
      }
91 97
      /* makes sure activity and disabled-during-submit are removed */
92 98
      $('#more-user-links, #listing, #statistics').removeClass('activity');
......
178 184
      return true;
179 185
    }
180 186
    event.preventDefault();
181
    $(document).trigger('backoffice-filter-change', $('form#listing-settings').serialize());
187
    $(document).trigger('backoffice-filter-change', {qs: $('form#listing-settings').serialize()});
182 188
    return false;
183 189
  });
184 190

  
......
186 192
    var idle_id = null;
187 193
    $(window).on('mousemove keydown mousedown touchstart', function() {
188 194
      if (idle_id) window.clearInterval(idle_id);
189
      idle_id = setInterval(refresh_table, 30000);
195
      idle_id = setInterval(autorefresh_table, 30000);
190 196
    });
191 197
  }
192 198

  
193
-