-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Implements detail view for locations. * Improves libraries brief view. Co-Authored-by: Alicia Zangger <alicia.zangger@rero.ch>
- Loading branch information
Showing
10 changed files
with
332 additions
and
179 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
174 changes: 0 additions & 174 deletions
174
projects/admin/src/app/record/brief-view/libraries-brief-view.component.ts
This file was deleted.
Oops, something went wrong.
41 changes: 41 additions & 0 deletions
41
.../admin/src/app/record/brief-view/libraries-brief-view/libraries-brief-view.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<!-- | ||
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/>. | ||
--> | ||
|
||
<h5 class="mb-0 d-inline"> | ||
<a [routerLink]="[detailUrl.link]">{{ record.metadata.name }}</a> | ||
</h5> | ||
<small class="ml-2"> {{ record.metadata.code }}</small> | ||
<section> | ||
<a class="ml-2 text-secondary" (click)="toggleCollapse()" [attr.aria-expanded]="!isCollapsed" | ||
aria-controls="collapseBasic"> | ||
<i class="fa" [ngClass]="{'fa-caret-down': !isCollapsed, 'fa-caret-right': isCollapsed }" aria-hidden="true"> | ||
</i> | ||
<span translate> locations</span> | ||
</a> | ||
<a class="ml-2 text-secondary" routerLinkActive="active" [queryParams]="{library: record.metadata.pid}" | ||
[routerLink]="['/records/locations/new']"> | ||
<i class="fa fa-plus" aria-hidden="true"></i> {{ 'Add' | translate }} | ||
</a> | ||
<div id="collapseBasic" [collapse]="isCollapsed"> | ||
<ul *ngIf="locations.length" class="list-group list-group-flush"> | ||
<li *ngFor="let location of locations;" class="list-group-item p-1"> | ||
<admin-location [location]="location" class="col-12" (deleteItem)="deleteLocation($event)"></admin-location> | ||
</li> | ||
</ul> | ||
<div *ngIf="!locations.length" translate>no location</div> | ||
</div> | ||
</section> |
74 changes: 74 additions & 0 deletions
74
...ts/admin/src/app/record/brief-view/libraries-brief-view/libraries-brief-view.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/* | ||
* 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, RecordService } from '@rero/ng-core'; | ||
|
||
@Component({ | ||
selector: 'admin-libraries-brief-view', | ||
templateUrl: './libraries-brief-view.component.html', | ||
styles: [] | ||
}) | ||
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 }; | ||
|
||
/** Is collapsed variable */ | ||
isCollapsed = true; | ||
|
||
/** Locations array */ | ||
locations = []; | ||
|
||
/** Constructor */ | ||
constructor( | ||
private recordService: RecordService | ||
) { } | ||
|
||
/** Toggle collapse to display related locations */ | ||
toggleCollapse() { | ||
if (this.isCollapsed) { | ||
const libraryPid = this.record.metadata.pid; | ||
this.recordService | ||
.getRecords('locations', `library.pid:${libraryPid}`, 1, RecordService.MAX_REST_RESULTS_SIZE) | ||
.subscribe(data => { | ||
this.locations = data.hits.hits || []; | ||
this.isCollapsed = !this.isCollapsed; | ||
}); | ||
} else { | ||
this.isCollapsed = !this.isCollapsed; | ||
} | ||
} | ||
|
||
/** | ||
* Delete the location | ||
* @param locationPid - location PID | ||
*/ | ||
deleteLocation(locationPid: Event) { | ||
this.locations = this.locations.filter((location: any) => locationPid !== location.metadata.pid); | ||
} | ||
|
||
} |
33 changes: 33 additions & 0 deletions
33
...cts/admin/src/app/record/brief-view/libraries-brief-view/location/location.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<!-- | ||
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/>. | ||
--> | ||
|
||
<a [routerLink]="['/records/locations/detail', location.metadata.pid]">{{ location.metadata.name }}</a> | ||
<div class="float-right ml-2"> | ||
<a *ngIf="!location.permissions.cannot_update" class="btn btn-link p-0 ml-2 text-primary" | ||
[routerLink]="['/records', 'locations', 'edit', location.metadata.pid]"> | ||
<i class="fa fa-pencil"></i> | ||
</a> | ||
<a *ngIf="!location.permissions.cannot_delete; else notDelete" class="btn btn-link p-0 ml-2 text-primary" | ||
(click)="delete(location.metadata.pid)"> | ||
<i class="fa fa-trash"></i> | ||
</a> | ||
<ng-template #notDelete> | ||
<a class="btn btn-link p-0 ml-2 text-secondary" (click)="showDeleteMessage(location)"> | ||
<i class="fa fa-trash"></i> | ||
</a> | ||
</ng-template> | ||
</div> |
Oops, something went wrong.