medic / cht-core

The CHT Core Framework makes it faster to build responsive, offline-first digital health apps that equip health workers to provide better care in their communities. It is a central resource of the Community Health Toolkit.
https://communityhealthtoolkit.org
GNU Affero General Public License v3.0
439 stars 211 forks source link

Refactor TasksContent controller to use unique URLs for actions #5910

Open garethbowen opened 5 years ago

garethbowen commented 5 years ago

Currently tasks have one or more actions associated with them. Having multiple possible actions is an underused feature of tasks but it would be really useful for example if an ANC visit task could lead to a Delivery or a Visit report being filed to resolve it.

If you select a task with exactly one action then you go straight to completing that action. If there are multiple possible actions, or the task has a detailed description (another underused feature) then you see a summary page and can select one of the actions.

Currently these both invoke the $scope.performAction function, but this requires a redux listener to detect when a task is selected. This is bad form.

Instead each action should have a unique URL (eg: /tasks/:id/actions/:actionId) which is handled by a new child controller. Put the $scope.performAction logic in the new controller. When selecting a task with only one action we can go straight to /tasks/:id/actions/0. When selecting a task with multiple actions use the existing TasksContent controller to render the detail and have each action button link to the new action URL.

kennsippell commented 4 years ago

@vimemo you might want to work from this pr to avoid a downstream merge https://github.com/medic/cht-core/pull/6041

garethbowen commented 4 years ago

@vimemo Any progress on this? If not, I'm thinking it should be delayed until 3.9.0 as it's not high priority.