mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Add paging to listview
This commit is contained in:
parent
afd37d6287
commit
f942465afc
2 changed files with 75 additions and 6 deletions
|
@ -3,6 +3,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="flex-grow padded-left padded-right padded-bottom-page pageContainerTopPadding">
|
<div class="flex-grow padded-left padded-right padded-bottom-page pageContainerTopPadding">
|
||||||
<div class="flex align-items-center focuscontainer-x itemsViewSettingsContainer padded-top padded-bottom flex-wrap-wrap">
|
<div class="flex align-items-center focuscontainer-x itemsViewSettingsContainer padded-top padded-bottom flex-wrap-wrap">
|
||||||
|
<div class="paging"></div>
|
||||||
<button is="emby-button" class="btnPlay button-flat hide listTextButton-autohide">
|
<button is="emby-button" class="btnPlay button-flat hide listTextButton-autohide">
|
||||||
<span>${HeaderPlayAll}</span>
|
<span>${HeaderPlayAll}</span>
|
||||||
</button>
|
</button>
|
||||||
|
@ -50,5 +51,8 @@
|
||||||
</div>
|
</div>
|
||||||
<div is="emby-itemscontainer" class="vertical-wrap itemsContainer centered">
|
<div is="emby-itemscontainer" class="vertical-wrap itemsContainer centered">
|
||||||
</div>
|
</div>
|
||||||
|
<div class="flex align-items-center justify-content-center flex-wrap-wrap padded-top padded-left padded-right padded-bottom focuscontainer-x">
|
||||||
|
<div class="paging"></div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
import globalize from '../scripts/globalize';
|
import globalize from '../scripts/globalize';
|
||||||
import listView from '../components/listview/listview';
|
import listView from '../components/listview/listview';
|
||||||
import layoutManager from '../components/layoutManager';
|
|
||||||
import * as userSettings from '../scripts/settings/userSettings';
|
import * as userSettings from '../scripts/settings/userSettings';
|
||||||
import focusManager from '../components/focusManager';
|
import focusManager from '../components/focusManager';
|
||||||
import cardBuilder from '../components/cardbuilder/cardBuilder';
|
import cardBuilder from '../components/cardbuilder/cardBuilder';
|
||||||
import loading from '../components/loading/loading';
|
import loading from '../components/loading/loading';
|
||||||
import AlphaNumericShortcuts from '../scripts/alphanumericshortcuts';
|
import AlphaNumericShortcuts from '../scripts/alphanumericshortcuts';
|
||||||
|
import libraryBrowser from '../scripts/libraryBrowser';
|
||||||
import { playbackManager } from '../components/playback/playbackmanager';
|
import { playbackManager } from '../components/playback/playbackmanager';
|
||||||
import AlphaPicker from '../components/alphaPicker/alphaPicker';
|
import AlphaPicker from '../components/alphaPicker/alphaPicker';
|
||||||
import '../elements/emby-itemscontainer/emby-itemscontainer';
|
import '../elements/emby-itemscontainer/emby-itemscontainer';
|
||||||
|
@ -423,14 +423,75 @@ import { appRouter } from '../components/appRouter';
|
||||||
|
|
||||||
class ItemsView {
|
class ItemsView {
|
||||||
constructor(view, params) {
|
constructor(view, params) {
|
||||||
|
const query = {
|
||||||
|
StartIndex: 0,
|
||||||
|
Limit: undefined
|
||||||
|
};
|
||||||
|
|
||||||
|
if (userSettings.libraryPageSize() > 0) {
|
||||||
|
query['Limit'] = userSettings.libraryPageSize();
|
||||||
|
}
|
||||||
|
|
||||||
|
let isLoading = false;
|
||||||
|
|
||||||
|
function onNextPageClick() {
|
||||||
|
if (!isLoading && query.Limit > 0) {
|
||||||
|
query.StartIndex += query.Limit;
|
||||||
|
self.itemsContainer.refreshItems().then(() => {
|
||||||
|
window.scrollTo(0, 0);
|
||||||
|
autoFocus();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function onPreviousPageClick() {
|
||||||
|
if (!isLoading && query.Limit > 0) {
|
||||||
|
query.StartIndex = Math.max(0, query.StartIndex - query.Limit);
|
||||||
|
self.itemsContainer.refreshItems().then(() => {
|
||||||
|
window.scrollTo(0, 0);
|
||||||
|
autoFocus();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function updatePaging(startIndex, totalRecordCount, limit) {
|
||||||
|
const pagingHtml = libraryBrowser.getQueryPagingHtml({
|
||||||
|
startIndex,
|
||||||
|
limit,
|
||||||
|
totalRecordCount,
|
||||||
|
showLimit: false,
|
||||||
|
updatePageSizeSetting: false,
|
||||||
|
addLayoutButton: false,
|
||||||
|
sortButton: false,
|
||||||
|
filterButton: false
|
||||||
|
});
|
||||||
|
|
||||||
|
for (const elem of view.querySelectorAll('.paging')) {
|
||||||
|
elem.innerHTML = pagingHtml;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const elem of view.querySelectorAll('.btnNextPage')) {
|
||||||
|
elem.addEventListener('click', onNextPageClick);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const elem of view.querySelectorAll('.btnPreviousPage')) {
|
||||||
|
elem.addEventListener('click', onPreviousPageClick);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function fetchData() {
|
function fetchData() {
|
||||||
return getItems(self, params, self.currentItem).then(function (result) {
|
isLoading = true;
|
||||||
|
|
||||||
|
return getItems(self, params, self.currentItem, null, query.StartIndex, query.Limit).then(function (result) {
|
||||||
if (self.totalItemCount == null) {
|
if (self.totalItemCount == null) {
|
||||||
self.totalItemCount = result.Items ? result.Items.length : result.length;
|
self.totalItemCount = result.Items ? result.Items.length : result.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
updateAlphaPickerState(self, self.totalItemCount);
|
updateAlphaPickerState(self, self.totalItemCount);
|
||||||
|
updatePaging(result.StartIndex, result.TotalRecordCount, query.Limit);
|
||||||
return result;
|
return result;
|
||||||
|
}).finally(() => {
|
||||||
|
isLoading = false;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -559,15 +620,13 @@ class ItemsView {
|
||||||
|
|
||||||
self.alphaPicker = new AlphaPicker({
|
self.alphaPicker = new AlphaPicker({
|
||||||
element: alphaPickerElement,
|
element: alphaPickerElement,
|
||||||
itemsContainer: layoutManager.tv ? self.itemsContainer : null,
|
valueChangeEvent: 'click'
|
||||||
itemClass: 'card',
|
|
||||||
valueChangeEvent: layoutManager.tv ? null : 'click'
|
|
||||||
});
|
});
|
||||||
self.alphaPicker.on('alphavaluechanged', onAlphaPickerValueChanged);
|
self.alphaPicker.on('alphavaluechanged', onAlphaPickerValueChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
function onAlphaPickerValueChanged() {
|
function onAlphaPickerValueChanged() {
|
||||||
self.alphaPicker.value();
|
query.StartIndex = 0;
|
||||||
self.itemsContainer.refreshItems();
|
self.itemsContainer.refreshItems();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -710,6 +769,12 @@ class ItemsView {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function autoFocus() {
|
||||||
|
import('../components/autoFocuser').then(({default: autoFocuser}) => {
|
||||||
|
autoFocuser.autoFocus(view);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
const self = this;
|
const self = this;
|
||||||
self.params = params;
|
self.params = params;
|
||||||
this.itemsContainer = view.querySelector('.itemsContainer');
|
this.itemsContainer = view.querySelector('.itemsContainer');
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue