add task type in list

This commit is contained in:
Julien Fastré 2018-07-05 15:12:09 +02:00
parent bae3904b1d
commit 9852430b13
3 changed files with 12 additions and 6 deletions

View File

@ -57,6 +57,7 @@ Filter: Filtrer
Any user: Tous les utilisateurs
Unassigned: Non assigné
Associated person: Personne associée
Default task: Tâche par défaut
# transitions

View File

@ -6,7 +6,7 @@
<thead>
<tr>
<th class="chill-red">{{ 'Title'|trans }}</th>
{# <th class="chill-green">{{ 'Task type'|trans }}</th> #}
<th class="chill-green">{{ 'Task type'|trans }}</th>
{% if person is null %}
<th>{{ 'Person'|trans }}</th>
{% endif %}
@ -18,7 +18,7 @@
{% for task in tasks %}
<tr>
<td>{{ task.title }}</td>
{# <td>{{ task.type }}</td> #}
<td>{{ task_workflow_metadata(task, 'definition.name') }}</td>
{% if person is null %}
<td><a href="{{ path('chill_person_view', {person_id : task.person.Id}) }}">{{ task.person}}</a></td>
{% endif %}

View File

@ -45,6 +45,10 @@ class DefaultTaskDefinition implements \Chill\TaskBundle\Workflow\TaskWorkflowDe
'sentence' => '%user% has started the task'
]
];
const DEFINITION_METADATA = [
'name' => 'Default task'
];
public function supports(AbstractTask $task)
{
@ -71,20 +75,21 @@ class DefaultTaskDefinition implements \Chill\TaskBundle\Workflow\TaskWorkflowDe
}
return $this->getTransitionMetadata(\implode('.', \array_slice($keys, 1)), $metadataSubject);
case 'definition':
return self::DEFINITION_METADATA[$keys[1]] ?? $key;
default:
throw new \LogicException("this key '$key' is not implemented");
return $key;
}
}
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");
return $key;
}
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 $key;
}
return self::TRANSITION_METADATA[$transition->getName()][$key];