diff --git a/rdmo/projects/assets/js/interview/components/main/page/Page.js b/rdmo/projects/assets/js/interview/components/main/page/Page.js index acdcc03147..dcab494514 100644 --- a/rdmo/projects/assets/js/interview/components/main/page/Page.js +++ b/rdmo/projects/assets/js/interview/components/main/page/Page.js @@ -72,6 +72,11 @@ const Page = ({ config, templates, overview, page, sets, values, fetchPage, value.set_prefix == currentSetPrefix && value.set_index == currentSetIndex ))} + siblings={values.filter((value) => ( + value.attribute == element.attribute && + value.set_prefix == currentSetPrefix && + value.set_index != currentSetIndex + ))} disabled={overview.read_only} isManager={isManager} currentSet={currentSet} diff --git a/rdmo/projects/assets/js/interview/components/main/question/Question.js b/rdmo/projects/assets/js/interview/components/main/question/Question.js index ce6c838581..617cfc945e 100644 --- a/rdmo/projects/assets/js/interview/components/main/question/Question.js +++ b/rdmo/projects/assets/js/interview/components/main/question/Question.js @@ -12,7 +12,7 @@ import QuestionText from './QuestionText' import QuestionWarning from './QuestionWarning' import QuestionWidget from './QuestionWidget' -const Question = ({ templates, question, values, disabled, isManager, +const Question = ({ templates, question, values, siblings, disabled, isManager, currentSet, createValue, updateValue, deleteValue, copyValue }) => { return checkQuestion(question, currentSet) && (
@@ -26,6 +26,7 @@ const Question = ({ templates, question, values, disabled, isManager, { } return !disabled && question.is_collection && ( - ) diff --git a/rdmo/projects/assets/js/interview/components/main/question/QuestionCopyValue.js b/rdmo/projects/assets/js/interview/components/main/question/QuestionCopyValue.js index 47ae6388ed..f943386117 100644 --- a/rdmo/projects/assets/js/interview/components/main/question/QuestionCopyValue.js +++ b/rdmo/projects/assets/js/interview/components/main/question/QuestionCopyValue.js @@ -3,10 +3,13 @@ import PropTypes from 'prop-types' import { isEmptyValue } from '../../../utils/value' -const QuestionCopyValue = ({ question, value, copyValue }) => { +const QuestionCopyValue = ({ question, value, siblings, copyValue }) => { return ( - question.set_collection && !isEmptyValue(value) && ( - @@ -17,6 +20,7 @@ const QuestionCopyValue = ({ question, value, copyValue }) => { QuestionCopyValue.propTypes = { question: PropTypes.object.isRequired, value: PropTypes.object.isRequired, + siblings: PropTypes.object.isRequired, copyValue: PropTypes.func.isRequired } diff --git a/rdmo/projects/assets/js/interview/components/main/question/QuestionCopyValues.js b/rdmo/projects/assets/js/interview/components/main/question/QuestionCopyValues.js index e981de95c9..8a08b0d016 100644 --- a/rdmo/projects/assets/js/interview/components/main/question/QuestionCopyValues.js +++ b/rdmo/projects/assets/js/interview/components/main/question/QuestionCopyValues.js @@ -3,26 +3,35 @@ import PropTypes from 'prop-types' import { isEmptyValue } from '../../../utils/value' -const QuestionCopyValues = ({ question, values, copyValue }) => { +const QuestionCopyValues = ({ question, values, siblings, copyValue }) => { const handleCopyValues = () => { values.forEach((value) => copyValue(value)) } - console.log(values) + const button = question.widget_type == 'checkbox' ? ( + + ) : ( + + ) return ( - question.set_collection && values.some((v) => !isEmptyValue(v)) && ( - - ) + question.is_collection && + question.set_collection && + values.some((v) => !isEmptyValue(v)) && + siblings.some((value) => isEmptyValue(value)) && + button ) } QuestionCopyValues.propTypes = { question: PropTypes.object.isRequired, values: PropTypes.array.isRequired, + siblings: PropTypes.array, copyValue: PropTypes.func.isRequired } diff --git a/rdmo/projects/assets/js/interview/components/main/questionset/QuestionSet.js b/rdmo/projects/assets/js/interview/components/main/questionset/QuestionSet.js index a582ffaab5..0a807c3663 100644 --- a/rdmo/projects/assets/js/interview/components/main/questionset/QuestionSet.js +++ b/rdmo/projects/assets/js/interview/components/main/questionset/QuestionSet.js @@ -72,6 +72,11 @@ const QuestionSet = ({ templates, questionset, sets, values, disabled, isManager value.set_prefix == set.set_prefix && value.set_index == set.set_index ))} + siblings={values.filter((value) => ( + value.attribute == element.attribute && + value.set_prefix == set.set_prefix && + value.set_index != set.set_index + ))} disabled={disabled} isManager={isManager} currentSet={set} diff --git a/rdmo/projects/assets/js/interview/components/main/widget/CheckboxWidget.js b/rdmo/projects/assets/js/interview/components/main/widget/CheckboxWidget.js index c995c2531d..eff2db4e7b 100644 --- a/rdmo/projects/assets/js/interview/components/main/widget/CheckboxWidget.js +++ b/rdmo/projects/assets/js/interview/components/main/widget/CheckboxWidget.js @@ -10,7 +10,7 @@ import QuestionSuccess from '../question/QuestionSuccess' import CheckboxInput from './CheckboxInput' -const CheckboxWidget = ({ question, values, currentSet, disabled, +const CheckboxWidget = ({ question, values, siblings, currentSet, disabled, createValue, updateValue, deleteValue, copyValue }) => { const handleCreateValue = (option, additionalInput) => { @@ -71,7 +71,7 @@ const CheckboxWidget = ({ question, values, currentSet, disabled,
- +
@@ -83,6 +83,7 @@ const CheckboxWidget = ({ question, values, currentSet, disabled, CheckboxWidget.propTypes = { question: PropTypes.object.isRequired, values: PropTypes.array.isRequired, + siblings: PropTypes.array, disabled: PropTypes.bool, currentSet: PropTypes.object.isRequired, createValue: PropTypes.func.isRequired, diff --git a/rdmo/projects/assets/js/interview/components/main/widget/DateWidget.js b/rdmo/projects/assets/js/interview/components/main/widget/DateWidget.js index c4f79c3411..ae7f8ce42b 100644 --- a/rdmo/projects/assets/js/interview/components/main/widget/DateWidget.js +++ b/rdmo/projects/assets/js/interview/components/main/widget/DateWidget.js @@ -3,6 +3,7 @@ import PropTypes from 'prop-types' import QuestionAddValue from '../question/QuestionAddValue' import QuestionCopyValue from '../question/QuestionCopyValue' +import QuestionCopyValues from '../question/QuestionCopyValues' import QuestionDefault from '../question/QuestionDefault' import QuestionError from '../question/QuestionError' import QuestionEraseValue from '../question/QuestionEraseValue' @@ -11,7 +12,7 @@ import QuestionRemoveValue from '../question/QuestionRemoveValue' import DateInput from './DateInput' -const DateWidget = ({ question, values, currentSet, disabled, createValue, updateValue, deleteValue, copyValue }) => { +const DateWidget = ({ question, values, siblings, currentSet, disabled, createValue, updateValue, deleteValue, copyValue }) => { return (
{ @@ -34,7 +35,7 @@ const DateWidget = ({ question, values, currentSet, disabled, createValue, updat disabled={disabled} deleteValue={deleteValue} /> - +
} @@ -52,6 +53,12 @@ const DateWidget = ({ question, values, currentSet, disabled, createValue, updat createValue={createValue} copyValue={copyValue} /> + ) } @@ -59,6 +66,7 @@ const DateWidget = ({ question, values, currentSet, disabled, createValue, updat DateWidget.propTypes = { question: PropTypes.object.isRequired, values: PropTypes.array.isRequired, + siblings: PropTypes.array, disabled: PropTypes.bool, currentSet: PropTypes.object.isRequired, createValue: PropTypes.func.isRequired, diff --git a/rdmo/projects/assets/js/interview/components/main/widget/RadioWidget.js b/rdmo/projects/assets/js/interview/components/main/widget/RadioWidget.js index 79497a6cad..15ea8d32c8 100644 --- a/rdmo/projects/assets/js/interview/components/main/widget/RadioWidget.js +++ b/rdmo/projects/assets/js/interview/components/main/widget/RadioWidget.js @@ -5,6 +5,7 @@ import { gatherOptions } from '../../../utils/options' import QuestionAddValue from '../question/QuestionAddValue' import QuestionCopyValue from '../question/QuestionCopyValue' +import QuestionCopyValues from '../question/QuestionCopyValues' import QuestionDefault from '../question/QuestionDefault' import QuestionError from '../question/QuestionError' import QuestionSuccess from '../question/QuestionSuccess' @@ -13,7 +14,8 @@ import QuestionRemoveValue from '../question/QuestionRemoveValue' import RadioInput from './RadioInput' -const RadioWidget = ({ question, values, currentSet, disabled, createValue, updateValue, deleteValue, copyValue }) => { +const RadioWidget = ({ question, values, siblings, currentSet, disabled, + createValue, updateValue, deleteValue, copyValue }) => { return (
{ @@ -37,7 +39,7 @@ const RadioWidget = ({ question, values, currentSet, disabled, createValue, upda disabled={disabled} deleteValue={deleteValue} /> - +
} @@ -55,6 +57,12 @@ const RadioWidget = ({ question, values, currentSet, disabled, createValue, upda createValue={createValue} copyValue={copyValue} /> + ) } @@ -62,6 +70,7 @@ const RadioWidget = ({ question, values, currentSet, disabled, createValue, upda RadioWidget.propTypes = { question: PropTypes.object.isRequired, values: PropTypes.array.isRequired, + siblings: PropTypes.array, disabled: PropTypes.bool, currentSet: PropTypes.object.isRequired, createValue: PropTypes.func.isRequired, diff --git a/rdmo/projects/assets/js/interview/components/main/widget/RangeWidget.js b/rdmo/projects/assets/js/interview/components/main/widget/RangeWidget.js index 3bda3222ba..6bcd8f9903 100644 --- a/rdmo/projects/assets/js/interview/components/main/widget/RangeWidget.js +++ b/rdmo/projects/assets/js/interview/components/main/widget/RangeWidget.js @@ -5,6 +5,7 @@ import { initRange } from '../../../utils/value' import QuestionAddValue from '../question/QuestionAddValue' import QuestionCopyValue from '../question/QuestionCopyValue' +import QuestionCopyValues from '../question/QuestionCopyValues' import QuestionDefault from '../question/QuestionDefault' import QuestionError from '../question/QuestionError' import QuestionSuccess from '../question/QuestionSuccess' @@ -13,7 +14,8 @@ import QuestionRemoveValue from '../question/QuestionRemoveValue' import RangeInput from './RangeInput' -const RangeWidget = ({ question, values, currentSet, disabled, createValue, updateValue, deleteValue, copyValue }) => { +const RangeWidget = ({ question, values, siblings, currentSet, disabled, + createValue, updateValue, deleteValue, copyValue }) => { const handleCreateValue = (value) => { initRange(question, value) @@ -47,7 +49,7 @@ const RangeWidget = ({ question, values, currentSet, disabled, createValue, upda disabled={disabled} deleteValue={deleteValue} /> - + } @@ -65,6 +67,12 @@ const RangeWidget = ({ question, values, currentSet, disabled, createValue, upda createValue={handleCreateValue} copyValue={copyValue} /> + ) } @@ -72,6 +80,7 @@ const RangeWidget = ({ question, values, currentSet, disabled, createValue, upda RangeWidget.propTypes = { question: PropTypes.object.isRequired, values: PropTypes.array.isRequired, + siblings: PropTypes.array, disabled: PropTypes.bool, currentSet: PropTypes.object.isRequired, createValue: PropTypes.func.isRequired, diff --git a/rdmo/projects/assets/js/interview/components/main/widget/SelectWidget.js b/rdmo/projects/assets/js/interview/components/main/widget/SelectWidget.js index 60dbbbc4cf..7124f1d20f 100644 --- a/rdmo/projects/assets/js/interview/components/main/widget/SelectWidget.js +++ b/rdmo/projects/assets/js/interview/components/main/widget/SelectWidget.js @@ -5,6 +5,7 @@ import { gatherOptions } from '../../../utils/options' import QuestionAddValue from '../question/QuestionAddValue' import QuestionCopyValue from '../question/QuestionCopyValue' +import QuestionCopyValues from '../question/QuestionCopyValues' import QuestionDefault from '../question/QuestionDefault' import QuestionEraseValue from '../question/QuestionEraseValue' import QuestionError from '../question/QuestionError' @@ -13,7 +14,7 @@ import QuestionRemoveValue from '../question/QuestionRemoveValue' import SelectInput from './SelectInput' -const SelectWidget = ({ question, values, currentSet, disabled, creatable, +const SelectWidget = ({ question, values, siblings, currentSet, disabled, creatable, createValue, updateValue, deleteValue, copyValue }) => { return (
@@ -39,7 +40,7 @@ const SelectWidget = ({ question, values, currentSet, disabled, creatable, disabled={disabled} deleteValue={deleteValue} /> - +
} @@ -56,6 +57,12 @@ const SelectWidget = ({ question, values, currentSet, disabled, creatable, disabled={disabled} createValue={createValue} /> + ) } @@ -63,6 +70,7 @@ const SelectWidget = ({ question, values, currentSet, disabled, creatable, SelectWidget.propTypes = { question: PropTypes.object.isRequired, values: PropTypes.array.isRequired, + siblings: PropTypes.array, disabled: PropTypes.bool, creatable: PropTypes.bool, currentSet: PropTypes.object.isRequired, diff --git a/rdmo/projects/assets/js/interview/components/main/widget/TextWidget.js b/rdmo/projects/assets/js/interview/components/main/widget/TextWidget.js index d6119b0986..ed823ee857 100644 --- a/rdmo/projects/assets/js/interview/components/main/widget/TextWidget.js +++ b/rdmo/projects/assets/js/interview/components/main/widget/TextWidget.js @@ -3,6 +3,7 @@ import PropTypes from 'prop-types' import QuestionAddValue from '../question/QuestionAddValue' import QuestionCopyValue from '../question/QuestionCopyValue' +import QuestionCopyValues from '../question/QuestionCopyValues' import QuestionDefault from '../question/QuestionDefault' import QuestionError from '../question/QuestionError' import QuestionRemoveValue from '../question/QuestionRemoveValue' @@ -10,7 +11,7 @@ import QuestionSuccess from '../question/QuestionSuccess' import TextInput from './TextInput' -const TextWidget = ({ question, values, currentSet, disabled, +const TextWidget = ({ question, values, siblings, currentSet, disabled, createValue, updateValue, deleteValue, copyValue }) => { return (
@@ -33,7 +34,7 @@ const TextWidget = ({ question, values, currentSet, disabled, disabled={disabled} deleteValue={deleteValue} /> - +
} @@ -50,6 +51,12 @@ const TextWidget = ({ question, values, currentSet, disabled, disabled={disabled} createValue={createValue} /> + ) } @@ -57,6 +64,7 @@ const TextWidget = ({ question, values, currentSet, disabled, TextWidget.propTypes = { question: PropTypes.object.isRequired, values: PropTypes.array.isRequired, + siblings: PropTypes.array, disabled: PropTypes.bool, currentSet: PropTypes.object.isRequired, createValue: PropTypes.func.isRequired, diff --git a/rdmo/projects/assets/js/interview/components/main/widget/TextareaWidget.js b/rdmo/projects/assets/js/interview/components/main/widget/TextareaWidget.js index 3c70b8fb23..8d67201029 100644 --- a/rdmo/projects/assets/js/interview/components/main/widget/TextareaWidget.js +++ b/rdmo/projects/assets/js/interview/components/main/widget/TextareaWidget.js @@ -3,6 +3,7 @@ import PropTypes from 'prop-types' import QuestionAddValue from '../question/QuestionAddValue' import QuestionCopyValue from '../question/QuestionCopyValue' +import QuestionCopyValues from '../question/QuestionCopyValues' import QuestionDefault from '../question/QuestionDefault' import QuestionError from '../question/QuestionError' import QuestionSuccess from '../question/QuestionSuccess' @@ -10,7 +11,8 @@ import QuestionRemoveValue from '../question/QuestionRemoveValue' import TextareaInput from './TextareaInput' -const TextareaWidget = ({ question, values, currentSet, disabled, createValue, updateValue, deleteValue, copyValue }) => { +const TextareaWidget = ({ question, values, siblings, currentSet, disabled, + createValue, updateValue, deleteValue, copyValue }) => { return (
{ @@ -32,7 +34,7 @@ const TextareaWidget = ({ question, values, currentSet, disabled, createValue, u disabled={disabled} deleteValue={deleteValue} /> - +
} @@ -49,6 +51,12 @@ const TextareaWidget = ({ question, values, currentSet, disabled, createValue, u disabled={disabled} createValue={createValue} /> + ) } @@ -56,6 +64,7 @@ const TextareaWidget = ({ question, values, currentSet, disabled, createValue, u TextareaWidget.propTypes = { question: PropTypes.object.isRequired, values: PropTypes.array.isRequired, + siblings: PropTypes.array, disabled: PropTypes.bool, currentSet: PropTypes.object.isRequired, createValue: PropTypes.func.isRequired, diff --git a/rdmo/projects/assets/js/interview/components/main/widget/YesNoWidget.js b/rdmo/projects/assets/js/interview/components/main/widget/YesNoWidget.js index 7cc00576e1..5be4f02852 100644 --- a/rdmo/projects/assets/js/interview/components/main/widget/YesNoWidget.js +++ b/rdmo/projects/assets/js/interview/components/main/widget/YesNoWidget.js @@ -3,6 +3,7 @@ import PropTypes from 'prop-types' import QuestionAddValue from '../question/QuestionAddValue' import QuestionCopyValue from '../question/QuestionCopyValue' +import QuestionCopyValues from '../question/QuestionCopyValues' import QuestionDefault from '../question/QuestionDefault' import QuestionError from '../question/QuestionError' import QuestionEraseValue from '../question/QuestionEraseValue' @@ -11,7 +12,8 @@ import QuestionRemoveValue from '../question/QuestionRemoveValue' import YesNoInput from './YesNoInput' -const YesNoWidget = ({ question, values, currentSet, disabled, createValue, updateValue, deleteValue, copyValue }) => { +const YesNoWidget = ({ question, values, siblings, currentSet, disabled, + createValue, updateValue, deleteValue, copyValue }) => { return (
{ @@ -34,7 +36,7 @@ const YesNoWidget = ({ question, values, currentSet, disabled, createValue, upda disabled={disabled} deleteValue={deleteValue} /> - +
} @@ -51,6 +53,7 @@ const YesNoWidget = ({ question, values, currentSet, disabled, createValue, upda disabled={disabled} createValue={createValue} /> + ) } @@ -58,6 +61,7 @@ const YesNoWidget = ({ question, values, currentSet, disabled, createValue, upda YesNoWidget.propTypes = { question: PropTypes.object.isRequired, values: PropTypes.array.isRequired, + siblings: PropTypes.array, disabled: PropTypes.bool, currentSet: PropTypes.object.isRequired, createValue: PropTypes.func.isRequired,