Skip to content

Commit

Permalink
Tweaks #337
Browse files Browse the repository at this point in the history
  • Loading branch information
jlpereira committed Jan 17, 2019
1 parent dfa352f commit cd55dcd
Show file tree
Hide file tree
Showing 15 changed files with 69 additions and 11 deletions.
1 change: 0 additions & 1 deletion app/javascript/vue/components/autocomplete.vue
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,6 @@ export default {
else {
params += `&${key}=${this.addParams[key]}`
}
console.log(params)
})
}
return tempUrl + params
Expand Down
11 changes: 10 additions & 1 deletion app/javascript/vue/tasks/digitize/app.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@
import TaxonDeterminationLayout from './components/taxonDetermination/main.vue'
import CollectionEventLayout from './components/collectionEvent/main.vue'
import TypeMaterial from './components/typeMaterial/typeMaterial.vue'
import { GetUserPreferences } from './request/resources.js'
import { GetUserPreferences, GetIdentifier } 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 SpinnerComponent from 'components/spinner.vue'
import ContainerItems from './components/collectionObject/containerItems.vue'
Expand All @@ -50,9 +51,17 @@
}
},
mounted() {
let identifierId = location.pathname.split('/')[4]
GetUserPreferences().then(response => {
this.$store.commit(MutationNames.SetPreferences, response)
})
if (/^\d+$/.test(identifierId)) {
this.$store.dispatch(ActionNames.GetIdentifier, identifierId).then(response => {
this.$store.dispatch(ActionNames.LoadDigitalization, response.identifier_object_id)
})
}
},
methods: {
getMacKey() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
class="separate-right"
url="/namespaces/autocomplete"
min="2"
@getItem="namespace = $event.id"
@getItem="namespace = $event.id; namespaceSelected = $event.label"
:display="namespaceSelected"
label="label_html"
ref="autocomplete"
param="term"/>
Expand Down Expand Up @@ -88,9 +89,6 @@
this.$store.commit(MutationNames.SetSettings, value)
}
},
collectionObjects() {
return this.$store.getters[GetterNames.GetCollectionObjects]
},
namespace: {
get() {
return this.$store.getters[GetterNames.GetIdentifier].namespace_id
Expand All @@ -117,6 +115,14 @@
},
checkValidation() {
return !validateIdentifier({ namespace_id: this.namespace, identifier: this.identifier })
},
namespaceSelected: {
get() {
return this.$store.getters[GetterNames.GetNamespaceSelected]
},
set(value) {
this.$store.commit(MutationNames.SetNamespaceSelected, value)
}
}
},
data() {
Expand All @@ -131,6 +137,9 @@
if(!newVal) {
this.$refs.autocomplete.cleanInput()
}
},
namespaceSelected(newVal) {
this.$refs.autocomplete.setLabel(newVal)
}
},
methods: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
},
loadAssessionCode(object) {
this.$store.dispatch(ActionNames.LoadDigitalization, object.identifier_object_id)
this.$store.dispatch(ActionNames.GetIdentifier, object.id)
}
}
}
Expand Down
10 changes: 10 additions & 0 deletions app/javascript/vue/tasks/digitize/request/resources.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,14 @@ const GetRepository = function (id) {
return ajaxCall('get', `/repositories/${id}.json`)
}

const GetIdentifier = function (id) {
return ajaxCall('get', `/identifiers/${id}.json`)
}

const GetNamespace = function (id) {
return ajaxCall('get', `/namespaces/${id}.json`)
}

