Skip to content
Snippets Groups Projects
Commit 77b58359 authored by Pierre Fleutot's avatar Pierre Fleutot
Browse files

Liste des labels : ajout nb de mot-vedettes portant le label. Création CSS

parent a39acc11
No related branches found
No related tags found
No related merge requests found
...@@ -81,3 +81,34 @@ table.table-list > * > * > *:nth-child(1):after { ...@@ -81,3 +81,34 @@ table.table-list > * > * > *:nth-child(1):after {
.member-badge.member-badge-dark.member-badge-xl.circled { .member-badge.member-badge-dark.member-badge-xl.circled {
border-color: #66717d; border-color: #66717d;
} }
.label-category {
font-size: 2em;
font-weight: bold;
}
.hidden-column {
display: none;
}
table.label-table {
margin: 10px;
}
table.label-table > tbody > tr > td {
padding: 5px;
vertical-align: top;
}
.bg-label-personal {
background-color: #CAECFF;
}
.bg-label-group {
background-color: #79ccff;
}
.bg-label-public {
background-color: #00b3ff;
}
.bg-label-milestone {
background-color: #FF9E9E;
}
.bg-label-institutional {
background-color: #C4C2FF;
}
\ No newline at end of file
...@@ -4,6 +4,7 @@ namespace App\Manager; ...@@ -4,6 +4,7 @@ namespace App\Manager;
use App\Entity\Entry; use App\Entity\Entry;
use App\Entity\Group; use App\Entity\Group;
use App\Entity\Headword;
use App\Entity\Label; use App\Entity\Label;
use App\Entity\LabelVisibility; use App\Entity\LabelVisibility;
use App\Entity\Lexicon; use App\Entity\Lexicon;
...@@ -29,6 +30,7 @@ class LabelManager ...@@ -29,6 +30,7 @@ class LabelManager
$this->doctrine = $doctrine; $this->doctrine = $doctrine;
} }
// vrai si le label est visible pour user dans un lexique donné
public function isVisible(Label $label, Lexicon $lexicon, User $user) public function isVisible(Label $label, Lexicon $lexicon, User $user)
{ {
return $this->doctrine->getRepository(LabelVisibility::class)->count( return $this->doctrine->getRepository(LabelVisibility::class)->count(
...@@ -86,4 +88,11 @@ class LabelManager ...@@ -86,4 +88,11 @@ class LabelManager
'group' => $group, 'group' => $group,
]); ]);
} }
// Retourne le nb total de mot-vedettes portant le label
// Si $user est renseigné, Retourne le nb total de mot-vedettes portant le label ayant au moins une entrée dans un lexique de l'utilisateur
public function getHeadwordsNbWithLabel(Label $label, User $user = null)
{
return $this->doctrine->getRepository(Headword::class)->countHavingLabel($label, $user);
}
} }
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
namespace App\Repository; namespace App\Repository;
use App\Entity\Headword; use App\Entity\Headword;
use App\Entity\Label;
use App\Entity\User;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry; use Doctrine\Persistence\ManagerRegistry;
...@@ -73,13 +75,25 @@ class HeadwordRepository extends ServiceEntityRepository ...@@ -73,13 +75,25 @@ class HeadwordRepository extends ServiceEntityRepository
return $result; return $result;
} }
// public function findOneBySomeField($value): ?Headword public function countHavingLabel(Label $label, User $user = null)
// { {
// return $this->createQueryBuilder('l') $qb = $this->createQueryBuilder('h');
// ->andWhere('l.exampleField = :val') $qb ->innerJoin('h.labels', 'lb')
// ->setParameter('val', $value) ->select($qb->expr()->countDistinct('h.id'))
// ->getQuery() ->andWhere('lb = :label')
// ->getOneOrNullResult() ->setParameter('label', $label)
// ; ;
// } if ($user) {
$qb ->innerJoin('h.entries', 'e')
->innerJoin('e.lexicon', 'l')
->leftJoin('l.group', 'g')
->leftJoin('g.groupMemberships', 'gms')
->leftJoin('gms.user', 'u')
->andWhere('u = :user OR gms.user = :user')
->setParameter('user', $user)
;
}
return $qb->getQuery()->getSingleScalarResult();
}
} }
...@@ -10,13 +10,14 @@ ...@@ -10,13 +10,14 @@
<link rel="stylesheet" href="{{ asset('assets/css/app.css') }}"> <link rel="stylesheet" href="{{ asset('assets/css/app.css') }}">
{{ encore_entry_link_tags('app') }} {{ encore_entry_link_tags('app') }}
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-iYQeCzEYFbKjA/T2uDLTpkwGzCiq6soy8tYaI1GyVh/UjpbCx/TYkiZhlZB6+fzT" crossorigin="anonymous"> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-iYQeCzEYFbKjA/T2uDLTpkwGzCiq6soy8tYaI1GyVh/UjpbCx/TYkiZhlZB6+fzT" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.9.1/font/bootstrap-icons.css"> {% endblock %} <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.9.1/font/bootstrap-icons.css">
<link rel="stylesheet" href="{{ asset('assets/css/font-awesome.min.css') }}"> <link rel="stylesheet" href="{{ asset('assets/css/font-awesome.min.css') }}">
{% endblock %}
{% block javascripts %} {% block javascripts %}
{{ encore_entry_script_tags('app') }} {{ encore_entry_script_tags('app') }}
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.1/dist/js/bootstrap.bundle.min.js" integrity="sha384-u1OknCvxWvY5kfmNBILK2hRnQC3Pr17a+RTT6rIHI7NnikvbZlHgTPOOmMi466C8" crossorigin="anonymous"></script> {% endblock %} <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.1/dist/js/bootstrap.bundle.min.js" integrity="sha384-u1OknCvxWvY5kfmNBILK2hRnQC3Pr17a+RTT6rIHI7NnikvbZlHgTPOOmMi466C8" crossorigin="anonymous"></script>
</head> <script src="https://code.jquery.com/jquery-3.7.0.min.js" integrity="sha256-2Pmvv0kuTBOenSvLm6bvfBSSHrUJ+3A7x6P5Ebd07/g=" crossorigin="anonymous"></script></head>
{% endblock %}
<body> <body>
{% block nav %} {% block nav %}
......
<div class="row row-cols-auto flex-nowrap"> <tr>
<div class="col"> <td style="padding-bottom: 20px">
<span class="badge bg-primary">{{ label }}</span> <div class="badge rounded-pill position-relative text-black {{ bgColor }}" style="margin-right: 10px;">{{ label }}
</div> <span class="position-absolute top-100 start-100 text-black">{{ label_manager.getHeadwordsNbWithLabel(label, app.user) }}/{{ label_manager.getHeadwordsNbWithLabel(label) }}</span>
<div class="col collapse multi-collapse">
<div class="row row-cols-auto">
{% for lexicon in app.user.myLexicons %}
<div class="col text-center" style="width: 64px">
{% if label_manager.isVisible(label, lexicon, app.user) %}<i class="fa fa-check-square text-success"></i>{% else %}<i class="fa fa-square-o"></i>{% endif %}
</div>
{% endfor %}
</div> </div>
</div> </td>
</div> {% for lexicon in app.user.myLexicons %}
<td class="text-center col-collapse hidden-column">
{% if label_manager.isVisible(label, lexicon, app.user) %}<i class="fa fa-check-square text-success"></i>{% else %}<i class="fa fa-square-o"></i>{% endif %}
</td>
{% endfor %}
</tr>
\ No newline at end of file
<div class="row row-cols-auto flex-nowrap"> <tr>
<div class="col"> <td></td>
</div> <td colspan="{{ lexiconsNb }}" class="text-center col-collapse hidden-column">
<div style="background-color: #d9d9d9; border-radius: 3px; padding: 8px">{{ "Visibilité des labels dans les lexiques"|trans }}</div>
<div class="col collapse multi-collapse"> </td>
<div class="row row-cols-auto"> </tr>
{% for lexicon in app.user.myLexicons %} <tr>
<div class="col" style="width: 64px"> <td></td>
{{ lexicon|badge }} {% for lexicon in app.user.myLexicons %}
</div> <td class="text-center col-collapse hidden-column">{{ lexicon|badge }}</td>
{% endfor %} {% endfor %}
</div> </tr>
</div> \ No newline at end of file
</div>
...@@ -16,25 +16,35 @@ ...@@ -16,25 +16,35 @@
<div class="col"> <div class="col">
<div class="card"> <div class="card">
<div class="card-header d-flex justify-content-between"> {% set lexiconsNb = app.user.myLexicons|length %}
<h3>{{ "Général"|trans }}</h3>
<button class="btn btn-dark btn-sm" type="button" data-bs-toggle="collapse" data-bs-target=".multi-collapse">+ {{ "Visibilité"|trans }}</button>
</div>
<div class="card-body"> <table class="label-table">
<tr>
<td class="label-category">{{ "Général"|trans }}</td>
<td colspan="{{ lexiconsNb }}" class="text-end">
<button id="toggle-visibility" class="btn btn-dark btn-sm" type="button" data-bs-toggle="collapse" data-bs-target=".multi-collapse">
{{ "Visibilité"|trans }}
</button>
</td>
</tr>
{% include "label/_lexiconsHeaders.html.twig" %} {% include "label/_lexiconsHeaders.html.twig" %}
<p><strong> <tr>
{{ "Personnel"|trans }} <td class="d-flex justify-content-between">
<a title="{{ 'Ajouter un label'|trans }}" href="{{ path('app_label_new', {category: constant("App\\Entity\\Label::LABEL_CATEGORY_GENERAL"), masterType: constant("App\\Entity\\Label::MASTER_PERSONAL")}) }}" class="btn btn-dark btn-sm ms-2"><i class="bi-plus"></i></a> <strong>{{ "Personnel"|trans }}</strong>
</strong></p> <a title="{{ 'Ajouter un label'|trans }}" href="{{ path('app_label_new', {category: constant("App\\Entity\\Label::LABEL_CATEGORY_GENERAL"), masterType: constant("App\\Entity\\Label::MASTER_PERSONAL")}) }}" class="btn btn-dark btn-sm ms-2"><i class="bi-plus"></i></a>
</td>
<td colspan="{{ lexiconsNb }}"></td>
</tr>
{% for label in label_manager.findByCategoryAndMaster(constant("App\\Entity\\Label::LABEL_CATEGORY_GENERAL"), constant("App\\Entity\\Label::MASTER_PERSONAL"), app.user) %} {% for label in label_manager.findByCategoryAndMaster(constant("App\\Entity\\Label::LABEL_CATEGORY_GENERAL"), constant("App\\Entity\\Label::MASTER_PERSONAL"), app.user) %}
{% include "label/_labelLine.html.twig" %} {% include "label/_labelLine.html.twig" with { bgColor: 'bg-label-personal'} %}
{% endfor %} {% endfor %}
</div> </table>
</div> </div>
</div> </div>
...@@ -43,4 +53,17 @@ ...@@ -43,4 +53,17 @@
</div> </div>
</div> </div>
{% endblock %}
{% block javascripts %}
{{ parent() }}
<script type="text/javascript">
$(function() {
$('#toggle-visibility').on('click', function () {
$('.col-collapse:visible').hide('slow');
$('.col-collapse:hidden').show('slow');
})
});
</script>
{% endblock %} {% endblock %}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment