-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SHIBUI-1437 Integrated config component to replace summary
- Loading branch information
Showing
13 changed files
with
112 additions
and
310 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
import { MetadataConfiguration } from '../model/metadata-configuration'; | ||
import { WizardStep } from '../../../wizard/model'; | ||
import * as utils from '../../domain/utility/configuration'; | ||
import { getSplitSchema } from '../../../wizard/reducer'; | ||
|
||
export const getConfigurationSectionsFn = (models, definition, schema): MetadataConfiguration => { | ||
return !definition || !schema || !models ? null : | ||
({ | ||
dates: models.map(m => m ? m.modifiedDate : null), | ||
sections: definition.steps | ||
.filter(step => step.id !== 'summary') | ||
.map( | ||
(step: WizardStep, num: number) => { | ||
return ({ | ||
id: step.id, | ||
pageNumber: num + 1, | ||
index: step.index, | ||
label: step.label, | ||
properties: utils.getStepProperties( | ||
getSplitSchema(schema, step), | ||
definition.formatter({}), | ||
schema.definitions || {} | ||
) | ||
}); | ||
} | ||
) | ||
.map((section: any) => { | ||
return { | ||
...section, | ||
properties: assignValueToProperties(models, section.properties, definition) | ||
}; | ||
}) | ||
.map((section: any) => ({ | ||
...section, | ||
differences: section.properties.some(prop => prop.differences) | ||
})) | ||
}); | ||
}; | ||
|
||
export const assignValueToProperties = (models, properties, definition: any): any[] => { | ||
return properties.map(prop => { | ||
const differences = models.some((model, index, array) => { | ||
if (!array) { | ||
return false; | ||
} | ||
return JSON.stringify(model[prop.id]) !== JSON.stringify(array[0][prop.id]); | ||
}); | ||
|
||
const widget = prop.type === 'array' && prop.widget && prop.widget.data ? ({ | ||
...prop.widget, | ||
data: prop.widget.data.map(item => ({ | ||
...item, | ||
differences: models | ||
.map((model) => { | ||
const value = model[prop.id]; | ||
return value ? value.indexOf(item.key) > -1 : false; | ||
}) | ||
.reduce((current, val) => current !== val ? true : false, false) | ||
})) | ||
}) : null; | ||
|
||
switch (prop.type) { | ||
case 'object': | ||
return { | ||
...prop, | ||
differences, | ||
properties: assignValueToProperties( | ||
models.map(model => definition.formatter(model)[prop.id] || {}), | ||
prop.properties, | ||
definition | ||
) | ||
}; | ||
default: | ||
return { | ||
...prop, | ||
differences, | ||
value: models.map(model => { | ||
return model[prop.id]; | ||
}), | ||
widget | ||
}; | ||
} | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 0 additions & 13 deletions
13
ui/src/app/metadata/domain/component/wizard-summary.component.html
This file was deleted.
Oops, something went wrong.
103 changes: 0 additions & 103 deletions
103
ui/src/app/metadata/domain/component/wizard-summary.component.spec.ts
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.