make it possible to switch layers in access restriction overview
This commit is contained in:
parent
c44582c114
commit
34199b2bf3
3 changed files with 25 additions and 8 deletions
|
@ -183,12 +183,14 @@ editor = {
|
||||||
$('#sidebar').addClass('loading').find('.content').html('');
|
$('#sidebar').addClass('loading').find('.content').html('');
|
||||||
editor._cancel_editing();
|
editor._cancel_editing();
|
||||||
},
|
},
|
||||||
_fill_level_control: function (level_control, level_list) {
|
_fill_level_control: function (level_control, level_list, geometryURLs) {
|
||||||
var levels = level_list.find('a');
|
var levels = level_list.find('a');
|
||||||
|
level_control.geometryURLs = !!geometryURLs;
|
||||||
if (levels.length) {
|
if (levels.length) {
|
||||||
|
console.log('FILLING!!');
|
||||||
for (var i = 0; i < levels.length; i++) {
|
for (var i = 0; i < levels.length; i++) {
|
||||||
var level = $(levels[i]);
|
var level = $(levels[i]);
|
||||||
level_control.addLevel(level.attr('data-id'), level.text(), level.attr('href'), level.is('.current'));
|
level_control.addLevel(level.attr('data-id'), level.text(), level.attr('href'), geometryURLs ? (i==0) : level.is('.current'));
|
||||||
}
|
}
|
||||||
if (levels.length > 1) {
|
if (levels.length > 1) {
|
||||||
level_control.enable();
|
level_control.enable();
|
||||||
|
@ -393,9 +395,16 @@ editor = {
|
||||||
}
|
}
|
||||||
|
|
||||||
var geometry_url = content.find('[data-geometry-url]');
|
var geometry_url = content.find('[data-geometry-url]');
|
||||||
|
var level_geometry_urls = content.find('[data-level-geometry-urls]');
|
||||||
var $body = $('body');
|
var $body = $('body');
|
||||||
if (geometry_url.length) {
|
if (geometry_url.length) {
|
||||||
geometry_url = geometry_url.attr('data-geometry-url');
|
geometry_url = geometry_url.attr('data-geometry-url');
|
||||||
|
} else if (level_geometry_urls.length) {
|
||||||
|
geometry_url = content.find('[data-levels]').find('a').first().attr('href');
|
||||||
|
} else {
|
||||||
|
geometry_url = null;
|
||||||
|
}
|
||||||
|
if (geometry_url) {
|
||||||
var highlight_type = content.find('[data-list]');
|
var highlight_type = content.find('[data-list]');
|
||||||
var editing_id = content.find('[data-editing]');
|
var editing_id = content.find('[data-editing]');
|
||||||
if (editor._next_zoom === null) {
|
if (editor._next_zoom === null) {
|
||||||
|
@ -410,7 +419,7 @@ editor = {
|
||||||
editor._level_control.clearLevels();
|
editor._level_control.clearLevels();
|
||||||
editor._sublevel_control.clearLevels();
|
editor._sublevel_control.clearLevels();
|
||||||
|
|
||||||
editor._fill_level_control(editor._level_control, content.find('[data-levels]'));
|
editor._fill_level_control(editor._level_control, content.find('[data-levels]'), level_geometry_urls.length);
|
||||||
editor._fill_level_control(editor._sublevel_control, content.find('[data-sublevels]'));
|
editor._fill_level_control(editor._sublevel_control, content.find('[data-sublevels]'));
|
||||||
|
|
||||||
var level_control_offset = $(editor._level_control_container).position();
|
var level_control_offset = $(editor._level_control_container).position();
|
||||||
|
@ -996,7 +1005,7 @@ editor = {
|
||||||
_get_geometry_style: function (feature) {
|
_get_geometry_style: function (feature) {
|
||||||
// style callback for GeoJSON loader
|
// style callback for GeoJSON loader
|
||||||
var style = editor._get_mapitem_type_style(feature.properties.type);
|
var style = editor._get_mapitem_type_style(feature.properties.type);
|
||||||
if (editor._level_control.current_level_id === editor._sublevel_control.current_level_id) {
|
if (editor._level_control.current_level_id === editor._sublevel_control.current_level_id || editor._sublevel_control.level_ids.length === 0) {
|
||||||
if (editor._sublevel_control.level_ids.indexOf(feature.properties.level) >= 0 && editor._level_control.current_level_id !== feature.properties.level) {
|
if (editor._sublevel_control.level_ids.indexOf(feature.properties.level) >= 0 && editor._level_control.current_level_id !== feature.properties.level) {
|
||||||
style.stroke = true;
|
style.stroke = true;
|
||||||
style.weight = 1;
|
style.weight = 1;
|
||||||
|
@ -1577,6 +1586,7 @@ LevelControl = L.Control.extend({
|
||||||
this.level_ids = [];
|
this.level_ids = [];
|
||||||
this._disabled = true;
|
this._disabled = true;
|
||||||
this._expanded = false;
|
this._expanded = false;
|
||||||
|
this.geometryURLs = false;
|
||||||
this.hide();
|
this.hide();
|
||||||
|
|
||||||
if (!L.Browser.android) {
|
if (!L.Browser.android) {
|
||||||
|
@ -1650,8 +1660,16 @@ LevelControl = L.Control.extend({
|
||||||
this.expand();
|
this.expand();
|
||||||
} else if (!this._disabled) {
|
} else if (!this._disabled) {
|
||||||
$(e.target).addClass('current').siblings().removeClass('current');
|
$(e.target).addClass('current').siblings().removeClass('current');
|
||||||
editor._next_zoom = false;
|
if (this.geometryURLs) {
|
||||||
editor.sidebar_get(e.target.href);
|
editor.load_geometries(
|
||||||
|
e.target.href,
|
||||||
|
editor._highlight_type,
|
||||||
|
editor._editing_id
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
editor._next_zoom = false;
|
||||||
|
editor.sidebar_get(e.target.href);
|
||||||
|
}
|
||||||
this.collapse();
|
this.collapse();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
{% if levels %}
|
{% if levels %}
|
||||||
<ul data-levels>
|
<ul data-levels{% if level_geometry_urls %} data-level-geometry-urls{% endif %}>
|
||||||
{% for l in levels %}
|
{% for l in levels %}
|
||||||
<li>
|
<li>
|
||||||
<a data-id="{{ l.pk }}"
|
<a data-id="{{ l.pk }}"
|
||||||
|
|
|
@ -535,7 +535,6 @@ def list_objects(request, model=None, level=None, space=None, explicit_edit=Fals
|
||||||
ctx.update({
|
ctx.update({
|
||||||
"levels": levels,
|
"levels": levels,
|
||||||
"level_geometry_urls": True,
|
"level_geometry_urls": True,
|
||||||
"geometry_url": '/api/v2/editor/geometries/level/' + str(levels[0].pk) # todo: resolve correctly,
|
|
||||||
})
|
})
|
||||||
|
|
||||||
return APIHybridTemplateContextResponse('editor/list.html', ctx,
|
return APIHybridTemplateContextResponse('editor/list.html', ctx,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue