Skip to content
This repository has been archived by the owner on Jul 22, 2023. It is now read-only.

Commit

Permalink
added missed translation strings (#277)
Browse files Browse the repository at this point in the history
  • Loading branch information
crapStone committed Mar 12, 2021
1 parent 0946746 commit d423c78
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 42 deletions.
2 changes: 1 addition & 1 deletion src-tauri/cabr2_search/src/gestis/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ pub struct Alias {
#[serde(rename_all = "camelCase")]
pub enum SearchType {
ChemicalName,
ChemicalFormula,
Numbers,
EmpiricalFormula,
FullText,
}

Expand Down
3 changes: 2 additions & 1 deletion src/app/@core/services/search/search.model.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export type SearchType = 'chemicalName' | 'empiricalFormula' | 'numbers' | 'fullText';
export type SearchType = 'chemicalName' | 'chemicalFormula' | 'numbers' | 'fullText';
export const searchTypes: SearchType[] = ['chemicalName', 'chemicalFormula', 'numbers', 'fullText'];

export interface SearchTypeMapping {
viewValue: string;
Expand Down
19 changes: 11 additions & 8 deletions src/app/@core/services/search/search.service.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
import { SearchArguments, SearchResult, SearchType, SearchTypeMapping } from './search.model';
import { BehaviorSubject, Observable } from 'rxjs';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';

import { GlobalModel } from '../../models/global.model';
import { TauriService } from '../tauri/tauri.service';

import { SearchArguments, SearchResult, SearchType, SearchTypeMapping, searchTypes } from './search.model';

@Injectable({
providedIn: 'root'
})
export class SearchService {
public searchTypeMappings: SearchTypeMapping[] = [
{ viewValue: 'Stoffname', value: 'chemicalName' },
{ viewValue: 'Summenformel', value: 'empiricalFormula' },
{ viewValue: 'Nummern', value: 'numbers' },
{ viewValue: 'Volltext', value: 'fullText' },
];
searchTypeMappingsSubject = new BehaviorSubject<SearchTypeMapping[]>([]);
searchTypeMappingsObservable = this.searchTypeMappingsSubject.asObservable();

constructor(
private tauriService: TauriService,
private globals: GlobalModel,
) {
this.globals.localizedStringsObservable.subscribe((strings) => this.searchTypeMappingsSubject.next(
searchTypes.map((t) => ({ viewValue: strings.search.types[t], value: t }))
));
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/app/manual/manual.component.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div>{{ data.content }}</div>
<mat-divider></mat-divider>
<div mat-dialog-actions>
<button mat-button (click)="dialogRef.close()">Schließen</button>
<button mat-button (click)="dialogRef.close()">{{ strings.base.close }}</button>
</div>
15 changes: 12 additions & 3 deletions src/app/manual/manual.component.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,25 @@
import { Component, Inject, OnInit } from '@angular/core';
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';

import { GlobalModel } from '../@core/models/global.model';
import { LocalizedStrings } from '../@core/services/i18n/i18n.service';

@Component({
selector: 'app-manual',
templateUrl: './manual.component.html',
styleUrls: ['./manual.component.scss'],
})
export class ManualComponent implements OnInit {
strings!: LocalizedStrings;

constructor(
public dialogRef: MatDialogRef<ManualComponent>,
@Inject(MAT_DIALOG_DATA) public data: {content: string },
) {}
@Inject(MAT_DIALOG_DATA) public data: { content: string },

private globals: GlobalModel,
) {
this.globals.localizedStringsObservable.subscribe((strings) => this.strings = strings);
}

ngOnInit(): void {}
ngOnInit(): void { }
}
10 changes: 5 additions & 5 deletions src/app/menubar/menubar.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
<img src="assets/icons/menu.svg" />
</button>
<mat-menu #menu="matMenu">
<button mat-menu-item (click)="newDocument()">{{strings.menu.newDocument}}</button>
<button mat-menu-item (click)="loadFile()">{{strings.menu.loadFile}}</button>
<button mat-menu-item (click)="saveFile('cb2')">{{strings.menu.saveFile}}</button>
<button mat-menu-item (click)="exportPDF()">{{strings.menu.exportPDF}}</button>
<button mat-menu-item (click)="newDocument()">{{ strings.menu.newDocument }}</button>
<button mat-menu-item (click)="loadFile()">{{ strings.menu.loadFile }}</button>
<button mat-menu-item (click)="saveFile('cb2')">{{ strings.menu.saveFile }}</button>
<button mat-menu-item (click)="exportPDF()">{{ strings.menu.exportPDF }}</button>
<mat-divider></mat-divider>
<button mat-menu-item (click)='openManualDialog()'>Anleitung</button>
<button mat-menu-item (click)="openManualDialog()">{{ strings.menu.quickStart }}</button>
</mat-menu>
<br />
<button class="icon" mat-icon-button (click)="scroll(headerTarget)">
Expand Down
43 changes: 22 additions & 21 deletions src/app/search/selected-search/selected-search.component.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Component, EventEmitter, OnInit, Output } from '@angular/core';
import { Component, EventEmitter, Output } from '@angular/core';
import { FormArray, FormBuilder, FormGroup } from '@angular/forms';
import { debounceTime } from 'rxjs/operators';

import { SearchArgument, SearchType, SearchTypeMapping } from '../../@core/services/search/search.model';
import { SearchArgument, SearchType, SearchTypeMapping, searchTypes } from '../../@core/services/search/search.model';
import { AlertService } from '../../@core/services/alertsnackbar/altersnackbar.service';
import { GlobalModel } from '../../@core/models/global.model';
import { LocalizedStrings } from '../../@core/services/i18n/i18n.service';
Expand All @@ -16,26 +16,19 @@ const logger = new Logger('selected-search');
templateUrl: './selected-search.component.html',
styleUrls: ['./selected-search.component.scss'],
})
export class SelectedSearchComponent implements OnInit {
export class SelectedSearchComponent {
@Output()
triggerSearch = new EventEmitter();

strings!: LocalizedStrings;

searchOptions: SearchTypeMapping[] = this.searchService.searchTypeMappings;

availableSearchTypes: SearchType[] = this.searchService.searchTypeMappings.map(value => value.value);
searchOptions!: SearchTypeMapping[];

form: FormGroup = this.formBuilder.group({
selections: this.formBuilder.array([this.initSelectionForm()]),
});

suggestionResults: Map<SearchType, string[]> = new Map([
['chemicalName', []],
['empiricalFormula', []],
['numbers', []],
['fullText', []],
]);
suggestionResults: Map<SearchType, string[]> = new Map(searchTypes.map((t) => [t, []]));

addButtonHover = false;

Expand All @@ -46,14 +39,25 @@ export class SelectedSearchComponent implements OnInit {
private formBuilder: FormBuilder
) {
this.globals.localizedStringsObservable.subscribe((strings) => this.strings = strings);
}

ngOnInit(): void {
this.searchService.searchTypeMappingsObservable.subscribe((mapping) => this.searchOptions = mapping);
}

initSelectionForm(): FormGroup {
let searchOption;

for (const option of searchTypes) {
if (!this.selections?.controls.some((selection) => selection.get('searchOption')?.value === option)) {
searchOption = option;
break;
}
}

if (!searchOption) {
throw new Error('searchOption is undefined');
}

const selectionGroup = this.formBuilder.group({
searchOption: this.availableSearchTypes.shift(),
searchOption,
userInput: '',
hover: false,
});
Expand All @@ -72,12 +76,11 @@ export class SelectedSearchComponent implements OnInit {
}

removeSearchOption(index: number): void {
this.availableSearchTypes.push(this.selections.at(index).get('searchOption')?.value);
this.selections.removeAt(index);
}

isDisabled(option: string): boolean {
return this.selections.controls.filter(value => value.get('searchOption')?.value === option).length > 0;
isDisabled(option: SearchType): boolean {
return this.selections.controls.some((selection) => selection.get('searchOption')?.value === option);
}

onEnter(event: any): boolean {
Expand All @@ -89,8 +92,6 @@ export class SelectedSearchComponent implements OnInit {
return false;
}

// TODO handle change in searchTypeSelection

onSubmit(): SearchArgument[] {
return this.selections.controls.map<SearchArgument>(control => ({
searchType: control.get('searchOption')?.value,
Expand Down
12 changes: 10 additions & 2 deletions translations/de_de.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,16 @@
"print": "Drucken",
"cancel": "Abbrechen",
"ok": "Ok",
"save": "Speichern"
"save": "Speichern",
"close": "Schließen"
},
"menu": {
"newDocument": "Neue Betriebsanweisung",
"loadFile": "Bestehende Betriebsanweisung öffnen",
"saveFile": "Betriebsanweisung speichern",
"exportPDF": "Als PDF exportieren",
"darkModeSwitchInfo": "Auf helles/dunkles Thema umschalten"
"darkModeSwitchInfo": "Auf helles/dunkles Thema umschalten",
"quickStart": "Anleitung"
},
"header": {
"docTitle": "Dokument Titel:",
Expand All @@ -27,6 +29,12 @@
"preparation": "Herzustellendes Präparat:"
},
"search": {
"types": {
"chemicalName": "Stoffname",
"chemicalFormula": "Summenformel",
"numbers": "Nummer",
"fullText": "Volltext"
},
"exact": "Exakte Suche",
"option": "Suchoption:",
"searchButton": "Suche",
Expand Down

0 comments on commit d423c78

Please sign in to comment.