diff --git a/ChangeLog b/ChangeLog index 14fd56b03..cef2e1fc8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,7 @@ Version 1.0.27 (unreleased) Improvements: +* Improve automatic action creation * Move notifications to the bottom of the screen * Added the possibility to import automatic actions from another project * Added Ajax loading icon for submit buttons diff --git a/app/Controller/Action.php b/app/Controller/Action.php index 6c3243241..8881e8ecf 100644 --- a/app/Controller/Action.php +++ b/app/Controller/Action.php @@ -3,7 +3,7 @@ namespace Kanboard\Controller; /** - * Automatic actions management + * Automatic Actions * * @package controller * @author Frederic Guillot @@ -37,98 +37,6 @@ class Action extends Base ))); } - /** - * Choose the event according to the action (step 2) - * - * @access public - */ - public function event() - { - $project = $this->getProject(); - $values = $this->request->getValues(); - - if (empty($values['action_name']) || empty($values['project_id'])) { - $this->response->redirect($this->helper->url->to('action', 'index', array('project_id' => $project['id']))); - } - - $this->response->html($this->helper->layout->project('action/event', array( - 'values' => $values, - 'project' => $project, - 'events' => $this->actionManager->getCompatibleEvents($values['action_name']), - 'title' => t('Automatic actions') - ))); - } - - /** - * Define action parameters (step 3) - * - * @access public - */ - public function params() - { - $project = $this->getProject(); - $values = $this->request->getValues(); - - if (empty($values['action_name']) || empty($values['project_id']) || empty($values['event_name'])) { - $this->response->redirect($this->helper->url->to('action', 'index', array('project_id' => $project['id']))); - } - - $action = $this->actionManager->getAction($values['action_name']); - $action_params = $action->getActionRequiredParameters(); - - if (empty($action_params)) { - $this->doCreation($project, $values + array('params' => array())); - } - - $projects_list = $this->projectUserRole->getActiveProjectsByUser($this->userSession->getId()); - unset($projects_list[$project['id']]); - - $this->response->html($this->helper->layout->project('action/params', array( - 'values' => $values, - 'action_params' => $action_params, - 'columns_list' => $this->column->getList($project['id']), - 'users_list' => $this->projectUserRole->getAssignableUsersList($project['id']), - 'projects_list' => $projects_list, - 'colors_list' => $this->color->getList(), - 'categories_list' => $this->category->getList($project['id']), - 'links_list' => $this->link->getList(0, false), - 'project' => $project, - 'title' => t('Automatic actions') - ))); - } - - /** - * Create a new action (last step) - * - * @access public - */ - public function create() - { - $this->doCreation($this->getProject(), $this->request->getValues()); - } - - /** - * Save the action - * - * @access private - * @param array $project Project properties - * @param array $values Form values - */ - private function doCreation(array $project, array $values) - { - list($valid, ) = $this->actionValidator->validateCreation($values); - - if ($valid) { - if ($this->action->create($values) !== false) { - $this->flash->success(t('Your automatic action have been created successfully.')); - } else { - $this->flash->failure(t('Unable to create your automatic action.')); - } - } - - $this->response->redirect($this->helper->url->to('action', 'index', array('project_id' => $project['id']))); - } - /** * Confirmation dialog before removing an action * diff --git a/app/Controller/ActionCreation.php b/app/Controller/ActionCreation.php new file mode 100644 index 000000000..24a12d923 --- /dev/null +++ b/app/Controller/ActionCreation.php @@ -0,0 +1,121 @@ +getProject(); + + $this->response->html($this->template->render('action_creation/create', array( + 'project' => $project, + 'values' => array('project_id' => $project['id']), + 'available_actions' => $this->actionManager->getAvailableActions(), + ))); + } + + /** + * Choose the event according to the action (step 2) + * + * @access public + */ + public function event() + { + $project = $this->getProject(); + $values = $this->request->getValues(); + + if (empty($values['action_name']) || empty($values['project_id'])) { + return $this->create(); + } + + $this->response->html($this->template->render('action_creation/event', array( + 'values' => $values, + 'project' => $project, + 'available_actions' => $this->actionManager->getAvailableActions(), + 'events' => $this->actionManager->getCompatibleEvents($values['action_name']), + ))); + } + + /** + * Define action parameters (step 3) + * + * @access public + */ + public function params() + { + $project = $this->getProject(); + $values = $this->request->getValues(); + + if (empty($values['action_name']) || empty($values['project_id']) || empty($values['event_name'])) { + return $this->create(); + } + + $action = $this->actionManager->getAction($values['action_name']); + $action_params = $action->getActionRequiredParameters(); + + if (empty($action_params)) { + $this->doCreation($project, $values + array('params' => array())); + } + + $projects_list = $this->projectUserRole->getActiveProjectsByUser($this->userSession->getId()); + unset($projects_list[$project['id']]); + + $this->response->html($this->template->render('action_creation/params', array( + 'values' => $values, + 'action_params' => $action_params, + 'columns_list' => $this->column->getList($project['id']), + 'users_list' => $this->projectUserRole->getAssignableUsersList($project['id']), + 'projects_list' => $projects_list, + 'colors_list' => $this->color->getList(), + 'categories_list' => $this->category->getList($project['id']), + 'links_list' => $this->link->getList(0, false), + 'project' => $project, + 'available_actions' => $this->actionManager->getAvailableActions(), + 'events' => $this->actionManager->getCompatibleEvents($values['action_name']), + ))); + } + + /** + * Save the action (last step) + * + * @access public + */ + public function save() + { + $this->doCreation($this->getProject(), $this->request->getValues()); + } + + /** + * Common method to save the action + * + * @access private + * @param array $project Project properties + * @param array $values Form values + */ + private function doCreation(array $project, array $values) + { + list($valid, ) = $this->actionValidator->validateCreation($values); + + if ($valid) { + if ($this->action->create($values) !== false) { + $this->flash->success(t('Your automatic action have been created successfully.')); + } else { + $this->flash->failure(t('Unable to create your automatic action.')); + } + } + + $this->response->redirect($this->helper->url->to('action', 'index', array('project_id' => $project['id']))); + } +} diff --git a/app/Controller/ActionProject.php b/app/Controller/ActionProject.php index 6de0fe583..e5063f73e 100644 --- a/app/Controller/ActionProject.php +++ b/app/Controller/ActionProject.php @@ -16,7 +16,7 @@ class ActionProject extends Base $projects = $this->projectUserRole->getProjectsByUser($this->userSession->getId()); unset($projects[$project['id']]); - $this->response->html($this->helper->layout->project('action_project/project', array( + $this->response->html($this->template->render('action_project/project', array( 'project' => $project, 'projects_list' => $projects, ))); @@ -33,6 +33,6 @@ class ActionProject extends Base $this->flash->failure(t('Unable to duplicate actions.')); } - $this->response->redirect($this->helper->url->to('Action', 'index', array('project_id' => $project['id']))); + $this->response->redirect($this->helper->url->to('action', 'index', array('project_id' => $project['id']))); } } diff --git a/app/ServiceProvider/AuthenticationProvider.php b/app/ServiceProvider/AuthenticationProvider.php index 6d55a1e1b..5ed28fe10 100644 --- a/app/ServiceProvider/AuthenticationProvider.php +++ b/app/ServiceProvider/AuthenticationProvider.php @@ -68,6 +68,7 @@ class AuthenticationProvider implements ServiceProviderInterface $acl->add('Action', '*', Role::PROJECT_MANAGER); $acl->add('ActionProject', '*', Role::PROJECT_MANAGER); + $acl->add('ActionCreation', '*', Role::PROJECT_MANAGER); $acl->add('Analytic', '*', Role::PROJECT_MANAGER); $acl->add('Board', 'save', Role::PROJECT_MEMBER); $acl->add('BoardPopover', '*', Role::PROJECT_MEMBER); diff --git a/app/Template/action/index.php b/app/Template/action/index.php index 1cc147827..63d638872 100644 --- a/app/Template/action/index.php +++ b/app/Template/action/index.php @@ -3,79 +3,69 @@ - + +

