From 23edde36cbe471a036b2141a4da0406724dfe40d Mon Sep 17 00:00:00 2001 From: Jochen Klar Date: Thu, 20 Jun 2024 15:21:03 +0200 Subject: [PATCH 1/5] Fix option set translation in EditQuestion (#1020) --- rdmo/management/assets/js/components/edit/EditQuestion.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/rdmo/management/assets/js/components/edit/EditQuestion.js b/rdmo/management/assets/js/components/edit/EditQuestion.js index 41a6277876..5fdf2502a0 100644 --- a/rdmo/management/assets/js/components/edit/EditQuestion.js +++ b/rdmo/management/assets/js/components/edit/EditQuestion.js @@ -40,6 +40,10 @@ const EditQuestion = ({ config, question, elements, elementActions}) => { const info = + // for reasons unknown, the strings are not picked up by makemessages from the props + const addOptionText = gettext('Add existing optionset') + const createOptionText = gettext('Create new optionset') + return (
@@ -153,7 +157,7 @@ const EditQuestion = ({ config, question, elements, elementActions}) => { From 99d7544be97b0c61d15b8076b5c92196572fece8 Mon Sep 17 00:00:00 2001 From: Jochen Klar Date: Thu, 20 Jun 2024 15:23:12 +0200 Subject: [PATCH 2/5] Add resize: vertical to textarea (#1021) --- rdmo/core/static/core/css/base.scss | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/rdmo/core/static/core/css/base.scss b/rdmo/core/static/core/css/base.scss index 44bf835add..7f3a60de77 100644 --- a/rdmo/core/static/core/css/base.scss +++ b/rdmo/core/static/core/css/base.scss @@ -35,6 +35,10 @@ h4 { form { margin-bottom: 20px; } +textarea { + resize: vertical; +} + .extend { width: 100%; } From 4026e55be10db716007cf4eefae6b62d6cdba512 Mon Sep 17 00:00:00 2001 From: Jochen Klar Date: Thu, 20 Jun 2024 15:27:09 +0200 Subject: [PATCH 3/5] Fix EditQuestion component --- rdmo/management/assets/js/components/edit/EditAttribute.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rdmo/management/assets/js/components/edit/EditAttribute.js b/rdmo/management/assets/js/components/edit/EditAttribute.js index 304444cca0..1d49213573 100644 --- a/rdmo/management/assets/js/components/edit/EditAttribute.js +++ b/rdmo/management/assets/js/components/edit/EditAttribute.js @@ -65,14 +65,14 @@ const EditAttribute = ({ config, attribute, elements, elementActions }) => { { parent && parent.questionset &&

%s.'), [parent.questionset.uri]) + __html:interpolate(gettext('This attribute will be added to the question set %s.'), [parent.questionset.uri]) }} />

} { parent && parent.question &&

%s.'), [parent.question.uri]) + __html:interpolate(gettext('This attribute will be added to the question %s.'), [parent.question.uri]) }} />

} From 756799be1a7dcd9581f6c310e8ab03dc020115b6 Mon Sep 17 00:00:00 2001 From: Jochen Klar Date: Thu, 20 Jun 2024 18:12:39 +0200 Subject: [PATCH 4/5] Add proper href to links in efit components (#1007) --- .../assets/js/components/common/Links.js | 5 ++-- .../assets/js/components/element/Attribute.js | 2 +- .../assets/js/components/element/Catalog.js | 2 +- .../assets/js/components/element/Condition.js | 2 +- .../assets/js/components/element/Option.js | 2 +- .../assets/js/components/element/OptionSet.js | 18 +++++++++++- .../assets/js/components/element/Page.js | 25 ++++++++++++++-- .../assets/js/components/element/Question.js | 29 ++++++++++++++++--- .../js/components/element/QuestionSet.js | 25 ++++++++++++++-- .../assets/js/components/element/Section.js | 2 +- .../assets/js/components/element/Task.js | 11 +++++-- .../assets/js/components/element/View.js | 2 +- .../assets/js/constants/elements.js | 2 +- rdmo/options/serializers/v1/optionset.py | 6 ++++ 14 files changed, 111 insertions(+), 22 deletions(-) diff --git a/rdmo/management/assets/js/components/common/Links.js b/rdmo/management/assets/js/components/common/Links.js index fd9d0b594a..9a8dd10e32 100644 --- a/rdmo/management/assets/js/components/common/Links.js +++ b/rdmo/management/assets/js/components/common/Links.js @@ -198,10 +198,10 @@ ExtendLink.propTypes = { onClick: PropTypes.func.isRequired } -const CodeLink = ({ className, uri, onClick, order }) => { +const CodeLink = ({ className, uri, href, onClick, order }) => { return ( <> - + {uri} {!isNil(order) ? ( @@ -214,6 +214,7 @@ const CodeLink = ({ className, uri, onClick, order }) => { CodeLink.propTypes = { className: PropTypes.string.isRequired, uri: PropTypes.string.isRequired, + href: PropTypes.string, onClick: PropTypes.func.isRequired, order: PropTypes.number } diff --git a/rdmo/management/assets/js/components/element/Attribute.js b/rdmo/management/assets/js/components/element/Attribute.js index 423ef5919c..8d4915a36a 100644 --- a/rdmo/management/assets/js/components/element/Attribute.js +++ b/rdmo/management/assets/js/components/element/Attribute.js @@ -42,7 +42,7 @@ const Attribute = ({ config, attribute, elementActions, display='list', indent=0

{gettext('Attribute')}{': '} - fetchEdit()} /> + fetchEdit()} />

diff --git a/rdmo/management/assets/js/components/element/Catalog.js b/rdmo/management/assets/js/components/element/Catalog.js index 11dbdd670c..5623a37013 100644 --- a/rdmo/management/assets/js/components/element/Catalog.js +++ b/rdmo/management/assets/js/components/element/Catalog.js @@ -57,7 +57,7 @@ const Catalog = ({ config, catalog, elementActions, display='list',

{ get(config, 'display.uri.catalogs', true) && - fetchEdit()} /> + fetchEdit()} /> }
diff --git a/rdmo/management/assets/js/components/element/Condition.js b/rdmo/management/assets/js/components/element/Condition.js index 86c441db11..37c1d1c82b 100644 --- a/rdmo/management/assets/js/components/element/Condition.js +++ b/rdmo/management/assets/js/components/element/Condition.js @@ -35,7 +35,7 @@ const Condition = ({ config, condition, elementActions, filter=false, filterEdit

{gettext('Condition')}{': '} - fetchEdit()} /> + fetchEdit()} />

diff --git a/rdmo/management/assets/js/components/element/Option.js b/rdmo/management/assets/js/components/element/Option.js index ac6e9e85f9..a04a069897 100644 --- a/rdmo/management/assets/js/components/element/Option.js +++ b/rdmo/management/assets/js/components/element/Option.js @@ -38,7 +38,7 @@ const Option = ({ config, option, elementActions, display='list', indent=0, filt

{ get(config, 'display.uri.options', true) && - fetchEdit()} /> + fetchEdit()} /> }
diff --git a/rdmo/management/assets/js/components/element/OptionSet.js b/rdmo/management/assets/js/components/element/OptionSet.js index 1ef7c1aaa3..cbc6cfba2e 100644 --- a/rdmo/management/assets/js/components/element/OptionSet.js +++ b/rdmo/management/assets/js/components/element/OptionSet.js @@ -1,5 +1,6 @@ import React from 'react' import PropTypes from 'prop-types' +import get from 'lodash/get' import { filterElement } from '../../utils/filter' import { buildPath } from '../../utils/location' @@ -18,12 +19,15 @@ const OptionSet = ({ config, optionset, elementActions, display='list', filter=f const nestedUrl = buildPath(config.baseUrl, 'optionsets', optionset.id, 'nested') const exportUrl = buildPath(config.apiUrl, 'options', 'optionsets', optionset.id, 'export') + const getConditionUrl = (index) => buildPath(config.apiUrl, 'conditions', 'conditions', optionset.conditions[index]) + const fetchEdit = () => elementActions.fetchElement('optionsets', optionset.id) const fetchCopy = () => elementActions.fetchElement('optionsets', optionset.id, 'copy') const fetchNested = () => elementActions.fetchElement('optionsets', optionset.id, 'nested') const toggleLocked = () => elementActions.storeElement('optionsets', {...optionset, locked: !optionset.locked }) const createOption = () => elementActions.createElement('options', { optionset }) + const fetchCondition = (index) => elementActions.fetchElement('conditions', optionset.conditions[index]) const elementNode = (
@@ -41,8 +45,20 @@ const OptionSet = ({ config, optionset, elementActions, display='list', filter=f

{gettext('Option set')}{': '} - fetchEdit()} /> + fetchEdit()} />

+ { + get(config, 'display.uri.conditions', true) && optionset.condition_uris.map((uri, index) => ( +

+ fetchCondition(index)} + /> +

+ )) + }
diff --git a/rdmo/management/assets/js/components/element/Page.js b/rdmo/management/assets/js/components/element/Page.js index d1cf203511..2ca84fde25 100644 --- a/rdmo/management/assets/js/components/element/Page.js +++ b/rdmo/management/assets/js/components/element/Page.js @@ -23,6 +23,9 @@ const Page = ({ config, page, configActions, elementActions, display='list', ind const copyUrl = buildPath(config.baseUrl, 'pages', page.id, 'copy') const nestedUrl = buildPath(config.baseUrl, 'pages', page.id, 'nested') const exportUrl = buildPath(config.apiUrl, 'questions', 'pages', page.id, 'export') + const attributeUrl = buildPath(config.apiUrl, 'domain', 'attributes', page.attribute) + + const getConditionUrl = (index) => buildPath(config.apiUrl, 'conditions', 'conditions', page.conditions[index]) const fetchEdit = () => elementActions.fetchElement('pages', page.id) const fetchCopy = () => elementActions.fetchElement('pages', page.id, 'copy') @@ -58,18 +61,34 @@ const Page = ({ config, page, configActions, elementActions, display='list', ind

{ get(config, 'display.uri.pages', true) &&

- fetchEdit()} order={order} /> + fetchEdit()} + order={order} + />

} { get(config, 'display.uri.attributes', true) && page.attribute_uri &&

- fetchAttribute()} /> + fetchAttribute()} + />

} { get(config, 'display.uri.conditions', true) && page.condition_uris.map((uri, index) => (

- fetchCondition(index)} /> + fetchCondition(index)} + />

)) } diff --git a/rdmo/management/assets/js/components/element/Question.js b/rdmo/management/assets/js/components/element/Question.js index 95e2ec3ea4..0b22515506 100644 --- a/rdmo/management/assets/js/components/element/Question.js +++ b/rdmo/management/assets/js/components/element/Question.js @@ -18,6 +18,10 @@ const Question = ({ config, question, elementActions, display='list', indent=0, const editUrl = buildPath(config.baseUrl, 'questions', question.id) const copyUrl = buildPath(config.baseUrl, 'questions', question.id, 'copy') const exportUrl = buildPath(config.apiUrl, 'questions', 'questions', question.id, 'export') + const attributeUrl = buildPath(config.apiUrl, 'domain', 'attributes', question.attribute) + + const getConditionUrl = (index) => buildPath(config.apiUrl, 'conditions', 'conditions', question.conditions[index]) + const getOptionSetUrl = (index) => buildPath(config.apiUrl, 'options', 'optionsets', question.optionsets[index]) const fetchEdit = () => elementActions.fetchElement('questions', question.id) const fetchCopy = () => elementActions.fetchElement('questions', question.id, 'copy') @@ -46,25 +50,42 @@ const Question = ({ config, question, elementActions, display='list', indent=0,

{ get(config, 'display.uri.questions', true) &&

- fetchEdit()} order={order} /> + fetchEdit()} + order={order} />

} { get(config, 'display.uri.attributes', true) && question.attribute_uri &&

- fetchAttribute()} /> + fetchAttribute()} />

} { get(config, 'display.uri.conditions', true) && question.condition_uris.map((uri, index) => (

- fetchCondition(index)} /> + fetchCondition(index)} />

)) } { get(config, 'display.uri.optionsets', true) && question.optionset_uris.map((uri, index) => (

- fetchOptionSet(index)} /> + fetchOptionSet(index)} />

)) } diff --git a/rdmo/management/assets/js/components/element/QuestionSet.js b/rdmo/management/assets/js/components/element/QuestionSet.js index 904f201699..aa7e7fd98f 100644 --- a/rdmo/management/assets/js/components/element/QuestionSet.js +++ b/rdmo/management/assets/js/components/element/QuestionSet.js @@ -22,6 +22,9 @@ const QuestionSet = ({ config, questionset, configActions, elementActions, displ const copyUrl = buildPath(config.baseUrl, 'questionsets', questionset.id, 'copy') const nestedUrl = buildPath(config.baseUrl, 'questionsets', questionset.id, 'nested') const exportUrl = buildPath(config.apiUrl, 'questions', 'questionsets', questionset.id, 'export') + const attributeUrl = buildPath(config.apiUrl, 'domain', 'attributes', questionset.attribute) + + const getConditionUrl = (index) => buildPath(config.apiUrl, 'conditions', 'conditions', questionset.conditions[index]) const fetchEdit = () => elementActions.fetchElement('questionsets', questionset.id) const fetchCopy = () => elementActions.fetchElement('questionsets', questionset.id, 'copy') @@ -57,18 +60,34 @@ const QuestionSet = ({ config, questionset, configActions, elementActions, displ

{ get(config, 'display.uri.questionsets', true) &&

- fetchEdit()} order={order} /> + fetchEdit()} + order={order} + />

} { get(config, 'display.uri.attributes', true) && questionset.attribute_uri &&

- fetchAttribute()} /> + fetchAttribute()} + />

} { get(config, 'display.uri.conditions', true) && questionset.condition_uris.map((uri, index) => (

- fetchCondition(index)} /> + fetchCondition(index)} + />

)) } diff --git a/rdmo/management/assets/js/components/element/Section.js b/rdmo/management/assets/js/components/element/Section.js index 3f6915352c..f70f56a62a 100644 --- a/rdmo/management/assets/js/components/element/Section.js +++ b/rdmo/management/assets/js/components/element/Section.js @@ -55,7 +55,7 @@ const Section = ({ config, section, configActions, elementActions, display='list

{ get(config, 'display.uri.sections', true) && - fetchEdit()} order={order} /> + fetchEdit()} order={order} /> } diff --git a/rdmo/management/assets/js/components/element/Task.js b/rdmo/management/assets/js/components/element/Task.js index 771df79485..5b87a79902 100644 --- a/rdmo/management/assets/js/components/element/Task.js +++ b/rdmo/management/assets/js/components/element/Task.js @@ -17,6 +17,8 @@ const Task = ({ config, task, elementActions, filter=false, filterSites=false, f const copyUrl = buildPath(config.baseUrl, 'tasks', task.id, 'copy') const exportUrl = buildPath(config.apiUrl, 'tasks', 'tasks', task.id, 'export') + const getConditionUrl = (index) => buildPath(config.apiUrl, 'conditions', 'conditions', task.conditions[index]) + const fetchEdit = () => elementActions.fetchElement('tasks', task.id) const fetchCopy = () => elementActions.fetchElement('tasks', task.id, 'copy') const toggleAvailable = () => elementActions.storeElement('tasks', {...task, available: !task.available }) @@ -51,13 +53,18 @@ const Task = ({ config, task, elementActions, filter=false, filterSites=false, f

{ get(config, 'display.uri.tasks', true) &&

- fetchEdit()} /> + fetchEdit()} />

} { get(config, 'display.uri.conditions', true) && task.condition_uris.map((uri, index) => (

- fetchCondition(index)} /> + fetchCondition(index)} + />

)) } diff --git a/rdmo/management/assets/js/components/element/View.js b/rdmo/management/assets/js/components/element/View.js index c173631572..e1fbe24ab4 100644 --- a/rdmo/management/assets/js/components/element/View.js +++ b/rdmo/management/assets/js/components/element/View.js @@ -44,7 +44,7 @@ const View = ({ config, view, elementActions, filter=false, filterSites=false, f

{gettext('View')}{': '} - fetchEdit()} /> + fetchEdit()} />

