[develop | DONE | ADDED] displayClaims: add bulk delete functionality for claims, change the claims cards to a more compact claims list

This commit is contained in:
Alex Martzios 2024-03-28 13:07:11 +02:00
parent b6cda48e2f
commit cafe0e4926
5 changed files with 133 additions and 73 deletions

View File

@ -56,57 +56,76 @@
<div *ngIf="claims && claims.length == 0" class="uk-card uk-card-default uk-padding-large uk-text-center uk-margin-bottom uk-text-bold"> <div *ngIf="claims && claims.length == 0" class="uk-card uk-card-default uk-padding-large uk-text-center uk-margin-bottom uk-text-bold">
<div>No links found</div> <div>No links found</div>
</div> </div>
<ul class="uk-margin-small-top uk-list uk-list-xlarge"> <ng-container *ngIf="claims && claims.length > 0">
<li *ngFor="let claim of claims; let i=index" class="uk-card uk-card-default">
<div class="uk-card-body"> <div class="uk-flex uk-flex-middle uk-margin-top uk-margin-small-bottom uk-padding-small uk-padding-remove-horizontal">
<div class="uk-grid uk-grid-small" uk-grid> <div class="uk-width-xsmall uk-flex uk-flex-center uk-flex-middle">
<div class="uk-width-expand"> <label>
<div class="uk-margin-bottom"> <input id="checkAll" type="checkbox" (click)="selectAll($event)" class="uk-checkbox" title="Select All"
<claim-entity [entity]="claim.target" [type]="claim.targetType" [properties]=properties [ngModel]="selected.length == claims.length"/>
[externalPortalUrl]=externalPortalUrl [source]="true" [linkAvailable]="isClaimAvailable(claim)"></claim-entity> </label>
</div> </div>
<div class="uk-margin-bottom"> <button class="uk-button uk-button-link" [class.uk-disabled]="selected.length == 0" [disabled]="selected.length == 0"
<span *ngIf="isClaimAvailable(claim) else notAvailable" class="uk-label uk-label-success" (click)="deleteOpen()">
[attr.uk-tooltip]="'title: The link information is available in the portal and the APIs.'">available</span> <span>Delete ({{selected.length}})</span>
<ng-template #notAvailable> </button>
<span class="uk-label uk-label-danger" </div>
[attr.uk-tooltip]="'title:The link information will be added in the portal and the APIs in the next content provision workflow.'">pending</span>
</ng-template> <ul class="uk-margin-small-top uk-list uk-list-striped">
</div> <li *ngFor="let claim of claims; let i=index" class="uk-flex uk-flex-middle uk-padding-small uk-padding-remove-horizontal">
<div class="uk-text-small"> <div class="uk-width-xsmall uk-flex uk-flex-center uk-flex-middle">
<div *ngIf="showUserEmail" class="uk-margin-small-bottom"> <input type="checkbox" class="uk-checkbox"
<span class="uk-text-meta">Claimed by:</span> [id]="claim.id" (click)="selectClaim(claim, $event)" [ngModel]="isSelectedClaim(claim.id)">
<span class="uk-margin-xsmall-left">{{claim.userMail}}</span> </div>
<div class="uk-width-expand">
<div class="uk-grid uk-grid-small uk-flex-middle" uk-grid>
<div class="uk-width-expand">
<div class="uk-margin-small-bottom">
<claim-entity [entity]="claim.target" [type]="claim.targetType" [properties]=properties
[externalPortalUrl]=externalPortalUrl [source]="true" [linkAvailable]="isClaimAvailable(claim)"></claim-entity>
</div> </div>
<div> <div class="uk-margin-small-bottom">
<span class="uk-text-meta">Claimed date:</span> <span *ngIf="isClaimAvailable(claim) else notAvailable" class="uk-label uk-label-small uk-label-success"
<span class="uk-margin-xsmall-left">{{claim.date}}</span> [attr.uk-tooltip]="'title: The link information is available in the portal and the APIs.'">available</span>
<ng-template #notAvailable>
<span class="uk-label uk-label-small uk-label-danger"
[attr.uk-tooltip]="'title:The link information will be added in the portal and the APIs in the next content provision workflow.'">pending</span>
</ng-template>
</div>
<div class="uk-text-small">
<div *ngIf="showUserEmail" class="uk-margin-xsmall-bottom">
<span class="uk-text-meta">Claimed by:</span>
<span class="uk-margin-xsmall-left">{{claim.userMail}}</span>
</div>
<div>
<span class="uk-text-meta">Claimed date:</span>
<span class="uk-margin-xsmall-left">{{claim.date}}</span>
</div>
</div> </div>
</div> </div>
</div> <div class="uk-visible@m">
<div class="uk-visible@m"> <div class="claim-divider">
<div class="claim-divider"> <icon class="uk-position-center" name="link" customClass="uk-text-primary" ratio="2" [flex]="true"></icon>
<icon class="uk-position-center" name="link" customClass="uk-text-primary" ratio="2" [flex]="true"></icon> </div>
</div>
<div class="uk-width-1-2@m uk-width-1-1">
<claim-entity [entity]="claim.source" [type]="claim.sourceType" [source]="false" [properties]=properties
[externalPortalUrl]=externalPortalUrl></claim-entity>
</div> </div>
</div>
<div class="uk-width-1-2@m uk-width-1-1 uk-flex uk-flex-column uk-flex-center">
<claim-entity [entity]="claim.source" [type]="claim.sourceType" [source]="false" [properties]=properties
[externalPortalUrl]=externalPortalUrl></claim-entity>
</div> </div>
</div> </div>
</div> <div class="uk-width-xsmall uk-flex uk-flex-center uk-flex-middle">
<div class="uk-card-footer uk-flex uk-flex-right"> <button class="uk-button uk-button-link uk-flex uk-flex-middle" (click)="deleteOpen(i)">
<button class="uk-button uk-button-link uk-flex uk-flex-middle" (click)="deleteOpen(i)"> <icon name="delete" [flex]="true"></icon>
<icon name="delete" [flex]="true"></icon> </button>
<span class="uk-margin-xsmall-left">Delete</span> </div>
</button> </li>
</div> </ul>
</li> <div class="uk-margin-medium-top uk-flex uk-flex-center uk-flex-right@m">
</ul> <paging-no-load *ngIf="resultsNum" [currentPage]="page" [totalResults]="resultsNum" [size]="size"
<div class="uk-margin-medium-top uk-flex uk-flex-center uk-flex-right@m"> (pageChange)="pageChange($event)"></paging-no-load>
<paging-no-load *ngIf="resultsNum" [currentPage]="page" [totalResults]="resultsNum" [size]="size" </div>
(pageChange)="pageChange($event)"></paging-no-load> </ng-container>
</div>
</div> </div>
</div> </div>
</div> </div>

