Skip to content

Commit

Permalink
items: display item notes
Browse files Browse the repository at this point in the history
Replaces the sticky icon by the note content into the document detailed
view.

Closes rero/rero-ils#1501

Co-Authored-by: Renaud Michotte <renaud.michotte@gmail.com>
  • Loading branch information
zannkukai committed Dec 8, 2020
1 parent 2b36b47 commit c2996a3
Show file tree
Hide file tree
Showing 9 changed files with 209 additions and 140 deletions.
4 changes: 3 additions & 1 deletion projects/admin/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ import { HoldingDetailComponent } from './record/detail-view/document-detail-vie
import { CustomShortcutHelpComponent } from './widgets/custom-shortcut-help/custom-shortcut-help.component';
import { IllRequestsBriefViewComponent } from './record/brief-view/ill-requests-brief-view/ill-requests-brief-view.component';
import { IllRequestDetailViewComponent } from './record/detail-view/ill-request-detail-view/ill-request-detail-view.component';
import { HoldingItemNoteComponent } from './record/detail-view/document-detail-view/holding/holding-item-note/holding-item-note.component';

/** Init application factory */
export function appInitFactory(appInitService: AppInitService) {
Expand Down Expand Up @@ -224,7 +225,8 @@ export function appInitFactory(appInitService: AppInitService) {
CorporateBodiesDetailViewComponent,
IllRequestsBriefViewComponent,
IllRequestDetailViewComponent,
CustomShortcutHelpComponent
CustomShortcutHelpComponent,
HoldingItemNoteComponent
],
imports: [
AppRoutingModule,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,65 +14,59 @@
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="item && permissions">
<div class="col-sm-3">
<span class="badge badge-secondary float-right small pt-1" *ngIf="item.metadata.notes && item.metadata.notes.length > 0">
<i class="fa fa-sticky-note-o"></i> {{ item.metadata.notes.length }}
</span>
<a [routerLink]="['/records', 'items', 'detail', item.metadata.pid]" name="barcode">
{{ item.metadata.barcode }}
</a>
</div>
<div class="col-sm-2" name="status">
{{ item.metadata.status | translate }}
</div>
<div class="col-sm-3" name="issue">
{{ item.metadata.enumerationAndChronology }}
</div>
<div class="col-sm-2" name="call-number">
{{ callNumber }}
</div>
<div class="col-sm-2 text-right" name="buttons">
<button *ngIf="permissions.canRequest && permissions.canRequest.can; else notRequest"
type="button" class="btn btn-sm btn-outline-primary " (click)="addRequest(item.metadata.pid)"
title="{{ 'Item request' | translate}}"
name="request">
<i class="fa fa-shopping-basket" aria-hidden="true"></i>
</button>
<ng-template #notRequest>
<button type="buttton" class="btn btn-sm btn-outline-primary disabled"
<div class="container px-0 mt-1 mb-2" *ngIf="item && permissions">
<div class="row"> <!-- First row :: item detail -->
<div class="col-sm-3">
<a [routerLink]="['/records', 'items', 'detail', item.metadata.pid]" name="barcode">
{{ item.metadata.barcode }}
</a>
</div>
<div class="col-sm-2" name="status">{{ item.metadata.status | translate }}</div>
<div class="col-sm-3" name="issue">{{ item.metadata.enumerationAndChronology }}</div>
<div class="col-sm-2" name="call-number">{{ callNumbers }}</div>
<div class="col-sm-2 text-right" name="buttons">
<button *ngIf="permissions.canRequest && permissions.canRequest.can; else notRequest"
type="button" class="btn btn-sm btn-outline-primary " (click)="addRequest(item.metadata.pid)"
title="{{ 'Item request' | translate}}"
[popover]="tolTemplate" triggers="mouseenter:mouseleave"
name="request">
<i class="fa fa-shopping-basket" aria-hidden="true"></i>
</button>
<ng-template #tolTemplate><div [innerHtml]="cannotRequestInfoMessage | nl2br"></div></ng-template>
</ng-template>
<button *ngIf="permissions.update && permissions.update.can"
type="button" class="btn btn-sm btn-outline-primary ml-1"
title="{{ 'Edit' | translate}}"
[routerLink]="['/records', 'items', 'edit', item.metadata.pid]"
name="edit">
<i class="fa fa-pencil"></i>
</button>
<button *ngIf="permissions.delete && permissions.delete.can; else deleteInfo"
type="button" class="btn btn-outline-danger btn-sm ml-1"
title="{{ 'Delete' | translate}}"
(click)="delete(item.metadata.pid)"
name="delete">
<i class="fa fa-trash" ></i>
</button>
<ng-template #deleteInfo>
<button type="button" class="btn btn-sm btn-outline-danger ml-1 disabled"
title="{{ 'Delete' | translate}}"
[popover]="tolTemplate" triggers="mouseenter:mouseleave"
<ng-template #notRequest>
<button type="buttton" class="btn btn-sm btn-outline-primary disabled"
title="{{ 'Item request' | translate }}"
[popover]="tolTemplate" triggers="mouseenter:mouseleave"
name="request">
<i class="fa fa-shopping-basket" aria-hidden="true"></i>
</button>
<ng-template #tolTemplate><div [innerHtml]="cannotRequestInfoMessage | nl2br"></div></ng-template>
</ng-template>
<button *ngIf="permissions.update && permissions.update.can"
type="button" class="btn btn-sm btn-outline-primary ml-1"
title="{{ 'Edit' | translate }}"
[routerLink]="['/records', 'items', 'edit', item.metadata.pid]"
name="edit">
<i class="fa fa-pencil"></i>
</button>
<button *ngIf="permissions.delete && permissions.delete.can; else deleteInfo"
type="button" class="btn btn-outline-danger btn-sm ml-1"
title="{{ 'Delete' | translate }}"
(click)="delete(item.metadata.pid)"
name="delete">
<i class="fa fa-trash"></i>
</button>
<ng-template #tolTemplate><div [innerHtml]="deleteInfoMessage | nl2br"></div></ng-template>
</ng-template>
<ng-template #deleteInfo>
<button type="button" class="btn btn-sm btn-outline-danger ml-1 disabled"
title="{{ 'Delete' | translate }}"
[popover]="tolTemplate" triggers="mouseenter:mouseleave"
name="delete">
<i class="fa fa-trash"></i>
</button>
<ng-template #tolTemplate><div [innerHtml]="deleteInfoMessage | nl2br"></div></ng-template>
</ng-template>
</div>
</div>
<admin-holding-item-in-collection [itemPid]="item.metadata.pid" [class]="'col-sm-12'"></admin-holding-item-in-collection>
</ng-container>
<admin-holding-item-note [note]="note" *ngFor="let note of item.metadata.notes"></admin-holding-item-note>
<admin-holding-item-in-collection [itemPid]="item.metadata.pid"></admin-holding-item-in-collection>
</div>


Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,29 @@ import { ItemRequestComponent } from '../../item-request/item-request.component'
})
export class DefaultHoldingItemComponent implements OnInit {

// COMPONENT ATTRIBUTES ============================================================
/** Holding record */
@Input() holding: any;

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

/** Event for delete Item */
@Output() deleteItem = new EventEmitter();

/** Item permissions */
permissions: any;

// GETTER & SETTER =================================================================
/**
* Get formatted item call numbers
* @return formatted string
*/
get callNumbers(): string {
return [this.item.metadata.call_number, this.item.metadata.second_call_number || null]
.filter(element => element !== null)
.join(' | ');
}

// CONSTRUCTOR & HOOKS ==============================================================
/**
* Constructor
* @param _recordUiService - RecordUiService
Expand All @@ -59,13 +70,15 @@ export class DefaultHoldingItemComponent implements OnInit {
protected _itemService: ItemsService
) { }

/** Init */
/** OnInit hook */
ngOnInit() {
this.getPermissions();
this._getPermissions();
}


// COMPONENT FUNCTIONS ================================================================
/** Get permissions */
getPermissions() {
private _getPermissions() {
const permissionObs = this._recordPermissionService.getPermission('items', this.item.metadata.pid);
const canRequestObs = this._itemService.canRequest(this.item.metadata.pid);
forkJoin([permissionObs, canRequestObs]).subscribe(
Expand All @@ -75,18 +88,6 @@ export class DefaultHoldingItemComponent implements OnInit {
});
}

/**
* Get formatted call number
*
* Join call number and second call number separate by ` - `
* @returns - formatted string
*/
get callNumber(): string {
if (this.item.metadata.second_call_number) {
return this.item.metadata.call_number + ' | ' + this.item.metadata.second_call_number;
}
return this.item.metadata.call_number;
}

/**
* Add request on item and refresh permissions
Expand All @@ -96,9 +97,7 @@ export class DefaultHoldingItemComponent implements OnInit {
const modalRef = this._modalService.show(ItemRequestComponent, {
initialState: { itemPid }
});
modalRef.content.onSubmit.pipe(first()).subscribe(value => {
this.getPermissions();
});
modalRef.content.onSubmit.pipe(first()).subscribe(_ => this._getPermissions());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,18 @@
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="collections">
<div [class]="class" *ngIf="collections.length > 0">
<i class="fa fa-long-arrow-right pl-4 pr-1"></i>
<span class="label-title" translate>Temporary location</span>
<ng-container *ngFor="let collection of collections; let last=last">
<a [routerLink]="['/records', 'collections', 'detail', collection.metadata.pid]">
{{ collection.metadata.title }}
</a>{{ last ? '' : '; ' }}
</ng-container>
<ng-container *ngIf="collections && collections.length > 0">
<div class="row">
<div class="col-sm-4 col-md-3 pl-5">
<i class="fa fa-long-arrow-right pr-1"></i>
<span class="label-title" translate>Temporary location</span>
</div>
<div class="col-sm-8 col-md-9">
<ng-container *ngFor="let collection of collections; let last=last">
<a [routerLink]="['/records', 'collections', 'detail', collection.metadata.pid]">
{{ collection.metadata.title }}
</a>{{ last ? '' : '; ' }}
</ng-container>
</div>
</div>
</ng-container>
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ export class HoldingItemInCollectionComponent implements OnInit {

/** Item pid */
@Input() itemPid: string;

/** CSS Class for div element */
@Input() class: string;

Expand All @@ -39,9 +38,11 @@ export class HoldingItemInCollectionComponent implements OnInit {
* Constructor
* @param _recordService - RecordService
*/
constructor(private _recordService: RecordService) { }
constructor(
private _recordService: RecordService
) { }

/** Init */
/** OnInit hook */
ngOnInit() {
this.isItemInCollection(this.itemPid);
}
Expand All @@ -62,9 +63,9 @@ export class HoldingItemInCollectionComponent implements OnInit {
'title'
).pipe(
map((result: any) => {
return this._recordService.totalHits(result.hits.total) === 0
? []
: result.hits.hits;
return (this._recordService.totalHits(result.hits.total) === 0)
? []
: result.hits.hits;
})
).subscribe(collections => this.collections = collections);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* RERO ILS UI
* Copyright (C) 2020 RERO
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, version 3 of the License.
*
* 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 Affero General Public License for more details.
*
* 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 { ComponentFixture, TestBed } from '@angular/core/testing';

import { HoldingItemNoteComponent } from './holding-item-note.component';

describe('HoldingItemNoteComponent', () => {
let component: HoldingItemNoteComponent;
let fixture: ComponentFixture<HoldingItemNoteComponent>;

beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ HoldingItemNoteComponent ]
})
.compileComponents();
});

