Skip to content

Commit

Permalink
Fix #993
Browse files Browse the repository at this point in the history
  • Loading branch information
jlpereira committed Jun 7, 2019
1 parent 05af557 commit e996fd7
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 4 deletions.
33 changes: 31 additions & 2 deletions app/javascript/vue/nomenclature/new_taxon_name/components/type.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,22 @@
class="body"
v-if="expanded">
<div v-if="!taxonRelation">
<div
v-if="editType"
class="horizontal-left-content">
<span>
<span v-html="GetRelationshipsCreated[0].object_status_tag"/>
<a
v-html="GetRelationshipsCreated[0].subject_object_tag"
:href="`/tasks/nomenclature/browse/${GetRelationshipsCreated[0].subject_taxon_name_id}`"/>
</span>
<span
class="button circle-button btn-undo button-default"
@click="editType = undefined"/>
</div>
<hard-validation
field="type"
v-if="!showForThisGroup(['SpeciesGroup', 'SpeciesAndInfraspeciesGroup'], taxon) && !(GetRelationshipsCreated.length)">
v-if="!showForThisGroup(['SpeciesGroup', 'SpeciesAndInfraspeciesGroup'], taxon) && (!(GetRelationshipsCreated.length) || editType)">
<autocomplete
slot="body"
url="/taxon_names/autocomplete"
Expand Down Expand Up @@ -96,8 +109,10 @@
<list-entrys
@update="loadTaxonRelationships"
@addCitation="setType"
:edit="true"
:list="GetRelationshipsCreated"
@delete="removeType"
@edit="editType = $event"
:display="['object_status_tag', { link: '/tasks/nomenclature/browse/', label: 'subject_object_tag', param: 'subject_taxon_name_id'}]"/>
</div>
</form>
Expand Down Expand Up @@ -179,6 +194,7 @@ export default {
objectLists: this.makeLists(),
expanded: true,
showAdvance: false,
editType: undefined,
childOfParent: childOfParent,
typeMaterialList: []
}
Expand Down Expand Up @@ -235,7 +251,20 @@ export default {
if (this.getRankGroup == 'Family') { this.addEntry(this.objectLists.tree[Object.keys(this.objectLists.tree)[0]]) }
},
addEntry: function (item) {
this.$store.dispatch(ActionNames.AddTaxonType, item)
if(this.editType) {
item.id = this.editType.id
this.$store.dispatch(ActionNames.UpdateTaxonType, item).then(() => {
this.$store.commit(MutationNames.UpdateLastSave)
this.editType = undefined
this.$store.dispatch(ActionNames.UpdateTaxonName, this.taxon)
})
}
else {
this.$store.dispatch(ActionNames.AddTaxonType, item).then(() => {
this.$store.commit(MutationNames.UpdateLastSave)
this.$store.dispatch(ActionNames.UpdateTaxonName, this.taxon)
})
}
},
filterList: function (list, filter) {
let tmp = {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import removeSource from './removeSource'
import updateClassification from './updateClassification'
import updateTaxonRelationship from './updateTaxonRelationship'
import updateTaxonStatus from './updateTaxonStatus'
import updateTaxonType from './updateTaxonType'

const ActionNames = {
SetParentAndRanks: 'setParentAndRanks',
Expand All @@ -43,7 +44,8 @@ const ActionNames = {
RemoveSource: 'removeSource',
UpdateClassification: 'updateClassification',
UpdateTaxonRelationship: 'updateTaxonRelationship',
UpdateTaxonStatus: 'updateTaxonStatus'
UpdateTaxonStatus: 'updateTaxonStatus',
UpdateTaxonType: 'updateTaxonType'
}

const ActionFunctions = {
Expand All @@ -68,7 +70,8 @@ const ActionFunctions = {
[ActionNames.ChangeTaxonSource]: changeTaxonSource,
[ActionNames.UpdateClassification]: updateClassification,
[ActionNames.UpdateTaxonRelationship]: updateTaxonRelationship,
[ActionNames.UpdateTaxonStatus]: updateTaxonStatus
[ActionNames.UpdateTaxonStatus]: updateTaxonStatus,
[ActionNames.UpdateTaxonType]: updateTaxonType
}

export {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { updateTaxonRelationship } from '../../request/resources'
import { MutationNames } from '../mutations/mutations'

export default function ({ commit, state, dispatch }, data) {
let relationship = {
taxon_name_relationship: {
id: data.id,
object_taxon_name_id: state.taxon_name.id,
subject_taxon_name_id: state.taxonType.id,
type: data.type
}
}
updateTaxonRelationship(relationship).then(response => {
commit(MutationNames.AddTaxonRelationship, response)
dispatch('loadSoftValidation', 'taxonRelationshipList')
dispatch('loadSoftValidation', 'taxon_name')
}, response => {
commit(MutationNames.SetHardValidation, response)
})
state.taxonType = undefined
}

0 comments on commit e996fd7

Please sign in to comment.