Skip to content

Commit

Permalink
[PS-1465] Fix #2806 - The "Import Data" page's file selector button c…
Browse files Browse the repository at this point in the history
…annot be translated (#3502)

* Add translations for en and fi to test with

* Fix file select not being translated

* Add more translations for en and fi to test with

* Update permission labels to locale version

* Revert forms.scss file

* Revert changes

* Specify file selector button type

Co-authored-by: Daniel James Smith <djsmith@web.de>
Co-authored-by: Daniel James Smith <djsmith85@users.noreply.github.com>
  • Loading branch information
3 people authored Oct 20, 2022
1 parent 3ed1221 commit 768de03
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
13 changes: 13 additions & 0 deletions apps/web/src/app/tools/import-export/import.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -291,12 +291,25 @@ <h1>{{ "importData" | i18n }}</h1>
<div class="col-6">
<div class="form-group">
<label for="file">2. {{ "selectImportFile" | i18n }}</label>
<br />
<div class="file-selector">
<button
type="button"
class="btn btn-outline-primary"
onclick="document.getElementById('file').click()"
>
{{ "chooseFile" | i18n }}
</button>
{{ this.fileSelected ? this.fileSelected.name : ("noFileChosen" | i18n) }}
</div>
<input
type="file"
id="file"
class="form-control-file"
name="file"
style="display: none"
[disabled]="importBlockedByPolicy$ | async"
(change)="setSelectedFile($event)"
/>
</div>
</div>
Expand Down
6 changes: 6 additions & 0 deletions apps/web/src/app/tools/import-export/import.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export class ImportComponent implements OnInit, OnDestroy {
importOptions: ImportOption[];
format: ImportType = null;
fileContents: string;
fileSelected: File;
formPromise: Promise<ImportError>;
loading = false;
importBlockedByPolicy$ = this.policyService.policyAppliesToActiveUser$(
Expand Down Expand Up @@ -184,6 +185,11 @@ export class ImportComponent implements OnInit, OnDestroy {
});
}

setSelectedFile(event: Event) {
const fileInputEl = <HTMLInputElement>event.target;
this.fileSelected = fileInputEl.files.length > 0 ? fileInputEl.files[0] : null;
}

private async error(error: Error) {
await Swal.fire({
heightAuto: false,
Expand Down
6 changes: 6 additions & 0 deletions apps/web/src/locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -1192,6 +1192,12 @@
"selectImportFile": {
"message": "Select the import file"
},
"chooseFile": {
"message": "Choose File"
},
"noFileChosen": {
"message": "No file chosen"
},
"orCopyPasteFileContents": {
"message": "or copy/paste the import file contents"
},
Expand Down

0 comments on commit 768de03

Please sign in to comment.