feat: add library action confirmations

Closes #334
This commit is contained in:
Jovan Krunić
2022-11-11 14:08:53 +00:00
committed by Rainer Killinger
parent 6b08af6a74
commit 42b860e417
7 changed files with 53 additions and 23 deletions

View File

@@ -147,6 +147,7 @@ export class AppComponent implements AfterContentInit {
const toast = await this.toastController.create({
message: message,
duration: 2000,
color: 'success',
});
await toast.present();
}

View File

@@ -123,6 +123,7 @@ export class FeedbackPageComponent {
'feedback.system_messages.success',
),
duration: 2000,
color: 'success',
});
await toast.present();
}

View File

@@ -14,7 +14,7 @@
<stapps-paia-item
*ngFor="let checkedOutItem of checkedOutItems"
[item]="checkedOutItem"
[propertiesToShow]="['endtime', 'label']"
[propertiesToShow]="['label', 'renewals', 'endtime']"
(documentAction)="onDocumentAction($event)"
listName="checked_out"
>

View File

@@ -48,7 +48,7 @@
<!-- {{ 'library.account.actions.cancel.header' | translate }}</ion-button-->
<!-- >-->
<ion-button
*ngIf="item.canrenew"
[disabled]="!item.canrenew"
color="primary"
(click)="onClick('renew')"
>

View File

@@ -33,7 +33,7 @@ import {PAIATokenResponse} from '../../auth/paia/paia-token-response';
import {AuthHelperService} from '../../auth/auth-helper.service';
import {ConfigProvider} from '../../config/config.provider';
import {TranslateService} from '@ngx-translate/core';
import {AlertController} from '@ionic/angular';
import {AlertController, ToastController} from '@ionic/angular';
import {HebisSearchResponse} from '../../hebis/protocol/response';
@Injectable({
@@ -57,6 +57,7 @@ export class LibraryAccountService {
readonly configProvider: ConfigProvider,
private readonly translateService: TranslateService,
private readonly alertController: AlertController,
private readonly toastController: ToastController,
) {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const config: SCFeatureConfigurationExtern = (
@@ -165,18 +166,28 @@ export class LibraryAccountService {
return;
}
cancelReservation(document: PAIADocument) {
return this.performRequest<void>(
async cancelReservation(document: PAIADocument) {
const result = await this.performRequest<void>(
`${this.baseUrl}/{patron}/cancel`,
'POST',
{doc: [document]},
);
if (result) {
void this.onSuccess('cancel');
}
}
renewLanding(document: PAIADocument) {
return this.performRequest<void>(`${this.baseUrl}/{patron}/renew`, 'POST', {
doc: [document],
});
async renewLending(document: PAIADocument) {
const result = await this.performRequest<void>(
`${this.baseUrl}/{patron}/renew`,
'POST',
{
doc: [document],
},
);
if (result) {
void this.onSuccess('renew');
}
}
async handleDocumentAction(documentAction: DocumentAction): Promise<boolean> {
@@ -187,7 +198,7 @@ export class LibraryAccountService {
return this.cancelReservation(documentAction.doc);
break;
case 'renew':
return this.renewLanding(documentAction.doc);
return this.renewLending(documentAction.doc);
}
};
const alert = await this.alertController.create({
@@ -234,4 +245,15 @@ export class LibraryAccountService {
await alert.present();
}
async onSuccess(action: DocumentAction['action']) {
const toast = await this.toastController.create({
message: this.translateService.instant(
`library.account.actions.${action}.success`,
),
duration: 2000,
color: 'success',
});
await toast.present();
}
}

View File

@@ -284,7 +284,8 @@
"title": "Titel",
"about": "Mehr Informationen",
"label": "Signatur",
"endtime": "Rückgabedatum"
"endtime": "Leihfristende",
"renewals": "Verlängerungen"
}
},
"fines": {
@@ -292,7 +293,7 @@
"labels": {
"amount": "Betrag",
"about": "Information",
"date": "Rückgabedatum",
"date": "Leihfristende",
"item": "Artikel",
"edition": "Ausgabe",
"feetype": "Gebührenart",
@@ -304,13 +305,15 @@
"actions": {
"cancel": {
"header": "Vormerkung löschen",
"text": "Bist Du dir sicher, die Vormerkung von \"{{value}}\" zu löschen?",
"unknown_book": "unbekanntem Titel"
"text": "Soll die Vormerkung von \"{{value}}\" gelöscht werden?",
"unknown_book": "unbekannter Titel",
"success": "Vormerkung erfolgreich gelöscht."
},
"renew": {
"header": "Ausleihfrist verlängern",
"text": "Bist Du dir sicher, die Ausleihfrist von \"{{value}}\" zu verlängern?",
"unknown_book": "unbekanntem Titel"
"text": "Soll die Ausleihfrist von \"{{value}}\" verlängert werden?",
"unknown_book": "unbekannter Titel",
"success": "Ausleihfrist erfolgreich verlängert."
}
}
}

View File

@@ -284,7 +284,8 @@
"title": "Title",
"about": "More information",
"label": "Label",
"endtime": "Return date"
"endtime": "Due date",
"renewals": "Renewals"
}
},
"fines": {
@@ -292,7 +293,7 @@
"labels": {
"amount": "Amount",
"about": "About",
"date": "Return date",
"date": "Due date",
"item": "Item",
"edition": "Edition",
"feetype": "Fee type",
@@ -304,13 +305,15 @@
"actions": {
"cancel": {
"header": "Cancel reservation",
"text": "Are you sure you want to extend the landing period of \"{{value}}\"?",
"unknown_book": "unknown title"
"text": "Are you sure you want to extend the lending period of \"{{value}}\"?",
"unknown_book": "unknown title",
"success": "Reservation cancelled successfully."
},
"renew": {
"header": "Extend landing period",
"text": "Are you sure you want to extend the landing period of \"{{value}}\"?",
"unknown_book": "unknown title"
"header": "Extend lending period",
"text": "Are you sure you want to extend the lending period of \"{{value}}\"?",
"unknown_book": "unknown title",
"success": "Lending period extended successfully."
}
}
}