mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-28 10:33:49 +00:00
front-end dev of tasks lists
This commit is contained in:
@@ -22,7 +22,7 @@ use Chill\TaskBundle\Entity\SingleTask;
|
||||
use Symfony\Component\Workflow\Transition;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*
|
||||
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
||||
*/
|
||||
@@ -31,66 +31,63 @@ class DefaultTaskDefinition implements \Chill\TaskBundle\Workflow\TaskWorkflowDe
|
||||
const TRANSITION_METADATA = [
|
||||
'close' => [
|
||||
'verb' => 'close',
|
||||
'background-color' => 'var(--yellow)', // css variable, see https://developer.mozilla.org/fr/docs/Web/CSS/Les_variables_CSS
|
||||
'text-color' => 'black'
|
||||
'class' => 'sc-button task-close'
|
||||
],
|
||||
'cancel' => [
|
||||
'verb' => 'cancel',
|
||||
'background-color' => 'var(--red)', // css variable, see https://developer.mozilla.org/fr/docs/Web/CSS/Les_variables_CSS
|
||||
'text-color' => 'black'
|
||||
'class' => 'sc-button bt-delete task-cancel'
|
||||
],
|
||||
'start' => [
|
||||
'verb' => 'start',
|
||||
'background-color' => 'var(--green)', // css variable, see https://developer.mozilla.org/fr/docs/Web/CSS/Les_variables_CSS
|
||||
'text-color' => 'black'
|
||||
'class' => 'sc-button bt-update task-start'
|
||||
]
|
||||
];
|
||||
|
||||
public function supports(AbstractTask $task)
|
||||
|
||||
public function supports(AbstractTask $task)
|
||||
{
|
||||
|
||||
|
||||
return $task instanceof SingleTask
|
||||
&& $task->getType() === 'task_default';
|
||||
}
|
||||
|
||||
|
||||
public static function getAssociatedWorkflowName()
|
||||
{
|
||||
return 'task_default';
|
||||
}
|
||||
|
||||
|
||||
public function getWorkflowMetadata(
|
||||
string $key,
|
||||
string $key,
|
||||
$metadataSubject = null
|
||||
) {
|
||||
$keys = \explode('.', $key);
|
||||
|
||||
|
||||
switch($keys[0]) {
|
||||
case 'transition':
|
||||
if (!$metadataSubject instanceof Transition) {
|
||||
throw new \LogicException("You must give a transition as metadatasubject");
|
||||
}
|
||||
|
||||
|
||||
return $this->getTransitionMetadata(\implode('.', \array_slice($keys, 1)), $metadataSubject);
|
||||
default:
|
||||
throw new \LogicException("this key '$key' is not implemented");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected function getTransitionMetadata($key, Transition $transition)
|
||||
{
|
||||
if (!\array_key_exists($transition->getName(), self::TRANSITION_METADATA)) {
|
||||
throw new \LogicException("the metadata for this transition are not defined");
|
||||
}
|
||||
|
||||
|
||||
if (!\array_key_exists($key, self::TRANSITION_METADATA[$transition->getName()])) {
|
||||
throw new \LogicException("The metadata ".$key." is not "
|
||||
. "defined for the transition ".$transition.getName());
|
||||
}
|
||||
|
||||
|
||||
return self::TRANSITION_METADATA[$transition->getName()][$key];
|
||||
}
|
||||
|
||||
public function isClosed(AbstractTask $task)
|
||||
|
||||
public function isClosed(AbstractTask $task)
|
||||
{
|
||||
return \array_key_exists('closed', $task->getCurrentStates())
|
||||
|| \array_key_exists('canceled', $task->getCurrentStates());
|
||||
|
Reference in New Issue
Block a user