Fix MCA view answer yaml issue

https://github.com/rancher/rancher/issues/18196
This commit is contained in:
loganhz 2019-04-15 16:19:52 +08:00
parent 6d75ad47e6
commit 9af7b24edc
1 changed files with 4 additions and 2 deletions

View File

@ -419,14 +419,16 @@ export default Component.extend(NewOrEdit, CatalogApp, {
if (get(model, 'questions')) {
let neu = {};
(get(this, 'answersArray') || []).forEach((a) => {
(get(this, 'answersArray') || []).filter((a) => typeof a.answer !== 'object' ).forEach((a) => {
neu[a.variable] = isEmpty(a.answer) ? a.default : a.answer;
});
const customAnswers = get(model, 'customAnswers') || {};
Object.keys(customAnswers).forEach((key) => {
neu[key] = customAnswers[key];
if ( typeof customAnswers[key] !== 'object' ) {
neu[key] = customAnswers[key];
}
});
return YAML.stringify(neu);