Skip to content

Commit

Permalink
library: adapt library brief/detail view
Browse files Browse the repository at this point in the history
According to the PO, it's better to display the locations linked to a library not into the
'library brief view' but into the 'library detail view'.

Co-Authored-by: Renaud Michotte <renaud.michotte@gmail.com>
  • Loading branch information
zannkukai committed Apr 2, 2020
1 parent 161c648 commit fe391a5
Show file tree
Hide file tree
Showing 22 changed files with 144 additions and 179 deletions.
4 changes: 2 additions & 2 deletions projects/admin/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ import { BudgetsBriefViewComponent } from './record/brief-view/budgets-brief-vie
import { CircPoliciesBriefViewComponent } from './record/brief-view/circ-policies-brief-view.component';
import { DocumentsBriefViewComponent } from './record/brief-view/documents-brief-view/documents-brief-view.component';
import { ItemTypesBriefViewComponent } from './record/brief-view/item-types-brief-view.component';
import { LibrariesBriefViewComponent } from './record/brief-view/libraries-brief-view/libraries-brief-view.component';
import { LocationComponent } from './record/brief-view/libraries-brief-view/location/location.component';
import { LibrariesBriefViewComponent } from './record/brief-view/libraries-brief-view.component';
import { LocationComponent } from './record/detail-view/library-detail-view/location/location.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';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ import { ResultItem } from '@rero/ng-core';
selector: 'admin-acquisition-order-brief-view',
template: `
<h5 class="mb-0 card-title">
<a [routerLink]="['/records', 'acq_orders', 'detail', record.metadata.pid]">
{{ record.metadata.order_number }}
</a>
<a [routerLink]="[detailUrl.link]">{{ record.metadata.order_number }}</a>
</h5>
`,
styleUrls: []
Expand All @@ -39,5 +37,4 @@ export class AcquisitionOrderBriefViewComponent implements ResultItem {

@Input()
detailUrl: { link: string, external: boolean };

}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import { ResultItem } from '@rero/ng-core';
selector: 'admin-circ-policies-brief-view',
template: `
<h5 class="mb-0 card-title"><a [routerLink]="[detailUrl.link]">{{ record.metadata.name }}</a></h5>
<div class="card-text">
<span *ngIf="record.metadata.description">
{{ record.metadata.description }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ import { ResultItem } from '@rero/ng-core';
selector: 'admin-item-types-brief-view',
template: `
<h5 class="mb-0 card-title">
<a [routerLink]="['/records', 'item_types', 'detail', record.metadata.pid]">
{{ record.metadata.name }}
</a>
<a [routerLink]="[detailUrl.link]">{{ record.metadata.name }}</a>
</h5>
<div class="card-text">
<span *ngIf="record.metadata.description">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* 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 { Component, Input } from '@angular/core';
import { ResultItem } from '@rero/ng-core';

@Component({
selector: 'admin-libraries-brief-view',
template: `
<h5 class="mb-0 card-title">
<a [routerLink]="[detailUrl.link]">{{ record.metadata.name }}</a>
</h5>
<div class="card-text">
<small> {{ record.metadata.code }}</small>
<span *ngIf="record.metadata.description">
{{ record.metadata.description }}
</span>
</div>
`,
})
export class LibrariesBriefViewComponent implements ResultItem {

/** Record data */
@Input()
record: any;

/** Resource type */
@Input()
type: string;

/** Detail URL to navigate to detail view */
@Input()
detailUrl: { link: string, external: boolean };
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ import { ResultItem } from '@rero/ng-core';
selector: 'admin-patron-types-brief-view',
template: `
<h5 class="mb-0 card-title">
<a [routerLink]="['/records', 'patron_types', 'detail', record.metadata.pid]">
{{ record.metadata.name }}
</a>
<a [routerLink]="[detailUrl.link]">{{ record.metadata.name }}</a>
</h5>
<div class="card-text">
<span *ngIf="record.metadata.description">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ import { ResultItem } from '@rero/ng-core';
template: `
<ng-container *ngIf="record">
<h5 class="card-title mb-0">
<a [routerLink]="['/records', 'patrons', 'detail', record.metadata.pid]">
{{ record.metadata.last_name }}, {{ record.metadata.first_name }}
</a>
<a [routerLink]="[detailUrl.link]">{{ record.metadata.last_name }}, {{ record.metadata.first_name }}</a>
<small class="ml-3" *ngIf="record.metadata.barcode">
<a [routerLink]="['/circulation', 'patron', record.metadata.barcode]">
<i class="fa fa-exchange mr-2"></i>
Expand Down Expand Up @@ -57,6 +55,4 @@ export class PatronsBriefViewComponent implements ResultItem {

@Input()
detailUrl: { link: string, external: boolean };

constructor() { }
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,8 @@ import { ResultItem } from '@rero/ng-core';
selector: 'admin-vendor-brief-view',
template: `
<h5 class="mb-0 card-title">
<a [routerLink]="['/records', 'vendors', 'detail', record.metadata.pid]">
{{ record.metadata.name }}
</a>
<a [routerLink]="[detailUrl.link]">{{ record.metadata.name }}</a>
</h5>
<div class="card-text">
<span *ngIf="record.metadata.name">
{{ record.metadata.name }}
</span>
</div>
`,
styleUrls: []
})
Expand All @@ -44,5 +37,4 @@ export class VendorBriefViewComponent implements ResultItem {

/** Detail URL to navigate to detail view */
detailUrl: { link: string, external: boolean };

}
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,25 @@ <h1>{{ record.metadata.name }}</h1>
</ul>
</article>
</article>

