Skip to content

Commit

Permalink
Added delete option for type material #337
Browse files Browse the repository at this point in the history
  • Loading branch information
jlpereira committed Sep 11, 2018
1 parent 1756d6f commit 8cf8c69
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 61 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export default {
},
data: function () {
return {
delayCall: undefined,
creatingType: false,
displayBody: true,
figuresList: [],
Expand All @@ -84,9 +85,13 @@ export default {
objectValue (newVal, oldVal) {
if (newVal.id && (newVal.id != oldVal.id)) {
this.$refs.depiction.setOption('autoProcessQueue', true)
this.getDepictions(newVal.id).then(response => {
this.figuresList = response
})
if(this.delayCall) { clearTimeout(this.delayCall) }
this.delayCall = setTimeout(() => {
this.getDepictions(newVal.id).then(response => {
this.figuresList = response
})
}, 1000)
} else {
this.figuresList = []
this.$refs.depiction.setOption('autoProcessQueue', false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,64 +7,74 @@
<validation-component :show-message="!typeMaterialCheck"/>
</div>
<div slot="body">
<div>
<label>Taxon name</label>
<div
v-if="taxon"
class="horizontal-left-content">
<span v-html="taxon.object_tag"/>
<span
class="button circle-button btn-delete"
@click="taxon = undefined"/>
</div>
<autocomplete
v-else
url="/taxon_names/autocomplete"
min="2"
param="term"
placeholder="Select a taxon name"
@getItem="selectTaxon"
label="label"
:add-params="{
'type[]': 'Protonym',
'nomenclature_group[]': 'SpeciesGroup',
valid: true
}"/>
<div
v-if="typeMaterial.id"
class="horizontal-left-content">
<span v-html="typeMaterial.object_tag"/>
<span
class="button circle-button btn-delete"
@click="destroyTypeMateria(typeMaterial.id)"/>
</div>
<div>
<label>Type type</label>
<br>
<select
v-model="type"
class="normal-input">
<template v-if="checkForTypeList">
<template v-else>
<div>
<label>Taxon name</label>
<div
v-if="taxon"
class="horizontal-left-content">
<span v-html="taxon.object_tag"/>
<span
class="button circle-button btn-delete"
@click="taxon = undefined"/>
</div>
<autocomplete
v-else
url="/taxon_names/autocomplete"
min="2"
param="term"
placeholder="Select a taxon name"
@getItem="selectTaxon"
label="label"
:add-params="{
'type[]': 'Protonym',
'nomenclature_group[]': 'SpeciesGroup',
valid: true
}"/>
</div>
<div>
<label>Type type</label>
<br>
<select
v-model="type"
class="normal-input">
<template v-if="checkForTypeList">
<option
class="capitalize"
:value="key"
v-for="(item, key) in types[taxon.nomenclatural_code]">{{ key }}
</option>
</template>
<option
class="capitalize"
:value="key"
v-for="(item, key) in types[taxon.nomenclatural_code]">{{ key }}
</option>
</template>
<option
:value="undefined"
selected
disabled
v-else>Select a taxon name first</option>
</select>
</div>
<label>Type designator</label>
<role-picker
v-model="roles"
:autofocus="false"
role-type="TypeDesignator"
class="types_field"/>
:value="undefined"
selected
disabled
v-else>Select a taxon name first</option>
</select>
</div>
<label>Type designator</label>
<role-picker
v-model="roles"
:autofocus="false"
role-type="TypeDesignator"
class="types_field"/>
</template>
</div>
</block-layout>
</template>

<script>
import Autocomplete from '../../../../components/autocomplete.vue'
import { GetTypes } from '../../request/resources.js'
import { GetTypes, DestroyTypeMaterial } from '../../request/resources.js'
import RolePicker from '../../../../components/role_picker.vue'
import ActionNames from '../../store/actions/actionNames.js'
import { GetterNames } from '../../store/getters/getters.js'
Expand All @@ -84,6 +94,9 @@
checkForTypeList () {
return this.types && this.taxon
},
typeMaterial() {
return this.$store.getters[GetterNames.GetTypeMaterial]
},
taxon: {
get() {
return this.$store.getters[GetterNames.GetTypeMaterial].taxon
Expand Down Expand Up @@ -126,6 +139,11 @@
selectTaxon(taxon) {
this.$store.dispatch(ActionNames.GetTaxon, taxon.id)
},
destroyTypeMateria(id) {
DestroyTypeMaterial(id).then(() => {
this.$store.commit(MutationNames.NewTypeMaterial)
})
}
}
}
</script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,18 @@ export default function ({ commit, dispatch, state }) {
dispatch(ActionNames.SaveCollectionEvent).then(() => {
dispatch(ActionNames.SaveCollectionObject).then(() => {
dispatch(ActionNames.SaveTypeMaterial).then(() => {
if(!state.container) {
dispatch(ActionNames.SaveContainer).then(() => {
dispatch(ActionNames.SaveContainerItem)
dispatch(ActionNames.SaveIdentifier).then(() => {
dispatch(ActionNames.SaveDetermination).then(() => {
if(!state.container) {
dispatch(ActionNames.SaveContainer).then(() => {
dispatch(ActionNames.SaveContainerItem)
})
}
else {
dispatch(ActionNames.SaveContainerItem)
}
})
}
else {
dispatch(ActionNames.SaveContainerItem)
}
dispatch(ActionNames.SaveIdentifier)
dispatch(ActionNames.SaveDetermination)
})
})
})
})
Expand Down

0 comments on commit 8cf8c69

Please sign in to comment.