View File

@ -4,14 +4,4 @@
position: relative; position: relative;
padding: 0 20px; padding: 0 20px;
height: 100%; height: 100%;
&::before {
content: '';
position: absolute;
top: 0;
left: 50%;
right: 0;
bottom: 0;
border-left: @global-border-width solid @global-border;
}
} }

View File

@ -52,6 +52,7 @@ export class DisplayClaimsComponent implements OnInit, OnDestroy {
lastIndexDate = null; lastIndexDate = null;
public filterForm: FormGroup; public filterForm: FormGroup;
public entities: string[] = []; public entities: string[] = [];
selected = [];
allOptions: Option[] = [ allOptions: Option[] = [
{label: OpenaireEntities.PUBLICATIONS, value: "publication"}, {label: OpenaireEntities.PUBLICATIONS, value: "publication"},
@ -310,23 +311,34 @@ export class DisplayClaimsComponent implements OnInit, OnDestroy {
} }
isSelected(value: string) { isSelected(value: string) {
return this.filterForm && this.filterForm.get('entities').value.find(entity => entity === value) return this.filterForm && this.filterForm.get('entities').value.find(entity => entity === value);
} }
deleteOpen(index: number) { deleteOpen(index: number = null) {
this.index = index; this.index = index;
this.deleteModal.alertTitle = 'Delete Confirmation'; this.deleteModal.alertTitle = 'Delete Confirmation';
this.deleteModal.message = 'Are you sure you want to delete this link?'; this.deleteModal.message = 'Are you sure you want to delete ' + (this.index != null ? '1' : this.selected.length) + ' link(s)?';
this.deleteModal.okButtonText = 'Yes'; this.deleteModal.okButtonText = 'Yes';
this.deleteModal.open(); this.deleteModal.open();
} }
delete() { delete() {
this.subscriptions.push(this._claimService.deleteBulk([this.claims[this.index].id], this.properties.claimsAPIURL).subscribe( let claimsToBeDeleted = ((this.index != null) ? [this.claims[this.index].id] : this.selected.map(claim => claim.id));
console.log(claimsToBeDeleted);
this.subscriptions.push(this._claimService.deleteBulk(claimsToBeDeleted, this.properties.claimsAPIURL).subscribe(
res => { res => {
this.claims.splice(this.index, 1); if (this.index != null) {
this.resultsNum = this.resultsNum - 1; this.claims.splice(this.index, 1);
NotificationHandler.rise('Link has been deleted successfully'); this.resultsNum = this.resultsNum - 1;
NotificationHandler.rise('Link has been deleted successfully');
} else {
claimsToBeDeleted.forEach(claimId => {
this.claims.splice(this.claims.findIndex((id) => id == claimId), 1);
});
this.resultsNum = this.resultsNum - claimsToBeDeleted.length;
NotificationHandler.rise(claimsToBeDeleted.length + ' links have been deleted successfully');
}
this.selected = [];
let goToPage = this.page; let goToPage = this.page;
if (this.totalPages(this.resultsNum) < this.page && this.page > 0) { if (this.totalPages(this.resultsNum) < this.page && this.page > 0) {
goToPage = this.page - 1; goToPage = this.page - 1;
@ -334,7 +346,8 @@ export class DisplayClaimsComponent implements OnInit, OnDestroy {
this.goTo(goToPage); this.goTo(goToPage);
}, err => { }, err => {
this.handleErrors(err, "Error deleting claim with id: " + this.claims[this.index].id); this.handleErrors(err, "Error deleting claim with id: " + this.claims[this.index].id);
})); }
));
} }
pageChange($event) { pageChange($event) {
@ -362,7 +375,44 @@ export class DisplayClaimsComponent implements OnInit, OnDestroy {
} }
return totalPages; return totalPages;
} }
selectClaim(item: any, event) {
let value = event.currentTarget.checked;
if (value) {
this.selected.push(item);
} else {
for (var _i = 0; _i < this.selected.length; _i++) {
let claim = this.selected[_i];
if (claim['id'] == item.id) {
this.selected.splice(_i, 1);
}
}
}
}
selectAll(event) {
let value = event.currentTarget.checked;
if (value) {
this.selected = [];
for (let _i = 0; _i < this.claims.length; _i++) {
let claim = this.claims[_i];
this.selected.push(claim);
}
} else {
this.selected = [];
}
}
isSelectedClaim(id: string) {
for (let _i = 0; _i < this.selected.length; _i++) {
let claim = this.selected[_i];
if (claim['id'] == id) {
return true;
}
}
return false;
}
private updateDescription(description: string) { private updateDescription(description: string) {
this._meta.updateTag({content: description}, "name='description'"); this._meta.updateTag({content: description}, "name='description'");
this._meta.updateTag({content: description}, "property='og:description'"); this._meta.updateTag({content: description}, "property='og:description'");

View File

@ -15,21 +15,22 @@ import {StringUtils} from "../../../utils/string-utils.class";
<div *ngIf="source" class="uk-text-small"> <div *ngIf="source" class="uk-text-small">
{{getEntityName(type)}} {{getEntityName(type)}}
</div> </div>
<div class="uk-flex"> <div>
<span *ngIf="!source" class="uk-text-meta uk-margin-small-right uk-text-large uk-text-nowrap">Link to:</span> <span *ngIf="!source" class="uk-text-meta uk-text-small uk-margin-small-right uk-text-nowrap">Link to:</span>
<publication-title [entity]="entity" param="id" <publication-title [entity]="entity" param="id"
path="/search/result" [externalPortalUrl]=externalPortalUrl [linkAvailable]="linkAvailable"></publication-title> path="/search/result" [externalPortalUrl]=externalPortalUrl [linkAvailable]="linkAvailable"></publication-title>
</div> </div>
</div> </div>
<div *ngIf="type == 'project'" [attr.uk-tooptip]="getEntityName(type)" <div *ngIf="type == 'project'" [attr.uk-tooptip]="getEntityName(type)">
class="uk-flex"> <span class="uk-text-meta uk-text-small uk-margin-small-right uk-text-nowrap">Link to:</span>
<span class="uk-text-meta uk-margin-small-right uk-text-large uk-text-nowrap">Link to:</span>
<project-title [project]="entity" [searchLink]=properties.searchLinkToProject <project-title [project]="entity" [searchLink]=properties.searchLinkToProject
[externalPortalUrl]=externalPortalUrl></project-title> [externalPortalUrl]=externalPortalUrl></project-title>
</div> </div>
<div *ngIf="type == 'context'" class="uk-flex uk-text-large"> <div *ngIf="type == 'context'">
<span class="uk-text-meta uk-margin-small-right uk-text-nowrap">Link to:</span> <span class="uk-text-meta uk-text-small uk-margin-small-right uk-text-nowrap">Link to:</span>
<span class="uk-text-truncate" uk-tooltip="Concept">{{entity.title}}</span> <h6 class="uk-h6 uk-margin-remove">
<span class="uk-text-truncate" uk-tooltip="Concept">{{entity.title}}</span>
</h6>
</div> </div>
` `
}) })

View File

@ -20,7 +20,7 @@ import {properties} from "../../../../../environments/environment";
</h6> </h6>
</ng-container> </ng-container>
<span *ngIf="project['funderName']" class="uk-margin-small-top"> <span *ngIf="project['funderName']" class="uk-margin-small-top">
<span class="uk-text-muted">Funder: </span>{{project['funderName']}} <span class="uk-text-meta">Funder: </span>{{project['funderName']}}
</span> </span>
` `
}) })