Add new api procedures: getDefaultTaskColor(), getDefaultTaskColors() and getColorList()

This commit is contained in:
Frederic Guillot
2015-07-29 18:45:26 -04:00
parent f595fb2786
commit 2d6b6533ac
5 changed files with 259 additions and 11 deletions

View File

@@ -19,4 +19,19 @@ class App extends \Core\Base
{
return APP_VERSION;
}
public function getDefaultTaskColor()
{
return $this->color->getDefaultColor();
}
public function getDefaultTaskColors()
{
return $this->color->getDefaultColors();
}
public function getColorList()
{
return $this->color->getList();
}
}

View File

@@ -24,6 +24,9 @@ abstract class Base extends \Core\Base
private $both_allowed_procedures = array(
'getTimezone',
'getVersion',
'getDefaultTaskColor',
'getDefaultTaskColors',
'getColorList',
'getProjectById',
'getTask',
'getTaskByReference',
@@ -67,6 +70,7 @@ abstract class Base extends \Core\Base
{
if (! empty($task)) {
$task['url'] = $this->helper->url->to('task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id']), '', true);
$task['color'] = $this->color->getColorProperties($task['color_id']);
}
return $task;

View File

@@ -122,6 +122,22 @@ class Color extends Base
return '';
}
/**
* Get color properties
*
* @access public
* @param string $color_id
* @return array
*/
public function getColorProperties($color_id)
{
if (isset($this->default_colors[$color_id])) {
return $this->default_colors[$color_id];
}
return $this->default_colors[$this->getDefaultColor()];
}
/**
* Get available colors
*
@@ -150,6 +166,17 @@ class Color extends Base
return $this->config->get('default_color', 'yellow');
}
/**
* Get the default colors
*
* @access public
* @return array
*/
public function getDefaultColors()
{
return $this->default_colors;
}
/**
* Get Bordercolor from string
*
@@ -159,11 +186,8 @@ class Color extends Base
*/
public function getBorderColor($color_id)
{
if (isset($this->default_colors[$color_id])) {
return $this->default_colors[$color_id]['border'];
}
return $this->default_colors[$this->getDefaultColor()]['border'];
$color = $this->getColorProperties($color_id);
return $color['border'];
}
/**
@@ -175,11 +199,8 @@ class Color extends Base
*/
public function getBackgroundColor($color_id)
{
if (isset($this->default_colors[$color_id])) {
return $this->default_colors[$color_id]['background'];
}
return $this->default_colors[$this->getDefaultColor()]['background'];
$color = $this->getColorProperties($color_id);
return $color['background'];
}
/**