show dynamic locations in the frontend already!
This commit is contained in:
parent
7e56927a72
commit
cc1a53d0d6
2 changed files with 26 additions and 2 deletions
|
@ -501,7 +501,7 @@ class DynamicLocation(CustomLocationProxyMixin, SpecificLocation, models.Model):
|
||||||
'title': self.title,
|
'title': self.title,
|
||||||
'subtitle': '%s %s, %s' % (_('currently unavailable'), _('(moving)'), self.subtitle)
|
'subtitle': '%s %s, %s' % (_('currently unavailable'), _('(moving)'), self.subtitle)
|
||||||
}
|
}
|
||||||
result = custom_location.serialize()
|
result = custom_location.serialize(simple_geometry=True)
|
||||||
result.update({
|
result.update({
|
||||||
'available': True,
|
'available': True,
|
||||||
'id': self.pk,
|
'id': self.pk,
|
||||||
|
@ -590,7 +590,7 @@ class Position(CustomLocationProxyMixin, models.Model):
|
||||||
'title': self.name,
|
'title': self.name,
|
||||||
'subtitle': _('currently unavailable'),
|
'subtitle': _('currently unavailable'),
|
||||||
}
|
}
|
||||||
result = custom_location.serialize()
|
result = custom_location.serialize(simple_geometry=True)
|
||||||
result.update({
|
result.update({
|
||||||
'available': True,
|
'available': True,
|
||||||
'id': 'p:%s' % self.secret,
|
'id': 'p:%s' % self.secret,
|
||||||
|
|
|
@ -1524,6 +1524,15 @@ c3nav = {
|
||||||
// if location is not in the searchable list...
|
// if location is not in the searchable list...
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
console.log(location);
|
||||||
|
if (location.dynamic) {
|
||||||
|
if (!('available' in location)) {
|
||||||
|
$.getJSON('/api/locations/dynamic/' + location.id + '/', c3nav._dynamic_location_loaded);
|
||||||
|
return;
|
||||||
|
} else if (!location.available) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
// add a location to the map as a marker
|
// add a location to the map as a marker
|
||||||
if (location.locations) {
|
if (location.locations) {
|
||||||
var bounds = {};
|
var bounds = {};
|
||||||
|
@ -1566,6 +1575,21 @@ c3nav = {
|
||||||
bounds[level_id] = bounds[level_id] ? bounds[level_id].extend(new_bounds[level_id]) : new_bounds[level_id];
|
bounds[level_id] = bounds[level_id] ? bounds[level_id].extend(new_bounds[level_id]) : new_bounds[level_id];
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
_dynamic_location_loaded: function(data) {
|
||||||
|
if (c3nav._maybe_update_dynamic_location($('#origin-input'), data) || c3nav._maybe_update_dynamic_location($('#destination-input'), data)) {
|
||||||
|
c3nav.update_state();
|
||||||
|
// todo: fly to bounds
|
||||||
|
}
|
||||||
|
},
|
||||||
|
_maybe_update_dynamic_location: function(elem, location) {
|
||||||
|
if (elem.is('.empty')) return false;
|
||||||
|
var orig_location = elem.data('location');
|
||||||
|
if (orig_location.id !== location.id) return false;
|
||||||
|
|
||||||
|
new_location = $.extend({}, orig_location, location);
|
||||||
|
c3nav._locationinput_set(elem, new_location);
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
|
||||||
_location_geometry_loaded: function(data) {
|
_location_geometry_loaded: function(data) {
|
||||||
if (c3nav._visible_map_locations.indexOf(data.id) === -1 || data.geometry === null || data.level === null) return;
|
if (c3nav._visible_map_locations.indexOf(data.id) === -1 || data.geometry === null || data.level === null) return;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue