mirror of
https://github.com/ansible/awx.git
synced 2026-05-19 14:57:39 -02:30
Fixes empty chip issue when user adds empty new line.
This commit is contained in:
@@ -18,6 +18,13 @@ export default function SurveyQuestionAdd({ survey, updateSurvey }) {
|
|||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (question.type === 'multiselect') {
|
||||||
|
question.default = question.default
|
||||||
|
.split('\n')
|
||||||
|
.filter(v => v !== '' || '\n')
|
||||||
|
.map(v => v.trim())
|
||||||
|
.join('\n');
|
||||||
|
}
|
||||||
const newSpec = survey.spec ? survey.spec.concat(question) : [question];
|
const newSpec = survey.spec ? survey.spec.concat(question) : [question];
|
||||||
await updateSurvey(newSpec);
|
await updateSurvey(newSpec);
|
||||||
history.push(match.url.replace('/add', ''));
|
history.push(match.url.replace('/add', ''));
|
||||||
|
|||||||
@@ -39,6 +39,13 @@ export default function SurveyQuestionEdit({ survey, updateSurvey }) {
|
|||||||
if (questionIndex === -1) {
|
if (questionIndex === -1) {
|
||||||
throw new Error('Question not found in spec');
|
throw new Error('Question not found in spec');
|
||||||
}
|
}
|
||||||
|
if (formData.type === 'multiselect') {
|
||||||
|
formData.default = formData.default
|
||||||
|
.split('\n')
|
||||||
|
.filter(v => v !== '' || '\n')
|
||||||
|
.map(v => v.trim())
|
||||||
|
.join('\n');
|
||||||
|
}
|
||||||
await updateSurvey([
|
await updateSurvey([
|
||||||
...survey.spec.slice(0, questionIndex),
|
...survey.spec.slice(0, questionIndex),
|
||||||
formData,
|
formData,
|
||||||
|
|||||||
@@ -68,10 +68,8 @@ function SurveyQuestionForm({
|
|||||||
}) {
|
}) {
|
||||||
const defaultIsNotAvailable = choices => {
|
const defaultIsNotAvailable = choices => {
|
||||||
return defaultValue => {
|
return defaultValue => {
|
||||||
const answerChoices = new Set(choices);
|
|
||||||
const defaultAnswers = new Set(defaultValue);
|
|
||||||
let errorMessage;
|
let errorMessage;
|
||||||
const found = [...defaultAnswers].every(dA => answerChoices.has(dA));
|
const found = [...defaultValue].every(dA => choices.indexOf(dA) > -1);
|
||||||
|
|
||||||
if (!found) {
|
if (!found) {
|
||||||
errorMessage = i18n._(
|
errorMessage = i18n._(
|
||||||
|
|||||||
Reference in New Issue
Block a user