feat: allow manually saving if auto logging is off

This commit is contained in:
Tom Fong 2022-12-01 20:57:26 +08:00
parent 3a42fb84ef
commit 90ebc52537
9 changed files with 86 additions and 42 deletions

View file

@ -106,19 +106,22 @@
[ngStyle]="env.colorTheme === 'dark'? {'background-color': '#222428'} : (env.colorTheme === 'black'? {'background-color': '#000000'} : {'background-color': '#F0F0F0'})">
<ng-container *ngIf="env.resultPageButtons === 'icon-only'">
<ion-row *ngIf="contentType === 'freeText' && env.showOpenFoodFactsButton === 'on' && isValidEan" class="d-flex justify-content-center">
<ion-row *ngIf="contentType === 'freeText' && env.showOpenFoodFactsButton === 'on' && isValidEan"
class="d-flex justify-content-center">
<ion-button (click)="tapHaptic(); searchOpenFoodFacts()" [color]="'primary'" fill="clear">
<ion-icon name="fast-food"></ion-icon>
</ion-button>
</ion-row>
<ion-row *ngIf="contentType === 'url' && env.showBrowseButton === 'on' && isHttp" class="d-flex justify-content-center">
<ion-row *ngIf="contentType === 'url' && env.showBrowseButton === 'on' && isHttp"
class="d-flex justify-content-center">
<ion-button (click)="tapHaptic(); browseWebsite()" [color]="'primary'" fill="clear">
<ion-icon name="globe"></ion-icon>
</ion-button>
</ion-row>
<ion-row *ngIf="contentType === 'url' && env.showOpenUrlButton === 'on' && !isHttp" class="d-flex justify-content-center">
<ion-row *ngIf="contentType === 'url' && env.showOpenUrlButton === 'on' && !isHttp"
class="d-flex justify-content-center">
<ion-button (click)="tapHaptic(); openLink()" [color]="'primary'" fill="clear">
<ion-icon name="open"></ion-icon>
</ion-button>
@ -170,7 +173,13 @@
</ion-button>
</ion-row>
<ion-row class="ion-padding-horizontal justify-content-around">
<ion-row class="ion-padding-horizontal">
<div class="d-flex justify-content-between detailed-action-button-container">
<ion-button
*ngIf="!resultSaved && this.env.scanRecordLogging == 'off' && this.qrCodeContent != null && this.qrCodeContent != '' "
(click)="tapHaptic(); saveRecord()" [color]="env.colorTheme === 'light'? 'dark' : 'light'" fill="clear">
<ion-icon slot="icon-only" src="assets/icon/history.svg"></ion-icon>
</ion-button>
<ion-button *ngIf="env.showSearchButton === 'on'" (click)="tapHaptic(); webSearch()"
[color]="env.colorTheme === 'light'? 'dark' : 'light'" fill="clear"
[disabled]="!qrCodeContent || (qrCodeContent && qrCodeContent.trim().length <= 0)">
@ -207,15 +216,25 @@
[disabled]="!qrCodeContent || (qrCodeContent && qrCodeContent.trim().length <= 0)">
<ion-icon slot="icon-only" name="bookmark"></ion-icon>
</ion-button>
</div>
</ion-row>
</ng-container>
<ng-container *ngIf="env.resultPageButtons === 'detailed'">
<ion-row class="ion-padding-horizontal py-2">
<div class="d-flex justify-content-between detailed-action-button-container">
<ion-button class="pr-1" *ngIf="contentType === 'freeText' && env.showOpenFoodFactsButton === 'on' && isValidEan"
(click)="tapHaptic(); searchOpenFoodFacts()" [color]="env.colorTheme === 'light'? 'dark' : 'light'" fill="outline"
<ion-button class="pr-1"
*ngIf="!resultSaved && this.env.scanRecordLogging == 'off' && this.qrCodeContent != null && this.qrCodeContent != '' "
(click)="tapHaptic(); saveRecord()" [color]="env.colorTheme === 'light'? 'dark' : 'light'" fill="outline"
shape="round" [@inAnimation]>
<ion-icon class="pr-2" src="assets/icon/history.svg"></ion-icon>
<ion-label>{{ 'SAVE' | translate }}</ion-label>
</ion-button>
<ion-button class="pr-1"
*ngIf="contentType === 'freeText' && env.showOpenFoodFactsButton === 'on' && isValidEan"
(click)="tapHaptic(); searchOpenFoodFacts()" [color]="env.colorTheme === 'light'? 'dark' : 'light'"
fill="outline" shape="round" [@inAnimation]>
<ion-icon class="pr-2" name="fast-food"></ion-icon>
<ion-label>Facts</ion-label>
</ion-button>