const CreateTypeMaterial = function (data) {
return ajaxCall('post', `/type_materials.json`, { type_material: data })
}
Expand Down Expand Up @@ -243,6 +251,8 @@ export {
GetTypeDesignatorSmartSelector,
FilterCollectingEvent,
GetTaxonDeterminationCO,
GetNamespace,
GetIdentifier,
GetTypeMaterialCO,
GetTypes,
GetTaxon,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const ActionNames = {
GetTaxon: 'getTaxon',
GetIdentifier: 'getIdentifier',
GetCollectionObject: 'getCollectionObject',
GetCollectionEvent: 'getCollectionEvent',
GetTypeMaterial: 'getTypeMaterial',
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 @@ -6,6 +6,7 @@ import getTypeMaterial from './getTypeMaterial'
import getTaxonDeterminations from './getTaxonDeterminations'
import getCollectionObject from './getCollectionObject'
import getCollectionEvent from './getCollectionEvent'
import getIdentifier from './getIdentifier'
import saveDigitalization from './saveDigitalization'
import saveIdentifier from './saveIdentifier'
import saveCollectionObject from './saveCollectionObject'
Expand All @@ -31,6 +32,7 @@ const ActionFunctions = {
[ActionNames.AddToContainer]: addToContainer,
[ActionNames.LoadDigitalization]: loadDigitalization,
[ActionNames.GetTaxon]: getTaxon,
[ActionNames.GetIdentifier]: getIdentifier,
[ActionNames.GetTypeMaterial]: getTypeMaterial,
[ActionNames.GetCollectionObject]: getCollectionObject,
[ActionNames.GetCollectionEvent]: getCollectionEvent,
Expand Down
14 changes: 14 additions & 0 deletions app/javascript/vue/tasks/digitize/store/actions/getIdentifier.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { GetIdentifier, GetNamespace } from '../../request/resources'
import { MutationNames } from '../mutations/mutations'

export default function ({ commit }, id) {
return new Promise((resolve, reject) => {
GetIdentifier(id).then(response => {
commit(MutationNames.SetIdentifier, response)
GetNamespace(response.namespace_id).then(namespace => {
commit(MutationNames.SetNamespaceSelected, namespace.name)
return resolve(response)
})
})
})
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ export default function ({ commit, dispatch, state }, coId) {
dispatch(ActionNames.GetCollectionObject, coId).then((coObject) => {
if(coObject.collecting_event_id)
dispatch(ActionNames.GetCollectionEvent, coObject.collecting_event_id)
//dispatch(ActionNames.GetIdentifiers)
dispatch(ActionNames.GetTypeMaterial, coId)
dispatch(ActionNames.GetTaxonDeterminations, coId)
commit(MutationNames.AddCollectionObject, coObject)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function(state) {
return state.namespaceSelected
}
7 changes: 5 additions & 2 deletions app/javascript/vue/tasks/digitize/store/getters/getters.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import getPreparationType from './getPreparationType'
import getMaterialTypes from './getMaterialTypes'
import getLabel from './getLabel'
import getTaxonDeterminations from './getTaxonDeterminations'
import getNamespaceSelected from './getNamespaceSelected'

const GetterNames = {
IsSaving: 'isSaving',
Expand All @@ -39,7 +40,8 @@ const GetterNames = {
GetPreparationType: 'getPreparationType',
GetMaterialTypes: 'getMaterialTypes',
GetLabel: 'GetLabel',
GetTaxonDeterminations: 'GetTaxonDeterminations'
GetTaxonDeterminations: 'GetTaxonDeterminations',
GetNamespaceSelected: 'getNamespaceSelected'
}

const GetterFunctions = {
Expand All @@ -62,7 +64,8 @@ const GetterFunctions = {
[GetterNames.GetPreparationType]: getPreparationType,
[GetterNames.GetMaterialTypes]: getMaterialTypes,
[GetterNames.GetLabel]: getLabel,
[GetterNames.GetTaxonDeterminations]: getTaxonDeterminations
[GetterNames.GetTaxonDeterminations]: getTaxonDeterminations,
[GetterNames.GetNamespaceSelected]: getNamespaceSelected
}

export {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import resetStore from './resetStore'

import setDepictions from './setDepictions'

import setNamespaceSelected from './setNamespaceSelected'

import setBiocurations from './setBiocurations'
import addBiocuration from './addBiocuration'
import removeBiocuration from './removeBiocuration'
Expand Down Expand Up @@ -117,6 +119,7 @@ const MutationNames = {
ResetStore: 'resetStore',

SetDepictions: 'setDepictions',
SetNamespaceSelected: 'setNamespaceSelected',

SetLabel: 'setLabel',
SetLabelText: 'setLabelText',
Expand Down Expand Up @@ -227,6 +230,7 @@ const MutationFunctions = {
[MutationNames.ResetStore]: resetStore,

[MutationNames.SetDepictions]: setDepictions,
[MutationNames.SetNamespaceSelected]: setNamespaceSelected,

[MutationNames.SetBiocurations]: setBiocurations,
[MutationNames.AddBiocuration]: addBiocuration,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function(state, value) {
state.namespaceSelected = value
}
3 changes: 2 additions & 1 deletion app/javascript/vue/tasks/digitize/store/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,8 @@ function makeInitialState () {
COTypes: [],
biocurations: [],
preparation_type_id: undefined,
taxon_determinations: []
taxon_determinations: [],
namespaceSelected: ''
}
}

Expand Down
2 changes: 1 addition & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -819,7 +819,7 @@

scope :accessions do
scope :comprehensive, controller: 'tasks/accessions/comprehensive' do
get 'index', as: 'comprehensive_collection_object_task'
get '(:id)', action: :index, as: 'comprehensive_collection_object_task'
end

scope :report do
Expand Down

0 comments on commit cd55dcd

Please sign in to comment.