mirror of
https://github.com/ansible/awx.git
synced 2026-03-14 07:27:28 -02:30
Fixes display of multi-select survey question fields
This commit is contained in:
@@ -130,7 +130,8 @@ function MultiSelectField({ question, i18n }) {
|
||||
<FormGroup
|
||||
fieldId={id}
|
||||
helperTextInvalid={
|
||||
meta.error || i18n._(t`Must select a value for this field.`)
|
||||
meta.error ||
|
||||
i18n._(t`At least one value must be selected for this field.`)
|
||||
}
|
||||
isRequired={question.required}
|
||||
validated={isValid ? 'default' : 'error'}
|
||||
|
||||
@@ -107,9 +107,11 @@ function getInitialValues(launchConfig, surveyConfig, resource) {
|
||||
if (surveyConfig?.spec) {
|
||||
surveyConfig.spec.forEach(question => {
|
||||
if (question.type === 'multiselect') {
|
||||
values[`survey_${question.variable}`] = question.default.split('\n');
|
||||
values[`survey_${question.variable}`] = question.default
|
||||
? question.default.split('\n')
|
||||
: [];
|
||||
} else {
|
||||
values[`survey_${question.variable}`] = question.default;
|
||||
values[`survey_${question.variable}`] = question.default || null;
|
||||
}
|
||||
if (resource?.extra_data) {
|
||||
Object.entries(resource.extra_data).forEach(([key, value]) => {
|
||||
|
||||
@@ -104,7 +104,9 @@ function SurveyPreviewModal({
|
||||
isReadOnly
|
||||
variant={SelectVariant.typeaheadMulti}
|
||||
isOpen={false}
|
||||
selections={q.default.length > 0 && q.default.split('\n')}
|
||||
selections={
|
||||
q.default.length > 0 ? q.default.split('\n') : []
|
||||
}
|
||||
onToggle={() => {}}
|
||||
aria-label={i18n._(t`Multi-Select`)}
|
||||
id={`survey-preview-multiSelect-${q.variable}`}
|
||||
|
||||
Reference in New Issue
Block a user