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);
|
imageLoader.lazyChildren(childrenItemsContainer);
|
||||||
if (item.Type == 'BoxSet') {
|
if (item.Type == 'BoxSet') {
|
||||||
const collectionItemTypes = [{
|
const collectionItemTypes = [{
|
||||||
name: globalize.translate('HeaderVideos'),
|
name: globalize.translate('Movies'),
|
||||||
mediaType: 'Video'
|
type: 'Movie'
|
||||||
}, {
|
}, {
|
||||||
name: globalize.translate('Series'),
|
name: globalize.translate('Series'),
|
||||||
type: 'Series'
|
type: 'Series'
|
||||||
|
}, {
|
||||||
|
name: globalize.translate('Episodes'),
|
||||||
|
type: 'Episode'
|
||||||
|
}, {
|
||||||
|
name: globalize.translate('HeaderVideos'),
|
||||||
|
mediaType: 'Video'
|
||||||
}, {
|
}, {
|
||||||
name: globalize.translate('Albums'),
|
name: globalize.translate('Albums'),
|
||||||
type: 'MusicAlbum'
|
type: 'MusicAlbum'
|
||||||
|
@ -1626,13 +1632,16 @@ function inferContext(item) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function filterItemsByCollectionItemType(items, typeInfo) {
|
function filterItemsByCollectionItemType(items, typeInfo) {
|
||||||
return items.filter(function (item) {
|
const filteredItems = [];
|
||||||
if (typeInfo.mediaType) {
|
const leftoverItems = [];
|
||||||
return item.MediaType == typeInfo.mediaType;
|
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) {
|
function canPlaySomeItemInCollection(items) {
|
||||||
|
@ -1651,31 +1660,28 @@ function renderCollectionItems(page, parentItem, types, items) {
|
||||||
page.querySelector('.collectionItems').classList.remove('hide');
|
page.querySelector('.collectionItems').classList.remove('hide');
|
||||||
page.querySelector('.collectionItems').innerHTML = '';
|
page.querySelector('.collectionItems').innerHTML = '';
|
||||||
|
|
||||||
|
if (!items.length) {
|
||||||
|
renderCollectionItemType(page, parentItem, {
|
||||||
|
name: globalize.translate('Items')
|
||||||
|
}, items);
|
||||||
|
} else {
|
||||||
|
let typeItems = [];
|
||||||
|
let otherTypeItems = items;
|
||||||
|
|
||||||
for (const type of types) {
|
for (const type of types) {
|
||||||
const typeItems = filterItemsByCollectionItemType(items, type);
|
[typeItems, otherTypeItems] = filterItemsByCollectionItemType(otherTypeItems, type);
|
||||||
|
|
||||||
if (typeItems.length) {
|
if (typeItems.length) {
|
||||||
renderCollectionItemType(page, parentItem, type, typeItems);
|
renderCollectionItemType(page, parentItem, type, typeItems);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (otherTypeItems.length) {
|
||||||
const otherType = {
|
const otherType = {
|
||||||
name: globalize.translate('HeaderOtherItems')
|
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);
|
renderCollectionItemType(page, parentItem, otherType, otherTypeItems);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!items.length) {
|
|
||||||
renderCollectionItemType(page, parentItem, {
|
|
||||||
name: globalize.translate('Items')
|
|
||||||
}, items);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const containers = page.querySelectorAll('.collectionItemsContainer');
|
const containers = page.querySelectorAll('.collectionItemsContainer');
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue