Skip to content

Commit

Permalink
Add TASK_MODIFY_ALL action (addresses vit-project#240)
Browse files Browse the repository at this point in the history
This action is a first use case (but really just one special case) of bulk editing, which  makes use of the new 'modify_multiple' operation by passing the filter expression that matches all tasks visible in the current view.
  • Loading branch information
kevinstadler committed Apr 7, 2021
1 parent b72569a commit 6c4d35f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions vit/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ def register(self):
self.action_registrar.register('TASK_DELETE', 'Delete task')
self.action_registrar.register('TASK_DENOTATE', 'Denotate a task')
self.action_registrar.register('TASK_MODIFY', 'Modify task (supports tab completion)')
self.action_registrar.register('TASK_MODIFY_ALL', 'Modify all tasks currently in view')
self.action_registrar.register('TASK_START_STOP', 'Start/stop task')
self.action_registrar.register('TASK_DONE', 'Mark task done')
self.action_registrar.register('TASK_PRIORITY', 'Modify task priority')
Expand Down
6 changes: 6 additions & 0 deletions vit/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ def register_managed_actions(self):
self.action_manager_registrar.register('TASK_DELETE', self.task_action_delete)
self.action_manager_registrar.register('TASK_DENOTATE', self.task_action_denotate)
self.action_manager_registrar.register('TASK_MODIFY', self.task_action_modify)
self.action_manager_registrar.register('TASK_MODIFY_ALL', self.task_action_modify_all)
self.action_manager_registrar.register('TASK_START_STOP', self.task_action_start_stop)
self.action_manager_registrar.register('TASK_DONE', self.task_action_done)
self.action_manager_registrar.register('TASK_PRIORITY', self.task_action_priority)
Expand Down Expand Up @@ -763,6 +764,11 @@ def task_action_modify(self):
self.activate_command_bar('modify', 'Modify: ', {'uuid': uuid})
self.task_list.focus_by_task_uuid(uuid, self.previous_focus_position)

def task_action_modify_all(self):
currentviewfilter = self.active_view_filters()
ntasks = self.model.get_n_tasks(currentviewfilter)
self.activate_command_bar('modify_multiple', 'Modify all (%s tasks): ' % ntasks, {'target': currentviewfilter, 'ntasks': ntasks})

def task_action_start_stop(self):
uuid, task = self.get_focused_task()
if task:
Expand Down

0 comments on commit 6c4d35f

Please sign in to comment.