feat(content-restrictions): add age rating and content rating support (#2619)
This commit is contained in:
+44
@@ -419,6 +419,50 @@
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="field-group small-field">
|
||||
<label for="ageRating">Age Rating</label>
|
||||
<div class="field-with-lock">
|
||||
<p-select
|
||||
id="ageRating"
|
||||
formControlName="ageRating"
|
||||
[options]="ageRatingOptions"
|
||||
optionLabel="label"
|
||||
optionValue="value"
|
||||
placeholder="Select"
|
||||
[showClear]="true"
|
||||
appendTo="body">
|
||||
</p-select>
|
||||
@if (!book.metadata!['ageRatingLocked']) {
|
||||
<p-button icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('ageRating')" severity="success"></p-button>
|
||||
}
|
||||
@if (book.metadata!['ageRatingLocked']) {
|
||||
<p-button icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('ageRating')" severity="warn"></p-button>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="field-group small-field">
|
||||
<label for="contentRating">Content Rating</label>
|
||||
<div class="field-with-lock">
|
||||
<p-select
|
||||
id="contentRating"
|
||||
formControlName="contentRating"
|
||||
[options]="contentRatingOptions"
|
||||
optionLabel="label"
|
||||
optionValue="value"
|
||||
placeholder="Select"
|
||||
[showClear]="true"
|
||||
appendTo="body">
|
||||
</p-select>
|
||||
@if (!book.metadata!['contentRatingLocked']) {
|
||||
<p-button icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('contentRating')" severity="success"></p-button>
|
||||
}
|
||||
@if (book.metadata!['contentRatingLocked']) {
|
||||
<p-button icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('contentRating')" severity="warn"></p-button>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
+39
@@ -21,6 +21,7 @@ import {DatePicker} from "primeng/datepicker";
|
||||
import {Textarea} from "primeng/textarea";
|
||||
import {Image} from "primeng/image";
|
||||
import {LazyLoadImageModule} from "ng-lazyload-image";
|
||||
import {Select} from "primeng/select";
|
||||
import {TaskHelperService} from '../../../../settings/task-management/task-helper.service';
|
||||
import {BookDialogHelperService} from "../../../../book/components/book-browser/book-dialog-helper.service";
|
||||
import {BookNavigationService} from '../../../../book/service/book-navigation.service';
|
||||
@@ -50,6 +51,7 @@ import {MetadataProviderSpecificFields} from '../../../../../shared/model/app-se
|
||||
Textarea,
|
||||
Image,
|
||||
LazyLoadImageModule,
|
||||
Select,
|
||||
],
|
||||
})
|
||||
export class MetadataEditorComponent implements OnInit {
|
||||
@@ -102,6 +104,9 @@ export class MetadataEditorComponent implements OnInit {
|
||||
filteredSeries: string[] = [];
|
||||
private metadataCenterViewMode: 'route' | 'dialog' = 'route';
|
||||
|
||||
contentRatingOptions: {label: string, value: string}[] = [];
|
||||
ageRatingOptions: {label: string, value: number}[] = [];
|
||||
|
||||
providerSpecificFields: MetadataProviderSpecificFields = {
|
||||
asin: true,
|
||||
amazonRating: true,
|
||||
@@ -246,7 +251,29 @@ export class MetadataEditorComponent implements OnInit {
|
||||
coverLocked: new FormControl(false),
|
||||
audiobookCoverLocked: new FormControl(false),
|
||||
reviewsLocked: new FormControl(false),
|
||||
ageRating: new FormControl(""),
|
||||
contentRating: new FormControl(""),
|
||||
ageRatingLocked: new FormControl(false),
|
||||
contentRatingLocked: new FormControl(false),
|
||||
});
|
||||
|
||||
this.contentRatingOptions = [
|
||||
{label: 'Everyone', value: 'EVERYONE'},
|
||||
{label: 'Teen', value: 'TEEN'},
|
||||
{label: 'Mature', value: 'MATURE'},
|
||||
{label: 'Adult', value: 'ADULT'},
|
||||
{label: 'Explicit', value: 'EXPLICIT'}
|
||||
];
|
||||
|
||||
this.ageRatingOptions = [
|
||||
{label: 'All Ages', value: 0},
|
||||
{label: '6+', value: 6},
|
||||
{label: '10+', value: 10},
|
||||
{label: '13+', value: 13},
|
||||
{label: '16+', value: 16},
|
||||
{label: '18+', value: 18},
|
||||
{label: '21+', value: 21}
|
||||
];
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
@@ -401,6 +428,10 @@ export class MetadataEditorComponent implements OnInit {
|
||||
coverLocked: metadata.coverLocked ?? false,
|
||||
audiobookCoverLocked: metadata.audiobookCoverLocked ?? false,
|
||||
reviewsLocked: metadata.reviewsLocked ?? false,
|
||||
ageRating: metadata.ageRating ?? null,
|
||||
contentRating: metadata.contentRating ?? null,
|
||||
ageRatingLocked: metadata.ageRatingLocked ?? false,
|
||||
contentRatingLocked: metadata.contentRatingLocked ?? false,
|
||||
});
|
||||
|
||||
const lockableFields: { key: keyof BookMetadata; control: string }[] = [
|
||||
@@ -443,6 +474,8 @@ export class MetadataEditorComponent implements OnInit {
|
||||
{key: "coverLocked", control: "thumbnailUrl"},
|
||||
{key: "audiobookCoverLocked", control: "audiobookCover"},
|
||||
{key: "reviewsLocked", control: "reviews"},
|
||||
{key: "ageRatingLocked", control: "ageRating"},
|
||||
{key: "contentRatingLocked", control: "contentRating"},
|
||||
];
|
||||
|
||||
for (const {key, control} of lockableFields) {
|
||||
@@ -634,6 +667,10 @@ export class MetadataEditorComponent implements OnInit {
|
||||
coverLocked: form.get("coverLocked")?.value,
|
||||
audiobookCoverLocked: form.get("audiobookCoverLocked")?.value,
|
||||
reviewsLocked: form.get("reviewsLocked")?.value,
|
||||
ageRating: form.get("ageRating")?.value,
|
||||
contentRating: form.get("contentRating")?.value,
|
||||
ageRatingLocked: form.get("ageRatingLocked")?.value,
|
||||
contentRatingLocked: form.get("contentRatingLocked")?.value,
|
||||
|
||||
...(shouldLockAllFields !== undefined && {
|
||||
allFieldsLocked: shouldLockAllFields,
|
||||
@@ -690,6 +727,8 @@ export class MetadataEditorComponent implements OnInit {
|
||||
seriesTotal: wasCleared("seriesTotal"),
|
||||
audiobookCover: wasCleared("audiobookCover"),
|
||||
cover: false,
|
||||
ageRating: wasCleared("ageRating"),
|
||||
contentRating: wasCleared("contentRating"),
|
||||
};
|
||||
|
||||
return {metadata, clearFlags};
|
||||
|
||||
+22
@@ -524,6 +524,28 @@
|
||||
}
|
||||
</div>
|
||||
|
||||
<div class="metadata-item">
|
||||
<span class="metadata-key">Age Rating:</span>
|
||||
@if (book?.metadata?.ageRating != null) {
|
||||
<span class="metadata-value metadata-link" (click)="goToAgeRating(book?.metadata?.ageRating!)">
|
||||
{{ getAgeRatingLabel(book?.metadata?.ageRating) }}
|
||||
</span>
|
||||
} @else {
|
||||
<span class="metadata-value">-</span>
|
||||
}
|
||||
</div>
|
||||
|
||||
<div class="metadata-item">
|
||||
<span class="metadata-key">Content Rating:</span>
|
||||
@if (book?.metadata?.contentRating) {
|
||||
<span class="metadata-value metadata-link" (click)="goToContentRating(book?.metadata?.contentRating!)">
|
||||
{{ getContentRatingLabel(book?.metadata?.contentRating) }}
|
||||
</span>
|
||||
} @else {
|
||||
<span class="metadata-value">-</span>
|
||||
}
|
||||
</div>
|
||||
|
||||
@if (hasDigitalFile(book)) {
|
||||
<div class="metadata-item">
|
||||
<span class="metadata-key">File Size:</span>
|
||||
|
||||
+20
-1
@@ -28,7 +28,7 @@ import {Image} from 'primeng/image';
|
||||
import {BookDialogHelperService} from '../../../../book/components/book-browser/book-dialog-helper.service';
|
||||
import {TagColor, TagComponent} from '../../../../../shared/components/tag/tag.component';
|
||||
import {TaskHelperService} from '../../../../settings/task-management/task-helper.service';
|
||||
import {fileSizeRanges, matchScoreRanges, pageCountRanges} from '../../../../book/components/book-browser/book-filter/book-filter.config';
|
||||
import {AGE_RATING_OPTIONS, CONTENT_RATING_LABELS, fileSizeRanges, matchScoreRanges, pageCountRanges} from '../../../../book/components/book-browser/book-filter/book-filter.config';
|
||||
import {BookNavigationService} from '../../../../book/service/book-navigation.service';
|
||||
import {Divider} from 'primeng/divider';
|
||||
import {BookMetadataHostService} from '../../../../../shared/service/book-metadata-host.service';
|
||||
@@ -832,6 +832,25 @@ export class MetadataViewerComponent implements OnInit, OnChanges {
|
||||
}
|
||||
}
|
||||
|
||||
goToAgeRating(ageRating: number): void {
|
||||
this.handleMetadataClick('ageRating', ageRating.toString());
|
||||
}
|
||||
|
||||
goToContentRating(contentRating: string): void {
|
||||
this.handleMetadataClick('contentRating', contentRating);
|
||||
}
|
||||
|
||||
getAgeRatingLabel(ageRating: number | null | undefined): string {
|
||||
if (ageRating == null) return '-';
|
||||
const match = AGE_RATING_OPTIONS.find(r => r.id === ageRating);
|
||||
return match?.label ?? `${ageRating}+`;
|
||||
}
|
||||
|
||||
getContentRatingLabel(contentRating: string | null | undefined): string {
|
||||
if (!contentRating) return '-';
|
||||
return CONTENT_RATING_LABELS[contentRating] ?? contentRating;
|
||||
}
|
||||
|
||||
private extractYear(dateString: string | null | undefined): string | null {
|
||||
if (!dateString) return null;
|
||||
const yearMatch = dateString.match(/\d{4}/);
|
||||
|
||||
Reference in New Issue
Block a user