-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1138 from ORCID/affiliation-delete
Affiliation delete
- Loading branch information
Showing
20 changed files
with
3,918 additions
and
3,120 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<form name="deleteForm" (ngSubmit)="confirmDelete(affiliation?.id)"> | ||
<div class="modal-header"> | ||
<h4 class="modal-title" jhiTranslate="entity.delete.title.string">Confirm deletion</h4> | ||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true" (click)="clear()">×</button> | ||
</div> | ||
<div class="modal-body" id="jhi-delete-assertion-heading"> | ||
<app-error-alert></app-error-alert> | ||
<p *ngIf="!affiliation?.addedToORCID" i18n="@@gatewayApp.assertionServiceAssertion.delete.fromPortal.string"> | ||
Are you sure you want to delete this affiliation from the portal? | ||
</p> | ||
<p *ngIf="affiliation?.addedToORCID"> | ||
{{ message | localize }} | ||
</p> | ||
</div> | ||
<div class="modal-footer"> | ||
<button type="button" class="btn btn-outline-primary" data-dismiss="modal" (click)="clear()"> | ||
<fa-icon [icon]="faBan"></fa-icon> <span i18n="@@entity.action.cancel.string">Cancel</span> | ||
</button> | ||
<button id="jhi-confirm-delete-assertion" type="submit" class="btn btn-danger"> | ||
<fa-icon [icon]="faTimes"></fa-icon> <span i18n="@@entity.action.delete.string">Delete</span> | ||
</button> | ||
</div> | ||
</form> |
Empty file.
23 changes: 23 additions & 0 deletions
23
ui/src/app/affiliation/affiliation-delete.component.spec.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,23 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing' | ||
|
||
import { AffiliationDeletePopupComponent } from './affiliation-delete.component' | ||
import { RouterTestingModule } from '@angular/router/testing' | ||
|
||
describe('AffiliationDeleteComponent', () => { | ||
let component: AffiliationDeletePopupComponent | ||
let fixture: ComponentFixture<AffiliationDeletePopupComponent> | ||
|
||
beforeEach(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [AffiliationDeletePopupComponent], | ||
imports: [RouterTestingModule], | ||
}) | ||
fixture = TestBed.createComponent(AffiliationDeletePopupComponent) | ||
component = fixture.componentInstance | ||
fixture.detectChanges() | ||
}) | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy() | ||
}) | ||
}) |
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,104 @@ | ||
import { Component, OnInit, OnDestroy } from '@angular/core' | ||
import { ActivatedRoute, Router } from '@angular/router' | ||
|
||
import { NgbActiveModal, NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap' | ||
|
||
import { AffiliationService } from './service/affiliations.service' | ||
import { EventService } from 'src/app/shared/service/event.service' | ||
import { AlertService } from 'src/app/shared/service/alert.service' | ||
import { IAffiliation } from './model/affiliation.model' | ||
import { AFFILIATION_STATUS } from 'src/app/shared/constants/orcid-api.constants' | ||
import { AlertType, EventType } from 'src/app/app.constants' | ||
import { Event } from 'src/app/shared/model/event.model' | ||
import { faBan, faTimes } from '@fortawesome/free-solid-svg-icons' | ||
|
||
@Component({ | ||
selector: 'app-affiliation-delete-dialog', | ||
templateUrl: './affiliation-delete.component.html', | ||
}) | ||
export class AffiliationDeleteDialogComponent implements OnInit { | ||
inOrcid: string = AFFILIATION_STATUS.IN_ORCID | ||
userRevokedAccess: string = AFFILIATION_STATUS.USER_REVOKED_ACCESS | ||
affiliation: IAffiliation | undefined | ||
errorUserRevoked = false | ||
faTimes = faTimes | ||
faBan = faBan | ||
message = '' | ||
|
||
constructor( | ||
protected affiliationService: AffiliationService, | ||
public activeModal: NgbActiveModal, | ||
protected eventService: EventService, | ||
private alertService: AlertService | ||
) {} | ||
|
||
clear() { | ||
this.activeModal.dismiss(true) | ||
} | ||
|
||
ngOnInit(): void { | ||
this.message = $localize`:@@gatewayApp.assertionServiceAssertion.delete.fromPortalAndRegistry.string:Are you sure you want to delete this affiliation for ${this.affiliation?.email}? The affiliation will be deleted from the portal and | ||
the user's ORCID record` | ||
} | ||
|
||
confirmDelete(id: string | undefined) { | ||
console.log(id) | ||
|
||
if (id) { | ||
this.affiliationService.delete(id).subscribe((response) => { | ||
if (response.body.deleted) { | ||
this.eventService.broadcast(new Event(EventType.AFFILIATION_LIST_MODIFICATION, 'Deleted an affiliation')) | ||
this.alertService.broadcast(AlertType.AFFILIATION_DELETED) | ||
} else { | ||
this.eventService.broadcast( | ||
new Event(EventType.AFFILIATION_LIST_MODIFICATION, 'Failed to delete an affiliation') | ||
) | ||
this.alertService.broadcast(AlertType.AFFILIATION_DELETE_FAILURE) | ||
} | ||
this.activeModal.dismiss(true) | ||
}) | ||
} | ||
} | ||
} | ||
|
||
@Component({ | ||
selector: 'app-affiliation-delete-popup', | ||
template: '', | ||
}) | ||
export class AffiliationDeletePopupComponent implements OnInit, OnDestroy { | ||
protected ngbModalRef: NgbModalRef | undefined | ||
|
||
constructor( | ||
protected activatedRoute: ActivatedRoute, | ||
protected router: Router, | ||
protected modalService: NgbModal | ||
) {} | ||
|
||
ngOnInit() { | ||
this.activatedRoute.data.subscribe(({ affiliation }) => { | ||
console.log(affiliation) | ||
|
||
setTimeout(() => { | ||
this.ngbModalRef = this.modalService.open(AffiliationDeleteDialogComponent as Component, { | ||
size: 'lg', | ||
backdrop: 'static', | ||
}) | ||
this.ngbModalRef.componentInstance.affiliation = affiliation | ||
this.ngbModalRef.result.then( | ||
(result) => { | ||
this.router.navigate(['/affiliations', { outlets: { popup: null } }]) | ||
this.ngbModalRef = undefined | ||
}, | ||
(reason) => { | ||
this.router.navigate(['/affiliations', { outlets: { popup: null } }]) | ||
this.ngbModalRef = undefined | ||
} | ||
) | ||
}, 0) | ||
}) | ||
} | ||
|
||
ngOnDestroy() { | ||
this.ngbModalRef = undefined | ||
} | ||
} |
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
Oops, something went wrong.