Skip to content
Snippets Groups Projects
Commit b9d66983 authored by David Mendez's avatar David Mendez
Browse files

Add missing file!!!

parent 2c649cb9
No related branches found
No related tags found
1 merge request!8Improve layout of report cards and search bar
import RequestNotifications from '@/web-components-submodule/utils/RequestNotifications.js'
import EntityNames from '~/web-components-submodule/standardisation/EntityNames.js'
import IndexNames from '~/web-components-submodule/standardisation/IndexNames.js'
import ESProxyService from '~/web-components-submodule/services/ESProxyService.js'
import ObjectPropertyAccess from '~/web-components-submodule/utils/ObjectPropertyAccess.js'
export const state = () => ({
calculatedProperties: [],
dataLoaded: false,
})
export const mutations = {
SET_DATA_LOADED(state, dataLoaded) {
state.dataLoaded = dataLoaded
},
SET_CALCULATED_PROPERTIES(state, calculatedProperties) {
state.calculatedProperties = calculatedProperties
},
}
export const actions = {
loadData({ commit, state, dispatch }, itemID) {
const entityID = EntityNames.EubopenCompound.entityID
const indexName = IndexNames.getIndexNameFromEntityID(entityID)
const groupName = 'calculated_properties'
ESProxyService.getPopertyGroupConfiguration(indexName, groupName)
.then((response) => {
const propertiesConfig = response.data.properties.default
const propertiesToFetch = propertiesConfig.map((propConfig) => {
return {
label: propConfig.label,
prop_id: propConfig.prop_id,
}
})
const docSource = propertiesToFetch.map(
(propConfig) => propConfig.prop_id
)
ESProxyService.getESDocument(indexName, itemID, docSource)
.then((response) => {
const sourceObtained = response.data._source
const calculatedProperties = propertiesToFetch.map((propConfig) => {
return {
label: propConfig.label,
value: ObjectPropertyAccess.getPropertyPalue(
sourceObtained,
propConfig.prop_id,
'--'
),
}
})
commit('SET_CALCULATED_PROPERTIES', calculatedProperties)
commit('SET_DATA_LOADED', true)
})
.catch((error) => {
RequestNotifications.dispatchRequestErrorNotification(
error,
dispatch,
`There was an error while loading the calculated properties!`
)
})
})
.catch((error) => {
RequestNotifications.dispatchRequestErrorNotification(
error,
dispatch,
`There was an error while fetching the list of properties for the calculated properties!`
)
})
},
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment