related to #1609 added number of photos in badges

This commit is contained in:
Matthieu Leproux
2022-04-05 10:32:10 +02:00
parent e304d85b0a
commit b04a2e92d5
3 changed files with 18 additions and 4 deletions

View File

@@ -170,8 +170,16 @@ function assocToOrderedTree($assocT)
{
$orderedTree = array();
$query = '
SELECT
category_id,
COUNT(*) AS nb_photos
FROM '.IMAGE_CATEGORY_TABLE.'
GROUP BY category_id
;';
$nb_photos_in = query2array($query, 'category_id', 'nb_photos');
// echo '<pre>'; print_r($assocT); echo '</pre>';
foreach($assocT as $cat)
{
$orderedCat = array();
@@ -179,7 +187,7 @@ function assocToOrderedTree($assocT)
$orderedCat['name'] = $cat['cat']['name'];
$orderedCat['status'] = $cat['cat']['status'];
$orderedCat['id'] = $cat['cat']['id'];
$orderedCat['nb_images'] = 'test2';
$orderedCat['nb_images'] = isset($nb_photos_in[$cat['cat']['id']]) ? $nb_photos_in[$cat['cat']['id']] : 0;
$orderedCat['last_updates'] = $cat['cat']['lastmodified'];
if (isset($cat['children']))
{

View File

@@ -74,7 +74,7 @@ $(document).ready(() => {
cont.find(".move-cat-title").after(
"<div class='badge-container'>"
+"<i class='icon-blue icon-sitemap nb-subcats'></i>"
+"<i class='icon-purple icon-picture nb-images'>"+ node.nb_images +"</i>"
+"<i class='icon-purple icon-picture nb-images'></i>"
+"<i class='icon-red icon-back-in-time last-update'>"+ node.last_updates +"</i>"
+"</div>"
)
@@ -84,6 +84,12 @@ $(document).ready(() => {
} else {
cont.find(".nb-subcats").hide();
}
if (node.nb_images != 0) {
cont.find(".nb-images").text(node.nb_images);
} else {
cont.find(".nb-images").hide();
}
}
var url_split = window.location.href.split("#");

View File

@@ -448,7 +448,7 @@ input[name="position"] {
.badge-container i {
padding: 2px 6px 2px 4px!important;
border-radius: 10px !important;
font-size: 10px !important;
font-size: 0.85em !important;
margin: 0 2px !important;
font-weight: 700;
font-style: normal;