From 6a9600fa33ef9f63a0a57b8fb2b8426268cb3966 Mon Sep 17 00:00:00 2001 From: Jochen Klar Date: Sat, 18 Nov 2023 11:22:12 +0100 Subject: [PATCH 1/3] Add condition URIs to tasks management --- .../assets/js/components/element/Task.js | 17 ++++++++++++++++- .../assets/js/components/elements/Tasks.js | 12 ++++++++++++ rdmo/tasks/serializers/v1.py | 6 ++++++ 3 files changed, 34 insertions(+), 1 deletion(-) diff --git a/rdmo/management/assets/js/components/element/Task.js b/rdmo/management/assets/js/components/element/Task.js index c8a4f981bf..12676cc89f 100644 --- a/rdmo/management/assets/js/components/element/Task.js +++ b/rdmo/management/assets/js/components/element/Task.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' @@ -21,6 +22,8 @@ const Task = ({ config, task, elementActions, filter=false, filterSites=false, f const toggleAvailable = () => elementActions.storeElement('tasks', {...task, available: !task.available }) const toggleLocked = () => elementActions.storeElement('tasks', {...task, locked: !task.locked }) + const fetchCondition = (index) => elementActions.fetchElement('conditions', task.conditions[index]) + return showElement && (
  • @@ -40,8 +43,20 @@ const Task = ({ config, task, elementActions, filter=false, filterSites=false, f

    {gettext('Task')}{': '} - fetchEdit()} /> + {task.title}

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

    + fetchEdit()} /> +

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

    + fetchCondition(index)} /> +

    + )) + }
    diff --git a/rdmo/management/assets/js/components/elements/Tasks.js b/rdmo/management/assets/js/components/elements/Tasks.js index 693181538f..136ecc6140 100644 --- a/rdmo/management/assets/js/components/elements/Tasks.js +++ b/rdmo/management/assets/js/components/elements/Tasks.js @@ -6,6 +6,7 @@ import { getUriPrefixes } from '../../utils/filter' import { FilterString, FilterUriPrefix, FilterSite} from '../common/Filter' import { BackButton, NewButton } from '../common/Buttons' +import { Checkbox } from '../common/Checkboxes' import Task from '../element/Task' @@ -16,6 +17,9 @@ const Tasks = ({ config, tasks, configActions, elementActions }) => { const updateFilterSite = (value) => configActions.updateConfig('filter.sites', value) const updateFilterEditor = (value) => configActions.updateConfig('filter.editors', value) + const updateDisplayTasksURI = (value) => configActions.updateConfig('display.uri.tasks', value) + const updateDisplayConditionsURI = (value) => configActions.updateConfig('display.uri.conditions', value) + const createTask = () => elementActions.createElement('tasks') return ( @@ -51,6 +55,14 @@ const Tasks = ({ config, tasks, configActions, elementActions }) => { } +
    + {gettext('Show URIs:')} + {gettext('Tasks')}} + value={get(config, 'display.uri.tasks', true)} onChange={updateDisplayTasksURI} /> + {gettext('Conditions')}} + value={get(config, 'display.uri.conditions', true)} onChange={updateDisplayConditionsURI} /> +
    +