mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-21 00:52:55 +00:00
feat: separate prettier from eslint
This commit is contained in:
committed by
Thea Schöbl
parent
939fb6ef0f
commit
a88d000ccd
@@ -1,27 +1,23 @@
|
||||
/*
|
||||
* Copyright (C) 2022 StApps
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, version 3.
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/* eslint-disable @typescript-eslint/no-non-null-assertion,@typescript-eslint/no-explicit-any */
|
||||
import {CUSTOM_ELEMENTS_SCHEMA} from '@angular/core';
|
||||
import {ComponentFixture, TestBed} from '@angular/core/testing';
|
||||
import {ActivatedRoute, RouterModule} from '@angular/router';
|
||||
import {
|
||||
TranslateLoader,
|
||||
TranslateModule,
|
||||
TranslateService,
|
||||
} from '@ngx-translate/core';
|
||||
import {TranslateLoader, TranslateModule, TranslateService} from '@ngx-translate/core';
|
||||
import {sampleThingsMap} from '../../../_helpers/data/sample-things';
|
||||
import {HebisRoutingModule} from '../hebis-routing.module';
|
||||
import {HebisModule} from '../hebis.module';
|
||||
@@ -63,20 +59,10 @@ describe('DaiaAvailabilityComponent', () => {
|
||||
},
|
||||
};
|
||||
|
||||
const storageProviderSpy = jasmine.createSpyObj('StorageProvider', [
|
||||
'init',
|
||||
'get',
|
||||
'has',
|
||||
'put',
|
||||
'search',
|
||||
]);
|
||||
const storageProviderSpy = jasmine.createSpyObj('StorageProvider', ['init', 'get', 'has', 'put', 'search']);
|
||||
|
||||
beforeEach(() => {
|
||||
configProviderMock = jasmine.createSpyObj('ConfigProvider', [
|
||||
'init',
|
||||
'getValue',
|
||||
'getAnyValue',
|
||||
]);
|
||||
configProviderMock = jasmine.createSpyObj('ConfigProvider', ['init', 'getValue', 'getAnyValue']);
|
||||
TestBed.configureTestingModule({
|
||||
imports: [
|
||||
RouterModule.forRoot([], {relativeLinkResolution: 'legacy'}),
|
||||
@@ -112,13 +98,8 @@ describe('DaiaAvailabilityComponent', () => {
|
||||
const workingDAIAurl = 'https://daia.hebis.de/DAIA2/UB_Frankfurt';
|
||||
dataProvider.daiaServiceUrl = workingDAIAurl;
|
||||
translateService = TestBed.inject(TranslateService);
|
||||
spyOn(dataProvider, 'getAvailability' as any).and.returnValue(
|
||||
Promise.resolve([]),
|
||||
);
|
||||
spyOn(
|
||||
DaiaAvailabilityComponent.prototype,
|
||||
'getAvailability',
|
||||
).and.callThrough();
|
||||
spyOn(dataProvider, 'getAvailability' as any).and.returnValue(Promise.resolve([]));
|
||||
spyOn(DaiaAvailabilityComponent.prototype, 'getAvailability').and.callThrough();
|
||||
fixture = await TestBed.createComponent(DaiaAvailabilityComponent);
|
||||
comp = fixture.componentInstance;
|
||||
translateService.use('foo');
|
||||
@@ -129,15 +110,11 @@ describe('DaiaAvailabilityComponent', () => {
|
||||
|
||||
it('should get the availability of an item', () => {
|
||||
comp.getAvailability(sampleThing.uid);
|
||||
expect(
|
||||
DaiaAvailabilityComponent.prototype.getAvailability,
|
||||
).toHaveBeenCalledWith(sampleThing.uid);
|
||||
expect(DaiaAvailabilityComponent.prototype.getAvailability).toHaveBeenCalledWith(sampleThing.uid);
|
||||
});
|
||||
|
||||
it('should get the availability of an item when the view is entered', () => {
|
||||
comp.ngOnInit();
|
||||
expect(
|
||||
DaiaAvailabilityComponent.prototype.getAvailability,
|
||||
).toHaveBeenCalledWith(sampleThing.uid);
|
||||
expect(DaiaAvailabilityComponent.prototype.getAvailability).toHaveBeenCalledWith(sampleThing.uid);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
/*
|
||||
* Copyright (C) 2022 StApps
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, version 3.
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {Component, OnInit} from '@angular/core';
|
||||
import {ActivatedRoute} from '@angular/router';
|
||||
@@ -32,10 +32,7 @@ import {groupByStable} from '../../../_helpers/collections/group-by';
|
||||
styleUrls: ['daia-availability.scss'],
|
||||
templateUrl: 'daia-availability.html',
|
||||
})
|
||||
export class DaiaAvailabilityComponent
|
||||
extends DataDetailComponent
|
||||
implements OnInit
|
||||
{
|
||||
export class DaiaAvailabilityComponent extends DataDetailComponent implements OnInit {
|
||||
holdings?: DaiaHolding[];
|
||||
|
||||
holdingsByDepartments?: Map<DaiaHolding['department']['id'], DaiaHolding[]>;
|
||||
@@ -57,13 +54,7 @@ export class DaiaAvailabilityComponent
|
||||
translateService: TranslateService,
|
||||
private daiaDataProvider: DaiaDataProvider,
|
||||
) {
|
||||
super(
|
||||
route,
|
||||
dataProvider,
|
||||
favoritesService,
|
||||
modalController,
|
||||
translateService,
|
||||
);
|
||||
super(route, dataProvider, favoritesService, modalController, translateService);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -85,10 +76,7 @@ export class DaiaAvailabilityComponent
|
||||
this.daiaDataProvider.getAvailability(uid).then(holdings => {
|
||||
if (typeof holdings !== 'undefined') {
|
||||
this.holdings = holdings;
|
||||
this.holdingsByDepartments = groupByStable(
|
||||
holdings,
|
||||
holding => holding.department.id,
|
||||
);
|
||||
this.holdingsByDepartments = groupByStable(holdings, holding => holding.department.id);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,3 +1,18 @@
|
||||
<!--
|
||||
~ Copyright (C) 2022 StApps
|
||||
~ This program is free software: you can redistribute it and/or modify it
|
||||
~ under the terms of the GNU General Public License as published by the Free
|
||||
~ Software Foundation, version 3.
|
||||
~
|
||||
~ This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
~ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
~ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
~ more details.
|
||||
~
|
||||
~ You should have received a copy of the GNU General Public License along with
|
||||
~ this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
-->
|
||||
|
||||
<ng-container>
|
||||
<ion-card>
|
||||
<ion-card-header>
|
||||
@@ -5,9 +20,7 @@
|
||||
</ion-card-header>
|
||||
<ion-card-content>
|
||||
<ng-container *ngIf="holdingsByDepartments">
|
||||
<ng-container
|
||||
*ngFor="let holdingsByDepartment of holdingsByDepartments | keyvalue"
|
||||
>
|
||||
<ng-container *ngFor="let holdingsByDepartment of holdingsByDepartments | keyvalue">
|
||||
<ion-label>
|
||||
<stapps-external-link
|
||||
*ngIf="holdingsByDepartment.value[0].department.href"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2022 StApps
|
||||
* Copyright (C) 2023 StApps
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, version 3.
|
||||
@@ -30,9 +30,6 @@ export class DaiaHoldingComponent implements OnInit {
|
||||
resourceLink?: string;
|
||||
|
||||
ngOnInit(): void {
|
||||
this.resourceLink = this.daiaDataProvider.getHoldingLink(
|
||||
this.holding,
|
||||
this.holding.open,
|
||||
);
|
||||
this.resourceLink = this.daiaDataProvider.getHoldingLink(this.holding, this.holding.open);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,32 +42,17 @@
|
||||
<ion-row *ngIf="holding.status">
|
||||
<ion-col size="3">{{ 'hebisSearch.daia.status' | translate }}</ion-col>
|
||||
<ion-col size="9">
|
||||
<ion-icon *ngIf="holding.status === 'available'" name="check_circle" color="success"></ion-icon>
|
||||
<ion-icon *ngIf="holding.status === 'library_only'" name="check_circle" color="warning"></ion-icon>
|
||||
<ion-icon
|
||||
*ngIf="holding.status === 'available'"
|
||||
name="check_circle"
|
||||
color="success"
|
||||
></ion-icon>
|
||||
<ion-icon
|
||||
*ngIf="holding.status === 'library_only'"
|
||||
name="check_circle"
|
||||
color="warning"
|
||||
></ion-icon>
|
||||
<ion-icon
|
||||
*ngIf="
|
||||
['checked_out', 'not_yet_available', 'not_available'].indexOf(
|
||||
holding.status
|
||||
) > -1
|
||||
"
|
||||
*ngIf="['checked_out', 'not_yet_available', 'not_available'].indexOf(holding.status) > -1"
|
||||
name="cancel"
|
||||
color="danger"
|
||||
>
|
||||
</ion-icon>
|
||||
{{ 'hebisSearch.daia.status_states' + '.' + holding.status | translate }}
|
||||
<stapps-external-link
|
||||
*ngIf="
|
||||
['available', 'library_only'].indexOf(holding.status) > -1 &&
|
||||
holding.available.href
|
||||
"
|
||||
*ngIf="['available', 'library_only'].indexOf(holding.status) > -1 && holding.available.href"
|
||||
[text]="'hebisSearch.daia.order' | translate"
|
||||
[link]="holding.available.href"
|
||||
>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2022 StApps
|
||||
* Copyright (C) 2023 StApps
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, version 3.
|
||||
@@ -39,8 +39,7 @@ describe('DaiaDataProvider', () => {
|
||||
let daiaDataProvider: DaiaDataProvider;
|
||||
let configProvider: ConfigProvider;
|
||||
const proxyUrl = 'https://some-proxy.com?q=';
|
||||
const getProxifiedUrl = (url: string) =>
|
||||
`${proxyUrl}${encodeURIComponent(url)}`;
|
||||
const getProxifiedUrl = (url: string) => `${proxyUrl}${encodeURIComponent(url)}`;
|
||||
|
||||
beforeEach(async () => {
|
||||
configProvider = jasmine.createSpyObj('ConfigProvider', ['getValue']);
|
||||
@@ -109,9 +108,7 @@ describe('DaiaDataProvider', () => {
|
||||
available: available,
|
||||
};
|
||||
|
||||
expect(daiaDataProvider.getHoldingLink(holding, holding.open)).toEqual(
|
||||
available.href as string,
|
||||
);
|
||||
expect(daiaDataProvider.getHoldingLink(holding, holding.open)).toEqual(available.href as string);
|
||||
});
|
||||
|
||||
it('should return the resource link with proxy when the resource is not open', () => {
|
||||
@@ -191,53 +188,33 @@ describe('DaiaDataProvider', () => {
|
||||
};
|
||||
|
||||
it('should return check out', () => {
|
||||
expect(daiaDataProvider.getHoldingStatus([], [checkedOut])).toEqual(
|
||||
'checked_out',
|
||||
);
|
||||
expect(daiaDataProvider.getHoldingStatus([], [checkedOut])).toEqual('checked_out');
|
||||
});
|
||||
|
||||
it('should return not yet available', () => {
|
||||
expect(
|
||||
daiaDataProvider.getHoldingStatus([], [notYetAvailableOnBuy]),
|
||||
).toEqual('not_yet_available');
|
||||
expect(
|
||||
daiaDataProvider.getHoldingStatus([], [notYetAvailableJustReturned]),
|
||||
).toEqual('not_yet_available');
|
||||
expect(daiaDataProvider.getHoldingStatus([], [notYetAvailableOnBuy])).toEqual('not_yet_available');
|
||||
expect(daiaDataProvider.getHoldingStatus([], [notYetAvailableJustReturned])).toEqual(
|
||||
'not_yet_available',
|
||||
);
|
||||
});
|
||||
|
||||
it('should return not available', () => {
|
||||
expect(
|
||||
daiaDataProvider.getHoldingStatus([], [notAvailableCopyIsMissing]),
|
||||
).toEqual('not_available');
|
||||
expect(
|
||||
daiaDataProvider.getHoldingStatus([], [notAvailableCanceled]),
|
||||
).toEqual('not_available');
|
||||
expect(daiaDataProvider.getHoldingStatus([], [notAvailableCopyIsMissing])).toEqual('not_available');
|
||||
expect(daiaDataProvider.getHoldingStatus([], [notAvailableCanceled])).toEqual('not_available');
|
||||
});
|
||||
|
||||
it('should return library only', () => {
|
||||
expect(
|
||||
daiaDataProvider.getHoldingStatus([], [libraryOnlyOnlyInHouse]),
|
||||
).toEqual('library_only');
|
||||
expect(
|
||||
daiaDataProvider.getHoldingStatus([libraryOnlyExternalLoan], []),
|
||||
).toEqual('library_only');
|
||||
expect(
|
||||
daiaDataProvider.getHoldingStatus([libraryOnlyPresentation], []),
|
||||
).toEqual('library_only');
|
||||
expect(daiaDataProvider.getHoldingStatus([], [libraryOnlyOnlyInHouse])).toEqual('library_only');
|
||||
expect(daiaDataProvider.getHoldingStatus([libraryOnlyExternalLoan], [])).toEqual('library_only');
|
||||
expect(daiaDataProvider.getHoldingStatus([libraryOnlyPresentation], [])).toEqual('library_only');
|
||||
});
|
||||
|
||||
it('should return available', () => {
|
||||
expect(
|
||||
daiaDataProvider.getHoldingStatus(
|
||||
[availableLimitationsUndefined, libraryOnlyPresentation],
|
||||
[],
|
||||
),
|
||||
daiaDataProvider.getHoldingStatus([availableLimitationsUndefined, libraryOnlyPresentation], []),
|
||||
).toEqual('available');
|
||||
expect(
|
||||
daiaDataProvider.getHoldingStatus(
|
||||
[availableLimitationsEmpty, libraryOnlyPresentation],
|
||||
[],
|
||||
),
|
||||
daiaDataProvider.getHoldingStatus([availableLimitationsEmpty, libraryOnlyPresentation], []),
|
||||
).toEqual('available');
|
||||
});
|
||||
|
||||
@@ -247,18 +224,10 @@ describe('DaiaDataProvider', () => {
|
||||
service: 'anything else',
|
||||
};
|
||||
|
||||
expect(daiaDataProvider.getHoldingStatus([withoutLoan], [])).toEqual(
|
||||
'unknown',
|
||||
);
|
||||
expect(daiaDataProvider.getHoldingStatus([], [withoutLoan])).toEqual(
|
||||
'unknown',
|
||||
);
|
||||
expect(
|
||||
daiaDataProvider.getHoldingStatus([], [availableLimitationsUndefined]),
|
||||
).toEqual('unknown');
|
||||
expect(
|
||||
daiaDataProvider.getHoldingStatus([], [availableLimitationsEmpty]),
|
||||
).toEqual('unknown');
|
||||
expect(daiaDataProvider.getHoldingStatus([withoutLoan], [])).toEqual('unknown');
|
||||
expect(daiaDataProvider.getHoldingStatus([], [withoutLoan])).toEqual('unknown');
|
||||
expect(daiaDataProvider.getHoldingStatus([], [availableLimitationsUndefined])).toEqual('unknown');
|
||||
expect(daiaDataProvider.getHoldingStatus([], [availableLimitationsEmpty])).toEqual('unknown');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2021 StApps
|
||||
* Copyright (C) 2023 StApps
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, version 3.
|
||||
@@ -13,11 +13,7 @@
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {Injectable} from '@angular/core';
|
||||
import {
|
||||
DaiaAvailabilityResponse,
|
||||
DaiaHolding,
|
||||
DaiaService,
|
||||
} from './protocol/response';
|
||||
import {DaiaAvailabilityResponse, DaiaHolding, DaiaService} from './protocol/response';
|
||||
import {StorageProvider} from '../storage/storage.provider';
|
||||
import {HttpClient, HttpHeaders} from '@angular/common/http';
|
||||
import {ConfigProvider} from '../config/config.provider';
|
||||
@@ -66,18 +62,13 @@ export class DaiaDataProvider {
|
||||
) {
|
||||
this.storageProvider = storageProvider;
|
||||
this.httpClient = httpClient;
|
||||
this.clientHeaders = this.clientHeaders.set(
|
||||
'Content-Type',
|
||||
'application/json',
|
||||
);
|
||||
this.clientHeaders = this.clientHeaders.set('Content-Type', 'application/json');
|
||||
}
|
||||
|
||||
async getAvailability(id: string): Promise<DaiaHolding[] | undefined> {
|
||||
if (typeof this.daiaServiceUrl === 'undefined') {
|
||||
try {
|
||||
const features = this.configProvider.getValue(
|
||||
'features',
|
||||
) as SCFeatureConfiguration;
|
||||
const features = this.configProvider.getValue('features') as SCFeatureConfiguration;
|
||||
if (features.extern?.daia?.url) {
|
||||
this.daiaServiceUrl = features.extern?.daia?.url;
|
||||
} else {
|
||||
@@ -110,11 +101,11 @@ export class DaiaDataProvider {
|
||||
document.item.map(element => {
|
||||
try {
|
||||
const {
|
||||
department: {
|
||||
id: departmentId,
|
||||
content: departmentLabel,
|
||||
href: departmentLink,
|
||||
} = {id: 'noDep', content: '', href: ''},
|
||||
department: {id: departmentId, content: departmentLabel, href: departmentLink} = {
|
||||
id: 'noDep',
|
||||
content: '',
|
||||
href: '',
|
||||
},
|
||||
label,
|
||||
about,
|
||||
available,
|
||||
@@ -122,22 +113,13 @@ export class DaiaDataProvider {
|
||||
chronology,
|
||||
unavailable,
|
||||
} = element;
|
||||
const holdingStatus = this.holdingHasStatus(
|
||||
available || [],
|
||||
)
|
||||
? this.getHoldingStatus(
|
||||
available || [],
|
||||
unavailable || [],
|
||||
)
|
||||
const holdingStatus = this.holdingHasStatus(available || [])
|
||||
? this.getHoldingStatus(available || [], unavailable || [])
|
||||
: undefined;
|
||||
|
||||
const dueDate =
|
||||
holdingStatus === 'checked_out'
|
||||
? (
|
||||
unavailable.find(
|
||||
item => item.service === 'loan',
|
||||
) as DaiaService
|
||||
).expected
|
||||
? (unavailable.find(item => item.service === 'loan') as DaiaService).expected
|
||||
: undefined;
|
||||
|
||||
holdings.push({
|
||||
@@ -152,31 +134,22 @@ export class DaiaDataProvider {
|
||||
dueDate: dueDate,
|
||||
online:
|
||||
Array.isArray(available) &&
|
||||
typeof available.find(
|
||||
item => item.service === 'remote',
|
||||
) !== 'undefined',
|
||||
typeof available.find(item => item.service === 'remote') !== 'undefined',
|
||||
available:
|
||||
(Array.isArray(available) &&
|
||||
available.find(item =>
|
||||
['openaccess', 'loan', 'presentation'].includes(
|
||||
item.service,
|
||||
),
|
||||
['openaccess', 'loan', 'presentation'].includes(item.service),
|
||||
)) ||
|
||||
undefined,
|
||||
unavailable:
|
||||
(Array.isArray(unavailable) &&
|
||||
unavailable.find(
|
||||
item => item.service === 'loan',
|
||||
)) ||
|
||||
(Array.isArray(unavailable) && unavailable.find(item => item.service === 'loan')) ||
|
||||
undefined,
|
||||
storage,
|
||||
about,
|
||||
holdings: chronology?.about,
|
||||
open:
|
||||
(Array.isArray(available) &&
|
||||
available.some(
|
||||
item => item.service === 'openaccess',
|
||||
)) ||
|
||||
available.some(item => item.service === 'openaccess')) ||
|
||||
undefined,
|
||||
});
|
||||
} catch {
|
||||
@@ -204,34 +177,24 @@ export class DaiaDataProvider {
|
||||
return;
|
||||
}
|
||||
const resourceLink = holding.available?.href;
|
||||
return open
|
||||
? resourceLink
|
||||
: `${this.hebisProxyUrl}${encodeURIComponent(resourceLink as string)}`;
|
||||
return open ? resourceLink : `${this.hebisProxyUrl}${encodeURIComponent(resourceLink as string)}`;
|
||||
}
|
||||
|
||||
holdingHasStatus(available: DaiaService[]): boolean {
|
||||
return !available.some(item => item.service === 'remote');
|
||||
}
|
||||
|
||||
getHoldingStatus(
|
||||
available: DaiaService[],
|
||||
unavailable: DaiaService[],
|
||||
): DaiaHolding['status'] {
|
||||
getHoldingStatus(available: DaiaService[], unavailable: DaiaService[]): DaiaHolding['status'] {
|
||||
const loan: {available: number; unavailable: number} = {
|
||||
available: available.findIndex(item => item.service === 'loan'),
|
||||
unavailable: unavailable.findIndex(item => item.service === 'loan'),
|
||||
};
|
||||
const presentation: {available: number; unavailable: number} = {
|
||||
available: available.findIndex(item => item.service === 'presentation'),
|
||||
unavailable: unavailable.findIndex(
|
||||
item => item.service === 'presentation',
|
||||
),
|
||||
unavailable: unavailable.findIndex(item => item.service === 'presentation'),
|
||||
};
|
||||
|
||||
if (
|
||||
loan.unavailable !== -1 &&
|
||||
typeof unavailable[loan.unavailable].expected !== 'undefined'
|
||||
) {
|
||||
if (loan.unavailable !== -1 && typeof unavailable[loan.unavailable].expected !== 'undefined') {
|
||||
return 'checked_out';
|
||||
}
|
||||
|
||||
@@ -260,9 +223,7 @@ export class DaiaDataProvider {
|
||||
available[loan.available].limitations?.some(limitation =>
|
||||
['ExternalLoan'].includes(limitation.id),
|
||||
)) ||
|
||||
(loan.available === -1 &&
|
||||
presentation.available !== -1 &&
|
||||
presentation.unavailable === -1)
|
||||
(loan.available === -1 && presentation.available !== -1 && presentation.unavailable === -1)
|
||||
)
|
||||
return 'library_only';
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2021 StApps
|
||||
* Copyright (C) 2022 StApps
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, version 3.
|
||||
@@ -61,11 +61,7 @@ export class HebisDataProvider extends DataProvider {
|
||||
super(stAppsWebHttpClient, storageProvider);
|
||||
this.storageProvider = storageProvider;
|
||||
this.httpClient = httpClient;
|
||||
this.client = new Client(
|
||||
stAppsWebHttpClient,
|
||||
this.backendUrl,
|
||||
this.appVersion,
|
||||
);
|
||||
this.client = new Client(stAppsWebHttpClient, this.backendUrl, this.appVersion);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -88,26 +84,21 @@ export class HebisDataProvider extends DataProvider {
|
||||
let page: number | undefined = searchRequest.page;
|
||||
|
||||
if (typeof page === 'undefined') {
|
||||
const preFlightResponse =
|
||||
await this.client.invokeRoute<HebisSearchResponse>(
|
||||
this.hebisSearchRoute,
|
||||
undefined,
|
||||
{
|
||||
...searchRequest,
|
||||
page: 0,
|
||||
},
|
||||
);
|
||||
const preFlightResponse = await this.client.invokeRoute<HebisSearchResponse>(
|
||||
this.hebisSearchRoute,
|
||||
undefined,
|
||||
{
|
||||
...searchRequest,
|
||||
page: 0,
|
||||
},
|
||||
);
|
||||
|
||||
page = preFlightResponse.pagination.total;
|
||||
}
|
||||
|
||||
return this.client.invokeRoute<HebisSearchResponse>(
|
||||
this.hebisSearchRoute,
|
||||
undefined,
|
||||
{
|
||||
...searchRequest,
|
||||
page,
|
||||
},
|
||||
);
|
||||
return this.client.invokeRoute<HebisSearchResponse>(this.hebisSearchRoute, undefined, {
|
||||
...searchRequest,
|
||||
page,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,31 +1,25 @@
|
||||
<!--
|
||||
~ Copyright (C) 2022 StApps
|
||||
~ This program is free software: you can redistribute it and/or modify it
|
||||
~ under the terms of the GNU General Public License as published by the Free
|
||||
~ Software Foundation, version 3.
|
||||
~ Copyright (C) 2023 StApps
|
||||
~ This program is free software: you can redistribute it and/or modify it
|
||||
~ under the terms of the GNU General Public License as published by the Free
|
||||
~ Software Foundation, version 3.
|
||||
~
|
||||
~ This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
~ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
~ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
~ more details.
|
||||
~ This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
~ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
~ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
~ more details.
|
||||
~
|
||||
~ You should have received a copy of the GNU General Public License along with
|
||||
~ this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
~ You should have received a copy of the GNU General Public License along with
|
||||
~ this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
-->
|
||||
|
||||
<div [ngSwitch]="item.type">
|
||||
<stapps-book-detail-content
|
||||
[item]="item"
|
||||
*ngSwitchCase="'book'"
|
||||
></stapps-book-detail-content>
|
||||
<stapps-book-detail-content [item]="item" *ngSwitchCase="'book'"></stapps-book-detail-content>
|
||||
<stapps-periodical-detail-content
|
||||
[item]="item"
|
||||
*ngSwitchCase="'periodical'"
|
||||
></stapps-periodical-detail-content>
|
||||
<stapps-article-content
|
||||
[item]="item"
|
||||
*ngSwitchCase="'article'"
|
||||
></stapps-article-content>
|
||||
<stapps-article-content [item]="item" *ngSwitchCase="'article'"></stapps-article-content>
|
||||
<ng-container *ngSwitchDefault>
|
||||
<ion-item class="ion-text-wrap" lines="inset">
|
||||
<ion-thumbnail slot="start" class="ion-margin-end">
|
||||
|
||||
@@ -1,3 +1,18 @@
|
||||
/*!
|
||||
* Copyright (C) 2022 StApps
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
:host ::ng-deep {
|
||||
ion-card {
|
||||
margin: 0;
|
||||
@@ -14,13 +29,15 @@
|
||||
padding-bottom: 4px;
|
||||
font-weight: bold;
|
||||
}
|
||||
ion-grid, ion-col {
|
||||
ion-grid,
|
||||
ion-col {
|
||||
padding-inline-start: 0;
|
||||
padding-top: 0;
|
||||
padding-bottom: 0;
|
||||
}
|
||||
}
|
||||
ion-grid, ion-col {
|
||||
ion-grid,
|
||||
ion-col {
|
||||
padding-inline-start: 0;
|
||||
padding-top: 0;
|
||||
padding-bottom: 0;
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
/*
|
||||
* Copyright (C) 2022 StApps
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, version 3.
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/* eslint-disable @typescript-eslint/no-non-null-assertion,@typescript-eslint/no-explicit-any */
|
||||
@@ -18,11 +18,7 @@
|
||||
import {CUSTOM_ELEMENTS_SCHEMA} from '@angular/core';
|
||||
import {ComponentFixture, TestBed} from '@angular/core/testing';
|
||||
import {ActivatedRoute, RouterModule} from '@angular/router';
|
||||
import {
|
||||
TranslateLoader,
|
||||
TranslateModule,
|
||||
TranslateService,
|
||||
} from '@ngx-translate/core';
|
||||
import {TranslateLoader, TranslateModule, TranslateService} from '@ngx-translate/core';
|
||||
import {sampleThingsMap} from '../../../_helpers/data/sample-things';
|
||||
import {HebisRoutingModule} from '../hebis-routing.module';
|
||||
import {HebisModule} from '../hebis.module';
|
||||
@@ -63,13 +59,7 @@ describe('HebisDetailComponent', () => {
|
||||
},
|
||||
};
|
||||
|
||||
const storageProviderSpy = jasmine.createSpyObj('StorageProvider', [
|
||||
'init',
|
||||
'get',
|
||||
'has',
|
||||
'put',
|
||||
'search',
|
||||
]);
|
||||
const storageProviderSpy = jasmine.createSpyObj('StorageProvider', ['init', 'get', 'has', 'put', 'search']);
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
@@ -100,9 +90,7 @@ describe('HebisDetailComponent', () => {
|
||||
beforeEach(() => {
|
||||
dataProvider = TestBed.inject(HebisDataProvider);
|
||||
translateService = TestBed.inject(TranslateService);
|
||||
spyOn(dataProvider, 'get' as any).and.returnValue(
|
||||
Promise.resolve(sampleThing),
|
||||
);
|
||||
spyOn(dataProvider, 'get' as any).and.returnValue(Promise.resolve(sampleThing));
|
||||
spyOn(HebisDetailComponent.prototype, 'getItem').and.callThrough();
|
||||
fixture = TestBed.createComponent(HebisDetailComponent);
|
||||
comp = fixture.componentInstance;
|
||||
@@ -114,17 +102,11 @@ describe('HebisDetailComponent', () => {
|
||||
|
||||
it('should get a data item', () => {
|
||||
comp.getItem(sampleThing.uid, false);
|
||||
expect(HebisDetailComponent.prototype.getItem).toHaveBeenCalledWith(
|
||||
sampleThing.uid,
|
||||
false,
|
||||
);
|
||||
expect(HebisDetailComponent.prototype.getItem).toHaveBeenCalledWith(sampleThing.uid, false);
|
||||
});
|
||||
|
||||
it('should get a data item when the view is entered', () => {
|
||||
comp.ionViewWillEnter();
|
||||
expect(HebisDetailComponent.prototype.getItem).toHaveBeenCalledWith(
|
||||
sampleThing.uid,
|
||||
false,
|
||||
);
|
||||
expect(HebisDetailComponent.prototype.getItem).toHaveBeenCalledWith(sampleThing.uid, false);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
/*
|
||||
* Copyright (C) 2022 StApps
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, version 3.
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {Component} from '@angular/core';
|
||||
import {ActivatedRoute} from '@angular/router';
|
||||
@@ -51,13 +51,7 @@ export class HebisDetailComponent extends DataDetailComponent {
|
||||
translateService: TranslateService,
|
||||
private hebisDataProvider: HebisDataProvider,
|
||||
) {
|
||||
super(
|
||||
route,
|
||||
dataProvider,
|
||||
favoritesService,
|
||||
modalController,
|
||||
translateService,
|
||||
);
|
||||
super(route, dataProvider, favoritesService, modalController, translateService);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
<!--
|
||||
~ Copyright (C) 2022 StApps
|
||||
~ This program is free software: you can redistribute it and/or modify it
|
||||
~ under the terms of the GNU General Public License as published by the Free
|
||||
~ Software Foundation, version 3.
|
||||
~ This program is free software: you can redistribute it and/or modify it
|
||||
~ under the terms of the GNU General Public License as published by the Free
|
||||
~ Software Foundation, version 3.
|
||||
~
|
||||
~ This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
~ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
~ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
~ more details.
|
||||
~ This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
~ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
~ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
~ more details.
|
||||
~
|
||||
~ You should have received a copy of the GNU General Public License along with
|
||||
~ this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
~ You should have received a copy of the GNU General Public License along with
|
||||
~ this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
-->
|
||||
|
||||
<ion-header>
|
||||
@@ -20,10 +20,7 @@
|
||||
</ion-buttons>
|
||||
<ion-title>{{ 'data.detail.TITLE' | translate }}</ion-title>
|
||||
<ion-buttons slot="primary">
|
||||
<stapps-favorite-button
|
||||
*ngIf="item"
|
||||
[item]="$any(item)"
|
||||
></stapps-favorite-button>
|
||||
<stapps-favorite-button *ngIf="item" [item]="$any(item)"></stapps-favorite-button>
|
||||
</ion-buttons>
|
||||
</ion-toolbar>
|
||||
</ion-header>
|
||||
@@ -32,17 +29,13 @@
|
||||
<ng-container *ngSwitchCase="!item && (isDisconnected | async)">
|
||||
<div class="centeredMessageContainer">
|
||||
<ion-icon name="signal_disconnected"></ion-icon>
|
||||
<ion-label>
|
||||
{{ 'data.detail.COULD_NOT_CONNECT' | translate }}
|
||||
</ion-label>
|
||||
<ion-label> {{ 'data.detail.COULD_NOT_CONNECT' | translate }} </ion-label>
|
||||
</div>
|
||||
</ng-container>
|
||||
<ng-container *ngSwitchCase="item === null">
|
||||
<div class="centeredMessageContainer">
|
||||
<ion-icon name="link_off"></ion-icon>
|
||||
<ion-label>
|
||||
{{ 'data.detail.NOT_FOUND' | translate }}
|
||||
</ion-label>
|
||||
<ion-label> {{ 'data.detail.NOT_FOUND' | translate }} </ion-label>
|
||||
</div>
|
||||
</ng-container>
|
||||
<ng-container *ngSwitchCase="!item && item !== null">
|
||||
|
||||
@@ -34,10 +34,7 @@ import {ConfigProvider} from '../../config/config.provider';
|
||||
templateUrl: 'hebis-search-page.html',
|
||||
styleUrls: ['../../data/list/search-page.scss'],
|
||||
})
|
||||
export class HebisSearchPageComponent
|
||||
extends SearchPageComponent
|
||||
implements OnInit, OnDestroy
|
||||
{
|
||||
export class HebisSearchPageComponent extends SearchPageComponent implements OnInit, OnDestroy {
|
||||
/**
|
||||
* If routing should be done if the user clicks on an item
|
||||
*/
|
||||
@@ -164,24 +161,19 @@ export class HebisSearchPageComponent
|
||||
this.queryChanged.next();
|
||||
}
|
||||
}),
|
||||
this.settingsProvider.settingsActionChanged$.subscribe(
|
||||
({type, payload}) => {
|
||||
if (type === 'stapps.settings.changed') {
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
const {category, name, value} = payload!;
|
||||
this.logger.log(`received event "settings.changed" with category:
|
||||
this.settingsProvider.settingsActionChanged$.subscribe(({type, payload}) => {
|
||||
if (type === 'stapps.settings.changed') {
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
const {category, name, value} = payload!;
|
||||
this.logger.log(`received event "settings.changed" with category:
|
||||
${category}, name: ${name}, value: ${JSON.stringify(value)}`);
|
||||
}
|
||||
},
|
||||
),
|
||||
}
|
||||
}),
|
||||
this.dataRoutingService.itemSelectListener().subscribe(async item => {
|
||||
if (this.itemRouting) {
|
||||
void this.router.navigate([
|
||||
'hebis-detail',
|
||||
(item.origin &&
|
||||
'originalId' in item.origin &&
|
||||
item.origin['originalId']) ||
|
||||
'',
|
||||
(item.origin && 'originalId' in item.origin && item.origin['originalId']) || '',
|
||||
]);
|
||||
}
|
||||
}),
|
||||
|
||||
@@ -44,17 +44,13 @@
|
||||
size="large"
|
||||
>{{ 'search.type' | translate }}
|
||||
</ion-button>
|
||||
<ion-button class="button-active" size="large">{{
|
||||
'hebisSearch.type' | translate
|
||||
}}</ion-button>
|
||||
<ion-button class="button-active" size="large">{{ 'hebisSearch.type' | translate }}</ion-button>
|
||||
</ion-buttons>
|
||||
</ion-toolbar>
|
||||
</ion-header>
|
||||
|
||||
<ion-content>
|
||||
<div
|
||||
[style.display]="!showDefaultData && !items && !loading ? 'block' : 'none'"
|
||||
>
|
||||
<div [style.display]="!showDefaultData && !items && !loading ? 'block' : 'none'">
|
||||
<ion-label class="centeredMessageContainer">
|
||||
{{ 'hebisSearch.instruction' | translate }}
|
||||
</ion-label>
|
||||
|
||||
@@ -1,9 +1,19 @@
|
||||
import {
|
||||
SCArticle,
|
||||
SCBook,
|
||||
SCPeriodical,
|
||||
SCSearchResultPagination,
|
||||
} from '@openstapps/core';
|
||||
/*
|
||||
* Copyright (C) 2022 StApps
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import {SCArticle, SCBook, SCPeriodical, SCSearchResultPagination} from '@openstapps/core';
|
||||
|
||||
export interface HebisSearchResponse {
|
||||
/**
|
||||
@@ -63,11 +73,5 @@ export interface DaiaHolding {
|
||||
open?: boolean;
|
||||
dueDate?: string;
|
||||
holdings?: string;
|
||||
status?:
|
||||
| 'checked_out'
|
||||
| 'not_yet_available'
|
||||
| 'not_available'
|
||||
| 'library_only'
|
||||
| 'available'
|
||||
| 'unknown';
|
||||
status?: 'checked_out' | 'not_yet_available' | 'not_available' | 'library_only' | 'available' | 'unknown';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user