diff --git a/rdmo/management/assets/js/constants/elements.js b/rdmo/management/assets/js/constants/elements.js index 9c32d008a1..112dd13fa8 100644 --- a/rdmo/management/assets/js/constants/elements.js +++ b/rdmo/management/assets/js/constants/elements.js @@ -4,7 +4,7 @@ const elementTypes = { 'questions.page': 'pages', 'questions.questionset': 'questionsets', 'questions.question': 'questions', - 'domain.attribute':'attributes', + 'domain.attribute': 'attributes', 'options.optionset': 'optionsets', 'options.option': 'options', 'conditions.condition': 'conditions', diff --git a/rdmo/options/serializers/v1/optionset.py b/rdmo/options/serializers/v1/optionset.py index 264c2f7128..5f9ee6cb66 100644 --- a/rdmo/options/serializers/v1/optionset.py +++ b/rdmo/options/serializers/v1/optionset.py @@ -33,6 +33,8 @@ class OptionSetSerializer(ThroughModelSerializerMixin, ElementModelSerializerMix read_only = serializers.SerializerMethodField() + condition_uris = serializers.SerializerMethodField() + class Meta: model = OptionSet fields = ( @@ -51,6 +53,7 @@ class Meta: 'questions', 'editors', 'read_only', + 'condition_uris', ) through_fields = ( ('options', 'optionset', 'option', 'optionset_options'), @@ -60,6 +63,9 @@ class Meta: OptionSetLockedValidator() ) + def get_condition_uris(self, obj): + return [condition.uri for condition in obj.conditions.all()] + class OptionSetNestedSerializer(OptionSetSerializer): From 30a644f1981f21a21b72a1dbd13c151b08c3e77e Mon Sep 17 00:00:00 2001 From: Jochen Klar Date: Tue, 2 Jul 2024 16:04:13 +0200 Subject: [PATCH 5/5] Unset parent for init actions in elementsReducer --- rdmo/management/assets/js/reducers/elementsReducer.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/rdmo/management/assets/js/reducers/elementsReducer.js b/rdmo/management/assets/js/reducers/elementsReducer.js index 02082a6f25..fc8f62d982 100644 --- a/rdmo/management/assets/js/reducers/elementsReducer.js +++ b/rdmo/management/assets/js/reducers/elementsReducer.js @@ -32,6 +32,7 @@ export default function elementsReducer(state = initialState, action) { elementId: null, elementAction: null, element: null, + parent: null, errors: {} } case 'elements/fetchElementsSuccess': @@ -46,6 +47,7 @@ export default function elementsReducer(state = initialState, action) { elementId: action.elementId, elementAction: action.elementAction, element: null, + parent: null, errors: {} } case 'elements/fetchElementSuccess': @@ -89,6 +91,7 @@ export default function elementsReducer(state = initialState, action) { elementId: null, elementAction: 'create', element: null, + parent: null, errors: {} } case 'elements/createElementSuccess':