From bd2490d03aa7022eac37c56d6ece07296e78a1f4 Mon Sep 17 00:00:00 2001 From: Daniel Strano Date: Mon, 12 Dec 2022 10:38:13 -0500 Subject: [PATCH] #747: No top level task keys in modala --- src/components/SubmissionRefsAddModal.js | 2 +- src/views/Submission.js | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/components/SubmissionRefsAddModal.js b/src/components/SubmissionRefsAddModal.js index 48bd4ac6..a07a145b 100644 --- a/src/components/SubmissionRefsAddModal.js +++ b/src/components/SubmissionRefsAddModal.js @@ -253,7 +253,7 @@ const SubmissionRefsAddModal = (props) => { />
(if any)')} labelKey='name' + label={`Parent ${key}` + (props.modalMode === 'Task' ? '' : '
(if any)')} labelKey='name' options={props.allNames} onSelect={handleOnSelectParent} onChange={handleOnChangeParent} diff --git a/src/views/Submission.js b/src/views/Submission.js index ff4eb56a..a39236a6 100644 --- a/src/views/Submission.js +++ b/src/views/Submission.js @@ -120,6 +120,7 @@ class Submission extends React.Component { this.handleOnChange = this.handleOnChange.bind(this) this.handleSortNames = this.handleSortNames.bind(this) this.handleTrimTasks = this.handleTrimTasks.bind(this) + this.handleTrimParentTasks = this.handleTrimParentTasks.bind(this) this.handleTrimMethods = this.handleTrimMethods.bind(this) this.handleTrimPlatforms = this.handleTrimPlatforms.bind(this) this.handleTrimTags = this.handleTrimTags.bind(this) @@ -398,6 +399,7 @@ class Submission extends React.Component { } handleTrimTasks (submission, tasks) { + this.handleTrimParentTasks(tasks) for (let i = 0; i < submission.tasks.length; i++) { for (let j = 0; j < tasks.length; j++) { if (submission.tasks[i].id === tasks[j].id) { @@ -408,6 +410,15 @@ class Submission extends React.Component { } } + handleTrimParentTasks (tasks) { + for (let j = 0; j < tasks.length; j++) { + if (tasks[j].top) { + tasks.splice(j, 1) + --j + } + } + } + handleTrimMethods (submission, methods) { for (let i = 0; i < submission.methods.length; i++) { for (let j = 0; j < methods.length; j++) {