Add items suffix to collections and playlist table

This commit is contained in:
JonnyWong16 2020-10-01 09:57:01 -07:00
parent 2c360b6472
commit 15e928ecf2
No known key found for this signature in database
GPG key ID: B1F1F9807184697A
6 changed files with 43 additions and 11 deletions

View file

@ -303,6 +303,19 @@ DOCUMENTATION :: END
</div>
% endif
% endif
<div class="summary-content-details-tag">
% if data['media_type'] in ('collection', 'playlist') and data['children_count']:
<%
if data['media_type'] == 'collection':
suffix = MEDIA_TYPE_HEADERS[data['sub_media_type']]
elif data['media_type'] == 'playlist':
suffix = MEDIA_TYPE_HEADERS[data['playlist_type']]
if data['children_count'] == 1:
suffix = suffix[:-1]
%>
Items <strong> ${data['children_count']} ${suffix} </strong>
% endif
</div>
<div class="summary-content-details-tag">
% if data['directors']:
Directed by <strong> ${data['directors'][0]}</strong>
@ -328,11 +341,6 @@ DOCUMENTATION :: END
Year <strong> ${data['year']}</strong>
% endif
</div>
<div class="summary-content-details-tag">
% if data['duration']:
Items <strong> ${data['children_count']} ${'track' if data['playlist_type'] == 'audio' else 'video'}${'s' if data['children_count'] > 1 else ''} </strong>
% endif
</div>
<div class="summary-content-details-tag">
% if data['duration']:
Runtime <strong> <span id="runtime">${data['duration']}</span></strong>
@ -459,7 +467,7 @@ DOCUMENTATION :: END
</div>
</div>
<div class="table-card-back">
<div id="children-list" class="children-list"><i class="fa fa-refresh fa-spin"></i>&nbsp; Loading movies list...</div>
<div id="children-list" class="children-list"><i class="fa fa-refresh fa-spin"></i>&nbsp; Loading collection items...</div>
</div>
</div>
<div id="collection-related-list-container" style="display: none;">
@ -468,11 +476,11 @@ DOCUMENTATION :: END
<div class="col-md-12">
<div class="table-card-header">
<div class="header-bar">
<span>${'Track' if data['playlist_type'] == 'audio' else 'Video'} List for <strong>${data['title']}</strong></span>
<span>${MEDIA_TYPE_HEADERS[data['playlist_type']]} List for <strong>${data['title']}</strong></span>
</div>
</div>
<div class="table-card-back">
<div id="children-list" class="children-list"><i class="fa fa-refresh fa-spin"></i>&nbsp; Loading ${'track' if data['playlist_type'] == 'audio' else 'video'} list...</div>
<div id="children-list" class="children-list"><i class="fa fa-refresh fa-spin"></i>&nbsp; Loading playlist items...</div>
</div>
</div>
% endif

View file

@ -835,3 +835,16 @@ function user_page(user_id, user) {
return params;
}
MEDIA_TYPE_HEADERS = {
'movie': 'Movies',
'show': 'TV Shows',
'season': 'Seasons',
'episode': 'Episodes',
'artist': 'Artists',
'album': 'Albums',
'track': 'Tracks',
'video': 'Videos',
'audio': 'Tracks',
'photo': 'Photos'
}

View file

@ -73,7 +73,11 @@ collections_table_options = {
"data": "childCount",
"createdCell": function (td, cellData, rowData, row, col) {
if (cellData !== '') {
$(td).html(cellData);
var type = MEDIA_TYPE_HEADERS[rowData['subtype']] || '';
if (rowData['childCount'] == 1) {
type = type.slice(0, -1);
}
$(td).html(cellData + ' ' + type);
}
},
"width": "10%",

View file

@ -39,7 +39,11 @@ playlists_table_options = {
"data": "leafCount",
"createdCell": function (td, cellData, rowData, row, col) {
if (cellData !== '') {
$(td).html(cellData);
var type = MEDIA_TYPE_HEADERS[rowData['playlistType']] || '';
if (rowData['leafCount'] == 1) {
type = type.slice(0, -1);
}
$(td).html(cellData + ' ' + type);
}
},
"width": "20%",

View file

@ -73,6 +73,9 @@ MEDIA_TYPE_HEADERS = {
'artist': 'Artists',
'album': 'Albums',
'track': 'Tracks',
'video': 'Videos',
'audio': 'Tracks',
'photo': 'Photos'
}
PLATFORM_NAME_OVERRIDES = {

View file

@ -1271,7 +1271,7 @@ class PmsConnect(object):
'collections': collections,
'guids': guids,
'full_title': helpers.get_xml_attr(metadata_main, 'title'),
'children_count': helpers.cast_to_int(helpers.get_xml_attr(metadata_main, 'leafCount')),
'children_count': helpers.cast_to_int(helpers.get_xml_attr(metadata_main, 'childCount')),
'live': int(helpers.get_xml_attr(metadata_main, 'live') == '1')
}