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 committed Feb 14, 2020
1 parent c6fe56c commit 931dae5
Show file tree
Hide file tree
Showing 13 changed files with 489 additions and 18 deletions.
7 changes: 5 additions & 2 deletions projects/admin/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ import { AcquisitionAccountComponent } from './record/detail-view/budget-detail-
import { OrganisationDetailViewComponent } from './record/detail-view/organisation-detail-view/organisation-detail-view.component';
import { BudgetSelectComponent } from './record/detail-view/organisation-detail-view/budget-select/budget-select.component';
import { BudgetSelectLineComponent } from './record/detail-view/organisation-detail-view/budget-select-line/budget-select-line.component';
import { ItemRequestComponent } from './record/detail-view/document-detail-view/item-request/item-request.component';

@NgModule({
declarations: [
Expand Down Expand Up @@ -161,7 +162,8 @@ import { BudgetSelectLineComponent } from './record/detail-view/organisation-det
AcquisitionAccountComponent,
OrganisationDetailViewComponent,
BudgetSelectComponent,
BudgetSelectLineComponent
BudgetSelectLineComponent,
ItemRequestComponent
],
imports: [
AppRoutingModule,
Expand Down Expand Up @@ -245,7 +247,8 @@ import { BudgetSelectLineComponent } from './record/detail-view/organisation-det
AcquisitionOrderLineDetailViewComponent,
BudgetsBriefViewComponent,
BudgetDetailViewComponent,
OrganisationDetailViewComponent
OrganisationDetailViewComponent,
ItemRequestComponent
],
bootstrap: [AppComponent]
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,20 @@
</div>
<div class="col-sm-4 text-right">
<ng-container *ngIf="isAvailableActions; else noactions">
<button *ngIf="!item.permissions.cannot_update" 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="!item.permissions.cannot_update" 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="!item.permissions.cannot_delete; else notDelete" type="button" class="btn btn-primary btn-sm ml-1"
<button *ngIf="!item.permissions.cannot_delete; else notDelete" type="button" class="btn btn-link p-0"
(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(item)">
<i class="fa fa-trash"></i> {{ 'Delete' | translate }}
<button type="button" class="btn btn-link text-muted btn-sm p-0" (click)="showDeleteMessage(item)">
<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 @@ -19,6 +19,8 @@ import { Component, EventEmitter, Input, Output } from '@angular/core';
import { RecordUiService } from '@rero/ng-core';
import { RecordPermissionMessageService } from 'projects/admin/src/app/service/record-permission-message.service';
import { UserService } from 'projects/admin/src/app/service/user.service';
import { BsModalService } from 'ngx-bootstrap';
import { ItemRequestComponent } from '../item-request/item-request.component';

@Component({
selector: 'admin-holding-item',
Expand Down Expand Up @@ -50,9 +52,20 @@ export class HoldingItemComponent {
constructor(
private recordUiService: RecordUiService,
private recordPermissionMessage: RecordPermissionMessageService,
private userService: UserService
private userService: UserService,
private _modalService: BsModalService
) { }

/**
* 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 931dae5

Please sign in to comment.