_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): def details_display(self):
return { return {
'id': self.pk,
'display': [ 'display': [
(str(_('Type')), str(self.__class__._meta.verbose_name)), (str(_('Type')), str(self.__class__._meta.verbose_name)),
(str(_('ID')), str(self.pk)), (str(_('ID')), str(self.pk)),

View file

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