mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Merge pull request #5760 from venkat-karasani/collection-header-names
This commit is contained in:
commit
cfa0ec6b53
1 changed files with 34 additions and 28 deletions
|
@ -1457,11 +1457,17 @@ function renderChildren(page, item) {
|
|||
imageLoader.lazyChildren(childrenItemsContainer);
|
||||
if (item.Type == 'BoxSet') {
|
||||
const collectionItemTypes = [{
|
||||
name: globalize.translate('HeaderVideos'),
|
||||
mediaType: 'Video'
|
||||
name: globalize.translate('Movies'),
|
||||
type: 'Movie'
|
||||
}, {
|
||||
name: globalize.translate('Series'),
|
||||
type: 'Series'
|
||||
}, {
|
||||
name: globalize.translate('Episodes'),
|
||||
type: 'Episode'
|
||||
}, {
|
||||
name: globalize.translate('HeaderVideos'),
|
||||
mediaType: 'Video'
|
||||
}, {
|
||||
name: globalize.translate('Albums'),
|
||||
type: 'MusicAlbum'
|
||||
|
@ -1626,13 +1632,16 @@ function inferContext(item) {
|
|||
}
|
||||
|
||||
function filterItemsByCollectionItemType(items, typeInfo) {
|
||||
return items.filter(function (item) {
|
||||
if (typeInfo.mediaType) {
|
||||
return item.MediaType == typeInfo.mediaType;
|
||||
const filteredItems = [];
|
||||
const leftoverItems = [];
|
||||
items.forEach(function(item) {
|
||||
if ((typeInfo.mediaType && item.MediaType == typeInfo.mediaType) || (item.Type == typeInfo.type)) {
|
||||
filteredItems.push(item);
|
||||
} else {
|
||||
leftoverItems.push(item);
|
||||
}
|
||||
|
||||
return item.Type == typeInfo.type;
|
||||
});
|
||||
return [filteredItems, leftoverItems];
|
||||
}
|
||||
|
||||
function canPlaySomeItemInCollection(items) {
|
||||
|
@ -1651,31 +1660,28 @@ function renderCollectionItems(page, parentItem, types, items) {
|
|||
page.querySelector('.collectionItems').classList.remove('hide');
|
||||
page.querySelector('.collectionItems').innerHTML = '';
|
||||
|
||||
for (const type of types) {
|
||||
const typeItems = filterItemsByCollectionItemType(items, type);
|
||||
|
||||
if (typeItems.length) {
|
||||
renderCollectionItemType(page, parentItem, type, typeItems);
|
||||
}
|
||||
}
|
||||
|
||||
const otherType = {
|
||||
name: globalize.translate('HeaderOtherItems')
|
||||
};
|
||||
const otherTypeItems = items.filter(function (curr) {
|
||||
return !types.filter(function (t) {
|
||||
return filterItemsByCollectionItemType([curr], t).length > 0;
|
||||
}).length;
|
||||
});
|
||||
|
||||
if (otherTypeItems.length) {
|
||||
renderCollectionItemType(page, parentItem, otherType, otherTypeItems);
|
||||
}
|
||||
|
||||
if (!items.length) {
|
||||
renderCollectionItemType(page, parentItem, {
|
||||
name: globalize.translate('Items')
|
||||
}, items);
|
||||
} else {
|
||||
let typeItems = [];
|
||||
let otherTypeItems = items;
|
||||
|
||||
for (const type of types) {
|
||||
[typeItems, otherTypeItems] = filterItemsByCollectionItemType(otherTypeItems, type);
|
||||
|
||||
if (typeItems.length) {
|
||||
renderCollectionItemType(page, parentItem, type, typeItems);
|
||||
}
|
||||
}
|
||||
|
||||
if (otherTypeItems.length) {
|
||||
const otherType = {
|
||||
name: globalize.translate('HeaderOtherItems')
|
||||
};
|
||||
renderCollectionItemType(page, parentItem, otherType, otherTypeItems);
|
||||
}
|
||||
}
|
||||
|
||||
const containers = page.querySelectorAll('.collectionItemsContainer');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue