Commit 840b8780 authored by Mat's avatar Mat

affichage de la période et de l'offre, commun pour aside ou pour les lettre-header

parent 9afc46d5
...@@ -90,7 +90,7 @@ class InfoRepository extends \Doctrine\ORM\EntityRepository ...@@ -90,7 +90,7 @@ class InfoRepository extends \Doctrine\ORM\EntityRepository
public function findAllForLettreReadInfosSorted($id, $sorted) public function findAllForLettreReadInfosSorted($id, $sorted)
{ {
$qb = $this->createQueryBuilder('i') $qb = $this->createQueryBuilder('i')
->select('i.id', 'i.title', 'i.subtitle', 'i.text', 'i.color', 'i.status') ->select('i.id', 'i.title', 'i.subtitle', 'i.text', 'i.color', 'i.status', 'i.postedAt')
->join('i.lettres', 'l') ->join('i.lettres', 'l')
->addSelect('l.id id_lettre') ->addSelect('l.id id_lettre')
->where('l.id = :id') ->where('l.id = :id')
...@@ -111,7 +111,7 @@ class InfoRepository extends \Doctrine\ORM\EntityRepository ...@@ -111,7 +111,7 @@ class InfoRepository extends \Doctrine\ORM\EntityRepository
public function findAllForLettreReadInfos($id) public function findAllForLettreReadInfos($id)
{ {
$qb = $this->createQueryBuilder('i') $qb = $this->createQueryBuilder('i')
->select('i.id', 'i.title', 'i.subtitle', 'i.text', 'i.color', 'i.status') ->select('i.id', 'i.title', 'i.subtitle', 'i.text', 'i.color', 'i.status', 'i.postedAt')
->join('i.lettres', 'l') ->join('i.lettres', 'l')
->addSelect('l.id id_lettre') ->addSelect('l.id id_lettre')
->where('l.id = :id') ->where('l.id = :id')
......
...@@ -72,34 +72,8 @@ function buildRowLettre(jsonRow) ...@@ -72,34 +72,8 @@ function buildRowLettre(jsonRow)
} }
tr.appendChild(td2); tr.appendChild(td2);
let offreLink = Routing.generate('potage_offre_legumes_ajax_display', {'id': jsonRow.offre.id });
let abonnes = jsonRow.groupe.utilisateurs.length + ' abonné' + (jsonRow.groupe.utilisateurs.length > 1 ? 's' : '');
let legumes = jsonRow.offre.offre_legumes.length + ' légume' + (jsonRow.offre.offre_legumes.length > 1 ? 's' : '');
let td3 = document.createElement('td'); let td3 = document.createElement('td');
td3.innerHTML = `<dl> td3.innerHTML = displayHeaderLettre(jsonRow);
<dt>Pour:</dt>
<dd>
groupe ${jsonRow.groupe.nom}
<span class="details parenth">${abonnes}</span>
</dd>
<dt>Sujet:</dt>
<dd>
${jsonRow.subject}
</dd>
<dt>Période:</dt>
<dd>
${formatStringDate(jsonRow.started_at, true, true, false, false)}
${formatStringDate(jsonRow.ended_at, true, true, false, false)}
</dd>
<dt>Offre:</dt>
<dd>
<a href="${offreLink}" title="Voir l'offre" class="btn btn-outline-dark btn-sm">
<i class="fas fa-paperclip fa-fw"></i> ${jsonRow.offre.reference}</a>
<span class="details parenth">${legumes}</span>
</dd>
</dl>`;
tr.appendChild(td3); tr.appendChild(td3);
let td4 = document.createElement('td'); let td4 = document.createElement('td');
......
...@@ -46,22 +46,12 @@ ...@@ -46,22 +46,12 @@
</dl> </dl>
</li> </li>
<li class="list-group-item"> <li class="list-group-item">
<dl> <dl class="field-lettre field2"></dl>
<dt>Pour:</dt>
<dd class="field-lettre field2">Groupe {{ lettre.groupe.nom }}</dd>
<dt>Sujet:</dt>
<dd class="field-lettre field3">{{ lettre.subject }}</dd>
<dt>Période:</dt>
<dd>
<span class="field-lettre field4">{{ lettre.startedAt.format('d/m/Y') }}</span>
<span class="field-lettre field5">{{ lettre.endedAt.format('d/m/Y') }}</span>
</dd>
</dl>
</li> </li>
<li class="list-group-item border-bottom-0"> <li class="list-group-item border-bottom-0">
<dl> <dl>
<dt>Statut:</dt> <dt>Statut:</dt>
<dd class="field-lettre field6">{{ lettre.status }}</dd> <dd class="field-lettre field3">{{ lettre.status }}</dd>
</dl> </dl>
</li> </li>
</ul> </ul>
...@@ -106,6 +96,7 @@ ...@@ -106,6 +96,7 @@
</div> </div>
<div id="maingrid" class="grid lettre-infos {{ lettre.status }}"> <div id="maingrid" class="grid lettre-infos {{ lettre.status }}">
<div id="lettre-header" class="border-bottom mb-4"></div>
<div id="sortable"></div> <div id="sortable"></div>
<div class="clearfix"></div> <div class="clearfix"></div>
</div> </div>
......
...@@ -113,6 +113,8 @@ if (sortForm) ...@@ -113,6 +113,8 @@ if (sortForm)
function reloadBlocLettre() function reloadBlocLettre()
{ {
let fieldsLettre = document.querySelectorAll('.field-lettre'); let fieldsLettre = document.querySelectorAll('.field-lettre');
let headerLettre = document.querySelector('#lettre-header');
AJAX('GET', AJAX('GET',
Routing.generate('api_lettre_read_one', {'id': id_lettre}), Routing.generate('api_lettre_read_one', {'id': id_lettre}),
function(request) { function(request) {
...@@ -122,11 +124,10 @@ function reloadBlocLettre() ...@@ -122,11 +124,10 @@ function reloadBlocLettre()
let colors = {'draft': 'warning', 'current': 'info', 'sent': 'success', 'closed': 'secondary', 'trash': 'danger'}; let colors = {'draft': 'warning', 'current': 'info', 'sent': 'success', 'closed': 'secondary', 'trash': 'danger'};
fieldsLettre[0].textContent = formatStringDateTime(json.created_at, true, true, false, false); fieldsLettre[0].textContent = formatStringDateTime(json.created_at, true, true, false, false);
fieldsLettre[1].textContent = json.updated_at ? formatStringDateTime(json.updated_at, true, true, false, false) : null; fieldsLettre[1].textContent = json.updated_at ? formatStringDateTime(json.updated_at, true, true, false, false) : null;
fieldsLettre[2].textContent = 'Groupe ' + json.groupe.nom; fieldsLettre[2].innerHTML = displayPeriodAndOffre(json);
fieldsLettre[3].textContent = json.subject; fieldsLettre[3].innerHTML = buildColorSquare(json.status, colors) + listStatus[json.status];
fieldsLettre[4].textContent = formatStringDate(json.started_at, true, true, false, false);
fieldsLettre[5].textContent = formatStringDate(json.ended_at, true, true, false, false); headerLettre.innerHTML = displayHeaderLettre(json, true);
fieldsLettre[6].innerHTML = buildColorSquare(json.status, colors) + listStatus[json.status];
} }
); );
} }
......
...@@ -129,7 +129,7 @@ dd { ...@@ -129,7 +129,7 @@ dd {
aside.col-3 dd { aside.col-3 dd {
padding-left: 0; padding-left: 0;
} }
table.lettres dd { .lettre-header dd {
margin-top: -1.5em; /* nécessaire template Lettre */ margin-top: -1.5em; /* nécessaire template Lettre */
} }
...@@ -190,7 +190,7 @@ span#rebours { ...@@ -190,7 +190,7 @@ span#rebours {
table#maintab td { table#maintab td {
max-width: 400px; max-width: 400px;
} }
table span.details { /* span.details { /*
font-style: italic; */ font-style: italic; */
font-size: 10pt; font-size: 10pt;
color: #6f6f6f; color: #6f6f6f;
...@@ -215,7 +215,7 @@ table span.details { /* ...@@ -215,7 +215,7 @@ table span.details { /*
} }
/* /*
#offre_legumes_ajax_display # maingrid
*/ */
#maingrid.draft, #maingrid.draft,
#maingrid.current, #maingrid.current,
...@@ -229,6 +229,10 @@ table span.details { /* ...@@ -229,6 +229,10 @@ table span.details { /*
border: 6px dashed #d8d8d8; border: 6px dashed #d8d8d8;
padding: 2em; padding: 2em;
} }
#lettre_infos_ajax_display #maingrid.current #sortable div.info:hover,
#maingrid.draft #sortable div.info:hover {
background-color: #e8e8e8;
}
#lettre_infos_ajax_display #maingrid.current:after, #lettre_infos_ajax_display #maingrid.current:after,
#maingrid.draft:after { #maingrid.draft:after {
content: "Glisser les éléments avec la souris pour les repositionner"; content: "Glisser les éléments avec la souris pour les repositionner";
...@@ -258,9 +262,16 @@ table span.details { /* ...@@ -258,9 +262,16 @@ table span.details { /*
margin-top: -1em; */ margin-top: -1em; */
background-color: white; background-color: white;
} }
#sortable div.info:hover { #sortable div.info h2 {
background-color: #e8e8e8; font-size: 150%;
}
#sortable div.info h4 {
font-size: 120%;
} }
#sortable div.info p {
font-size: 90%;
}
#sortable div.ui-state-default { #sortable div.ui-state-default {
margin: 1em 1em 0 0; margin: 1em 1em 0 0;
padding: 0; padding: 0;
...@@ -306,4 +317,3 @@ span.posted:first-letter { ...@@ -306,4 +317,3 @@ span.posted:first-letter {
text-transform: uppercase; text-transform: uppercase;
} }
...@@ -246,12 +246,13 @@ function boolTriggerHideTarget(trigger, target) ...@@ -246,12 +246,13 @@ function boolTriggerHideTarget(trigger, target)
/* /*
* Affiche une Actualité * Affiche une Actualité
* @param info json
*/ */
function displayBodyOneInfo(body, info) function displayBodyOneInfo(body, info)
{ {
let subtitle = info.subtitle ? '<h4>' + info.subtitle + '</h4>' : ''; let subtitle = info.subtitle ? '<h4>' + info.subtitle + '</h4>' : '';
let publiDate = (typeof info.posted_at !== 'undefined') ? let publiDate = (typeof info.postedAt !== 'undefined') ?
'<span class="posted">' + formatStringDateTime(info.posted_at, true, true, false, false) + '</span>' : '<span class="posted">' + formatStringDate(info.postedAt, true, true, false, false) + '</span>' :
''; '';
let color = info.color ? ' style="color: ' + info.color + ';"' : ''; let color = info.color ? ' style="color: ' + info.color + ';"' : '';
body.innerHTML = '<div class="info"' body.innerHTML = '<div class="info"'
...@@ -264,6 +265,48 @@ function displayBodyOneInfo(body, info) ...@@ -264,6 +265,48 @@ function displayBodyOneInfo(body, info)
; ;
} }
/*
* Affiche l'entête d'une lettre
* @param lettre json
*/
function displayPeriodAndOffre(lettre)
{
let offreLink = Routing.generate('potage_offre_legumes_ajax_display', {'id': lettre.offre.id });
let legumes = lettre.offre.offre_legumes.length + ' légume' + (lettre.offre.offre_legumes.length > 1 ? 's' : '');
return `<dt>Période:</dt>
<dd>
${formatStringDate(lettre.started_at, true, true, false, false)}
${formatStringDate(lettre.ended_at, true, true, false, false)}
</dd>
<dt>Offre:</dt>
<dd>
<a href="${offreLink}" title="Voir l'offre" class="btn btn-outline-dark btn-sm">
<i class="fas fa-paperclip fa-fw"></i> ${lettre.offre.reference}</a>
<span class="details parenth">${legumes}</span>
</dd>
`;
}
function displayHeaderLettre(lettre, facultatif = false)
{
let abonnes = lettre.groupe.utilisateurs.length + ' abonné' + (lettre.groupe.utilisateurs.length > 1 ? 's' : '');
let periode = facultatif ? '' : displayPeriodAndOffre(lettre);
return `<div class="lettre-header"><dl>
<dt>Pour:</dt>
<dd>
groupe ${lettre.groupe.nom}
<span class="details parenth">${abonnes}</span>
</dd>
<dt>Sujet:</dt>
<dd>
${lettre.subject}
</dd>
${periode}
</dl></div>`;
}
/* /*
* F O N C T I O N S A J A X * F O N C T I O N S A J A X
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment