Skip to content

Commit

Permalink
contribution: refactoring to integrate organisation
Browse files Browse the repository at this point in the history
* Adds MefPersonTypeahead and MefOrganisationTypeahead.
* Adds a new module shared outside the project.
* Adds a new pipe to extact sources data on contributions.
* Adds a new directive ngVar.
* Adds license.
* Fixes tests with new shared module.
* Deletes a shared pipe module on admin project.
* Moves some elements on shared module.

Co-Authored-by: Bertrand Zuchuat <bertrand.zuchuat@rero.ch>
  • Loading branch information
Garfield-fr committed Oct 21, 2020
1 parent f5a95df commit 14e0e3a
Show file tree
Hide file tree
Showing 79 changed files with 1,456 additions and 698 deletions.
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
"@ngx-formly/bootstrap": "^5.9.1",
"@ngx-formly/core": "^5.9.1",
"@ngx-translate/core": "^12.1.1",
"@rero/ng-core": "^0.11.1",
"@rero/ng-core": "^0.12.1",
"bootstrap": "^4.3.1",
"crypto-js": "^3.1.9-1",
"document-register-element": "^1.7.2",
Expand Down
46 changes: 22 additions & 24 deletions projects/admin/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,20 @@ 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 { MainTitlePipe } from 'projects/shared/pipe/main-title.pipe';
import { SharedModule } from 'projects/shared/shared.module';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { DocumentsTypeahead } from './class/documents-typeahead';
import { ItemsTypeahead } from './class/items-typeahead';
import { MefOrganisationTypeahead } from './class/mef-organisation-typeahead';
import { MefPersonTypeahead } from './class/mef-person-typeahead';
import { MefTypeahead } from './class/mef-typeahead';
import { TabOrderDirective } from './directives/tab-order.directive';
import { ErrorPageComponent } from './error/error-page/error-page.component';
import { NoCacheHeaderInterceptor } from './interceptor/no-cache-header.interceptor';
import { MenuComponent } from './menu/menu.component';
import { BioInformationsPipe } from './pipe/bio-informations.pipe';
import { BirthDatePipe } from './pipe/birth-date.pipe';
import { MainTitlePipe } from './pipe/main-title.pipe';
import { MarcPipe } from './pipe/marc.pipe';
import { MefTitlePipe } from './pipe/mef-title.pipe';
import { NotesFormatPipe } from './pipe/notes-format.pipe';
import { AcquisitionOrderBriefViewComponent } from './record/brief-view/acquisition-order-brief-view.component';
import { BudgetsBriefViewComponent } from './record/brief-view/budgets-brief-view.component';
Expand All @@ -57,7 +57,6 @@ import { ItemsBriefViewComponent } from './record/brief-view/items-brief-view/it
import { LibrariesBriefViewComponent } from './record/brief-view/libraries-brief-view.component';
import { PatronTypesBriefViewComponent } from './record/brief-view/patron-types-brief-view.component';
import { PatronsBriefViewComponent } from './record/brief-view/patrons-brief-view.component';
import { PersonsBriefViewComponent } from './record/brief-view/persons-brief-view.component';
import { TemplatesBriefViewComponent } from './record/brief-view/templates-brief-view.component';
import { VendorBriefViewComponent } from './record/brief-view/vendor-brief-view.component';
import { CirculationPolicyComponent } from './record/custom-editor/circulation-settings/circulation-policy/circulation-policy.component';
Expand All @@ -83,7 +82,13 @@ import { BudgetDetailViewComponent } from './record/detail-view/budget-detail-vi
import { CircPolicyDetailViewComponent } from './record/detail-view/circ-policy-detail-view/circ-policy-detail-view.component';
import { CollectionDetailViewComponent } from './record/detail-view/collection-detail-view/collection-detail-view.component';
import { CollectionItemsComponent } from './record/detail-view/collection-detail-view/collection-items/collection-items.component';
import { ContributionDetailViewComponent } from './record/detail-view/contribution-detail-view/contribution-detail-view.component';
import {
CorporateBodiesDetailViewComponent
} from './record/detail-view/contribution-detail-view/corporate-bodies-detail-view/corporate-bodies-detail-view.component';
import { PersonDetailViewComponent } from './record/detail-view/contribution-detail-view/person-detail-view/person-detail-view.component';
import { DocumentDetailViewComponent } from './record/detail-view/document-detail-view/document-detail-view.component';
import { HoldingDetailComponent } from './record/detail-view/document-detail-view/holding-detail/holding-detail.component';
import {
DefaultHoldingItemComponent
} from './record/detail-view/document-detail-view/holding/default-holding-item/default-holding-item.component';
Expand Down Expand Up @@ -116,18 +121,15 @@ import { BudgetSelectComponent } from './record/detail-view/organisation-detail-
import { OrganisationDetailViewComponent } from './record/detail-view/organisation-detail-view/organisation-detail-view.component';
import { PatronDetailViewComponent } from './record/detail-view/patron-detail-view/patron-detail-view.component';
import { PatronTypesDetailViewComponent } from './record/detail-view/patron-types-detail-view/patron-types-detail-view.component';
import { PersonDetailViewComponent } from './record/detail-view/person-detail-view/person-detail-view.component';
import { TemplateDetailViewComponent } from './record/detail-view/template-detail-view/template-detail-view.component';
import { VendorDetailViewComponent } from './record/detail-view/vendor-detail-view/vendor-detail-view.component';
import { DocumentRecordSearchComponent } from './record/document-record-search/document-record-search.component';
import { ItemAvailabilityComponent } from './record/item-availability/item-availability.component';
import { AppConfigService } from './service/app-config.service';
import { AppInitService } from './service/app-init.service';
import { UiRemoteTypeaheadService } from './service/ui-remote-typeahead.service';
import { SharedPipesModule } from './shared/shared-pipes.module';
import { FrontpageBoardComponent } from './widgets/frontpage/frontpage-board/frontpage-board.component';
import { FrontpageComponent } from './widgets/frontpage/frontpage.component';
import { HoldingDetailComponent } from './record/detail-view/document-detail-view/holding-detail/holding-detail.component';

/** Init application factory */
export function appInitFactory(appInitService: AppInitService) {
Expand All @@ -137,8 +139,6 @@ export function appInitFactory(appInitService: AppInitService) {
@NgModule({
declarations: [
AppComponent,
BioInformationsPipe,
BirthDatePipe,
CircPoliciesBriefViewComponent,
CirculationPolicyComponent,
DocumentEditorComponent,
Expand All @@ -150,23 +150,17 @@ export function appInitFactory(appInitService: AppInitService) {
ItemTypeDetailViewComponent,
LibrariesBriefViewComponent,
LibraryComponent,
MefTitlePipe,
MenuComponent,
PatronsBriefViewComponent,
PatronTypesBriefViewComponent,
PatronTypesDetailViewComponent,
PersonsBriefViewComponent,
LibraryDetailViewComponent,
DayOpeningHoursComponent,
ExceptionDateComponent,
PersonDetailViewComponent,
DocumentDetailViewComponent,
HoldingEditorComponent,
HoldingComponent,
HoldingsComponent,
BioInformationsPipe,
BirthDatePipe,
MefTitlePipe,
LibraryComponent,
ExceptionDatesListComponent,
ExceptionDatesEditComponent,
Expand Down Expand Up @@ -215,7 +209,10 @@ export function appInitFactory(appInitService: AppInitService) {
CollectionItemsComponent,
HoldingItemInCollectionComponent,
DocumentRecordSearchComponent,
HoldingDetailComponent
HoldingDetailComponent,
ContributionDetailViewComponent,
PersonDetailViewComponent,
CorporateBodiesDetailViewComponent
],
imports: [
AppRoutingModule,
Expand All @@ -228,7 +225,6 @@ export function appInitFactory(appInitService: AppInitService) {
HttpClientModule,
ReactiveFormsModule,
RecordModule,
SharedPipesModule,
TabsModule.forRoot(),
TooltipModule.forRoot(),
PopoverModule.forRoot(),
Expand All @@ -239,7 +235,8 @@ export function appInitFactory(appInitService: AppInitService) {
useClass: TranslateLoader
}
}),
TypeaheadModule
TypeaheadModule,
SharedModule
],
providers: [
{
Expand Down Expand Up @@ -270,8 +267,10 @@ export function appInitFactory(appInitService: AppInitService) {
MefTypeahead,
DocumentsTypeahead,
ItemsTypeahead,
MainTitlePipe,
TruncateTextPipe
MefPersonTypeahead,
MefOrganisationTypeahead,
TruncateTextPipe,
MainTitlePipe
],
entryComponents: [
CircPoliciesBriefViewComponent,
Expand All @@ -287,11 +286,9 @@ export function appInitFactory(appInitService: AppInitService) {
PatronsBriefViewComponent,
PatronTypesDetailViewComponent,
PatronTypesBriefViewComponent,
PersonsBriefViewComponent,
ExceptionDatesEditComponent,
LibraryDetailViewComponent,
LibraryComponent,
PersonDetailViewComponent,
DocumentDetailViewComponent,
ExceptionDatesEditComponent,
CircPolicyDetailViewComponent,
Expand All @@ -315,7 +312,8 @@ export function appInitFactory(appInitService: AppInitService) {
CollectionBriefViewComponent,
CollectionDetailViewComponent,
HoldingItemInCollectionComponent,
DocumentRecordSearchComponent
DocumentRecordSearchComponent,
ContributionDetailViewComponent
],
bootstrap: [AppComponent]
})
Expand Down
4 changes: 2 additions & 2 deletions projects/admin/src/app/circulation/circulation.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import { FormlyModule } from '@ngx-formly/core';
import { RecordModule } from '@rero/ng-core';
import { BsDropdownModule } from 'ngx-bootstrap/dropdown';
import { CollapseModule } from 'ngx-bootstrap/collapse';
import { SharedPipesModule } from '../shared/shared-pipes.module';
import { CheckinComponent } from './checkin/checkin.component';
import { CirculationRoutingModule } from './circulation-routing.module';
import { ItemComponent } from './item/item.component';
Expand Down Expand Up @@ -52,6 +51,7 @@ import { ProfileComponent } from './patron/profile/profile.component';
import { PendingItemComponent } from './patron/pending/pending-item/pending-item.component';
import { PendingComponent } from './patron/pending/pending.component';
import { RequestedItemsListComponent } from './requested-items-list/requested-items-list.component';
import { SharedModule } from 'projects/shared/shared.module';


@NgModule({
Expand Down Expand Up @@ -88,7 +88,7 @@ import { RequestedItemsListComponent } from './requested-items-list/requested-it
FormsModule,
ReactiveFormsModule,
FormlyModule,
SharedPipesModule
SharedModule
],
entryComponents: [
PatronTransactionEventFormComponent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { TranslateModule } from '@ngx-translate/core';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { CirculationModule } from '../../../circulation.module';
import { HistoryItemComponent } from './history-item.component';
import { SharedModule } from 'projects/shared/shared.module';

describe('HistoryItemComponent', () => {
let component: HistoryItemComponent;
Expand All @@ -32,7 +33,8 @@ describe('HistoryItemComponent', () => {
TranslateModule.forRoot(),
RouterTestingModule,
HttpClientModule,
CirculationModule
CirculationModule,
SharedModule
]
})
.compileComponents();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

import { Component, Input, OnInit } from '@angular/core';
import { extractIdOnRef, RecordService } from '@rero/ng-core';
import { ProvisionActivityType } from 'projects/shared/pipe/provision-activity.pipe';
import { forkJoin } from 'rxjs';
import { ProvisionActivityType } from '../../../../pipe/provision-activity.pipe';
import { PatronService } from '../../../../service/patron.service';

@Component({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ import { Component, OnDestroy, OnInit } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { ToastrService } from 'ngx-toastr';
import { forkJoin, Subscription } from 'rxjs';
import { PatronBlockedMessagePipe } from 'projects/shared/pipe/patron-blocked-message.pipe';
import { Item, ItemAction, ItemNoteType, ItemStatus } from '../../../class/items';
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';
Expand Down
2 changes: 1 addition & 1 deletion projects/admin/src/app/class/documents-typeahead.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@

import { Inject, Injectable } from '@angular/core';
import { ApiService, RecordService, SuggestionMetadata } from '@rero/ng-core';
import { MainTitlePipe } from 'projects/shared/pipe/main-title.pipe';
import { of, Observable } from 'rxjs';
import { map } from 'rxjs/operators';
import { MainTitlePipe } from '../pipe/main-title.pipe';

/**
* Escape string using regular expression.
Expand Down
2 changes: 1 addition & 1 deletion projects/admin/src/app/class/items-typeahead.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
import { Inject, Injectable } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { ApiService, RecordService, SuggestionMetadata, TruncateTextPipe } from '@rero/ng-core';
import { MainTitlePipe } from 'projects/shared/pipe/main-title.pipe';
import { from, Observable, of } from 'rxjs';
import { map, mergeMap, switchMap, toArray } from 'rxjs/operators';
import { MainTitlePipe } from '../pipe/main-title.pipe';

@Injectable()
export class ItemsTypeahead {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* RERO ILS UI
* Copyright (C) 2019 RERO
* 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
Expand All @@ -14,20 +14,19 @@
* 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 { Pipe, PipeTransform } from '@angular/core';

@Pipe({
name: 'bioInformations'
})
export class BioInformationsPipe implements PipeTransform {
import { Inject, Injectable } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { RecordService } from '@rero/ng-core';
import { MefTypeahead } from './mef-typeahead';

transform(value: any): any {
for (const source of ['idref', 'gnd', 'bnf', 'rero']) {
if (value[source] && value[source].biographical_information) {
return value[source].biographical_information;
}
}
return null;
@Injectable()
export class MefOrganisationTypeahead extends MefTypeahead {
constructor(
@Inject(RecordService) _recordService: RecordService,
@Inject(TranslateService) _translateService: TranslateService
) {
super(_recordService, _translateService);
this.type = 'Organisation';
}

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* RERO ILS UI
* Copyright (C) 2019 RERO
* 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
Expand All @@ -14,19 +14,19 @@
* 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 { Pipe, PipeTransform } from '@angular/core';

@Pipe({
name: 'mefTitle'
})
export class MefTitlePipe implements PipeTransform {
import { Inject, Injectable } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { RecordService } from '@rero/ng-core';
import { MefTypeahead } from './mef-typeahead';

transform(value: any): any {
for (const source of ['idref', 'gnd', 'bnf', 'rero']) {
if (value[source] && value[source].preferred_name_for_person) {
return value[source].preferred_name_for_person;
}
}
return value.pid;
@Injectable()
export class MefPersonTypeahead extends MefTypeahead {
constructor(
@Inject(RecordService) _recordService: RecordService,
@Inject(TranslateService) _translateService: TranslateService
) {
super(_recordService, _translateService);
this.type = 'Person';
}
}
Loading

0 comments on commit 14e0e3a

Please sign in to comment.