mirror of
https://github.com/nasa/openmct.git
synced 2025-04-17 15:59:09 +00:00
Add source maps to map plan properties to expected properties (#4933)
This commit is contained in:
parent
5471e13d9e
commit
bcd668594d
@ -21,6 +21,7 @@
|
||||
*****************************************************************************/
|
||||
|
||||
export function getValidatedPlan(domainObject) {
|
||||
let sourceMap = domainObject.sourceMap;
|
||||
let body = domainObject.selectFile.body;
|
||||
let json = {};
|
||||
if (typeof body === 'string') {
|
||||
@ -33,5 +34,33 @@ export function getValidatedPlan(domainObject) {
|
||||
json = body;
|
||||
}
|
||||
|
||||
return json;
|
||||
if (sourceMap !== undefined && sourceMap.activities !== undefined && sourceMap.groupId !== undefined) {
|
||||
let mappedJson = {};
|
||||
json[sourceMap.activities].forEach((activity) => {
|
||||
if (activity[sourceMap.groupId]) {
|
||||
const groupIdKey = activity[sourceMap.groupId];
|
||||
let groupActivity = {
|
||||
...activity
|
||||
};
|
||||
|
||||
if (sourceMap.start) {
|
||||
groupActivity.start = activity[sourceMap.start];
|
||||
}
|
||||
|
||||
if (sourceMap.end) {
|
||||
groupActivity.end = activity[sourceMap.end];
|
||||
}
|
||||
|
||||
if (!mappedJson[groupIdKey]) {
|
||||
mappedJson[groupIdKey] = [];
|
||||
}
|
||||
|
||||
mappedJson[groupIdKey].push(groupActivity);
|
||||
}
|
||||
});
|
||||
|
||||
return mappedJson;
|
||||
} else {
|
||||
return json;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user