beforeEach(() => {
fixture = TestBed.createComponent(HoldingItemNoteComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* RERO ILS UI
* Copyright (C) 2020 RERO
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, version 3 of the License.
*
* 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 Affero General Public License for more details.
*
* 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 { ItemNote } from 'projects/admin/src/app/class/items';

@Component({
selector: 'admin-holding-item-note',
template: `
<div class="row" *ngIf="note">
<div class="col-sm-4 col-md-3 font-weight-bold label-title pl-5">{{ note.type.toString() | translate}}</div>
<div class="col-sm-8 col-md-9" [innerHTML]="note.content"></div>
</div>
`
})
export class HoldingItemNoteComponent {
/** the item note */
@Input() note: ItemNote;
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@
</div>
<admin-serial-holding-item
*ngFor="let item of items | slice:0: displayItemsCounter"
class="row mt-1 mb-2"
[holding]="holding"
[item]="item"
(deleteItem)="deleteItem($event)"
Expand Down Expand Up @@ -106,7 +105,6 @@
</div>
<admin-default-holding-item
*ngFor="let item of items | slice:0: displayItemsCounter"
class="row mt-1 mb-2"
[holding]="holding"
[item]="item"
(deleteItem)="deleteItem($event)"
Expand Down
Loading

0 comments on commit c2996a3

Please sign in to comment.