Panoptes-Front-End icon indicating copy to clipboard operation
Panoptes-Front-End copied to clipboard

Project builder task editors don't save changes

Open eatyourgreens opened this issue 2 years ago • 0 comments

Expected behavior

Changes should be saved in the project builder.

Current behavior

Since #6215, the task prop that is passed into task editors is a shallow copy of the original task, so the workflow won't be updated when the editor makes changes to the task. A consequence of this is that some tasks no longer update when you edit them in the project builder.

After changing the task prop, task editors should call the onChange callback with the new task:

  props.onChange(newTask);

That's a wrapper for workflow.update in the workflow editor:

  workflow.update({ [`tasks.${taskKey}`]: newTask }).save();

Instead, some editors change the task in place, then call workflow.update to mark workflow.tasks as having changed:

  this.props.task = newTask;
  this.props.workflow.update('tasks').save();

The second approach only worked when props.task was a reference to a task from workflow.tasks. Now that it's a new object, direct changes to props.task do not change the workflow object.

Tasks affected

  • [x] Survey tasks: changes to an existing task are no longer saved (#6221.)
  • [x] Generic task editor: 'Allow multiple' and 'hide previous marks' checkboxes don't save (#6222.)
  • [ ] Shortcut task: shortcuts can't be enabled for any workflow.

eatyourgreens avatar Oct 21 '22 08:10 eatyourgreens