Commit 9940171f authored by Konrad Mohrfeldt's avatar Konrad Mohrfeldt Committed by Robert

fix retrieval of gestalt profile data. refs #596

The dom-select adapter used for the author-selection in articles queries
our gestalt rest api. unfortunately it used the get method of the
gestalt adapter as if it were the list method and later filtered the
gestalt object from that. the new implementation just fetches the
gestalt based on the get method.
parent fd2dc360
import { find, matches } from 'lodash'
export default (gestaltApi, gestaltId, groupChoices) => {
const gestaltQuery = gestaltApi.get(gestaltId).catch(() => null)
export default (gestaltApi, gestaltId, groupAdapter) => {
const gestalten = gestaltApi.get()
.then(response => Promise.resolve(response.data), () => null)
const get = async choices => {
const groups = await groupChoices.get(choices)
const gestalt = await gestaltQuery
const result = {choices: groups.choices}
const get = choices => {
return Promise.all([groupAdapter.get(choices), gestalten])
.then(data => {
const [groups, gestalten] = data
const result = {choices: groups.choices}
const gestalt = find(gestalten, matches({id: gestaltId}))
if (gestalt) {
gestalt.value = ''
gestalt.text = gestalt.name
gestalt.label = gestalt.name
result.defaultChoice = gestalt
}
if (gestalt) {
gestalt.value = ''
gestalt.text = gestalt.name
gestalt.label = gestalt.name
result.defaultChoice = gestalt
}
return Promise.resolve(result)
})
return result
}
const texts = Object.assign({}, groupAdapter.texts, {
const texts = {
...groupChoices.texts,
noSelection: 'Du selbst'
})
}
return Object.assign({}, groupAdapter, {texts, get})
return {
...groupChoices,
texts,
get
}
}
......@@ -6,11 +6,14 @@ export default api => {
const ids = choices.map(option => option.value).join(',')
return api.list({id: ids})
.then(response => Promise.resolve(response.data))
.then(data => Promise.resolve(choices.map(choice => {
return Object.assign({}, choice, find(data, entity => entity.id === parseInt(choice.value, 10)))
})))
.then(choices => Promise.resolve({choices, defaultChoice: null}))
.then(response => response.data)
.then(data =>
choices.map(choice => ({
...choice,
...find(data, entity => entity.id === parseInt(choice.value, 10))
}))
)
.then(choices => ({choices, defaultChoice: null}))
}
const filter = (term, choice, defaultFilter) => {
......
Markdown is supported
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