+ + + + + + + -

-
- - - - - - - - - - - - - -
-
    -
  • - = - text->in($action['event_name'], $available_events) ?> -
  • -
  • - = - text->in($action['action_name'], $available_actions) ?> -
  • -
      -
-
    - $param_value): ?> -
  • - text->in($param_name, $available_params[$action['action_name']]) ?> = - - text->contains($param_name, 'column_id')): ?> - text->in($param_value, $columns_list) ?> - text->contains($param_name, 'user_id')): ?> - text->in($param_value, $users_list) ?> - text->contains($param_name, 'project_id')): ?> - text->in($param_value, $projects_list) ?> - text->contains($param_name, 'color_id')): ?> - text->in($param_value, $colors_list) ?> - text->contains($param_name, 'category_id')): ?> - text->in($param_value, $categories_list) ?> - text->contains($param_name, 'link_id')): ?> - text->in($param_value, $links_list) ?> - - text->e($param_value) ?> - - -
  • - -
-
- url->link(t('Remove'), 'action', 'confirm', array('project_id' => $project['id'], 'action_id' => $action['id']), false, 'popover') ?> -
- - - -

-
- form->csrf() ?> - form->hidden('project_id', $values) ?> - - form->label(t('Action'), 'action_name') ?> - form->select('action_name', $available_actions, $values) ?> - -
- -
-
\ No newline at end of file + + + +