Merge branch 'feature/translate-clear-all-btns-#6-7' into dev
This commit is contained in:
@@ -1,13 +1,21 @@
|
|||||||
<div class="btns">
|
<div class="btns">
|
||||||
<nwui-button (click)="fileInput.click()">
|
<nwui-button (click)="fileInput.click()">
|
||||||
<span><i class="lni lni-upload"></i> Upload</span>
|
<span><i class="lni lni-upload"></i> Upload</span>
|
||||||
<input type="file" (change)="submitFile($event)" #fileInput style="display: none" />
|
<input type="file" (change)="submitFile($event)" accept=".nps" #fileInput style="display: none" />
|
||||||
</nwui-button>
|
|
||||||
<nwui-button (click)="onClearClicked()">
|
|
||||||
<span><i class="lni lni-trash-can"></i> Clear</span>
|
|
||||||
</nwui-button>
|
</nwui-button>
|
||||||
<nwui-button (click)="onSaveClicked()">
|
<nwui-button (click)="onSaveClicked()">
|
||||||
<span><i class="lni lni-save"></i> Save</span>
|
<span><i class="lni lni-save"></i> Save</span>
|
||||||
</nwui-button>
|
</nwui-button>
|
||||||
|
@if (this.elements.length){
|
||||||
|
<nwui-button (click)="clearAllTranslations()" [disabled]="!has_translations">
|
||||||
|
<span><i class="lni lni-trash-can"></i> Clear translations</span>
|
||||||
|
</nwui-button>
|
||||||
|
<nwui-button (click)="getAllTranslations()">
|
||||||
|
<span><i class="lni lni-google"></i> Translate all</span>
|
||||||
|
</nwui-button>
|
||||||
|
<nwui-button (click)="onClearClicked()">
|
||||||
|
<span><i class="lni lni-trash-can"></i> Clear</span>
|
||||||
|
</nwui-button>
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
<app-text-list [elements]="elements"></app-text-list>
|
<app-text-list [elements]="elements"></app-text-list>
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { NgIf } from '@angular/common';
|
||||||
import { Component, OnInit, ViewChild } from '@angular/core';
|
import { Component, OnInit, ViewChild } from '@angular/core';
|
||||||
import { NWUIButtonComponent } from '@nwaifu-ui';
|
import { NWUIButtonComponent } from '@nwaifu-ui';
|
||||||
import { TextListComponent } from './components/text_list/text_list.component';
|
import { TextListComponent } from './components/text_list/text_list.component';
|
||||||
@@ -7,7 +8,7 @@ import { saveOriginalFile } from './lib/file_tools';
|
|||||||
import { parse } from './lib/parser';
|
import { parse } from './lib/parser';
|
||||||
@Component({
|
@Component({
|
||||||
standalone: true,
|
standalone: true,
|
||||||
imports: [TextListComponent, NWUIButtonComponent],
|
imports: [TextListComponent, NWUIButtonComponent, NgIf],
|
||||||
selector: 'app-root',
|
selector: 'app-root',
|
||||||
templateUrl: './app.component.html',
|
templateUrl: './app.component.html',
|
||||||
styleUrl: './app.component.scss',
|
styleUrl: './app.component.scss',
|
||||||
@@ -16,6 +17,7 @@ export class AppComponent implements OnInit {
|
|||||||
title = 'NitroPlusTranslator';
|
title = 'NitroPlusTranslator';
|
||||||
elements: TranslateData[] = [];
|
elements: TranslateData[] = [];
|
||||||
@ViewChild('fileInput') fileInput: HTMLInputElement | null = null;
|
@ViewChild('fileInput') fileInput: HTMLInputElement | null = null;
|
||||||
|
@ViewChild(TextListComponent) text_list: TextListComponent | null = null;
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
const data = localStorage.getItem(LocalStorageKeys.TRANSLATIONS);
|
const data = localStorage.getItem(LocalStorageKeys.TRANSLATIONS);
|
||||||
@@ -85,4 +87,22 @@ export class AppComponent implements OnInit {
|
|||||||
element.click();
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<h1 *ngIf="elements_data.length">Всего: {{ elements_data.length }}</h1>
|
<h1 *ngIf="elements_data.length">Всего: {{ elements_data.length }}</h1>
|
||||||
<div id="elements">
|
<div id="elements">
|
||||||
@for(item of elements_data; track $index) {
|
@for(item of elements_data; track $index) {
|
||||||
<app-translate-block [index]="$index" [item]="item"></app-translate-block>
|
<app-translate-block #translateBlock [index]="$index" [item]="item"></app-translate-block>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { CommonModule } from '@angular/common';
|
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 { TranslateData } from '../../dto/translate_data.dto';
|
||||||
import { TranslateBlockComponent } from '../translate_block/translate_block.component';
|
import { TranslateBlockComponent } from '../translate_block/translate_block.component';
|
||||||
|
|
||||||
@@ -11,6 +11,7 @@ import { TranslateBlockComponent } from '../translate_block/translate_block.comp
|
|||||||
imports: [CommonModule, TranslateBlockComponent],
|
imports: [CommonModule, TranslateBlockComponent],
|
||||||
})
|
})
|
||||||
export class TextListComponent {
|
export class TextListComponent {
|
||||||
|
@ViewChildren('translateBlock') translate_blocks: QueryList<TranslateBlockComponent> | null = null;
|
||||||
elements_data: TranslateData[] = [];
|
elements_data: TranslateData[] = [];
|
||||||
@Input() set elements(el: TranslateData[]) {
|
@Input() set elements(el: TranslateData[]) {
|
||||||
this.elements_data = el;
|
this.elements_data = el;
|
||||||
|
|||||||
Reference in New Issue
Block a user