Skip to content

Commit 7db1ede

Browse files
committed
Use select entities component
1 parent e578b26 commit 7db1ede

File tree

9 files changed

+725
-836
lines changed

9 files changed

+725
-836
lines changed

cloudapp/src/app/app.module.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { BrowserModule, Title } from '@angular/platform-browser';
44
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
55
import { MaterialModule, getTranslateModule, AlertModule } from '@exlibris/exl-cloudapp-angular-lib';
66
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
7+
import { SelectEntitiesModule } from 'eca-select-entities';
78

89
import { AppComponent } from './app.component';
910
import { AppRoutingModule } from './app-routing.module';
@@ -20,7 +21,6 @@ import { StoreComponent } from './store/store.component';
2021
import { TranslateComponent } from './translate/translate.component';
2122
import { ConfigurationComponent } from './configuration/configuration.component';
2223
import { MultiSelectComponent } from './multi-select/multi-select.component';
23-
import { SelectEntitiesComponent } from './multi-select/select-entities/select-entities.component';
2424
import { LightboxComponent } from './external/lightbox/lightbox.component'
2525
import { ErrorComponent } from './static/error.component';
2626
import { ConfirmationDialog, StyleComponent } from './style/style.component';
@@ -41,7 +41,6 @@ import { ConfirmationDialog, StyleComponent } from './style/style.component';
4141
TranslateComponent,
4242
ConfigurationComponent,
4343
MultiSelectComponent,
44-
SelectEntitiesComponent,
4544
LightboxComponent,
4645
ErrorComponent,
4746
StyleComponent,
@@ -57,6 +56,7 @@ import { ConfirmationDialog, StyleComponent } from './style/style.component';
5756
ReactiveFormsModule,
5857
getTranslateModule(),
5958
AlertModule,
59+
SelectEntitiesModule,
6060
],
6161
providers: [
6262
Title

cloudapp/src/app/multi-select/multi-select.component.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<app-topmenu></app-topmenu>
2-
<p>A total of <strong>{{ ids.size }}</strong> items have been selected.</p>
3-
<div *ngIf="entities.length>0 else noEntities">
2+
<p>A total of <strong>{{ selectedEntities.size }}</strong> items have been selected.</p>
3+
<div *ngIf="(entities$ | async).length>0 else noEntities">
44
<p>Select the desired items:</p>
5-
<app-select-entities #selectEntities
5+
<eca-select-entities #selectEntities
66
(entitySelected)="onEntitySelected($event)"
7-
[entityList]="entities"
8-
[selectedEntities]="ids">
9-
</app-select-entities>
7+
[entityList]="entities$ | async"
8+
[isEntitySelected]="isEntitySelected">
9+
</eca-select-entities>
1010
</div>
1111
<ng-template #noEntities>
1212
Please navigate to a list.

cloudapp/src/app/multi-select/multi-select.component.ts

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
11
import { Component, OnInit } from '@angular/core';
22
import { AppService } from '../app.service';
3-
import { Entity, CloudAppEventsService } from '@exlibris/exl-cloudapp-angular-lib';
4-
import { Subscription } from 'rxjs';
3+
import { CloudAppEventsService, Entity } from '@exlibris/exl-cloudapp-angular-lib';
54

65
@Component({
76
selector: 'app-multi-select',
87
templateUrl: './multi-select.component.html',
98
styleUrls: ['./multi-select.component.scss']
109
})
1110
export class MultiSelectComponent implements OnInit {
12-
private pageLoad$: Subscription;
13-
ids = new Set<string>();
14-
entities: Entity[];
11+
public entities$ = this.eventsService.entities$;
1512

1613
constructor(
1714
private appService: AppService,
@@ -20,18 +17,17 @@ export class MultiSelectComponent implements OnInit {
2017

2118
ngOnInit() {
2219
this.appService.setTitle('Multi-select');
23-
this.pageLoad$ = this.eventsService.onPageLoad( pageInfo => {
24-
this.entities = (pageInfo.entities||[]);
25-
});
2620
}
2721

2822
ngOnDestroy(): void {
29-
this.pageLoad$.unsubscribe();
3023
}
3124

32-
onEntitySelected(event) {
33-
if (event.checked) this.ids.add(event.mmsId);
34-
else this.ids.delete(event.mmsId);
25+
selectedEntities = new Set<string>();
26+
isEntitySelected = (entity: Entity) => this.selectedEntities.has(entity.id);
27+
28+
onEntitySelected(event: {entity: Entity, checked: boolean}) {
29+
if (event.checked) this.selectedEntities.add(event.entity.id);
30+
else this.selectedEntities.delete(event.entity.id);
3531
}
3632

3733

cloudapp/src/app/multi-select/select-entities/select-entities.component.html

Lines changed: 0 additions & 15 deletions
This file was deleted.

cloudapp/src/app/multi-select/select-entities/select-entities.component.scss

Whitespace-only changes.

cloudapp/src/app/multi-select/select-entities/select-entities.component.ts

Lines changed: 0 additions & 61 deletions
This file was deleted.

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
22
"id": "exlibrisgroup/cloudapp-tutorials",
33
"title": "Cloud App Tutorials",
4-
"description": "For more information on these tutorials, see https://developers.exlibrisgroup.com/cloudapps/tutorials/.",
54
"subtitle": "Accompanying code for the Cloud App tutorials in the Developer Network",
65
"author": "Ex Libris",
6+
"description": "For more information on these tutorials, see https://developers.exlibrisgroup.com/cloudapps/tutorials/.",
77
"contentSecurity": {
88
"connectSrc": [
99
"https://catalog.hathitrust.org/",

0 commit comments

Comments
 (0)