Skip to content

Commit

Permalink
item: circulation info in detail view
Browse files Browse the repository at this point in the history
* Removes redundant requests information.
* Adds item status.
* Displays requests for items at desk.
* Closes rero/rero-ils#798.

Co-Authored-by: Alicia Zangger <alicia.zangger@rero.ch>
  • Loading branch information
Alicia Zangger committed Feb 26, 2020
1 parent bd85eb5 commit 0d73707
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
 You should have received a copy of the GNU Affero General Public License
 along with this program. If not, see <http://www.gnu.org/licenses/>.
-->

<ng-container *ngIf="record">
<header class="row">
<h1>{{ 'Barcode' | translate }} {{ record.metadata.barcode }}</h1>
Expand Down Expand Up @@ -64,21 +65,6 @@ <h1>{{ 'Barcode' | translate }} {{ record.metadata.barcode }}</h1>
<dd class="col-sm-7 col-md-8 mb-0">
<admin-item-availability [item]="record"></admin-item-availability>
</dd>
<!-- NUMBER OF REQUEST -->
<ng-container *ngIf="numberOfRequests > 0">
<dt class="col-sm-3 offset-sm-2 offset-md-0">
{{ 'Request queue' | translate }}:
</dt>
<dd class="col-sm-7 col-md-8 mb-0">
{{ numberOfRequests }}
<ng-container *ngIf="numberOfRequests > 1; else request">
{{ 'requests' | translate }}
</ng-container>
<ng-template #request>
{{ 'request' | translate }}
</ng-template>
</dd>
</ng-container>
</dl>
</section>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { Component, OnInit, Input } from '@angular/core';
import { Component, OnInit, Input, ɵConsole } from '@angular/core';
import { LoanService } from 'projects/admin/src/app/service/loan.service';
import { Observable } from 'rxjs';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@
-->
<ng-container *ngIf="item">
<i class="fa fa-circle text-{{ item.metadata.available ? 'success': 'danger' }}"></i>
<ng-container *ngIf="item.metadata.available; else unavailable">
<!-- TODO: There will be a US to uniformize the display of availability. Remove or uncomment the following code accordingly: -->
<!-- <ng-container *ngIf="item.metadata.available; else unavailable">
{{ 'available' | translate }}
</ng-container>
<ng-template #unavailable>
{{ 'unavailable' | translate }}
</ng-template>
</ng-template> -->
({{ item.metadata.status | translate }})
</ng-container>
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,31 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { Component, Input } from '@angular/core';
import { Component, Input, OnInit } from '@angular/core';
import { LoanService } from '../../service/loan.service';
import { Observable } from 'rxjs';

@Component({
selector: 'admin-item-availability',
templateUrl: './item-availability.component.html',
styles: []
})
export class ItemAvailabilityComponent {
export class ItemAvailabilityComponent implements OnInit {

/** Item record */
@Input() item: any;

/** Number of requests */
numberOfRequest$: Observable<any>;

/**
* Constructor
* @param loanService - LoanService
*/
constructor(private loanService: LoanService) { }

ngOnInit() {
this.numberOfRequest$ = this.loanService.numberOfRequests$(this.item.metadata.pid);
console.log(this.numberOfRequest$);
}
}
4 changes: 2 additions & 2 deletions projects/admin/src/app/service/loan.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export class LoanService {
};

statusRequest = {
ON_DESK: 'ITEM_ON_DESK',
AT_DESK: 'ITEM_AT_DESK',
PENDING: 'PENDING',
IN_TRANSIT_FOR_PICKUP: 'ITEM_IN_TRANSIT_FOR_PICKUP'
};
Expand Down Expand Up @@ -73,7 +73,7 @@ export class LoanService {
requestedBy$(itemPid: string) {
return this.loans$(itemPid).pipe(
map(results => results.hits.hits.filter((data: any) =>
data.metadata.state === this.statusRequest.ON_DESK
data.metadata.state === this.statusRequest.AT_DESK
|| data.metadata.state === this.statusRequest.PENDING
|| data.metadata.state === this.statusRequest.IN_TRANSIT_FOR_PICKUP
))
Expand Down

0 comments on commit 0d73707

Please sign in to comment.