diff --git a/ChangeLog b/ChangeLog index fa2c25977..31b089b08 100644 --- a/ChangeLog +++ b/ChangeLog @@ -11,6 +11,7 @@ New features: Improvements: +* Use inline popup to create new columns * Improve filter box design * Improve image thumbnails and files table * Add confirmation inline popup to remove custom filter diff --git a/app/Controller/Column.php b/app/Controller/Column.php index 3201c5491..772041649 100644 --- a/app/Controller/Column.php +++ b/app/Controller/Column.php @@ -15,54 +15,62 @@ class Column extends Base * * @access public */ - public function index(array $values = array(), array $errors = array()) + public function index() { $project = $this->getProject(); $columns = $this->board->getColumns($project['id']); - foreach ($columns as $column) { - $values['title['.$column['id'].']'] = $column['title']; - $values['description['.$column['id'].']'] = $column['description']; - $values['task_limit['.$column['id'].']'] = $column['task_limit'] ?: null; - } - $this->response->html($this->helper->layout->project('column/index', array( - 'errors' => $errors, - 'values' => $values + array('project_id' => $project['id']), 'columns' => $columns, 'project' => $project, 'title' => t('Edit board') ))); } + /** + * Show form to create a new column + * + * @access public + */ + public function create(array $values = array(), array $errors = array()) + { + $project = $this->getProject(); + $columns = $this->board->getColumnsList($project['id']); + + if (empty($values)) { + $values = array('project_id' => $project['id']); + } + + $this->response->html($this->template->render('column/create', array( + 'values' => $values, + 'errors' => $errors, + 'project' => $project, + 'title' => t('Add a new column') + ))); + } + /** * Validate and add a new column * * @access public */ - public function create() + public function save() { $project = $this->getProject(); - $columns = $this->board->getColumnsList($project['id']); - $data = $this->request->getValues(); - $values = array(); + $values = $this->request->getValues(); - foreach ($columns as $column_id => $column_title) { - $values['title['.$column_id.']'] = $column_title; - } - - list($valid, $errors) = $this->columnValidator->validateCreation($data); + list($valid, $errors) = $this->columnValidator->validateCreation($values); if ($valid) { - if ($this->board->addColumn($project['id'], $data['title'], $data['task_limit'], $data['description'])) { - $this->flash->success(t('Board updated successfully.')); - $this->response->redirect($this->helper->url->to('column', 'index', array('project_id' => $project['id']))); + if ($this->board->addColumn($project['id'], $values['title'], $values['task_limit'], $values['description'])) { + $this->flash->success(t('Column created successfully.')); + return $this->response->redirect($this->helper->url->to('column', 'index', array('project_id' => $project['id'])), true); } else { - $this->flash->failure(t('Unable to update this board.')); + $errors['title'] = array(t('Another column with the same title exists in the project')); } } - $this->index($values, $errors); + $this->create($values, $errors); } /** diff --git a/app/Template/column/create.php b/app/Template/column/create.php new file mode 100644 index 000000000..58b130f57 --- /dev/null +++ b/app/Template/column/create.php @@ -0,0 +1,41 @@ +