Skip to content

Commit

Permalink
locations: implement detail view
Browse files Browse the repository at this point in the history
* Implements detail view for locations.
* Improves libraries brief view.

Co-Authored-by: Alicia Zangger <alicia.zangger@rero.ch>
  • Loading branch information
Alicia Zangger authored and jma committed Dec 3, 2019
1 parent 276d44e commit a5c958f
Show file tree
Hide file tree
Showing 10 changed files with 332 additions and 179 deletions.
13 changes: 10 additions & 3 deletions projects/admin/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import { FrontpageComponent } from './frontpage/frontpage.component';
import { ItemTypesBriefViewComponent } from './record/brief-view/item-types-brief-view.component';
import { CircPoliciesBriefViewComponent } from './record/brief-view/circ-policies-brief-view.component';
import { DocumentsBriefViewComponent } from './record/brief-view/documents-brief-view.component';
import { LibrariesBriefViewComponent } from './record/brief-view/libraries-brief-view.component';
import { LibrariesBriefViewComponent } from './record/brief-view/libraries-brief-view/libraries-brief-view.component';
import { PatronTypesBriefViewComponent } from './record/brief-view/patron-types-brief-view.component';
import { PatronTypesDetailViewComponent } from './record/detail-view/patron-types-detail-view.component';
import { PatronsBriefViewComponent } from './record/brief-view/patrons-brief-view.component';
Expand Down Expand Up @@ -60,6 +60,8 @@ import { HoldingItemComponent } from './record/detail-view/document-detail-view/
import { HoldingsComponent } from './record/detail-view/document-detail-view/holdings/holdings.component';
import { CircPolicyDetailViewComponent } from './record/detail-view/circ-policy-detail-view/circ-policy-detail-view.component';
import { CollapseListComponent } from './record/detail-view/circ-policy-detail-view/collapse-list/collapse-list.component';
import { LocationDetailViewComponent } from './record/detail-view/location-detail-view/location-detail-view.component';
import { LocationComponent } from './record/brief-view/libraries-brief-view/location/location.component';

@NgModule({
declarations: [
Expand Down Expand Up @@ -101,7 +103,10 @@ import { CollapseListComponent } from './record/detail-view/circ-policy-detail-v
ExceptionDatesEditComponent,
CirculationPolicyComponent,
CircPolicyDetailViewComponent,
CollapseListComponent
CollapseListComponent,
ExceptionDateComponent,
LocationDetailViewComponent,
LocationComponent
],
imports: [
Bootstrap4FrameworkModule,
Expand Down Expand Up @@ -160,7 +165,9 @@ import { CollapseListComponent } from './record/detail-view/circ-policy-detail-v
ExceptionDatesEditComponent,
CircPolicyDetailViewComponent,
CirculationPolicyComponent,
CollapseListComponent
CollapseListComponent,
LibraryComponent,
LocationDetailViewComponent
],
bootstrap: [AppComponent]
})
Expand Down

This file was deleted.

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>
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);
}

}
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>
Loading

0 comments on commit a5c958f

Please sign in to comment.