Skip to content

Commit

Permalink
Merge pull request #385 from wearepal/selecting_manual_extent_bugfix
Browse files Browse the repository at this point in the history
bugfix: when not using a masked extent, CQL and Layer set to null
  • Loading branch information
paulthatjazz authored Jun 14, 2024
2 parents 01f7dbb + 3c1df9d commit f0208aa
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
5 changes: 3 additions & 2 deletions app/controllers/projects_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,9 @@ def update
existing_source = @project.source || {}
existing_source["name"] = params.require(:project).require(:name)
existing_source["extent"] = params.require(:project).require(:extent).split(",").map(&:to_f)
existing_source["cql"] = params.require(:project).require(:cql)
existing_source["layer"] = params.require(:project).require(:layer)
existing_source["cql"] = params[:project][:cql] if params[:project].key?(:cql)
existing_source["layer"] = params[:project][:layer] if params[:project].key?(:layer)


if @project.update(source: existing_source)
if params[:commit] == 'Save and open project'
Expand Down
2 changes: 2 additions & 0 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,8 @@
],
])
);

if(fn) fn()
})

function updateMap() {
Expand Down
16 changes: 11 additions & 5 deletions app/views/projects/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,15 @@
const projEx = document.getElementById('PROJEDIT303')
if(!projEx) return

const fn = () => {
const savedVal = isSavedValue()
document.getElementById('project_value').value = savedVal
if(!savedVal){
document.getElementById('project_layer').value = null
document.getElementById('project_cql').value = null
}
}

const hardcoded_extents = [
{ id: -1, name: "✨Wealden", value: [ -4034.29345383, 6591225.55995304, 44295.78978777, 6647418.730598 ], layer_source: "shapefiles:westminster_const", layer_cql: "Name='Wealden Co Const'" },
{ id: -2, name: "✨Brighton Pravilion", value: [ -21125.72504206, 6589221.35051539, -9227.54925854, 6602279.95570845 ], layer_source: "shapefiles:westminster_const", layer_cql: "Name='Brighton, Pavilion Boro Const'" },
Expand Down Expand Up @@ -90,7 +99,7 @@
document.getElementById('project_cql').value = cql

document.getElementById('project_extent').value = extent.join(', ')
mapUpdate('PROJEDIT303')
mapUpdate('PROJEDIT303', fn)
})

function isSavedValue(){
Expand All @@ -104,10 +113,7 @@
return id
}

mapUpdate('PROJEDIT303', () => {
document.getElementById('project_value').value = isSavedValue()
}
)
mapUpdate('PROJEDIT303', fn)

document.getElementById('project_value').value = isSavedValue()

Expand Down

0 comments on commit f0208aa

Please sign in to comment.