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())); criteria.setGroupIds(Collections.singletonList(item.getProfile().getGroupId()));
List<DatasetProfile> profiles = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().getWithCriteria(criteria).toList(); List<DatasetProfile> profiles = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().getWithCriteria(criteria).toList();
boolean islast = false; boolean islast = false;
if (!profiles.isEmpty()) {
profiles = profiles.stream().sorted(Comparator.comparing(DatasetProfile::getVersion)).collect(Collectors.toList()); profiles = profiles.stream().sorted(Comparator.comparing(DatasetProfile::getVersion)).collect(Collectors.toList());
islast = profiles.get(0).getId().equals(item.getProfile().getId()); islast = profiles.get(0).getId().equals(item.getProfile().getId());
}
listingModel.setProfileLatestVersion(islast); listingModel.setProfileLatestVersion(islast);
return listingModel; return listingModel;
} }

View File

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

View File

@ -62,7 +62,8 @@
<div class="row "> <div class="row ">
<button class="dmp-btn" (click)="dmpClicked(dataset.dmp.id)"> <button class="dmp-btn" (click)="dmpClicked(dataset.dmp.id)">
<div class="dmp-btn-label"> <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> </div>
<mat-icon>launch</mat-icon> <mat-icon>launch</mat-icon>
</button> </button>
@ -143,7 +144,7 @@
<p class="authors-role">{{ roleDisplay(user) }}</p> <p class="authors-role">{{ roleDisplay(user) }}</p>
</div> </div>
</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> class="remove-btn">{{ 'GENERAL.CONFIRMATION-DIALOG.ACTIONS.REMOVE' | translate}}</button>
</div> </div>
</div> </div>

View File