<!-- LOCATIONS -->
<article class="card mt-4">
<header class="card-header">
<b translate>Locations</b>
<a class="ml-2 btn btn-sm btn-primary"
[routerLink]="['/', 'records', 'locations', 'new']"
[queryParams]="{ library: record.metadata.pid }">
<i class="fa fa-plus-square-o"></i> {{ 'Add' | translate }}
</a>
</header>
<article class="card-body collapsed show">
<ul class="list-group list-group-flush" *ngIf="locations; else no_locations">
<li *ngFor="let location of locations" class="list-group-item p-1">
<admin-location [location]="location" class="col-12" (deleteLocation)="deleteLocation($event)"></admin-location>
</li>
</ul>
<ng-template #no_locations><p translate>no location</p></ng-template>
</article>

</article>
</ng-container>
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,63 @@
* 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 { Observable } from 'rxjs';
import { Component, OnInit } from '@angular/core';
import { DetailRecord } from '@rero/ng-core/lib/record/detail/view/detail-record';
import { Observable } from 'rxjs';
import { RecordService } from '@rero/ng-core';
import { UserService } from '../../../service/user.service';

@Component({
selector: 'admin-library-detail-view',
templateUrl: './library-detail-view.component.html',
styles: []
})
export class LibraryDetailViewComponent implements DetailRecord {
export class LibraryDetailViewComponent implements DetailRecord, OnInit {

/** Observable resolving record data */
record$: Observable<any>;

/** Resource type */
type: string;

constructor() { }
/** linked locations */
locations = [];

constructor(
private _recordService: RecordService,
private _userService: UserService
) { }

ngOnInit() {
// Load linked locations
this.record$.subscribe(
(data) => {
const libraryPid = data.metadata.pid;
this._recordService
.getRecords(
'locations',
`library.pid:${libraryPid}`,
1,
RecordService.MAX_REST_RESULTS_SIZE,
[], // aggFilters
{}, // preFilters
null, // headers
'name'
)
.subscribe((record) => {
this.locations = record.hits.hits || [];
});
}
);
}

/** Delete a location event listener
* This function catch the event emitted when a location is deleted and removed the deleted location
* from the known locations list
* @param deletedLocationPid - The deleted location pid
*/
deleteLocation(deletedLocationPid: Event) {
this.locations = this.locations.filter((location: any) => deletedLocationPid !== location.metadata.pid);
}

}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Component, OnInit, Input, Output } from '@angular/core';
import { Component, Input, Output, EventEmitter } from '@angular/core';
import { RecordUiService } from '@rero/ng-core';
import { RecordPermissionMessageService } from 'projects/admin/src/app/service/record-permission-message.service';
import { EventEmitter } from 'events';

@Component({
selector: 'admin-location',
Expand Down
2 changes: 1 addition & 1 deletion projects/admin/src/app/routes/libraries-route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { BaseRoute } from './Base-route';
import { CanUpdateGuard } from '../guard/can-update.guard';
import { DetailComponent, RecordSearchComponent, RouteInterface } from '@rero/ng-core';
import { LibraryComponent } from '../record/custom-editor/libraries/library.component';
import { LibrariesBriefViewComponent } from '../record/brief-view/libraries-brief-view/libraries-brief-view.component';
import { LibrariesBriefViewComponent } from '../record/brief-view/libraries-brief-view.component';
import { LibraryDetailViewComponent } from '../record/detail-view/library-detail-view/library-detail-view.component';


Expand Down
Loading

0 comments on commit fe391a5

Please sign in to comment.