mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Migrate Movies
This commit is contained in:
parent
122c4ae600
commit
479c53eb8b
21 changed files with 1713 additions and 7 deletions
48
src/view/components/AlphaPickerContainer.tsx
Normal file
48
src/view/components/AlphaPickerContainer.tsx
Normal file
|
@ -0,0 +1,48 @@
|
|||
import React, { FunctionComponent, useEffect, useRef, useState } from 'react';
|
||||
import AlphaPicker from '../../components/alphaPicker/alphaPicker';
|
||||
import { IQuery } from './type';
|
||||
|
||||
type AlphaPickerProps = {
|
||||
query: IQuery;
|
||||
reloadItems: () => void;
|
||||
};
|
||||
|
||||
const AlphaPickerContainer: FunctionComponent<AlphaPickerProps> = ({ query, reloadItems }: AlphaPickerProps) => {
|
||||
const [ alphaPicker, setAlphaPicker ] = useState<AlphaPicker>();
|
||||
const element = useRef<HTMLDivElement>(null);
|
||||
|
||||
alphaPicker?.updateControls(query);
|
||||
|
||||
useEffect(() => {
|
||||
const alphaPickerElement = element.current?.querySelector('.alphaPicker');
|
||||
|
||||
if (alphaPickerElement) {
|
||||
alphaPickerElement.addEventListener('alphavaluechanged', (e) => {
|
||||
const newValue = (e as CustomEvent).detail.value;
|
||||
if (newValue === '#') {
|
||||
query.NameLessThan = 'A';
|
||||
delete query.NameStartsWith;
|
||||
} else {
|
||||
query.NameStartsWith = newValue;
|
||||
delete query.NameLessThan;
|
||||
}
|
||||
query.StartIndex = 0;
|
||||
reloadItems();
|
||||
});
|
||||
setAlphaPicker(new AlphaPicker({
|
||||
element: alphaPickerElement,
|
||||
valueChangeEvent: 'click'
|
||||
}));
|
||||
|
||||
alphaPickerElement.classList.add('alphaPicker-fixed-right');
|
||||
}
|
||||
}, [query, reloadItems, setAlphaPicker]);
|
||||
|
||||
return (
|
||||
<div ref={element}>
|
||||
<div className='alphaPicker alphaPicker-fixed alphaPicker-vertical alphabetPicker-right' />
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default AlphaPickerContainer;
|
Loading…
Add table
Add a link
Reference in a new issue