Lines 1-6
Link Here
|
1 |
import { APIClient } from "../fetch/api-client.js"; |
1 |
import { APIClient } from "../fetch/api-client.js"; |
2 |
|
2 |
|
3 |
export const get_lib_from_av_handler = (arr_name, av, store) => { |
3 |
const get_lib_from_av_handler = (arr_name, av, store) => { |
4 |
if (store.authorisedValues[arr_name] === undefined) { |
4 |
if (store.authorisedValues[arr_name] === undefined) { |
5 |
console.warn( |
5 |
console.warn( |
6 |
"The authorised value category for '%s' is not defined.".format( |
6 |
"The authorised value category for '%s' is not defined.".format( |
Lines 12-25
export const get_lib_from_av_handler = (arr_name, av, store) => {
Link Here
|
12 |
let o = store.authorisedValues[arr_name].find(e => e.value == av); |
12 |
let o = store.authorisedValues[arr_name].find(e => e.value == av); |
13 |
return o ? o.description : av; |
13 |
return o ? o.description : av; |
14 |
}; |
14 |
}; |
15 |
export const map_av_dt_filter_handler = (arr_name, store) => { |
15 |
const map_av_dt_filter_handler = (arr_name, store) => { |
16 |
return store.authorisedValues[arr_name].map(e => { |
16 |
return store.authorisedValues[arr_name].map(e => { |
17 |
e["_id"] = e["value"]; |
17 |
e["_id"] = e["value"]; |
18 |
e["_str"] = e["description"]; |
18 |
e["_str"] = e["description"]; |
19 |
return e; |
19 |
return e; |
20 |
}); |
20 |
}); |
21 |
}; |
21 |
}; |
22 |
export const loadAuthorisedValues = async (authorisedValues, targetStore) => { |
22 |
const load_authorised_values_handler = async ( |
|
|
23 |
authorisedValues, |
24 |
targetStore |
25 |
) => { |
23 |
const AVsToFetch = Object.keys(authorisedValues).reduce((acc, avKey) => { |
26 |
const AVsToFetch = Object.keys(authorisedValues).reduce((acc, avKey) => { |
24 |
if (Array.isArray(authorisedValues[avKey])) return acc; |
27 |
if (Array.isArray(authorisedValues[avKey])) return acc; |
25 |
acc[avKey] = authorisedValues[avKey]; |
28 |
acc[avKey] = authorisedValues[avKey]; |
Lines 48-50
export const loadAuthorisedValues = async (authorisedValues, targetStore) => {
Link Here
|
48 |
|
51 |
|
49 |
return Promise.all(promises); |
52 |
return Promise.all(promises); |
50 |
}; |
53 |
}; |
|
|
54 |
|
55 |
export function withAuthorisedValueActions(store) { |
56 |
return { |
57 |
loadAuthorisedValues(authorisedValues, targetStore) { |
58 |
return load_authorised_values_handler( |
59 |
authorisedValues, |
60 |
targetStore |
61 |
); |
62 |
}, |
63 |
get_lib_from_av(arr_name, av) { |
64 |
return get_lib_from_av_handler(arr_name, av, store); |
65 |
}, |
66 |
map_av_dt_filter(arr_name) { |
67 |
return map_av_dt_filter_handler(arr_name, store); |
68 |
}, |
69 |
}; |
70 |
} |