Skip to content

Commit

Permalink
Fix #1527
Browse files Browse the repository at this point in the history
  • Loading branch information
jlpereira committed Jul 20, 2020
1 parent 6fcf15a commit bef005f
Show file tree
Hide file tree
Showing 6 changed files with 215 additions and 9 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ This project <em>does not yet</em> adheres to [Semantic Versioning](https://semv
- Soft validations component for citations in radial annotator and tasks [#1552]
- Redirect to valid name in browse nomenclature [#446]
- sessionStorage for browse nomenclature autocomplete [#446]
- Observation matrices in radial object [#1527]

### Changed

Expand All @@ -30,9 +31,11 @@ This project <em>does not yet</em> adheres to [Semantic Versioning](https://semv
- Flip object to subject label on type section in new taxon name task
- Shapes are possible to drag even if this option is not set up
- Columns size of georeference table [#1622]
- Webpacker host and port bind on docker container

[#446]: https://github.com/SpeciesFileGroup/taxonworks/issues/446
[#1329]: https://github.com/SpeciesFileGroup/taxonworks/issues/1329
[#1527]: https://github.com/SpeciesFileGroup/taxonworks/issues/1527
[#1552]: https://github.com/SpeciesFileGroup/taxonworks/issues/1552
[#1576]: https://github.com/SpeciesFileGroup/taxonworks/issues/1576
[#1617]: https://github.com/SpeciesFileGroup/taxonworks/issues/1617
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
class="radial-annotator">
<modal
v-if="display"
:container-style="{ backgroundColor: 'transparent' }"
:container-style="{ backgroundColor: 'transparent', boxShadow: 'none' }"
@close="closeModal()">
<h3
slot="header"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<div class="radial-annotator">
<modal
v-if="display"
:container-style="{ backgroundColor: 'transparent' }"
:container-style="{ backgroundColor: 'transparent', boxShadow: 'none' }"
@close="closeModal()">
<h3
slot="header"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,17 @@ const vueAnnotator = {
data: function () {
return {
list: [],
urlList: undefined
urlList: undefined,
loadOnMounted: true
}
},
mounted: function () {
let that = this
this.getList((typeof this.urlList == 'undefined') ? `${this.url}/${this.type}.json` : this.urlList).then(response => {
that.list = response.body
})
if(this.loadOnMounted) {
this.getList((typeof this.urlList == 'undefined') ? `${this.url}/${this.type}.json` : this.urlList).then(response => {
that.list = response.body
})
}
},
watch: {
list: {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
<template>
<div>
<h3>Select observation matrix to open MRC or Image matrix</h3>
<div>
<spinner-component
v-if="loading"
legend="Loading"
/>
<div>
<div
class="separate-bottom horizontal-left-content"
>
<input
v-model="filterType"
type="text"
placeholder="Filter matrix"
>
<default-pin
section="ObservationMatrices"
type="ObservationMatrix"
@getId="setMatrix"
/>
</div>
<div class="flex-separate">
<div>
<ul class="no_bullets">
<template v-for="item in alreadyInMatrices">
<li
:key="item.id"
v-if="item.object_tag.toLowerCase().includes(filterType.toLowerCase())"
>
<button
class="button normal-input button-default margin-small-bottom"
@click="loadMatrix(item)"
v-html="item.object_tag"
/>
</li>
</template>
</ul>
<ul class="no_bullets">
<template v-for="item in matrices">
<li
:key="item.id"
v-if="item.object_tag.toLowerCase().includes(filterType.toLowerCase()) && !alreadyInMatrices.includes(item)"
>
<button
class="button normal-input button-submit margin-small-bottom"
@click="loadMatrix(item)"
v-html="item.object_tag"
/>
</li>
</template>
</ul>
</div>
</div>
</div>
</div>
</div>
</template>

<script>
import CRUD from '../../request/crud'
import annotatorExtend from '../annotatorExtend'
import {
GetObservationMatrices,
GetObservationRow,
CreateObservationMatrixRow,
GetObservationMatrix
} from 'tasks/observation_matrices/dashboard/request/resources'
export default {
mixins: [CRUD, annotatorExtend],
computed: {
alreadyInMatrices () {
return this.matrices.filter(item => {
return this.rows.find(row => { return item.id === row.observation_matrix_id })
})
},
alreadyInCurrentMatrix () {
return this.rows.filter(row => { return this.selectedMatrix.id === row.observation_matrix_id })
}
},
data () {
return {
show: false,
matrices: [],
selectedMatrix: undefined,
rows: [],
create: false,
filterType: '',
loading: false,
otuSelected: undefined,
loadOnMounted: false,
types: {
Otu: {
propertyName: 'otu_id',
type: 'ObservationMatrixRowItem::SingleOtu'
},
CollectionObject: {
propertyName: 'collection_object_id',
type: 'ObservationMatrixRowItem::SingleCollectionObject'
}
}
}
},
mounted () {
this.loading = true
this.show = true
GetObservationMatrices().then(response => {
this.matrices = response.body.sort((a, b) => {
const compareA = a.object_tag
const compareB = b.object_tag
if (compareA < compareB) {
return -1
} else if (compareA > compareB) {
return 1
} else {
return 0
}
})
this.loading = false
})
GetObservationRow({ [this.types[this.metadata.object_type].propertyName]: this.metadata.object_id }).then(response => {
this.rows = response.body
})
},
methods: {
loadMatrix (matrix) {
this.selectedMatrix = matrix
if (matrix.is_media_matrix) {
this.openImageMatrix()
} else {
this.openMatrixRowCoder()
}
},
reset () {
this.selectedMatrix = undefined
this.rows = []
this.create = false
this.show = false
},
createRow () {
return new Promise((resolve, reject) => {
if (window.confirm('Are you sure you want to add this otu to this matrix?')) {
const promises = []
Promise.all(promises).then(() => {
const data = {
observation_matrix_id: this.selectedMatrix.id,
[this.types[this.metadata.object_type].propertyName]: this.metadata.object_id,
type: this.types[this.metadata.object_type].type
}
CreateObservationMatrixRow(data).then(response => {
GetObservationRow({ [this.types[this.metadata.object_type].propertyName]: this.metadata.object_id }).then(response => {
this.rows = response.body
resolve(response)
})
})
})
}
})
},
setMatrix (id) {
GetObservationMatrix(id).then(response => {
this.selectedMatrix = response.body
this.loadMatrix(this.selectedMatrix)
})
},
openMatrixRowCoder () {
if (this.alreadyInCurrentMatrix.length) {
window.open(`/tasks/observation_matrices/row_coder/index?observation_matrix_row_id=${this.alreadyInCurrentMatrix[0].id}`, '_blank')
} else {
this.createRow().then(() => {
window.open(`/tasks/observation_matrices/row_coder/index?observation_matrix_row_id=${this.alreadyInCurrentMatrix[0].id}`, '_blank')
})
}
},
openImageMatrix () {
if (this.alreadyInCurrentMatrix.length) {
window.open(`/tasks/matrix_image/matrix_image/index?observation_matrix_id=${this.selectedMatrix.id}&row_id=${this.alreadyInCurrentMatrix[0].id}&row_position=${this.alreadyInCurrentMatrix[0].position}`, '_blank')
}
}
}
}
</script>
20 changes: 17 additions & 3 deletions app/javascript/vue/components/radials/object/radial.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<div class="radial-annotator">
<modal
v-if="display"
:container-style="{ backgroundColor: 'transparent' }"
:container-style="{ backgroundColor: 'transparent', boxShadow: 'none' }"
@close="closeModal()">
<h3
slot="header"
Expand Down Expand Up @@ -80,6 +80,7 @@ import common_namesAnnotator from './components/common_names/main.vue'
import contentsAnnotator from './components/contents/main.vue'
import biocuration_classificationsAnnotator from './components/biocurations/biocurations'
import taxon_determinationsAnnotator from './components/taxon_determinations/taxon_determinations'
import observation_matricesAnnotator from './components/observation_matrices/main.vue'
import Icons from './images/icons.js'
Expand All @@ -96,7 +97,8 @@ export default {
common_namesAnnotator,
contentsAnnotator,
biocuration_classificationsAnnotator,
taxon_determinationsAnnotator
taxon_determinationsAnnotator,
observation_matricesAnnotator
},
props: {
reload: {
Expand Down Expand Up @@ -144,7 +146,13 @@ export default {
title: 'Otu radial',
menuOptions: [],
defaultTag: undefined,
tagCreated: false
tagCreated: false,
hardcodeSections: [
{
section: 'observation_matrices',
objectTypes: ['Otu', 'CollectionObject']
}
]
}
},
computed: {
Expand Down Expand Up @@ -235,6 +243,7 @@ export default {
const that = this
this.getList(`/${this.type}/${encodeURIComponent(this.globalId)}/metadata`).then(response => {
that.metadata = response.body
that.metadata.endpoints = Object.assign({}, that.metadata.endpoints, ...this.addHardcodeSections(response.body.object_type))
that.title = response.body.object_tag
that.menuOptions = that.createMenuOptions(response.body.endpoints)
that.url = response.body.url
Expand Down Expand Up @@ -298,6 +307,11 @@ export default {
this.defaultTag = undefined
TW.workbench.alert.create('Tag item was successfully destroyed.', 'notice')
})
},
addHardcodeSections (type) {
return this.hardcodeSections.filter(item => item.objectTypes.includes(type)).map(item => {
return { [item.section]: { total: 0 } }
})
}
}
}
Expand Down

0 comments on commit bef005f

Please sign in to comment.