Skip to content

Commit

Permalink
Added clone button
Browse files Browse the repository at this point in the history
  • Loading branch information
jlpereira committed May 29, 2019
1 parent 053ef2e commit d06b526
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
Expand Up @@ -43,6 +43,12 @@
<span
class="circle-button button-default btn-undo"
@click="cleanCollectionEvent"/>
<button
type="button"
class="button normal-input button-submit"
@click="cloneCE">
Clone
</button>
</div>
<component
:is="actualComponent"
Expand Down Expand Up @@ -73,7 +79,7 @@
import { ActionNames } from '../../store/actions/actions.js'
import PinComponent from 'components/pin.vue'
import PinDefault from 'components/getDefaultPin'
import { GetCollectingEventsSmartSelector, GetCollectionEvent } from '../../request/resources.js'
import { GetCollectingEventsSmartSelector, GetCollectionEvent, CloneCollectionEvent } from '../../request/resources.js'
import makeCollectingEvent from '../../const/collectingEvent.js'
import orderSmartSelector from '../../helpers/orderSmartSelector.js'
Expand Down Expand Up @@ -159,6 +165,12 @@
},
cleanCollectionEvent() {
this.$store.dispatch(ActionNames.NewCollectionEvent)
},
cloneCE() {
CloneCollectionEvent(this.collectingEvent.id).then(response => {
this.$store.commit(MutationNames.SetCollectionEvent, Object.assign(makeCollectingEvent(), response))
this.$store.dispatch(ActionNames.SaveDigitalization)
})
}
}
}
Expand Down
5 changes: 5 additions & 0 deletions app/javascript/vue/tasks/digitize/request/resources.js
Expand Up @@ -153,6 +153,10 @@ const CreateCollectionEvent = function (data) {
return ajaxCall('post', `/collecting_events.json`, { collecting_event: data })
}

const CloneCollectionEvent = function (id) {
return ajaxCall('post', `/collecting_events/${id}/clone`)
}

const GetCollectionObject = function (id) {
return ajaxCall('get', `/collection_objects/${id}.json`)
}
Expand Down Expand Up @@ -283,6 +287,7 @@ const DestroyBiologicalAssociation = function (id) {

export {
CheckForExistingIdentifier,
CloneCollectionEvent,
GetLabelsFromCE,
GetUserPreferences,
GetOtu,
Expand Down

0 comments on commit d06b526

Please sign in to comment.