1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00

apply suggestions

This commit is contained in:
grafixeyehero 2022-01-22 19:20:09 +03:00
parent f5b69e0de3
commit 76f9b9c929
4 changed files with 20 additions and 14 deletions

View file

@ -12,7 +12,7 @@ const createButtonElement = ({tag}) => ({
}); });
type IProps = { type IProps = {
tag: any; tag?: string;
} }
const BlockedTagList: FunctionComponent<IProps> = ({tag}: IProps) => { const BlockedTagList: FunctionComponent<IProps> = ({tag}: IProps) => {

View file

@ -4,30 +4,31 @@ type IProps = {
className?: string; className?: string;
Name?: string; Name?: string;
Id?: string; Id?: string;
ItemType?: string;
AppName?: string; AppName?: string;
checkedAttribute?: string; checkedAttribute?: string;
} }
const createCheckBoxElement = ({className, Name, Id, AppName, checkedAttribute}) => ({ const createCheckBoxElement = ({className, Name, dataAttributes, AppName, checkedAttribute}) => ({
__html: `<label> __html: `<label>
<input <input
type="checkbox" type="checkbox"
is="emby-checkbox" is="emby-checkbox"
class="${className}" class="${className}"
data-id="${Id}" ${checkedAttribute} ${dataAttributes} ${checkedAttribute}
/> />
<span>${Name} ${AppName}</span> <span>${Name} ${AppName}</span>
</label>` </label>`
}); });
const CheckBoxListItem: FunctionComponent<IProps> = ({className, Name, Id, AppName, checkedAttribute}: IProps) => { const CheckBoxListItem: FunctionComponent<IProps> = ({className, Name, Id, ItemType, AppName, checkedAttribute}: IProps) => {
return ( return (
<div <div
className='sectioncheckbox' className='sectioncheckbox'
dangerouslySetInnerHTML={createCheckBoxElement({ dangerouslySetInnerHTML={createCheckBoxElement({
className: className, className: className,
Name: Name, Name: Name,
Id: Id, dataAttributes: ItemType ? `data-itemtype='${ItemType}'` : `data-id='${Id}'`,
AppName: AppName ? `- ${AppName}` : '', AppName: AppName ? `- ${AppName}` : '',
checkedAttribute: checkedAttribute checkedAttribute: checkedAttribute
})} })}

View file

@ -12,16 +12,21 @@ const createSelectElement = ({ className, label, option }) => ({
</select>` </select>`
}); });
type RatingsArr = {
Name: string;
Value: number;
}
type IProps = { type IProps = {
className?: string; className?: string;
label?: string; label?: string;
parentalRatings: any parentalRatings: RatingsArr[];
} }
const SelectMaxParentalRating: FunctionComponent<IProps> = ({ className, label, parentalRatings }: IProps) => { const SelectMaxParentalRating: FunctionComponent<IProps> = ({ className, label, parentalRatings }: IProps) => {
const renderOption = ratings => { const renderOption = () => {
let content = ''; let content = '';
for (const rating of ratings) { for (const rating of parentalRatings) {
content += `<option value='${rating.Value}'>${rating.Name}</option>`; content += `<option value='${rating.Value}'>${rating.Name}</option>`;
} }
return content; return content;
@ -32,7 +37,7 @@ const SelectMaxParentalRating: FunctionComponent<IProps> = ({ className, label,
dangerouslySetInnerHTML={createSelectElement({ dangerouslySetInnerHTML={createSelectElement({
className: className, className: className,
label: globalize.translate(label), label: globalize.translate(label),
option: renderOption(parentalRatings) option: renderOption()
})} })}
/> />
); );

View file

@ -13,9 +13,9 @@ import SectionTabs from '../dashboard/users/SectionTabs';
import loading from '../loading/loading'; import loading from '../loading/loading';
import toast from '../toast/toast'; import toast from '../toast/toast';
type Ratings = { type RatingsArr = {
Name: string; Name: string;
Value: string; Value: number;
} }
type ItemsArr = { type ItemsArr = {
@ -35,7 +35,7 @@ const UserParentalControl: FunctionComponent = () => {
const populateRatings = useCallback((allParentalRatings) => { const populateRatings = useCallback((allParentalRatings) => {
let rating; let rating;
const ratings: Ratings[] = []; const ratings: RatingsArr[] = [];
for (let i = 0, length = allParentalRatings.length; i < length; i++) { for (let i = 0, length = allParentalRatings.length; i < length; i++) {
rating = allParentalRatings[i]; rating = allParentalRatings[i];
@ -186,7 +186,7 @@ const UserParentalControl: FunctionComponent = () => {
user.Policy.BlockUnratedItems = Array.prototype.filter.call(element?.current?.querySelectorAll('.chkUnratedItem'), function (i) { user.Policy.BlockUnratedItems = Array.prototype.filter.call(element?.current?.querySelectorAll('.chkUnratedItem'), function (i) {
return i.checked; return i.checked;
}).map(function (i) { }).map(function (i) {
return i.getAttribute('data-id'); return i.getAttribute('data-itemtype');
}); });
user.Policy.AccessSchedules = getSchedulesFromPage(); user.Policy.AccessSchedules = getSchedulesFromPage();
user.Policy.BlockedTags = getBlockedTagsFromPage(); user.Policy.BlockedTags = getBlockedTagsFromPage();
@ -303,7 +303,7 @@ const UserParentalControl: FunctionComponent = () => {
return <CheckBoxListItem return <CheckBoxListItem
key={Item.value} key={Item.value}
className='chkUnratedItem' className='chkUnratedItem'
Id={Item.value} ItemType={Item.value}
Name={Item.name} Name={Item.name}
checkedAttribute={Item.checkedAttribute} checkedAttribute={Item.checkedAttribute}
/>; />;