Use inline popup to create new columns
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user