From 11d93f61db50cf23c66a91ef72c0ec783ac4624a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis=20V=C3=A9zina?= <5130500+morpheus65535@users.noreply.github.com> Date: Fri, 10 Apr 2020 12:41:09 -0400 Subject: [PATCH] Added seasons collapsing to episodes view. --- views/episodes.html | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/views/episodes.html b/views/episodes.html index 0d9367453..28db2ab2f 100644 --- a/views/episodes.html +++ b/views/episodes.html @@ -323,6 +323,8 @@ getLanguages(); getEnabledLanguages(); + var collapsedGroups = {}; + var table = $('#episodes').DataTable({ dom: "tr", processing: true, @@ -338,8 +340,18 @@ pageLength: {{ settings.general.page_size }}, ajax: "{{ url_for('api.episodes') }}?seriesid={{id}}", rowGroup: { - dataSrc: function (data) { - return 'Season ' + data.season; + dataSrc: 'season', + startRender: function (rows, group) { + var collapsed = !!collapsedGroups[group]; + + rows.nodes().each(function (r) { + r.style.display = collapsed ? 'none' : ''; + }); + + return $('') + .append('Season ' + group + '') + .attr('data-name', group) + .toggleClass('collapsed', collapsed); } }, columns: [ @@ -424,6 +436,12 @@ ] }); + $('#episodes').on('click', 'tr.dtrg-start', function () { + var name = $(this).data('name'); + collapsedGroups[name] = !collapsedGroups[name]; + table.draw(false); + }); + $('#episodes').on('click', '.remove_subtitles', function (e) { $(this).tooltip('dispose'); e.preventDefault();