@ -48,7 +48,9 @@ export class DatasetOverviewComponent extends BaseComponent implements OnInit {
expand = false; expand = false;
hasDOIToken = false; hasDOIToken = false;
researchers: ResearcherModel[]; researchers: ResearcherModel[];
lockStatus: Boolean; users: UserInfoListingModel[];
lockStatus = false;
// lockStatus: Boolean;
constructor( constructor(
private route: ActivatedRoute, private route: ActivatedRoute,
@ -85,11 +87,12 @@ export class DatasetOverviewComponent extends BaseComponent implements OnInit {
.subscribe(data => { .subscribe(data => {
this.dataset = data; this.dataset = data;
this.getDmpResearchers(); this.getDmpResearchers();
this.getDmpUsers();
this.datasetWizardService.getSingle(this.dataset.id).pipe(takeUntil(this._destroyed)) this.datasetWizardService.getSingle(this.dataset.id).pipe(takeUntil(this._destroyed))
.subscribe(data => { .subscribe(data => {
this.datasetWizardModel = new DatasetWizardEditorModel().fromModel(data); this.datasetWizardModel = new DatasetWizardEditorModel().fromModel(data);
}); });
this.checkLockStatus(this.dataset.id); // this.checkLockStatus(this.dataset.id);
this.setIsUserOwner(); this.setIsUserOwner();
const breadCrumbs = []; const breadCrumbs = [];
breadCrumbs.push({ parentComponentName: null, label: this.language.instant('NAV-BAR.MY-DATASET-DESCRIPTIONS'), url: "/datasets" }); 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 => { .subscribe(data => {
this.dataset = data; this.dataset = data;
this.getDmpResearchers(); this.getDmpResearchers();
this.getDmpUsers();
this.datasetWizardService.getSingle(this.dataset.id).pipe(takeUntil(this._destroyed)) this.datasetWizardService.getSingle(this.dataset.id).pipe(takeUntil(this._destroyed))
.subscribe(data => { .subscribe(data => {
this.datasetWizardModel = new DatasetWizardEditorModel().fromModel(data); this.datasetWizardModel = new DatasetWizardEditorModel().fromModel(data);
}); });
this.checkLockStatus(this.dataset.id); // this.checkLockStatus(this.dataset.id);
this.setIsUserOwner(); this.setIsUserOwner();
const breadCrumbs = []; const breadCrumbs = [];
breadCrumbs.push({ parentComponentName: null, label: this.language.instant('NAV-BAR.PUBLIC DATASETS'), url: "/explore" }); breadCrumbs.push({ parentComponentName: null, label: this.language.instant('NAV-BAR.PUBLIC DATASETS'), url: "/explore" });
@ -154,6 +158,12 @@ export class DatasetOverviewComponent extends BaseComponent implements OnInit {
this.location.back(); this.location.back();
} }
reloadComponent(): void {
this.router.navigateByUrl('/datasets', { skipLocationChange: true }).then(() => {
this.router.navigate([`/datasets/overview/${this.dataset.id}`]);
});
}
getDmpResearchers() { getDmpResearchers() {
this.dmpService.getSingle(this.dataset.dmp.id).pipe(takeUntil(this._destroyed)) this.dmpService.getSingle(this.dataset.dmp.id).pipe(takeUntil(this._destroyed))
.subscribe(data => { .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() { setIsUserOwner() {
if (this.dataset) { if (this.dataset) {
const principal: Principal = this.authentication.current(); const principal: Principal = this.authentication.current();
@ -261,7 +278,10 @@ export class DatasetOverviewComponent extends BaseComponent implements OnInit {
this.datasetService.delete(this.dataset.id) this.datasetService.delete(this.dataset.id)
.pipe(takeUntil(this._destroyed)) .pipe(takeUntil(this._destroyed))
.subscribe( .subscribe(
complete => { this.onCallbackSuccess() }, complete => {
this.onCallbackSuccess();
this.router.navigate(['/datasets']);
},
error => this.onDeleteCallbackError(error) error => this.onDeleteCallbackError(error)
); );
} }
@ -274,7 +294,6 @@ export class DatasetOverviewComponent extends BaseComponent implements OnInit {
onCallbackSuccess(): void { 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.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) { onDeleteCallbackError(error) {
@ -370,14 +389,36 @@ export class DatasetOverviewComponent extends BaseComponent implements OnInit {
}); });
} }
removeUserFromDmp() { updateUsers() {
// return this.dmpService.removeUserFromDmp().pipe(takeUntil(this._destroyed)) return this.dmpService.updateUsers(this.dataset.dmp.id, this.users).pipe(takeUntil(this._destroyed))
// .subscribe( .subscribe(
// complete => { this.onCallbackSuccess() }, complete => {
// error => this.onDeleteCallbackError(error) 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> <h1 mat-dialog-title class="title">{{'DMP-LISTING.ACTIONS.INVITE-AUTHORS' | translate}}</h1>
</div> </div>
<div mat-dialog-content class="row content"> <div mat-dialog-content class="row content">
<mat-form-field class="example-chip-list col mb-4"> <mat-form-field class="col pt-2 pb-2 mb-4">
<mat-chip-list #chipList> <mat-label></mat-label>
<mat-chip *ngFor="let email of emails" [selectable]="selectable" [removable]="removable" <app-multiple-auto-complete [formControl]="formGroup.get('users')"
(removed)="remove(email)"> placeholder="{{'INVITATION-EDITOR.AUTOCOMPLETE-USER-EMAIL' | translate}}"
{{email}} [configuration]="usersAutoCompleteConfiguration">
<mat-icon matChipRemove *ngIf="removable">cancel</mat-icon> </app-multiple-auto-complete>
</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> </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" <button mat-raised-button (click)="send()" type="button"
class="invite-btn">{{'DMP-LISTING.ACTIONS.INVITE-SHORT' | translate}}</button> class="invite-btn">{{'DMP-LISTING.ACTIONS.INVITE-SHORT' | translate}}</button>
</div> </div>

View File

@ -1,8 +1,7 @@
.form-container { .form-container {
width: 530px; width: 33em;
height: 228px; min-height: 14em;
padding: 4.5px 5.5px 14px 18px; padding: 0.28em 0.34em 0.875em 1.125em;
// margin: 28.5px 29.5px 38px 42px;
} }
.close-icon { .close-icon {
@ -10,24 +9,19 @@
} }
.title { .title {
// text-align: left; font-size: 2.375em;
font-size: 38px;
font-weight: lighter; font-weight: lighter;
color: #000000; color: #000000;
opacity: 0.8; opacity: 0.8;
margin-bottom: 32px; margin-bottom: 0.842em;
} }
.content { .content {
width: 496px; width: 31em;
margin: 0px; margin: 0px;
padding: 0px; padding: 0px;
} }
.input {
border: 2px black;
}
.mat-form-field { .mat-form-field {
background: #FAFAFA; background: #FAFAFA;
border: 1px solid #D1D1D1; border: 1px solid #D1D1D1;
@ -38,7 +32,15 @@
display: none; 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; display: none;
} }
@ -51,6 +53,6 @@
font-weight: bold; font-weight: bold;
letter-spacing: -0.35px; letter-spacing: -0.35px;
color: #B5B5B5; color: #B5B5B5;
margin-bottom: 1px; margin-bottom: 0.25em;
} }

View File

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

View File

@ -206,7 +206,7 @@
<p class="authors-role">{{ roleDisplay(user) }}</p> <p class="authors-role">{{ roleDisplay(user) }}</p>
</div> </div>
</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> class="remove-btn">{{ 'GENERAL.CONFIRMATION-DIALOG.ACTIONS.REMOVE' | translate}}</button>
</div> </div>
</div> </div>

View File

@ -566,12 +566,33 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit {
this.location.back(); this.location.back();
} }
removeUserFromDmp() { updateUsers() {
// return this.dmpService.updateUsers(this.dmp.id, this.dmp.users).pipe(takeUntil(this._destroyed)) return this.dmpService.updateUsers(this.dmp.id, this.dmp.users).pipe(takeUntil(this._destroyed))
// .subscribe( .subscribe(
// complete => { this.onCallbackSuccess() }, complete => { this.onCallbackSuccess() },
// error => this.onDeleteCallbackError(error) 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) { copyDoi(doi) {
@ -599,6 +620,8 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit {
} }
// advancedClicked() { // advancedClicked() {
// const dialogRef = this.dialog.open(ExportMethodDialogComponent, { // const dialogRef = this.dialog.open(ExportMethodDialogComponent, {
// maxWidth: '500px', // maxWidth: '500px',