Skip to content

Commit

Permalink
item: add request on item by librarian
Browse files Browse the repository at this point in the history
Co-Authored-by: Bertrand Zuchuat <[email protected]>
  • Loading branch information
Garfield-fr authored and jma committed Mar 5, 2020
1 parent 2cd145c commit 83928a9
Show file tree
Hide file tree
Showing 13 changed files with 488 additions and 10 deletions.
9 changes: 6 additions & 3 deletions projects/admin/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ import { BsDatepickerModule, BsLocaleService, CollapseModule, TabsModule, Toolti
import { UiSwitchModule } from 'ngx-toggle-switch';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { FrontpageComponent } from './frontpage/frontpage.component';
import { FrontpageBoardComponent } from './frontpage/frontpage-board/frontpage-board.component';
import { FrontpageComponent } from './frontpage/frontpage.component';
import { NoCacheHeaderInterceptor } from './interceptor/no-cache-header.interceptor';
import { InterfaceInfoComponent } from './interface-info/interface-info.component';
import { MenuComponent } from './menu/menu.component';
Expand Down Expand Up @@ -70,6 +70,7 @@ import { DocumentDetailViewComponent } from './record/detail-view/document-detai
import { HoldingItemComponent } from './record/detail-view/document-detail-view/holding-item/holding-item.component';
import { HoldingComponent } from './record/detail-view/document-detail-view/holding/holding.component';
import { HoldingsComponent } from './record/detail-view/document-detail-view/holdings/holdings.component';
import { ItemRequestComponent } from './record/detail-view/document-detail-view/item-request/item-request.component';
import { RelatedResourceComponent } from './record/detail-view/document-detail-view/related-resource/related-resource.component';
import { ResourceComponent } from './record/detail-view/document-detail-view/resource/resource.component';
import { ItemDetailViewComponent } from './record/detail-view/item-detail-view/item-detail-view.component';
Expand Down Expand Up @@ -160,7 +161,8 @@ import { TranslateLoader } from './translate/loader/translate-loader';
BudgetSelectLineComponent,
FrontpageBoardComponent,
RelatedResourceComponent,
ResourceComponent
ResourceComponent,
ItemRequestComponent
],
imports: [
AppRoutingModule,
Expand Down Expand Up @@ -244,7 +246,8 @@ import { TranslateLoader } from './translate/loader/translate-loader';
AcquisitionOrderLineDetailViewComponent,
BudgetsBriefViewComponent,
BudgetDetailViewComponent,
OrganisationDetailViewComponent
OrganisationDetailViewComponent,
ItemRequestComponent
],
bootstrap: [AppComponent]
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,20 @@
</div>
<div class="col-sm-4 text-right">
<ng-container *ngIf="isAvailableActions; else noactions">
<button *ngIf="permissions.update.can" type="button" class="btn btn-primary btn-sm"
<button type="button" class="btn btn-link p-0 mr-2" (click)="addRequest(item.metadata.pid)">
<i class="fa fa-shopping-basket" aria-hidden="true" title="{{ 'Request' | translate }}"></i>
</button>
<button *ngIf="permissions.update.can" type="button" class="btn btn-link p-0 mr-2"
[routerLink]="['/records', 'items', 'edit', item.metadata.pid]">
<i class="fa fa-pencil"></i> {{ 'Edit' | translate }}
<i class="fa fa-pencil" title="{{ 'Edit' | translate }}"></i>
</button>
<button *ngIf="permissions.delete.can; else notDelete" type="button" class="btn btn-primary btn-sm ml-1"
(click)="delete(item.metadata.pid)">
<i class="fa fa-trash"></i> {{ 'Delete' | translate }}
<i class="fa fa-trash" title="{{ 'Delete' | translate }}"></i>
</button>
<ng-template #notDelete>
<button type="button" class="btn btn-dark btn-sm ml-1" (click)="showDeleteMessage()">
<i class="fa fa-trash"></i> {{ 'Delete' | translate }}
<button type="button" class="btn btn-link text-muted btn-sm p-0" (click)="showDeleteMessage()">
<i class="fa fa-trash" title="{{ 'Delete' | translate }}"></i>
</button>
</ng-template>
</ng-container>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@
*/
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
import { RecordUiService } from '@rero/ng-core';
import { BsModalService } from 'ngx-bootstrap';
import { RecordPermission, RecordPermissionService } from '../../../../service/record-permission.service';
import { UserService } from '../../../../service/user.service';
import { ItemRequestComponent } from '../item-request/item-request.component';


@Component({
Expand Down Expand Up @@ -52,8 +54,9 @@ export class HoldingItemComponent implements OnInit {
*/
constructor(
private _recordUiService: RecordUiService,
private _recordPermissionService: RecordPermissionService,
private _userService: UserService,
private _recordPermissionService: RecordPermissionService
private _modalService: BsModalService
) { }

/**
Expand All @@ -64,6 +67,16 @@ export class HoldingItemComponent implements OnInit {
.subscribe(permissions => this.permissions = permissions);
}

/**
* Add request on item
* @param itemPid - string
*/
addRequest(itemPid: string) {
this._modalService.show(ItemRequestComponent, {
initialState: { itemPid }
});
}

/**
* Delete item
* @param itemPid - Item pid
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<!--
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/>.
-->
<div *ngIf="form" class="modal show d-block" role="dialog">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" translate>Item request</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true" data-dismiss="modal" (click)="closeModal()">&times;</span>
</button>
</div>
<div class="modal-body">
<div *ngIf="patron" class="card mb-2">
<div class="card-body">
<h5 class="card-title">{{ patron.last_name }}, {{ patron.first_name }}</h5>
<p class="card-text">
{{ patron.street }}<br>
{{ patron.postal_code }} {{ patron.city }}<br>
{{ patron.email }}
</p>
</div>
</div>
<form [formGroup]="form" (ngSubmit)="submit(model)">
<formly-form [form]="form" [fields]="formFields" [model]="model"></formly-form>
<div class="text-right">
<button class="btn btn-primary" [disabled]="!form.valid" translate>New Request</button>
</div>
</form>
</div>
</div>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* 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 { HttpClientModule } from '@angular/common/http';
import { LOCALE_ID } from '@angular/core';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { FormlyModule } from '@ngx-formly/core';
import { TranslateModule } from '@ngx-translate/core';
import { RecordModule } from '@rero/ng-core';
import { BsModalRef } from 'ngx-bootstrap';
import { ItemRequestComponent } from './item-request.component';


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

beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
FormsModule,
ReactiveFormsModule,
FormlyModule,
HttpClientModule,
RecordModule,
TranslateModule.forRoot()
],
declarations: [ ItemRequestComponent ],
providers: [BsModalRef, {provide: LOCALE_ID, useValue: 'en-US' }]
})
.compileComponents();
}));

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

it('should create', () => {
expect(component).toBeTruthy();
});
});
Loading

0 comments on commit 83928a9

Please sign in to comment.