diff --git a/bun.lockb b/bun.lockb
index 406a9aa..e87c6d2 100755
Binary files a/bun.lockb and b/bun.lockb differ
diff --git a/src/app/app.component.html b/src/app/app.component.html
index f8a40e6..9d6327c 100644
--- a/src/app/app.component.html
+++ b/src/app/app.component.html
@@ -1,13 +1,21 @@
Upload
-
-
-
- Clear
+
Save
+ @if (this.elements.length){
+
+ Clear translations
+
+
+ Translate all
+
+
+ Clear
+
+ }
diff --git a/src/app/app.component.ts b/src/app/app.component.ts
index a296e85..0243214 100644
--- a/src/app/app.component.ts
+++ b/src/app/app.component.ts
@@ -1,3 +1,4 @@
+import { NgIf } from '@angular/common';
import { Component, OnInit, ViewChild } from '@angular/core';
import { NWUIButtonComponent } from '@nwaifu-ui';
import { TextListComponent } from './components/text_list/text_list.component';
@@ -7,7 +8,7 @@ import { saveOriginalFile } from './lib/file_tools';
import { parse } from './lib/parser';
@Component({
standalone: true,
- imports: [TextListComponent, NWUIButtonComponent],
+ imports: [TextListComponent, NWUIButtonComponent, NgIf],
selector: 'app-root',
templateUrl: './app.component.html',
styleUrl: './app.component.scss',
@@ -16,6 +17,7 @@ export class AppComponent implements OnInit {
title = 'NitroPlusTranslator';
elements: TranslateData[] = [];
@ViewChild('fileInput') fileInput: HTMLInputElement | null = null;
+ @ViewChild(TextListComponent) text_list: TextListComponent | null = null;
ngOnInit(): void {
const data = localStorage.getItem(LocalStorageKeys.TRANSLATIONS);
@@ -85,4 +87,22 @@ export class AppComponent implements OnInit {
element.click();
}
}
+
+ //TODO: Dialog windows for clear op
+ clearAllTranslations() {
+ if (this.text_list)
+ if (this.text_list.translate_blocks) {
+ this.text_list.translate_blocks.filter((item) => item.item.translated_text).forEach((item) => item.clear());
+ }
+ }
+
+ getAllTranslations() {
+ if (this.text_list)
+ if (this.text_list.translate_blocks)
+ this.text_list.translate_blocks.forEach((item) => item.sendToGoogleTranslate());
+ }
+
+ get has_translations(): boolean {
+ return this.elements.some((i) => i.translated_text);
+ }
}
diff --git a/src/app/components/text_list/text_list.component.html b/src/app/components/text_list/text_list.component.html
index 744fd31..2040557 100644
--- a/src/app/components/text_list/text_list.component.html
+++ b/src/app/components/text_list/text_list.component.html
@@ -1,6 +1,6 @@
Всего: {{ elements_data.length }}
@for(item of elements_data; track $index) {
-
+
}
diff --git a/src/app/components/text_list/text_list.component.ts b/src/app/components/text_list/text_list.component.ts
index ab8899c..a6e130c 100644
--- a/src/app/components/text_list/text_list.component.ts
+++ b/src/app/components/text_list/text_list.component.ts
@@ -1,5 +1,5 @@
import { CommonModule } from '@angular/common';
-import { Component, Input } from '@angular/core';
+import { Component, Input, QueryList, ViewChildren } from '@angular/core';
import { TranslateData } from '../../dto/translate_data.dto';
import { TranslateBlockComponent } from '../translate_block/translate_block.component';
@@ -11,6 +11,7 @@ import { TranslateBlockComponent } from '../translate_block/translate_block.comp
imports: [CommonModule, TranslateBlockComponent],
})
export class TextListComponent {
+ @ViewChildren('translateBlock') translate_blocks: QueryList | null = null;
elements_data: TranslateData[] = [];
@Input() set elements(el: TranslateData[]) {
this.elements_data = el;