Remove remainder of file name editing from the edit sidebar

Signed-off-by: trivernis <trivernis@protonmail.com>
pull/4/head
trivernis 3 years ago
parent 0563c928d1
commit d03409ef21

@ -11,7 +11,6 @@ import {File} from "../../../../models/File";
import {Tag} from "../../../../models/Tag"; import {Tag} from "../../../../models/Tag";
import {CdkVirtualScrollViewport} from "@angular/cdk/scrolling"; import {CdkVirtualScrollViewport} from "@angular/cdk/scrolling";
import {TagService} from "../../../../services/tag/tag.service"; import {TagService} from "../../../../services/tag/tag.service";
import {FileService} from "../../../../services/file/file.service";
@Component({ @Component({
selector: "app-tag-edit", selector: "app-tag-edit",
@ -26,12 +25,10 @@ export class TagEditComponent implements OnInit, OnChanges {
public allTags: Tag[] = []; public allTags: Tag[] = [];
public editMode: string = "Toggle"; public editMode: string = "Toggle";
@ViewChild("tagScroll") tagScroll!: CdkVirtualScrollViewport; @ViewChild("tagScroll") tagScroll!: CdkVirtualScrollViewport;
@ViewChild("fileNameInput") fileNameInput!: ElementRef<HTMLInputElement>;
private fileTags: { [key: number]: Tag[] } = {}; private fileTags: { [key: number]: Tag[] } = {};
constructor( constructor(
private tagService: TagService, private tagService: TagService,
private fileService: FileService,
) { ) {
} }
@ -39,27 +36,11 @@ export class TagEditComponent implements OnInit, OnChanges {
this.tagService.tags.subscribe(tags => this.allTags = tags); this.tagService.tags.subscribe(tags => this.allTags = tags);
await this.tagService.loadTags(); await this.tagService.loadTags();
await this.loadFileTags(); await this.loadFileTags();
this.resetFileNameInput();
} }
async ngOnChanges(changes: SimpleChanges) { async ngOnChanges(changes: SimpleChanges) {
if (changes["files"]) { if (changes["files"]) {
await this.loadFileTags() await this.loadFileTags()
this.resetFileNameInput();
}
}
public async changeFileName(value: string) {
const name = value.trim();
if (name.length > 0) {
const file = this.files[0];
console.log("Updating name to", name);
const responseFile = await this.fileService.updateFileName(file,
name);
console.log("Updated name");
file.name = responseFile.name;
this.resetFileNameInput();
} }
} }
@ -137,12 +118,6 @@ export class TagEditComponent implements OnInit, OnChanges {
this.mapFileTagsToTagList(); this.mapFileTagsToTagList();
} }
private resetFileNameInput() {
if (this.files.length === 1) {
this.fileNameInput.nativeElement.value = this.files[0].name ?? "";
}
}
private mapFileTagsToTagList() { private mapFileTagsToTagList() {
let tags: Tag[] = []; let tags: Tag[] = [];
for (const file of this.files) { for (const file of this.files) {

Loading…
Cancel
Save