Ticket #8972: ol_admin_delete_selected.diff

File ol_admin_delete_selected.diff, 2.2 KB (added by springmeyer, 16 years ago)

Patch against SVN HEAD to allow the deletion of multiple features within the geodjango enabled admin interface

  • django/contrib/gis/templates/gis/admin/openlayers.html

     
    3030//]]>
    3131</script>
    3232<div id="{{ id }}_map"></div>
    33 <a href="javascript:{{ module }}.clearFeatures()">Delete all Features</a>
     33</p>Features: <a href="javascript:{{ module }}.clearSelectedFeatures()">Delete Selected</a> | <a href="javascript:{{ module }}.clearFeatures()">Delete All</a>
    3434{% if display_wkt %}<p> WKT debugging window:</p>{% endif %}
    3535<textarea id="{{ id }}" class="vWKTField required" cols="150" rows="10" name="{{ field_name }}">{{ wkt }}</textarea>
    3636<script type="text/javascript">{% block init_function %}{{ module }}.init();{% endblock %}</script>
  • django/contrib/gis/templates/gis/admin/openlayers.js

     
    6666{{ module }}.clearFeatures = function (){
    6767  {{ module }}.deleteFeatures();
    6868  document.getElementById('{{ id }}').value = '';
    69   {{ module }}.map.setCenter(new OpenLayers.LonLat({{ default_lon }}, {{ default_lat }}), {{ default_zoom }});
    7069}
     70
     71{{ module }}.clearSelectedFeatures = function (){
     72  //var selected = {{ module }}.map.layers[1].selectedFeatures;
     73  var selected = {{ module }}.layers.vector.selectedFeatures;
     74  if (selected && (selected.length > 0)) {
     75    {{ module }}.layers.vector.removeFeatures(selected);
     76    {{ module }}.layers.vector.selectedFeatures = []
     77    {{ module }}.modify_wkt();
     78    {{ module }}.map.getControlsByClass('OpenLayers.Control.ModifyFeature')[0].unselectFeature();
     79  }
     80}
     81
    7182// Add Select control
    7283{{ module }}.addSelectControl = function(){   
    73   var select = new OpenLayers.Control.SelectFeature({{ module }}.layers.vector, {'toggle' : true, 'clickout' : true});
     84  var select = new OpenLayers.Control.SelectFeature({{ module }}.layers.vector, {'toggle' : true, 'clickout' : true, 'multipleKey': "shiftKey",'multiple': true});
    7485  {{ module }}.map.addControl(select);
    7586  select.activate();
    7687}
Back to Top