Skip to content

Commit

Permalink
Fix #856
Browse files Browse the repository at this point in the history
  • Loading branch information
jlpereira committed Jul 22, 2020
1 parent 7d6636f commit f44df96
Show file tree
Hide file tree
Showing 2 changed files with 154 additions and 136 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ This project <em>does not yet</em> adheres to [Semantic Versioning](https://semv

## [unreleased]

### Added
- Map on OTU radial in asserted distribution form [#856]

[#856]: https://github.com/SpeciesFileGroup/taxonworks/issues/856

## [0.12.12] - 2020-07-22

### Added
- Interactive keys task
- Delete confirmation for original combinations [#1618]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,13 @@
@select="asserted_distribution.geographic_area_id = $event; createAsserted()"/>
</div>
</div>
<div>
<a
class="asserted-map-link"
:href="`/tasks/gis/otu_distribution_data?otu_id=${metadata.object_id}`"
target="blank">Map</a>
<div class="horizontal-left-content">
<map-component
width="90%"
height="300px"
:zoom="2"
:zoom-on-click="false"
:geojson="shapes"/>
</div>
<table-list
class="separate-top"
Expand All @@ -69,150 +71,159 @@
</template>
<script>
import CRUD from '../../request/crud.js'
import AnnotatorExtend from '../annotatorExtend.js'
import TableList from './table.vue'
import DisplayList from 'components/displayList.vue'
import GeographicArea from './geographicArea.vue'
import SourcePicker from './sourcePicker.vue'
import Spinner from 'components/spinner.vue'
import CRUD from '../../request/crud.js'
import AnnotatorExtend from '../annotatorExtend.js'
import TableList from './table.vue'
import DisplayList from 'components/displayList.vue'
import GeographicArea from './geographicArea.vue'
import SourcePicker from './sourcePicker.vue'
import Spinner from 'components/spinner.vue'
import MapComponent from 'components/georeferences/map.vue'
export default {
mixins: [CRUD, AnnotatorExtend],
components: {
Spinner,
TableList,
SourcePicker,
DisplayList,
GeographicArea
export default {
mixins: [CRUD, AnnotatorExtend],
components: {
Spinner,
TableList,
SourcePicker,
DisplayList,
GeographicArea,
MapComponent
},
computed: {
validateFields() {
return this.asserted_distribution.geographic_area_id && this.asserted_distribution.source_id
},
computed: {
validateFields() {
return this.asserted_distribution.geographic_area_id && this.asserted_distribution.source_id
},
splittedGlobalId() {
let splitted = this.globalId.split('/')
return splitted[splitted.length-1]
},
idIndex() {
return this.list.findIndex(item => item.id === this.asserted_distribution.id);
},
filterList() {
return this.list
},
existingArea() {
return this.list.find(item => { return item.geographic_area_id === this.asserted_distribution.geographic_area_id && (item.is_absent === null ? false : item.is_absent) === (this.asserted_distribution.is_absent === undefined ? false : this.asserted_distribution.is_absent) })
}
splittedGlobalId() {
let splitted = this.globalId.split('/')
return splitted[splitted.length-1]
},
data() {
return {
asserted_distribution: this.newAsserted(),
displayLabel: undefined,
displayGeographic: undefined,
editTitle: undefined,
lockSource: false,
lockGeo: false,
editCitation: undefined
}
idIndex() {
return this.list.findIndex(item => item.id === this.asserted_distribution.id);
},
mounted() {
this.asserted_distribution.otu_id = this.splittedGlobalId
filterList() {
return this.list
},
methods: {
setEditCitation(citation) {
let data = {
id: citation.id,
is_absent: undefined,
pages: citation.pages,
source_id: citation.source_id,
is_original: citation.is_original,
citation_source_body: citation.citation_source_body
}
this.editCitation = citation
this.$refs.source.setCitation(data)
},
createAsserted() {
if(!this.existingArea) {
this.create('/asserted_distributions.json', { asserted_distribution: this.asserted_distribution }).then(response => {
TW.workbench.alert.create('Asserted distribution was successfully created.', 'notice')
this.addToList(response.body)
})
}
else {
this.asserted_distribution['id'] = this.existingArea.id
this.update(`/asserted_distributions/${this.existingArea.id}.json`, { asserted_distribution: this.asserted_distribution }).then(response => {
TW.workbench.alert.create('Asserted distribution was successfully updated.', 'notice')
this.addToList(response.body)
})
}
},
removeCitation(item) {
let data = {
asserted_distribution: {
citations_attributes: [{
id: item.id,
_destroy: true
}]
}
}
this.update(`/asserted_distributions/${this.asserted_distribution.id}.json`, data).then(response => {
existingArea() {
return this.list.find(item => { return item.geographic_area_id === this.asserted_distribution.geographic_area_id && (item.is_absent === null ? false : item.is_absent) === (this.asserted_distribution.is_absent === undefined ? false : this.asserted_distribution.is_absent) })
},
shapes () {
return this.list.map(item => {
const shape = item.geographic_area.shape
shape.properties.is_absent = item.is_absent
return shape
})
}
},
data() {
return {
asserted_distribution: this.newAsserted(),
displayLabel: undefined,
displayGeographic: undefined,
editTitle: undefined,
lockSource: false,
lockGeo: false,
editCitation: undefined
}
},
mounted() {
this.asserted_distribution.otu_id = this.splittedGlobalId
},
methods: {
setEditCitation(citation) {
let data = {
id: citation.id,
is_absent: undefined,
pages: citation.pages,
source_id: citation.source_id,
is_original: citation.is_original,
citation_source_body: citation.citation_source_body
}
this.editCitation = citation
this.$refs.source.setCitation(data)
},
createAsserted() {
if(!this.existingArea) {
this.create('/asserted_distributions.json', { asserted_distribution: this.asserted_distribution }).then(response => {
TW.workbench.alert.create('Asserted distribution was successfully created.', 'notice')
this.addToList(response.body)
})
},
addToList(item) {
this.editTitle = item.object_tag
if(!this.lockSource) {
this.$refs.source.cleanInput()
this.$refs.source.setFocus()
}
if(this.idIndex > -1) {
this.$set(this.list, this.idIndex, item)
}
else {
this.list.push(item)
}
else {
this.asserted_distribution['id'] = this.existingArea.id
this.update(`/asserted_distributions/${this.existingArea.id}.json`, { asserted_distribution: this.asserted_distribution }).then(response => {
TW.workbench.alert.create('Asserted distribution was successfully updated.', 'notice')
this.addToList(response.body)
})
}
},
removeCitation(item) {
let data = {
asserted_distribution: {
citations_attributes: [{
id: item.id,
_destroy: true
}]
}
this.asserted_distribution = this.newAsserted()
},
setDistribution(item) {
this.asserted_distribution = this.newAsserted()
this.editTitle = item.object_tag
this.asserted_distribution.id = item.id
this.asserted_distribution.citations = item.citations
this.asserted_distribution.otu_id = item.otu_id
this.asserted_distribution.geographic_area_id = item.geographic_area_id
this.asserted_distribution.citations_attributes = [{
id: undefined,
}
this.update(`/asserted_distributions/${this.asserted_distribution.id}.json`, data).then(response => {
this.addToList(response.body)
})
},
addToList(item) {
this.editTitle = item.object_tag
if(!this.lockSource) {
this.$refs.source.cleanInput()
this.$refs.source.setFocus()
}
if(this.idIndex > -1) {
this.$set(this.list, this.idIndex, item)
}
else {
this.list.push(item)
}
this.asserted_distribution = this.newAsserted()
},
setDistribution(item) {
this.asserted_distribution = this.newAsserted()
this.editTitle = item.object_tag
this.asserted_distribution.id = item.id
this.asserted_distribution.citations = item.citations
this.asserted_distribution.otu_id = item.otu_id
this.asserted_distribution.geographic_area_id = item.geographic_area_id
this.asserted_distribution.citations_attributes = [{
id: undefined,
source_id: undefined,
pages: undefined,
is_original: undefined
}]
this.editCitation = undefined
this.$refs.source.cleanCitation()
},
newAsserted() {
this.displayLabel = ''
return {
id: undefined,
otu_id: this.splittedGlobalId,
geographic_area_id: this.lockGeo ? this.asserted_distribution.geographic_area_id : undefined,
citations: [],
citations_attributes: this.lockSource ? this.asserted_distribution.citations_attributes : [{
source_id: undefined,
pages: undefined,
is_original: undefined
}]
this.editCitation = undefined
this.$refs.source.cleanCitation()
},
newAsserted() {
this.displayLabel = ''
return {
id: undefined,
otu_id: this.splittedGlobalId,
geographic_area_id: this.lockGeo ? this.asserted_distribution.geographic_area_id : undefined,
citations: [],
citations_attributes: this.lockSource ? this.asserted_distribution.citations_attributes : [{
source_id: undefined,
pages: undefined,
is_original: undefined
}],
is_absent: undefined
}
},
setSource(source) {
this.asserted_distribution.is_absent = source.is_absent
this.asserted_distribution.citations_attributes[0].id = source.id
this.asserted_distribution.citations_attributes[0].source_id = source.source_id
this.asserted_distribution.citations_attributes[0].pages = source.pages
this.asserted_distribution.citations_attributes[0].is_original = source.is_original
}],
is_absent: undefined
}
},
}
setSource(source) {
this.asserted_distribution.is_absent = source.is_absent
this.asserted_distribution.citations_attributes[0].id = source.id
this.asserted_distribution.citations_attributes[0].source_id = source.source_id
this.asserted_distribution.citations_attributes[0].pages = source.pages
this.asserted_distribution.citations_attributes[0].is_original = source.is_original
}
},
}
</script>
<style lang="scss">
.radial-annotator {
Expand Down

0 comments on commit f44df96

Please sign in to comment.