mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-21 00:52:55 +00:00
committed by
Rainer Killinger
parent
6b08af6a74
commit
42b860e417
@@ -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"
|
||||
>
|
||||
|
||||
@@ -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')"
|
||||
>
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user