front-end dev of tasks lists

This commit is contained in:
nobohan 2018-04-27 17:42:21 +02:00
parent 3719ce0896
commit 2d57757682
5 changed files with 72 additions and 38 deletions

View File

@ -171,9 +171,9 @@ class SingleTaskController extends Controller
$em->flush(); $em->flush();
$this->addFlash('success', "Success : task updated!"); $this->addFlash('success', "The task has been updated");
return $this->redirectToRoute('chill_task_task_list_by_person', [ return $this->redirectToRoute('chill_task_singletask_list', [
'person_id' => $task->getPerson()->getId() 'person_id' => $task->getPerson()->getId()
]); ]);
@ -283,9 +283,9 @@ class SingleTaskController extends Controller
return $form; return $form;
} }
/** /**
* *
* @return Response * @return Response
* @Route( * @Route(
* "/{_locale}/task/single-task/list/my", * "/{_locale}/task/single-task/list/my",

View File

@ -8,6 +8,7 @@ Scope: Cercle
'End date': "Date d'échéance" 'End date': "Date d'échéance"
'Warning date': "Date d'avertissement" 'Warning date': "Date d'avertissement"
'Warning interval': "Délai d'avertissement de la date d'échéance" 'Warning interval': "Délai d'avertissement de la date d'échéance"
'Unknown dates': 'Dates non spécifiées'
'N': '' 'N': ''
'Unit': '' 'Unit': ''
Task: Tâche Task: Tâche
@ -15,6 +16,7 @@ Details: Détails
Person: Personne Person: Personne
Scope: Cercle Scope: Cercle
Date: Date Date: Date
Dates: Dates
User: Utilisateur User: Utilisateur
'Task list': 'Liste de tâches' 'Task list': 'Liste de tâches'
'Tasks with expired deadline': "Tâches avec une date d'échéance dépassée" 'Tasks with expired deadline': "Tâches avec une date d'échéance dépassée"
@ -24,6 +26,9 @@ User: Utilisateur
'Task start date': 'Date de début' 'Task start date': 'Date de début'
'Task warning date': "Date d'avertissement" 'Task warning date': "Date d'avertissement"
'Task end date': "Date d'échéance" 'Task end date': "Date d'échéance"
'Start: ': 'Début: '
'Warning: ': 'Avertissement: '
'End: ': 'Échéance: '
'Task type': 'Type' 'Task type': 'Type'
'Task status': 'Statut' 'Task status': 'Statut'
'Edit the task': 'Éditer la tâche' 'Edit the task': 'Éditer la tâche'
@ -33,14 +38,20 @@ User: Utilisateur
'Update the task': 'Mettre à jour la tâche' 'Update the task': 'Mettre à jour la tâche'
'Remove task': 'Supprimer la tâche' 'Remove task': 'Supprimer la tâche'
'Are you sure you want to remove the task about "%name%" ?': 'Êtes-vous sûr·e de vouloir supprimer la tâche de "%name%"?' 'Are you sure you want to remove the task about "%name%" ?': 'Êtes-vous sûr·e de vouloir supprimer la tâche de "%name%"?'
'See more': 'Voir plus'
Associated tasks: Tâches associées Associated tasks: Tâches associées
My tasks: Mes tâches My tasks: Mes tâches
# transitions
'new': 'nouvelle'
'in_progress': 'en cours'
'closed': 'fermée'
'canceled': 'supprimée'
#Flash messages #Flash messages
'The task is created': 'La tâche a été créée' 'The task is created': 'La tâche a été créée'
'The task has been successfully removed.': 'La tâche a bien été supprimée' 'The task has been successfully removed.': 'La tâche a bien été supprimée'
'This form contains errors': 'Ce formulaire contient des erreurs' 'This form contains errors': 'Ce formulaire contient des erreurs'
'Success : task updated!': 'Succès: la tâche a été mise à jour' 'The task has been updated': 'La tâche a été mise à jour'
'The transition is sucessfully applyed': 'La transition a bien été effectuée' 'The transition is sucessfully applyed': 'La transition a bien été effectuée'
'The transition could not be applyed': "La transition n'a pas pu être appliquée" 'The transition could not be applyed': "La transition n'a pas pu être appliquée"

View File

@ -7,10 +7,11 @@
<tr> <tr>
<th class="chill-red">{{ 'Title'|trans }}</th> <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 %}
<th class="chill-orange">{{ 'Task status'|trans }}</th> <th class="chill-orange">{{ 'Task status'|trans }}</th>
<th>{{ 'Task start date'|trans }}</th> <th>{{ 'Dates'|trans }}</th>
<th>{{ 'Task warning date'|trans }}</th>
<th>{{ 'Task end date'|trans }}</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@ -18,18 +19,41 @@
<tr> <tr>
<td>{{ task.title }}</td> <td>{{ task.title }}</td>
<td>{{ task.type }}</td> <td>{{ task.type }}</td>
{% if person is null %}
<td>{{ task.person }}</td>
{% endif %}
<td> <td>
{% for place in workflow_marked_places(task) %} {% for place in workflow_marked_places(task) %}
<span class="">{{ place }}</span> <span class="">{{ place|trans }}</span>
{% endfor %} {% endfor %}
{% for transition in workflow_transitions(task) %} {% for transition in workflow_transitions(task) %}
<a href="{{ path('chill_task_task_transition', { 'taskId': task.id, 'transition': transition.name, 'kind': 'single-task', 'return_path': app.request.uri }) }}" style="background-color: {{ task_workflow_metadata(task, 'transition.background-color', transition)|e('html_attr') }}; color: {{ task_workflow_metadata(task, 'transition.text-color', transition)|e('html_attr') }}">{{ task_workflow_metadata(task, 'transition.verb', transition) }}</a> <a href="{{ path('chill_task_task_transition', { 'taskId': task.id, 'transition': transition.name|trans, 'kind': 'single-task', 'return_path': app.request.uri }) }}" class="{{ task_workflow_metadata(task, 'transition.class', transition)|e('html_attr') }}">{{ task_workflow_metadata(task, 'transition.verb', transition) }}</a>
{% endfor %} {% endfor %}
</td> </td>
<td>{% if task.startDate is not null %}{{ task.startDate|localizeddate('medium', 'none') }}{% endif %}</td> <td>
<td>{% if task.warningDate is not null %}{{ task.warningDate|localizeddate('medium', 'none') }}{% endif %}</td> {% if task.startDate is null and task.warningDate is null and task.endDate is null %}
<td>{% if task.endDate is not null %}{{ task.endDate|localizeddate('medium', 'none') }}{% endif %}</td> {{'Unknown dates'|trans}}
{% else %}
<ul class="record_actions_column">
<li>
{% if task.startDate is not null %}
{{'Start: '|trans}}{{ task.startDate|localizeddate('medium', 'none') }}
{% endif %}
</li>
<li>
{% if task.warningDate is not null %}
{{'Warning: '|trans}}{{ task.warningDate|localizeddate('medium', 'none') }}
{% endif %}
</li>
<li>
{% if task.endDate is not null %}
{{'End: '|trans}}{{ task.endDate|localizeddate('medium', 'none') }}
{% endif %}
</li>
</ul>
{% endif %}
</td>
<td> <td>
<ul class="record_actions"> <ul class="record_actions">
<li> <li>
@ -54,7 +78,7 @@
{% if isSingleStatus %} {% if isSingleStatus %}
{% if tasks|length > paginator.getTotalItems %} {% if tasks|length < paginator.getTotalItems %}
{{ chill_pagination(paginator) }} {{ chill_pagination(paginator) }}
{% endif %} {% endif %}
@ -89,12 +113,12 @@
<ul class="record_actions"> <ul class="record_actions">
<li> <li>
{% if person is not null %} {% if person is not null %}
<a href="{{ path('chill_task_singletask_list', {'person_id': person.id, 'status' : [ status ] }) }}" class="sc-button bt-cancel"> <a href="{{ path('chill_task_singletask_list', {'person_id': person.id, 'status' : [ status ] }) }}" class="sc-button">
{{ 'See more' | trans }} {{ 'See more' | trans }}
</a> </a>
{% endif %} {% endif %}
{% if user is not null %} {% if user is not null %}
<a href="{{ path('chill_task_singletask_list', {'status' : [ status ] }) }}" class="sc-button bt-cancel"> <a href="{{ path('chill_task_singletask_list', {'status' : [ status ] }) }}" class="sc-button">
{{ 'See more' | trans }} {{ 'See more' | trans }}
</a> </a>
{% endif %} {% endif %}

View File

@ -38,6 +38,8 @@
{% endblock %} {% endblock %}
{% else %} {% else %}
{% block content %} {% block content %}
{% include 'ChillTaskBundle:SingleTask:_list.html.twig' %} <div class="grid-8 push-1 grid-mobile-9 grid-tablet-9 push-mobile-0 push-tablet-0">
{% include 'ChillTaskBundle:SingleTask:_list.html.twig' %}
</div>
{% endblock %} {% endblock %}
{% endif %} {% endif %}

View File

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