[PS-1465] Fix #2806 - The "Import Data" page's file selector button cannot 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>
This commit is contained in:
Sammy Chang 2022-10-20 07:13:21 -07:00 committed by GitHub
parent 3ed1221f7f
commit 768de03269
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 25 additions and 0 deletions

View File

@ -291,12 +291,25 @@
<div class="col-6"> <div class="col-6">
<div class="form-group"> <div class="form-group">
<label for="file">2. {{ "selectImportFile" | i18n }}</label> <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 <input
type="file" type="file"
id="file" id="file"
class="form-control-file" class="form-control-file"
name="file" name="file"
style="display: none"
[disabled]="importBlockedByPolicy$ | async" [disabled]="importBlockedByPolicy$ | async"
(change)="setSelectedFile($event)"
/> />
</div> </div>
</div> </div>

View File

@ -25,6 +25,7 @@ export class ImportComponent implements OnInit, OnDestroy {
importOptions: ImportOption[]; importOptions: ImportOption[];
format: ImportType = null; format: ImportType = null;
fileContents: string; fileContents: string;
fileSelected: File;
formPromise: Promise<ImportError>; formPromise: Promise<ImportError>;
loading = false; loading = false;
importBlockedByPolicy$ = this.policyService.policyAppliesToActiveUser$( importBlockedByPolicy$ = this.policyService.policyAppliesToActiveUser$(
@ -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) { private async error(error: Error) {
await Swal.fire({ await Swal.fire({
heightAuto: false, heightAuto: false,

View File

@ -1192,6 +1192,12 @@
"selectImportFile": { "selectImportFile": {
"message": "Select the import file" "message": "Select the import file"
}, },
"chooseFile": {
"message": "Choose File"
},
"noFileChosen": {
"message": "No file chosen"
},
"orCopyPasteFileContents": { "orCopyPasteFileContents": {
"message": "or copy/paste the import file contents" "message": "or copy/paste the import file contents"
}, },