_location_details_loaded

This commit is contained in:
Laura Klünder 2017-11-28 11:03:22 +01:00
parent 384ef43209
commit 6d7f012666
2 changed files with 37 additions and 36 deletions

View file

@ -34,6 +34,7 @@ class SerializableMixin(models.Model):
def details_display(self):
return {
'id': self.pk,
'display': [
(str(_('Type')), str(self.__class__._meta.verbose_name)),
(str(_('ID')), str(self.pk)),

View file

@ -139,8 +139,11 @@ c3nav = {
if (parseInt($location_details.attr('data-id')) !== location.id) {
$location_details.addClass('loading').attr('data-id', location.id);
var location_id = location.id;
$.getJSON('/api/locations/'+location.id+'/display', function (data) {
if (parseInt($location_details.attr('data-id')) !== location_id) {
$.getJSON('/api/locations/'+location.id+'/display', c3nav._location_details_loaded);
}
},
_location_details_loaded: function(data) {
if (parseInt($location_details.attr('data-id')) !== data.id) {
// loaded too late, information no longer needed
return;
}
@ -170,12 +173,9 @@ c3nav = {
}
elem.append(loclist);
}
}
$location_details.find('.details-body').html('').append(elem);
$location_details.removeClass('loading').find('.editor').attr('href', data.editor_url);
});
}
},
_equal_states: function (a, b) {
if (a.routing !== b.routing || a.details !== b.details) return false;