Skip to content

Commit

Permalink
serial: receive an issue
Browse files Browse the repository at this point in the history
Creates components and services allowing to receive an issue item.

* Creates component for 'serial' type holding.
* Adapts `ItemsRoute` to pre-populate the item editor with holding data
  in case where user add/update an issue item.
* Adapts and corrects `HoldingRoute` allowing to display an holding
  detail view.
* Moves `item.service` from CirculationModule to AppModule.
* Adapts the document detail view to correctly display item from serial
  type holding.

Co-authored-by : Renaud Michotte <renaud.michotte@gmail.com>
  • Loading branch information
zannkukai committed Jun 22, 2020
1 parent 4a31735 commit 5e5a75a
Show file tree
Hide file tree
Showing 48 changed files with 1,328 additions and 220 deletions.
43 changes: 27 additions & 16 deletions projects/admin/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,21 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

import { HttpClientModule, HTTP_INTERCEPTORS } from '@angular/common/http';
import { HTTP_INTERCEPTORS, HttpClientModule } from '@angular/common/http';
import { LOCALE_ID, NgModule } from '@angular/core';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { BrowserModule } from '@angular/platform-browser';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { FormlyModule } from '@ngx-formly/core';
import { TranslateLoader as BaseTranslateLoader, TranslateModule } from '@ngx-translate/core';
import { CoreConfigService, RecordModule, TranslateService } from '@rero/ng-core';
import { CoreConfigService, RecordModule, TranslateLoader, TranslateService } from '@rero/ng-core';
import { CollapseModule } from 'ngx-bootstrap/collapse';
import { BsDatepickerModule, BsLocaleService } from 'ngx-bootstrap/datepicker';
import { BsDropdownModule } from 'ngx-bootstrap/dropdown';
import { PopoverModule } from 'ngx-bootstrap/popover';
import { TabsModule } from 'ngx-bootstrap/tabs';
import { TooltipModule } from 'ngx-bootstrap/tooltip';
import { TypeaheadModule } from 'ngx-bootstrap/typeahead';
import { UiSwitchModule } from 'ngx-toggle-switch';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
Expand Down Expand Up @@ -57,6 +64,7 @@ import {
import {
AcquisitionOrderLinesComponent
} from './record/detail-view/acquisition-order-detail-view/order-lines/acquisition-order-lines.component';
import { OrderLineComponent } from './record/detail-view/acquisition-order-detail-view/order-lines/order-line/order-line.component';
import {
AcquisitionOrderLineDetailViewComponent
} from './record/detail-view/acquisition-order-line-detail-view/acquisition-order-line-detail-view.component';
Expand All @@ -66,12 +74,21 @@ import { AcquisitionAccountsComponent } from './record/detail-view/budget-detail
import { BudgetDetailViewComponent } from './record/detail-view/budget-detail-view/budget-detail-view.component';
import { CircPolicyDetailViewComponent } from './record/detail-view/circ-policy-detail-view/circ-policy-detail-view.component';
import { DocumentDetailViewComponent } from './record/detail-view/document-detail-view/document-detail-view.component';
import { HoldingItemComponent } from './record/detail-view/document-detail-view/holding-item/holding-item.component';
import {
DefaultHoldingItemComponent
} from './record/detail-view/document-detail-view/holding/default-holding-item/default-holding-item.component';
import { HoldingComponent } from './record/detail-view/document-detail-view/holding/holding.component';
import {
SerialHoldingItemComponent
} from './record/detail-view/document-detail-view/holding/serial-holding-item/serial-holding-item.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 { HoldingDetailViewComponent } from './record/detail-view/holding-detail-view/holding-detail-view.component';
import {
SerialHoldingDetailViewComponent
} from './record/detail-view/holding-detail-view/serial-holding-detail-view/serial-holding-detail-view.component';
import { ItemDetailViewComponent } from './record/detail-view/item-detail-view/item-detail-view.component';
import { ItemTransactionComponent } from './record/detail-view/item-detail-view/item-transaction/item-transaction.component';
import { ItemTransactionsComponent } from './record/detail-view/item-detail-view/item-transactions/item-transactions.component';
Expand All @@ -93,16 +110,6 @@ import { RemoteAutocompleteInputTypeComponent } from './record/editor/remote-aut
import { ItemAvailabilityComponent } from './record/item-availability/item-availability.component';
import { AppConfigService } from './service/app-config.service';
import { SharedPipesModule } from './shared/shared-pipes.module';
import { TranslateLoader } from '@rero/ng-core';
import { BsDatepickerModule } from 'ngx-bootstrap/datepicker';
import { BsDropdownModule } from 'ngx-bootstrap/dropdown';
import { CollapseModule } from 'ngx-bootstrap/collapse';
import { TypeaheadModule } from 'ngx-bootstrap/typeahead';
import { TabsModule } from 'ngx-bootstrap/tabs';
import { TooltipModule } from 'ngx-bootstrap/tooltip';
import { PopoverModule } from 'ngx-bootstrap/popover';
import { BsLocaleService } from 'ngx-bootstrap/datepicker';
import { OrderLineComponent } from './record/detail-view/acquisition-order-detail-view/order-lines/order-line/order-line.component';

@NgModule({
declarations: [
Expand Down Expand Up @@ -133,7 +140,6 @@ import { OrderLineComponent } from './record/detail-view/acquisition-order-detai
DocumentDetailViewComponent,
HoldingEditorComponent,
HoldingComponent,
HoldingItemComponent,
HoldingsComponent,
BioInformationsPipe,
BirthDatePipe,
Expand Down Expand Up @@ -174,7 +180,11 @@ import { OrderLineComponent } from './record/detail-view/acquisition-order-detai
ResourceComponent,
ItemRequestComponent,
ErrorPageComponent,
OrderLineComponent
OrderLineComponent,
SerialHoldingItemComponent,
SerialHoldingDetailViewComponent,
HoldingDetailViewComponent,
DefaultHoldingItemComponent
],
imports: [
AppRoutingModule,
Expand Down Expand Up @@ -264,7 +274,8 @@ import { OrderLineComponent } from './record/detail-view/acquisition-order-detai
BudgetDetailViewComponent,
OrganisationDetailViewComponent,
ItemRequestComponent,
ErrorPageComponent
ErrorPageComponent,
HoldingDetailViewComponent
],
bootstrap: [AppComponent]
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { User } from '../../class/user';
import { ItemsService } from '../../service/items.service';
import { PatronService } from '../../service/patron.service';
import { UserService } from '../../service/user.service';
import { Item, ItemAction, ItemNoteType, ItemStatus } from '../items';
import { Item, ItemAction, ItemNoteType, ItemStatus } from '../../class/items';

@Component({
selector: 'admin-circulation-checkout',
Expand Down
2 changes: 1 addition & 1 deletion projects/admin/src/app/circulation/item/item.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';
import { ItemsService } from '../../service/items.service';
import { OrganisationService } from '../../service/organisation.service';
import { Item, ItemAction, Loan, LoanState } from '../items';
import { Item, ItemAction, Loan, LoanState } from '../../class/items';
import { PatronTransactionService } from '../patron-transaction.service';

@Component({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

import { Component, EventEmitter, Input, Output } from '@angular/core';
import { User } from '../../class/user';
import { ItemAction } from '../items';
import { ItemAction } from '../../class/items';

@Component({
selector: 'admin-circulation-items-list',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import { HttpClientModule } from '@angular/common/http';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { RouterTestingModule } from '@angular/router/testing';
import { TranslateModule } from '@ngx-translate/core';
import { CirculationModule } from '../circulation.module';
import { MainRequestComponent } from './main-request.component';
Expand All @@ -29,6 +30,7 @@ describe('MainRequestComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
RouterTestingModule,
HttpClientModule,
TranslateModule.forRoot(),
CirculationModule
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,33 @@
import { TestBed } from '@angular/core/testing';

import { PatronTransactionService } from './patron-transaction.service';
/*
* RERO ILS UI
* Copyright (C) 2019 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 { TranslateModule } from '@ngx-translate/core';
import { TestBed } from '@angular/core/testing';
import { RouterTestingModule } from '@angular/router/testing';
import { ToastrModule } from 'ngx-toastr';
import { TranslateModule } from '@ngx-translate/core';
import { CirculationModule } from './circulation.module';
import { PatronTransactionService } from './patron-transaction.service';

describe('PatronTransactionService', () => {
beforeEach(() => TestBed.configureTestingModule({
imports: [
TranslateModule.forRoot({}),
HttpClientModule,
RouterTestingModule,
ToastrModule.forRoot()
CirculationModule
]
}));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ import { TranslateService } from '@ngx-translate/core';
import { ToastrService } from 'ngx-toastr';
import { forkJoin } from 'rxjs';
import { User } from '../../../class/user';
import { PatronBlockedMessagePipe } from '../../../pipe/patron-blocked-message.pipe';
import { ItemsService } from '../../../service/items.service';
import { PatronService } from '../../../service/patron.service';
import { UserService } from '../../../service/user.service';
import { Item, ItemAction, ItemNoteType, ItemStatus } from '../../items';
import { Item, ItemAction, ItemNoteType, ItemStatus } from '../../../class/items';
import { ItemsService } from '../../../service/items.service';
import { PatronBlockedMessagePipe } from '../../../pipe/patron-blocked-message.pipe';

@Component({
selector: 'admin-loan',
Expand Down Expand Up @@ -265,7 +265,4 @@ export class LoanComponent implements OnInit {
);
}
}


}

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Component, Input, OnInit } from '@angular/core';
import { RecordService } from '@rero/ng-core';
import { map, mergeMap } from 'rxjs/operators';
import { Item } from '../../../../items';
import { Item } from '../../../../../class/items';
import { PatronTransaction } from '../../../../patron-transaction';

@Component({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import { marker } from '@biesbjerg/ngx-translate-extract-marker';
import * as moment from 'moment';
import { Moment } from 'moment';
import { User } from '../class/user';
import { User } from './user';
import { RecordPermission } from '../service/record-permission.service';

export function _(str) {
Expand All @@ -44,6 +44,12 @@ export enum ItemNoteType {
CHECKOUT = _('checkout_note')
}

export enum IssueItemStatus {
RECEIVED = _('received'),
CLAIMED = _('claimed'),
DELETED = _('deleted')
}

export enum LoanState {
CREATED = _('CREATED'),
PENDING = _('PENDING'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,14 @@
-->

<h5 class="mb-0 card-title">
<a [routerLink]="[detailUrl.link]">{{ record.metadata.ui_title_text }}</a>
<a [routerLink]="[detailUrl.link]">
<ng-container *ngIf="record.metadata.ui_title_text else mainTitle">
{{ record.metadata.ui_title_text }}
</ng-container>
<ng-template #mainTitle>
{{ record.metadata.title | mainTitle }}
</ng-template>
</a>
<small> &ndash; {{ record.metadata.type | translate }}</small></h5>
<ng-container class="card-text">

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ <h5 translate>Examples (preview)</h5>
<ng-container *ngIf="!serialPreviewError; else previewError">
<ng-container *ngIf="serialPreviewExamples && serialPreviewExamples.length > 0; else noPreview">
<ul class="list-unstyled">
<li *ngFor="let issue of serialPreviewExamples | slice:0:10">{{issue}}</li>
<li *ngFor="let issue of serialPreviewExamples | slice:0:10">{{issue.issue}}</li>
</ul>
...
<ul class="list-unstyled">
<li *ngFor="let issue of serialPreviewExamples | slice:97:100">{{issue}}</li>
<li *ngFor="let issue of serialPreviewExamples | slice:97:100">{{issue.issue}}</li>
</ul>
</ng-container>
</ng-container>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,24 @@
/*
* 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 } from '@angular/core';
import { EditorService } from '../../../service/editor.service';
import { removeEmptyValues } from '@rero/ng-core';
import { EditorService } from '../../../service/editor.service';
import { PredictionIssue } from '../../../service/holdings.service';

/**
* Holding specific editor.
Expand All @@ -17,7 +35,7 @@ export class HoldingEditorComponent {
model = {};

/** Current list of the serial preview examples */
serialPreviewExamples = [];
serialPreviewExamples: Array<PredictionIssue> = [];

/** Number of the serial preview examples */
numberOfSerialPreviewExamples = 100;
Expand All @@ -42,9 +60,9 @@ export class HoldingEditorComponent {
this.serialPreviewError = null;
if (modelValue.patterns && modelValue.patterns.template) {
this._editorService.getHoldingPatternPreview(modelValue, this.numberOfSerialPreviewExamples).subscribe(
response => {
if (response && response.issues && response.issues.length > 0) {
this.serialPreviewExamples = response.issues;
(predictions) => {
if (predictions && predictions.length > 0) {
this.serialPreviewExamples = predictions;
}
},
(error: any) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
<!--
RERO ILS UI
Copyright (C) 2019 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/>.
Copyright (C) 2019 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/>.
-->
<ng-container *ngIf="item && permissions">
<div class="offset-sm-1 col-sm-3">
Expand Down
Loading

0 comments on commit 5e5a75a

Please sign in to comment.