Skip to content

Commit

Permalink
Add simplemappr export support
Browse files Browse the repository at this point in the history
  • Loading branch information
mjy committed Nov 14, 2024
1 parent a411b49 commit af87b8c
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 11 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ This project <em>does not yet</em> adheres to [Semantic Versioning](https://semv

### Added

- Simplemappr (https://www.simplemappr.net) export support from filter collection objects
- Print key task [#4071]
- `/api/v1/leads/key/:id` endpoint serving `pinpoint` key app
- Filter loans: Identifiers, created by and updated by columns [#4098]
Expand Down
8 changes: 8 additions & 0 deletions app/controllers/tasks/gis/simplemappr_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class Tasks::Gis::SimplemapprController < ApplicationController
include TaskControllerConfiguration

# POST
def index
end

end
18 changes: 14 additions & 4 deletions app/helpers/workbench/table_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,19 @@ def fancy_metadata_cells_tag(object)
def fancy_options_cells_tag(object)
m = metamorphosize_if(object)
fancy_show_tag(m) +
fancy_edit_tag(m) +
fancy_edit_tag(m) +
fancy_pin_tag(m) +
content_tag(:td, (link_to 'Destroy', m, method: :delete, data: {confirm: 'Are you sure?'}), class: 'table-options', data: {delete: true})
end
end

def fancy_show_tag(object)
defined?(object.annotated_object) ?
defined?(object.annotated_object) ?
content_tag(:td, (link_to 'Show', metamorphosize_if(object.annotated_object)), class: 'table-options', data: {show: true}) :
content_tag(:td, (link_to 'Show', object), class: 'table-options', data: {show: true})
end

def fancy_edit_tag(object)
content_tag(:td, edit_object_link(object), class: 'table-options', data: {edit: true})
content_tag(:td, edit_object_link(object), class: 'table-options', data: {edit: true})
end

def fancy_pin_tag(object)
Expand All @@ -61,4 +61,14 @@ def table_from_hash_tag(hash)
end
end

# Almost certainly not DRY within TW
def table_from_csv(csv, id: nil)
s = "<table id=\"#{id}\">"
csv.by_row.each do |r|
s << tag.tr( r.fields.collect{|a| tag.td(a)}.join.html_safe)
end
s << '</table>'
s.html_safe
end

end
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,11 @@ export const TASK_NEW_CONTAINER = {
queryParam: true,
saveQuery: true
}

export const TASK_SIMPLEMAPPR = {
label: 'SimpleMappr',
link: '/tasks/gis/simplemappr',
post: true,
queryParam: true
}

Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,28 @@ import {
TASK_COLLECTION_OBJECT_SUMMARY,
TASK_COLLECTION_OBJECT_OUTDATED_NAMES,
TASK_FIELD_SYNCHRONIZE,
TASK_NEW_CONTAINER
TASK_NEW_CONTAINER,
TASK_SIMPLEMAPPR
} from '../constants/links'

export const CollectionObject = {
all: [
TASK_COLLECTION_OBJECT_MATCH,
TASK_COLLECTION_OBJECT_TABLE,
TASK_COLLECTION_OBJECT_SUMMARY,
TASK_COLLECTION_OBJECT_OUTDATED_NAMES,
TASK_COLLECTION_OBJECT_SUMMARY,
TASK_COLLECTION_OBJECT_TABLE,
TASK_FIELD_SYNCHRONIZE,
TASK_NEW_CONTAINER
TASK_NEW_CONTAINER,
TASK_SIMPLEMAPPR
],
ids: [
TASK_COLLECTION_OBJECT_MATCH,
TASK_COLLECTION_OBJECT_TABLE,
TASK_COLLECTION_OBJECT_SUMMARY,
TASK_COLLECTION_OBJECT_OUTDATED_NAMES,
TASK_COLLECTION_OBJECT_SUMMARY,
TASK_COLLECTION_OBJECT_TABLE,
TASK_FIELD_SYNCHRONIZE,
TASK_NEW_CONTAINER
TASK_NEW_CONTAINER,
TASK_SIMPLEMAPPR
]
}

Expand Down
8 changes: 8 additions & 0 deletions app/views/tasks/gis/simplemappr/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<h1> Simplemappr table </h1>
<em> Paste the copied table into a text file, name it your_data.txt. The file should load at simplemappr. </em>
<br/>
<br/>
<%= copy_table_to_clipboard('div#simplemappr') %>
<div id="simplemappr">
<%= table_from_csv( simple_mappr_data(params) ) %>
</div>
4 changes: 4 additions & 0 deletions config/routes/tasks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,10 @@
end

scope :gis do
scope :simplemappr, controller: 'tasks/gis/simplemappr' do
match '/', action: :index, via: [:get, :post]
end

scope :geographic_area_lookup, controller: 'tasks/gis/geographic_area_lookup' do
get 'index', as: 'geographic_area_lookup_task'
get 'resolve', as: 'geographic_area_lookup_resolve_task', format: :js
Expand Down

0 comments on commit af87b8c

Please sign in to comment.