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