1
0
mirror of https://github.com/pcvolkmer/onkostar-plugin-dnpm.git synced 2025-07-01 17:02:53 +00:00
Files
onkostar-plugin-dnpm/scripts/studien-edit.js

27 lines
632 B
JavaScript

let text = getFieldValue('studienalle');
let json = [];
let newJson = [];
try {
json = JSON.parse(getFieldValue('studienallejson'));
if (!Array.isArray(json)) {
json = [];
}
} catch (e) {
json = [];
}
if (typeof text === 'string' || text instanceof String) {
text.split('\n').forEach(line => {
let id = line.split(';')[0];
json.forEach(entry => {
if (id === entry.nct) {
newJson.push(entry);
}
});
});
setFieldValue('studienallejson', JSON.stringify(newJson));
} else {
setFieldValue('studienallejson', JSON.stringify([]));
}