Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

document: improvement of the display get tab #521

Merged
merged 1 commit into from
Feb 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { Component, Input, OnInit } from '@angular/core';
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
import { TranslateService } from '@ngx-translate/core';
import { Record } from '@rero/ng-core';
import { BehaviorSubject, forkJoin, Observable } from 'rxjs';
import { first, map } from 'rxjs/operators';
import { map } from 'rxjs/operators';
import { OperationLogsApiService } from '../../api/operation-logs-api.service';
import { OperationLogsService } from '../../service/operation-logs.service';

Expand Down Expand Up @@ -117,8 +118,8 @@ export class OperationLogsComponent implements OnInit {
let count = this.recordTotals - (this.page * this.itemsPerPage);
if (count < 0) { count = 0; }
const linkText = (count > 1)
? '{{ counter }} hidden operation logs'
: '{{ counter }} hidden operation log';
? _('{{ counter }} hidden operation logs')
: _('{{ counter }} hidden operation log');
return this._translateService.instant(linkText, { counter: count });
}

Expand Down
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