home · contact · privacy
To /files view add sorting by tags amount.
authorChristian Heller <c.heller@plomlompom.de>
Thu, 20 Feb 2025 18:23:12 +0000 (19:23 +0100)
committerChristian Heller <c.heller@plomlompom.de>
Thu, 20 Feb 2025 18:23:12 +0000 (19:23 +0100)
src/templates/files.tmpl

index 2338cf84f121083243e2fbfce031c59c9a39de0b..bb60fc2b9706f230e354c638ae1422e8730b3263 100644 (file)
@@ -54,7 +54,10 @@ function draw_files_table() {
             inverter = -1;
             _sort_key = sort_key.substring(1);
         }
-        return inverter * ((a[_sort_key] > b[_sort_key]) ? 1 : -1);
+        const cmp = "tags_count" == _sort_key
+                    ? (a.tags_showable.length > b.tags_showable.length)
+                    : (a[_sort_key] > b[_sort_key]);
+        return inverter * (cmp ? 1 : -1);
     });
     const table = document.getElementById("files_table");
     Array.from(document.getElementsByClassName("file_row")).forEach((row) => row.remove());
@@ -129,7 +132,7 @@ known files (shown: <span id="files_count">?</span>):
 <th><button class="sorter" onclick="sort_by(this, 'size'); ">size</button></th>
 <th><button class="sorter" onclick="sort_by(this, 'duration'); ">duration</button></th>
 <th>actions</th>
-<th>tags</th>
+<th>tags <button class="sorter" onclick="sort_by(this, 'tags_count'); ">count</button></th>
 <th><button class="sorter" onclick="sort_by(this, 'rel_path'); ">path</button></th>
 </tr>
 </table>