dmp&dataset overview_remove user & invite user update

This commit is contained in:
gpapavgeri 2020-07-09 10:17:49 +03:00
parent a728e7da4a
commit a4b61c2172
9 changed files with 138 additions and 64 deletions

View File

@ -1054,8 +1054,10 @@ public class DatasetManager {
criteria.setGroupIds(Collections.singletonList(item.getProfile().getGroupId()));
List<DatasetProfile> profiles = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().getWithCriteria(criteria).toList();
boolean islast = false;
if (!profiles.isEmpty()) {
profiles = profiles.stream().sorted(Comparator.comparing(DatasetProfile::getVersion)).collect(Collectors.toList());
islast = profiles.get(0).getId().equals(item.getProfile().getId());
}
listingModel.setProfileLatestVersion(islast);
return listingModel;
}

View File

@ -303,12 +303,13 @@ export class MultipleAutoCompleteComponent extends _CustomComponentMixinBase imp
//Chip Functions
_addItem(event: MatChipInputEvent): void {
const input = event.input;
const value = event.value;
// Add our fruit
// if ((value || '').trim()) {
// this.selectedItems.push(value.trim());
// }
if ((value || '').trim()) {
this.optionSelectedInternal(value);
}
// Reset the input value
if (input) {
this.inputValue = '';

View File

@ -62,7 +62,8 @@
<div class="row ">
<button class="dmp-btn" (click)="dmpClicked(dataset.dmp.id)">
<div class="dmp-btn-label">
{{ 'DATASET-LISTING.TOOLTIP.DMP-FOR' | translate }}: {{ dataset.datasetTemplate.label }}
{{ this.dataset.dmp.label }}: {{ dataset.datasetTemplate.label }}
<!-- {{ 'DATASET-LISTING.TOOLTIP.DMP-FOR' | translate }}: {{ dataset.datasetTemplate.label }} -->
</div>
<mat-icon>launch</mat-icon>
</button>
@ -143,7 +144,7 @@
<p class="authors-role">{{ roleDisplay(user) }}</p>
</div>
</div>
<button *ngIf="isUserOwner && !dataset.status && user.role" (click)="removeUserFromDmp()"
<button *ngIf="isUserOwner && !dataset.status && user.role" (click)="removeUserFromDmp(user)"
class="remove-btn">{{ 'GENERAL.CONFIRMATION-DIALOG.ACTIONS.REMOVE' | translate}}</button>
</div>
</div>

View File

@ -48,7 +48,9 @@ export class DatasetOverviewComponent extends BaseComponent implements OnInit {
expand = false;
hasDOIToken = false;
researchers: ResearcherModel[];
lockStatus: Boolean;
users: UserInfoListingModel[];
lockStatus = false;
// lockStatus: Boolean;
constructor(
private route: ActivatedRoute,
@ -85,11 +87,12 @@ export class DatasetOverviewComponent extends BaseComponent implements OnInit {
.subscribe(data => {
this.dataset = data;
this.getDmpResearchers();
this.getDmpUsers();
this.datasetWizardService.getSingle(this.dataset.id).pipe(takeUntil(this._destroyed))
.subscribe(data => {
this.datasetWizardModel = new DatasetWizardEditorModel().fromModel(data);
});
this.checkLockStatus(this.dataset.id);
// this.checkLockStatus(this.dataset.id);
this.setIsUserOwner();
const breadCrumbs = [];
breadCrumbs.push({ parentComponentName: null, label: this.language.instant('NAV-BAR.MY-DATASET-DESCRIPTIONS'), url: "/datasets" });
@ -113,11 +116,12 @@ export class DatasetOverviewComponent extends BaseComponent implements OnInit {
.subscribe(data => {
this.dataset = data;
this.getDmpResearchers();
this.getDmpUsers();
this.datasetWizardService.getSingle(this.dataset.id).pipe(takeUntil(this._destroyed))
.subscribe(data => {
this.datasetWizardModel = new DatasetWizardEditorModel().fromModel(data);
});
this.checkLockStatus(this.dataset.id);
// this.checkLockStatus(this.dataset.id);
this.setIsUserOwner();
const breadCrumbs = [];
breadCrumbs.push({ parentComponentName: null, label: this.language.instant('NAV-BAR.PUBLIC DATASETS'), url: "/explore" });
@ -135,7 +139,7 @@ export class DatasetOverviewComponent extends BaseComponent implements OnInit {
});
}
checkLockStatus(id: string){
checkLockStatus(id: string) {
this.lockService.checkLockStatus(id).pipe(takeUntil(this._destroyed))
.subscribe(lockStatus => this.lockStatus = lockStatus);
}
@ -154,6 +158,12 @@ export class DatasetOverviewComponent extends BaseComponent implements OnInit {
this.location.back();
}
reloadComponent(): void {
this.router.navigateByUrl('/datasets', { skipLocationChange: true }).then(() => {
this.router.navigate([`/datasets/overview/${this.dataset.id}`]);
});
}
getDmpResearchers() {
this.dmpService.getSingle(this.dataset.dmp.id).pipe(takeUntil(this._destroyed))
.subscribe(data => {
@ -161,6 +171,13 @@ export class DatasetOverviewComponent extends BaseComponent implements OnInit {
});
}
getDmpUsers() {
this.dmpService.getSingle(this.dataset.dmp.id).pipe(takeUntil(this._destroyed))
.subscribe(data => {
this.users = data.users;
});
}
setIsUserOwner() {
if (this.dataset) {
const principal: Principal = this.authentication.current();
@ -261,7 +278,10 @@ export class DatasetOverviewComponent extends BaseComponent implements OnInit {
this.datasetService.delete(this.dataset.id)
.pipe(takeUntil(this._destroyed))
.subscribe(
complete => { this.onCallbackSuccess() },
complete => {
this.onCallbackSuccess();
this.router.navigate(['/datasets']);
},
error => this.onDeleteCallbackError(error)
);
}
@ -274,7 +294,6 @@ export class DatasetOverviewComponent extends BaseComponent implements OnInit {
onCallbackSuccess(): void {
this.uiNotificationService.snackBarNotification(this.isNew ? this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-CREATION') : this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE'), SnackBarNotificationLevel.Success);
this.router.navigate(['/datasets']);
}
onDeleteCallbackError(error) {
@ -370,14 +389,36 @@ export class DatasetOverviewComponent extends BaseComponent implements OnInit {
});
}
removeUserFromDmp() {
// return this.dmpService.removeUserFromDmp().pipe(takeUntil(this._destroyed))
// .subscribe(
// complete => { this.onCallbackSuccess() },
// error => this.onDeleteCallbackError(error)
// );
updateUsers() {
return this.dmpService.updateUsers(this.dataset.dmp.id, this.users).pipe(takeUntil(this._destroyed))
.subscribe(
complete => {
this.onCallbackSuccess();
this.reloadComponent();
},
error => this.onDeleteCallbackError(error)
);
}
removeUserFromDmp(user: UserInfoListingModel) {
const dialogRef = this.dialog.open(ConfirmationDialogComponent, {
data: {
message: this.language.instant('GENERAL.CONFIRMATION-DIALOG.DELETE-USER'),
confirmButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.REMOVE'),
cancelButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CANCEL'),
isDeleteConfirmation: false
}
});
dialogRef.afterClosed().subscribe(result => {
if (result) {
const index = this.users.findIndex(x => x.id === user.id);
if (index > -1) {
this.users.splice(index, 1);
}
this.updateUsers();
}
});
}
}

View File

@ -7,19 +7,14 @@
<h1 mat-dialog-title class="title">{{'DMP-LISTING.ACTIONS.INVITE-AUTHORS' | translate}}</h1>
</div>
<div mat-dialog-content class="row content">
<mat-form-field class="example-chip-list col mb-4">
<mat-chip-list #chipList>
<mat-chip *ngFor="let email of emails" [selectable]="selectable" [removable]="removable"
(removed)="remove(email)">
{{email}}
<mat-icon matChipRemove *ngIf="removable">cancel</mat-icon>
</mat-chip>
<input placeholder="{{'INVITATION-EDITOR.AUTOCOMPLETE-USER-EMAIL' | translate}}"
[matChipInputFor]="chipList" [matChipInputSeparatorKeyCodes]="separatorKeysCodes"
[matChipInputAddOnBlur]="addOnBlur" (matChipInputTokenEnd)="add($event)">
</mat-chip-list>
<mat-form-field class="col pt-2 pb-2 mb-4">
<mat-label></mat-label>
<app-multiple-auto-complete [formControl]="formGroup.get('users')"
placeholder="{{'INVITATION-EDITOR.AUTOCOMPLETE-USER-EMAIL' | translate}}"
[configuration]="usersAutoCompleteConfiguration">
</app-multiple-auto-complete>
</mat-form-field>
<div class="col-12 d-flex justify-content-end row m-0 p-1">
<div class="col-12 d-flex justify-content-end row m-0">
<button mat-raised-button (click)="send()" type="button"
class="invite-btn">{{'DMP-LISTING.ACTIONS.INVITE-SHORT' | translate}}</button>
</div>

View File

@ -1,8 +1,7 @@
.form-container {
width: 530px;
height: 228px;
padding: 4.5px 5.5px 14px 18px;
// margin: 28.5px 29.5px 38px 42px;
width: 33em;
min-height: 14em;
padding: 0.28em 0.34em 0.875em 1.125em;
}
.close-icon {
@ -10,24 +9,19 @@
}
.title {
// text-align: left;
font-size: 38px;
font-size: 2.375em;
font-weight: lighter;
color: #000000;
opacity: 0.8;
margin-bottom: 32px;
margin-bottom: 0.842em;
}
.content {
width: 496px;
width: 31em;
margin: 0px;
padding: 0px;
}
.input {
border: 2px black;
}
.mat-form-field {
background: #FAFAFA;
border: 1px solid #D1D1D1;
@ -38,11 +32,19 @@
display: none;
}
::ng-deep .multiple-auto-complete[_ngcontent-mut-c19] {
::ng-deep .mat-form-field-wrapper {
padding: 0em !important;
}
::ng-deep .mat-form-field-infix {
border: none;
}
::ng-deep .align-arrow-right {
display: none;
}
.invite-btn{
.invite-btn {
width: 6.64em;
height: 2.93em;
background: #FFFFFF;
@ -51,6 +53,6 @@
font-weight: bold;
letter-spacing: -0.35px;
color: #B5B5B5;
margin-bottom: 1px;
}
margin-bottom: 0.25em;
}

View File

@ -1,6 +1,6 @@
import { COMMA, ENTER } from '@angular/cdk/keycodes';
import { Component, Inject, OnInit } from '@angular/core';
import { Component, Inject, OnInit, ViewChild } from '@angular/core';
import { FormGroup } from '@angular/forms';
import { MatChipInputEvent } from '@angular/material/chips';
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
@ -33,12 +33,17 @@ export class DmpInvitationDialogComponent extends BaseComponent implements OnIni
addOnBlur = true;
readonly separatorKeysCodes: number[] = [ENTER, COMMA];
usersAutoCompleteConfiguration: MultipleAutoCompleteConfiguration = {
filterFn: this.filterUsers.bind(this),
initialItems: (excludedItems: any[]) => this.filterUsers('').pipe(map(result => result.filter(resultItem => (excludedItems || []).map(x => x.id).indexOf(resultItem.id) === -1))),
displayFn: (item) => item.name,
titleFn: (item) => item.name
displayFn: (item) => typeof(item) === 'string' ? item : item.name,
titleFn: (item) => typeof(item) === 'string' ? item : item.name,
valueAssign: (item) => {
const result = typeof(item) === 'string' ? item : item.email;
console.log(result);
return result;
}
};
add(event: MatChipInputEvent): void {
@ -79,8 +84,11 @@ export class DmpInvitationDialogComponent extends BaseComponent implements OnIni
let invitationObject: any = {};
invitationObject.dataManagementPlan = this.data.dmpId;
invitationObject.users = [];
invitationObject.users.push(...this.formGroup.get('users').value);
console.log(this.formGroup.get('users').value);
invitationObject.users.push(...(<any[]>this.formGroup.get('users').value).filter(user => typeof(user) === 'string').map(email => ({ email: email, name: email })));
invitationObject.users.push(...(<any[]>this.formGroup.get('users').value).filter(user => typeof(user) !== 'string'));
console.log(invitationObject.users);
//invitationObject.users.push(...this.formGroup.get('users').value);
this.emails.forEach(email => {
invitationObject.users.push({ email: email, name: email });
});
@ -114,4 +122,5 @@ export class DmpInvitationDialogComponent extends BaseComponent implements OnIni
// this.filteredUsersAsync = false;
// });
}
}

View File

@ -206,7 +206,7 @@
<p class="authors-role">{{ roleDisplay(user) }}</p>
</div>
</div>
<button *ngIf="isUserOwner && !dmp.status && user.role" (click)="removeUserFromDmp()"
<button *ngIf="isUserOwner && !dmp.status && user.role" (click)="removeUserFromDmp(user)"
class="remove-btn">{{ 'GENERAL.CONFIRMATION-DIALOG.ACTIONS.REMOVE' | translate}}</button>
</div>
</div>

View File

@ -566,12 +566,33 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit {
this.location.back();
}
removeUserFromDmp() {
// return this.dmpService.updateUsers(this.dmp.id, this.dmp.users).pipe(takeUntil(this._destroyed))
// .subscribe(
// complete => { this.onCallbackSuccess() },
// error => this.onDeleteCallbackError(error)
// );
updateUsers() {
return this.dmpService.updateUsers(this.dmp.id, this.dmp.users).pipe(takeUntil(this._destroyed))
.subscribe(
complete => { this.onCallbackSuccess() },
error => this.onDeleteCallbackError(error)
);
}
removeUserFromDmp(user: UserInfoListingModel) {
const dialogRef = this.dialog.open(ConfirmationDialogComponent, {
data: {
message: this.language.instant('GENERAL.CONFIRMATION-DIALOG.DELETE-USER'),
confirmButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.REMOVE'),
cancelButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CANCEL'),
isDeleteConfirmation: false
}
});
dialogRef.afterClosed().subscribe(result => {
if (result) {
const list= this.dmp.users;
const index = this.dmp.users.indexOf(user);
if (index > -1) {
this.dmp.users.splice(index, 1);
}
this.updateUsers();
}
});
}
copyDoi(doi) {
@ -599,6 +620,8 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit {
}
// advancedClicked() {
// const dialogRef = this.dialog.open(ExportMethodDialogComponent, {
// maxWidth: '500px',