-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature/collection add and remove entry (#537)
* can remove an entry from a collection * add tool to collection * ability to edit collection information on the collection page
- Loading branch information
1 parent
928bc53
commit 13f4e9a
Showing
28 changed files
with
623 additions
and
80 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
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
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
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
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 |
---|---|---|
@@ -1,15 +1,28 @@ | ||
import { NgModule } from '@angular/core'; | ||
import { CommonModule } from '@angular/common'; | ||
import { CollectionComponent } from './collection/collection.component'; | ||
import { MatCardModule, MatProgressBarModule, MatIconModule, MatChipsModule } from '@angular/material'; | ||
import { CollectionComponent, CollectionRemoveEntryDialogComponent } from './collection/collection.component'; | ||
import { MatCardModule, MatProgressBarModule, MatIconModule, MatChipsModule, MatButtonModule, MatTooltipModule, | ||
MatDialogModule } from '@angular/material'; | ||
import { HeaderModule } from '../shared/modules/header.module'; | ||
import { FlexLayoutModule } from '@angular/flex-layout'; | ||
import { RouterModule } from '@angular/router'; | ||
import { CreateCollectionModule } from './collections/create-collection.module'; | ||
|
||
@NgModule({ | ||
imports: [ CommonModule, HeaderModule, | ||
MatCardModule, MatProgressBarModule, MatIconModule, | ||
FlexLayoutModule, RouterModule, MatChipsModule ], | ||
declarations: [ CollectionComponent ] | ||
FlexLayoutModule, RouterModule, MatChipsModule, MatButtonModule, | ||
MatIconModule, MatTooltipModule, MatDialogModule, CreateCollectionModule ], | ||
declarations: [ | ||
CollectionComponent, | ||
CollectionRemoveEntryDialogComponent | ||
], | ||
exports: [ | ||
CollectionComponent, | ||
CollectionRemoveEntryDialogComponent | ||
], | ||
entryComponents: [ | ||
CollectionRemoveEntryDialogComponent | ||
] | ||
}) | ||
export class CollectionModule { } |
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,13 @@ | ||
import { NgModule } from '@angular/core'; | ||
import { CommonModule } from '@angular/common'; | ||
import { AddEntryComponent } from './add-entry/add-entry.component'; | ||
import { CustomMaterialModule } from '../../shared/modules/material.module'; | ||
import { FlexLayoutModule } from '@angular/flex-layout'; | ||
import { RefreshAlertModule } from '../../shared/alert/alert.module'; | ||
|
||
@NgModule({ | ||
imports: [ CommonModule, CustomMaterialModule, FlexLayoutModule, RefreshAlertModule ], | ||
declarations: [ AddEntryComponent ], | ||
entryComponents: [ AddEntryComponent ] | ||
}) | ||
export class AddEntryModule { } |
48 changes: 48 additions & 0 deletions
48
src/app/organizations/collection/add-entry/add-entry.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,48 @@ | ||
<h1 mat-dialog-title>Add to collection</h1> | ||
<div mat-dialog-content> | ||
|
||
<ng-template #loading> | ||
<mat-progress-bar mode="indeterminate"></mat-progress-bar> | ||
</ng-template> | ||
|
||
<div *ngIf="!(isLoading$ | async); else loading"> | ||
<div fxLayout="column" fxLayoutGap="15px"> | ||
<div fxFlex *ngIf="(memberships$ | async) as memberships"> | ||
<ng-template #noMemberships> | ||
<mat-card class="alert alert-info" role="alert"> | ||
<mat-icon>info</mat-icon> You must be part of an organization to add to a collection | ||
</mat-card> | ||
</ng-template> | ||
<mat-form-field *ngIf="memberships && memberships.length > 0; else noMemberships"> | ||
<mat-select id="selectOrganization" placeholder="Organization" [(value)]="selectedOrganisationId" (selectionChange)="onOrganisationChange($event)"> | ||
<mat-option *ngFor="let membership of memberships" [value]="membership.organisation.id"> | ||
{{membership.organisation.name}} | ||
</mat-option> | ||
</mat-select> | ||
</mat-form-field> | ||
</div> | ||
|
||
<div fxFlex *ngIf="(collections$ | async) as collections"> | ||
<ng-template #noCollections> | ||
<mat-card class="alert alert-info" role="alert"> | ||
<mat-icon>info</mat-icon> The selected organization has no collections | ||
</mat-card> | ||
</ng-template> | ||
<mat-form-field id="selectCollection" *ngIf="selectedOrganisationId && collections && collections.length > 0; else noCollections"> | ||
<mat-select placeholder="Collection" [(value)]="selectedCollectionId" [disabled]="!selectedOrganisationId"> | ||
<mat-option *ngFor="let collection of collections" [value]="collection.id"> | ||
{{collection.name}} | ||
</mat-option> | ||
</mat-select> | ||
</mat-form-field> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<div mat-dialog-actions align="end"> | ||
<button mat-button id="closeDialogButton" (click)="closeDialog()">Close</button> | ||
<button mat-flat-button id="addEntryToCollectionButton" color="primary" [disabled]="!selectedOrganisationId || !selectedCollectionId" (click)="addToCollection()"> | ||
<mat-icon>add</mat-icon>Add to collection | ||
</button> | ||
</div> |
Empty file.
55 changes: 55 additions & 0 deletions
55
src/app/organizations/collection/add-entry/add-entry.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,55 @@ | ||
import { Component, OnInit, Inject } from '@angular/core'; | ||
import { AddEntryService } from '../state/add-entry.service'; | ||
import { AddEntryQuery } from '../state/add-entry.query'; | ||
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material'; | ||
import { Observable } from 'rxjs'; | ||
import { OrganisationUser, Collection } from '../../../shared/swagger'; | ||
|
||
@Component({ | ||
selector: 'add-entry', | ||
templateUrl: './add-entry.component.html', | ||
styleUrls: ['./add-entry.component.scss'] | ||
}) | ||
export class AddEntryComponent implements OnInit { | ||
public memberships$: Observable<Array<OrganisationUser>>; | ||
public collections$: Observable<Array<Collection>>; | ||
isLoading$: Observable<boolean>; | ||
selectedOrganisationId: number; | ||
selectedCollectionId: number; | ||
constructor(private addEntryQuery: AddEntryQuery, | ||
private addEntryService: AddEntryService, | ||
@Inject(MAT_DIALOG_DATA) public data: any, | ||
public dialogRef: MatDialogRef<AddEntryComponent> | ||
) { } | ||
|
||
ngOnInit() { | ||
this.isLoading$ = this.addEntryQuery.isLoading$; | ||
this.addEntryService.updateMemberships(); | ||
this.memberships$ = this.addEntryQuery.memberships$; | ||
this.collections$ = this.addEntryQuery.collections$; | ||
} | ||
|
||
/** | ||
* Called when organisation is selected from dropdown | ||
* @param event event.value is the id of the organisation to add | ||
*/ | ||
onOrganisationChange(event) { | ||
this.selectedCollectionId = null; | ||
this.addEntryService.updateCollections(event.value); | ||
this.collections$ = this.addEntryQuery.collections$; | ||
} | ||
|
||
/** | ||
* Attempts to add the entry to the selected collection | ||
*/ | ||
addToCollection() { | ||
if (this.selectedCollectionId && this.selectedOrganisationId) { | ||
this.addEntryService.addEntryToCollection(this.selectedOrganisationId, this.selectedCollectionId, this.data.entryId); | ||
} | ||
} | ||
|
||
closeDialog(): void { | ||
this.dialogRef.close(); | ||
} | ||
|
||
} |
10 changes: 10 additions & 0 deletions
10
src/app/organizations/collection/collection-entry-confirm-remove.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,10 @@ | ||
<h1 mat-dialog-title>Remove Entry</h1> | ||
|
||
<div mat-dialog-content> | ||
<p>Are you sure you want to <strong>remove</strong> the entry <strong>{{data.entryName}}</strong> from the collection <strong>{{data.collectionName}}</strong>?</p> | ||
</div> | ||
<div mat-dialog-actions> | ||
<div fxFlex></div> | ||
<button mat-button (click)="onNoClick()">Cancel</button> | ||
<button mat-flat-button id="accept-remove-entry-from-org" [mat-dialog-close]="{ 'organizationId': data.organizationId, 'collectionId': data.collectionId, 'entryId': data.entryId, 'entryName': data.entryName }">Remove</button> | ||
</div> |
Oops, something went wrong.