Skip to content

Commit

Permalink
Tweak labels #337
Browse files Browse the repository at this point in the history
  • Loading branch information
jlpereira committed Jan 18, 2019
1 parent bdc7ccc commit 362823a
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@
type="number">
</span>
</div>
<div class="separate-bottom">
<a
v-if="label.id && que > 0"
target="blank"
href="/tasks/labels/print_labels/index">Preview
</a>
</div>
<label>Print label</label>
<textarea
v-model="printLabel"
Expand All @@ -32,6 +39,9 @@ import { MutationNames } from '../../../../store/mutations/mutations.js'
export default {
computed: {
label() {
return this.$store.getters[GetterNames.GetLabel]
},
printLabel: {
get() {
return this.$store.getters[GetterNames.GetLabel].text
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import { GetCollectionEvent } from '../../../../request/resources.js'
import { MutationNames } from '../../../../store/mutations/mutations.js'
import { ActionNames } from '../../../../store/actions/actions.js'
import { GetterNames } from '../../../../store/getters/getters.js'
import makeCollectingEvent from '../../../../const/collectingEvent.js'
Expand All @@ -41,6 +42,7 @@
getCollectingEvent(id) {
GetCollectionEvent(id).then(response => {
this.$store.commit(MutationNames.SetCollectionEvent, Object.assign(makeCollectingEvent(), response))
this.$store.dispatch(ActionNames.GetLabels, id)
})
}
}
Expand Down
5 changes: 5 additions & 0 deletions app/javascript/vue/tasks/digitize/request/resources.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ const GetIdentifiersFromCO = function (id) {
return ajaxCall('get', `/identifiers.json?identifier_object_type=CollectionObject&identifier_object_id=${id}&type=Identifier::Local::CatalogNumber`)
}

const GetLabelsFromCE = function (id) {
return ajaxCall('get', `/labels?label_object_id=${id}&label_object_type=CollectingEvent`)
}

const GetRecentCollectionObjects = function () {
return ajaxCall('get', `/collection_objects.json`, { params: { recent: true, per: 5 } })
}
Expand Down Expand Up @@ -247,6 +251,7 @@ const DestroyCollectionObject = function (id) {

export {
CheckForExistingIdentifier,
GetLabelsFromCE,
GetUserPreferences,
GetOtu,
GetIdentifiersFromCO,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const ActionNames = {
GetTaxon: 'getTaxon',
GetLabels: 'getLabels',
GetIdentifier: 'getIdentifier',
GetIdentifiers: 'getIdentifiers',
GetNamespace: 'getNamespace',
Expand Down
2 changes: 2 additions & 0 deletions app/javascript/vue/tasks/digitize/store/actions/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import ActionNames from './actionNames'

import loadDigitalization from './loadDigitalization'
import getTaxon from './getTaxon'
import getLabels from './getLabels'
import getNamespace from './getNamespace'
import getTypeMaterial from './getTypeMaterial'
import getTaxonDeterminations from './getTaxonDeterminations'
Expand Down Expand Up @@ -35,6 +36,7 @@ const ActionFunctions = {
[ActionNames.AddToContainer]: addToContainer,
[ActionNames.LoadDigitalization]: loadDigitalization,
[ActionNames.GetTaxon]: getTaxon,
[ActionNames.GetLabels]: getLabels,
[ActionNames.GetNamespace]: getNamespace,
[ActionNames.GetIdentifier]: getIdentifier,
[ActionNames.GetIdentifiers]: getIdentifiers,
Expand Down
14 changes: 14 additions & 0 deletions app/javascript/vue/tasks/digitize/store/actions/getLabels.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { GetLabelsFromCE } from '../../request/resources'
import { MutationNames } from '../mutations/mutations'

export default function ({ commit }, id) {
return new Promise((resolve, reject) => {
GetLabelsFromCE(id).then(response => {
if(response.length)
commit(MutationNames.SetLabel, response[0])
resolve(response)
}, error => {
reject(error)
})
})
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export default function ({ commit, dispatch, state }, coId) {
}))

promises.push(dispatch(ActionNames.GetTypeMaterial, coId))
promises.push(dispatch(ActionNames.GetLabels, coObject.collecting_event_id))
promises.push(dispatch(ActionNames.GetTaxonDeterminations, coId))
commit(MutationNames.AddCollectionObject, coObject)

Expand Down

0 comments on commit 362823a

Please sign in to comment.