Skip to content

Commit

Permalink
document: improvement of the display get tab
Browse files Browse the repository at this point in the history
* Fixes missing translations.
* Removes custom display of book.
* Adds cancel button on request dialog.
* Closes rero/rero-ils#1660.

Co-Authored-by: Bertrand Zuchuat <bertrand.zuchuat@rero.ch>
  • Loading branch information
Garfield-fr committed Feb 17, 2021
1 parent 4ad2a6a commit 409717b
Show file tree
Hide file tree
Showing 18 changed files with 47 additions and 352 deletions.
12 changes: 3 additions & 9 deletions projects/public-holdings-items/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ import { TranslateLoader as BaseTranslateLoader, TranslateModule } from '@ngx-tr
import { CoreConfigService, CoreModule, RecordModule, TranslateLoader } from '@rero/ng-core';
import { SharedModule } from '@rero/shared';
import { TypeaheadModule } from 'ngx-bootstrap/typeahead';
import { BookComponent } from 'projects/public-search/src/app/document-detail/book/book.component';
import { HoldingsItemsComponent } from 'projects/public-search/src/app/document-detail/holdings-items/holdings-items.component';
import { HoldingComponent } from 'projects/public-search/src/app/document-detail/holdings/holding/holding.component';
import { HoldingsComponent } from 'projects/public-search/src/app/document-detail/holdings/holdings.component';
import { ItemsComponent } from 'projects/public-search/src/app/document-detail/holdings/items/items.component';
Expand All @@ -48,8 +46,6 @@ export function appInitFactory(appInitializerService: AppInitializerService) {

@NgModule({
declarations: [
BookComponent,
HoldingsItemsComponent,
HoldingsComponent,
ItemComponent,
ItemsComponent,
Expand Down Expand Up @@ -88,8 +84,6 @@ export function appInitFactory(appInitializerService: AppInitializerService) {
}
],
entryComponents: [
BookComponent,
HoldingsItemsComponent,
HoldingsComponent,
ItemComponent,
ItemsComponent
Expand All @@ -104,9 +98,9 @@ export class AppModule {
}

ngDoBootstrap() {
if (!customElements.get('public-holdings-items')) {
const searchBar = createCustomElement(HoldingsItemsComponent, { injector: this.injector });
customElements.define('public-holdings-items', searchBar);
if (!customElements.get('public-search-holdings')) {
const searchBar = createCustomElement(HoldingsComponent, { injector: this.injector });
customElements.define('public-search-holdings', searchBar);
}
}
}
7 changes: 3 additions & 4 deletions projects/public-holdings-items/src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,10 @@
<h4 class="col">Document holdings items</h4>
</div>
<div class="row col">
<public-holdings-items
documenttype="docmaintype_book"
documentpid="203"
<public-search-holdings
documentpid="218"
viewcode="global"
></public-holdings-items>
></public-search-holdings>
</div>
</div>
</container>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,4 @@ describe('HoldingsService', () => {
expect(result.hits[0]).toEqual(record);
});
});

it('should return a set of Holdings Pids', () => {
service.getHoldingsPidsByDocumentPidAndViewcode('1', 'global').subscribe((result: string[]) => {
expect(result).toEqual(holdingsPids);
});
});
});
10 changes: 0 additions & 10 deletions projects/public-search/src/app/api/holdings-api.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,4 @@ export class HoldingsApiService {
.getRecords('holdings', `document.pid:${documentPid}`, page, itemsPerPage, undefined, { view: viewcode }, this._headers)
.pipe(map((response: Record) => response.hits));
}

/**
* Get Holdings pids by document pid and viewcode
* @param documentPid - string
* @param viewcode - string
* @return Observable
*/
getHoldingsPidsByDocumentPidAndViewcode(documentPid: string, viewcode: string): Observable<string[]> {
return this._httpClient.get<string[]>(`/api/holding/pids/${documentPid}?view=${viewcode}`);
}
}
6 changes: 0 additions & 6 deletions projects/public-search/src/app/api/item-api.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,6 @@ describe('ItemService', () => {
});
});

it('should return a set of Items by document pid', () => {
service.getItemsByDocumentPidAndViewcode('1', 'global', 1).subscribe((result: QueryResponse) => {
expect(result.hits[0]).toEqual(record);
});
});

it('should return item can request', () => {
service.canRequest('1', 'xxxxxxxx').subscribe((result: any) => {
expect(result).toEqual(canRequest);
Expand Down
36 changes: 1 addition & 35 deletions projects/public-search/src/app/api/item-api.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Record, RecordService } from '@rero/ng-core';
import { Observable } from 'rxjs';
import { map, switchMap } from 'rxjs/operators';
import { map } from 'rxjs/operators';
import { QueryResponse } from '../record';
import { HoldingsApiService } from './holdings-api.service';

Expand Down Expand Up @@ -61,40 +61,6 @@ export class ItemApiService {
).pipe(map((response: Record) => response.hits));
}

/**
* Get items by holdings pids and viewcode
* @param documentPid - string
* @param viewcode - string
* @param page - number
* @param itemsPerPage - number
* @return Observable
*/
getItemsByDocumentPidAndViewcode(
documentPid: string, viewcode: string, page: number, itemsPerPage: number = 5): Observable<QueryResponse> {
return this._holdingsApiService.getHoldingsPidsByDocumentPidAndViewcode(documentPid, viewcode)
.pipe(
switchMap((holdingPids: string[]) => {
return this.getItemsByHoldingsPids(holdingPids, viewcode, page, itemsPerPage);
})
);
}

/**
* Get Items by holdings pids
* @param holdingsPids - array of string
* @param viewcode - string
* @param page - number
* @param itemsPerPage -number
* @return Observable
*/
getItemsByHoldingsPids(
holdingsPids: string[], viewcode: string, page: number, itemsPerPage: number = 5): Observable<QueryResponse> {
const query = 'holding.pid:' + holdingsPids.join(' OR holding.pid:');
return this._recordService
.getRecords('items', query, page, itemsPerPage, undefined, { view: viewcode }, this._headers, 'library')
.pipe(map((response: Record) => response.hits));
}

/**
* Item Can request
* @param itemPid - string
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 409717b

Please sign in to comment.