View file

@ -54,6 +54,8 @@ export class ResultPage {
showQrFirst: boolean = false;
resultSaved: boolean = false;
@ViewChildren(MatFormField) formFields: QueryList<MatFormField>;
constructor(
@ -104,6 +106,14 @@ export class ResultPage {
this.reset();
}
async saveRecord() {
if (this.qrCodeContent != null && this.qrCodeContent != "") {
await this.env.saveScanRecord(this.qrCodeContent);
}
this.resultSaved = true;
this.presentToast(this.translate.instant("SAVED"), "short", "bottom");
}
reset() {
this.contentType = "freeText";
delete this.qrCodeContent;
@ -125,6 +135,7 @@ export class ResultPage {
this.base64DecodedText = "";
this.bookmarked = false;
this.showQrFirst = false;
this.resultSaved = false;
delete this.env.recordSource;
delete this.env.detailedRecordSource;
delete this.env.viewResultFrom;

View file

@ -165,6 +165,8 @@
"RESET_DEFAULT": "Standard zurücksetzen",
"RESTORE": "Wiederherstellen",
"RESULT": "Ergebnis",
"SAVE": "Speichern",
"SAVED": "Gespeichert",
"SCAN": "Scannen",
"SCANNED": "Gescannt",
"SCANNING_FEEDBACK_ONLY": "Nur Feedback scannen",

View file

@ -165,6 +165,8 @@
"RESET_DEFAULT": "Reset Default",
"RESTORE": "Restore",
"RESULT": "Result",
"SAVE": "Save",
"SAVED": "Saved",
"SCAN": "Scan",
"SCANNED": "Scanned",
"SCANNING_FEEDBACK_ONLY": "Scanning Feedback Only",

View file

@ -165,6 +165,8 @@
"RESET_DEFAULT": "Réinitialiser par défaut",
"RESTORE": "Restaurer",
"RESULT": "Résultat",
"SAVE": "Enregistrer",
"SAVED": "Enregistrée",
"SCAN": "Scanner",
"SCANNED": "Scanné",
"SCANNING_FEEDBACK_ONLY": "Vibrer lors de la numérisation uniquement",

View file

@ -165,6 +165,8 @@
"RESET_DEFAULT": "Ripristina predefinito",
"RESTORE": "Ripristina",
"RESULT": "Risultato",
"SAVE": "Salva",
"SAVED": "Salvato",
"SCAN": "Scannerizza",
"SCANNED": "Scannerizzato",
"SCANNING_FEEDBACK_ONLY": "Scansione esclusivamente del feedback",

View file

@ -165,6 +165,8 @@
"RESET_DEFAULT": "Настройки по умолчанию",
"RESTORE": "Восстановление",
"RESULT": "Результат",
"SAVE": "Сохранять",
"SAVED": "Сохранено",
"SCAN": "Сканировать",
"SCANNED": "Просканировано",
"SCANNING_FEEDBACK_ONLY": "Только отклик сканирования",

View file

@ -165,6 +165,8 @@
"RESET_DEFAULT": "还原预设值",
"RESTORE": "还原",
"RESULT": "结果",
"SAVE": "储存",
"SAVED": "已储存",
"SCAN": "扫描",
"SCANNED": "扫描",
"SCANNING_FEEDBACK_ONLY": "仅扫描反馈",

View file

@ -165,6 +165,8 @@
"RESET_DEFAULT": "還原預設值",
"RESTORE": "還原",
"RESULT": "結果",
"SAVE": "儲存",
"SAVED": "已儲存",
"SCAN": "掃描",
"SCANNED": "掃描",
"SCANNING_FEEDBACK_ONLY": "僅掃描反饋",