mirror of
https://github.com/Tzahi12345/YoutubeDL-Material.git
synced 2026-04-08 05:01:30 +03:00
Refactored retrieval of categories and improved runtime search of files in category
Fixed issue with editing/saving categories Database queries can now handle nested object paths Code cleanup
This commit is contained in:
@@ -28,12 +28,12 @@
|
||||
<mat-form-field class="info-field">
|
||||
<input [(ngModel)]="new_file.thumbnailURL" matInput placeholder="Thumbnail URL" i18n-placeholder="Thumbnail URL" [disabled]="!editing || new_file.thumbnailPath">
|
||||
</mat-form-field>
|
||||
<mat-form-field class="info-field">
|
||||
<mat-select placeholder="Category" i18n-placeholder="Category" [value]="category" (valueChange)="categoryChanged($event)" [compareWith]="categoryComparisonFunction" [disabled]="!editing">
|
||||
<mat-form-field *ngIf="initialized && postsService.categories" class="info-field">
|
||||
<mat-select placeholder="Category" i18n-placeholder="Category" [value]="category" (selectionChange)="categoryChanged($event)" [compareWith]="categoryComparisonFunction" [disabled]="!editing">
|
||||
<mat-option [value]="{}">
|
||||
N/A
|
||||
</mat-option>
|
||||
<mat-option *ngFor="let available_category of postsService.categories | keyvalue" [value]="available_category">
|
||||
<mat-option *ngFor="let available_category of postsService.categories | keyvalue" [value]="available_category.value">
|
||||
{{available_category.value.name}}
|
||||
</mat-option>
|
||||
</mat-select>
|
||||
|
||||
@@ -18,6 +18,7 @@ export class VideoInfoDialogComponent implements OnInit {
|
||||
upload_date: Date;
|
||||
category: Category;
|
||||
editing = false;
|
||||
initialized = false;
|
||||
|
||||
constructor(@Inject(MAT_DIALOG_DATA) public data: any, public postsService: PostsService, private datePipe: DatePipe) { }
|
||||
|
||||
@@ -37,15 +38,16 @@ export class VideoInfoDialogComponent implements OnInit {
|
||||
this.upload_date = new Date(this.new_file.upload_date);
|
||||
this.upload_date.setMinutes( this.upload_date.getMinutes() + this.upload_date.getTimezoneOffset() );
|
||||
|
||||
this.category = this.file.category ? this.category : {};
|
||||
this.category = this.file.category ? this.file.category : {};
|
||||
|
||||
// we need to align whether missing category is null or undefined. this line helps with that.
|
||||
if (!this.file.category) { this.new_file.category = null; this.file.category = null; }
|
||||
this.initialized = true;
|
||||
}
|
||||
|
||||
saveChanges(): void {
|
||||
const change_obj = {};
|
||||
const keys = Object.keys(this.file);
|
||||
const keys = Object.keys(this.new_file);
|
||||
keys.forEach(key => {
|
||||
if (this.file[key] !== this.new_file[key]) change_obj[key] = this.new_file[key];
|
||||
});
|
||||
@@ -67,7 +69,8 @@ export class VideoInfoDialogComponent implements OnInit {
|
||||
}
|
||||
|
||||
categoryChanged(event): void {
|
||||
this.new_file.category = Object.keys(event).length ? {uid: event.uid, name: event.name} : null;
|
||||
const new_category = event.value;
|
||||
this.new_file.category = Object.keys(new_category).length ? {uid: new_category.uid, name: new_category.name} : null;
|
||||
}
|
||||
|
||||
categoryComparisonFunction(option: Category, value: Category): boolean {
|
||||
|
||||
Reference in New Issue
Block a user