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

item: add request on item by librarian #147

Merged
merged 1 commit into from
Mar 9, 2020
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
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