diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetManager.java index a0fe6d159..725f130e8 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetManager.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetManager.java @@ -1054,8 +1054,10 @@ public class DatasetManager { criteria.setGroupIds(Collections.singletonList(item.getProfile().getGroupId())); List profiles = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().getWithCriteria(criteria).toList(); boolean islast = false; - profiles = profiles.stream().sorted(Comparator.comparing(DatasetProfile::getVersion)).collect(Collectors.toList()); - islast = profiles.get(0).getId().equals(item.getProfile().getId()); + 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; } diff --git a/dmp-frontend/src/app/library/auto-complete/multiple/multiple-auto-complete.component.ts b/dmp-frontend/src/app/library/auto-complete/multiple/multiple-auto-complete.component.ts index ff0663383..5f05404a0 100644 --- a/dmp-frontend/src/app/library/auto-complete/multiple/multiple-auto-complete.component.ts +++ b/dmp-frontend/src/app/library/auto-complete/multiple/multiple-auto-complete.component.ts @@ -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 = ''; diff --git a/dmp-frontend/src/app/ui/dataset/overview/dataset-overview.component.html b/dmp-frontend/src/app/ui/dataset/overview/dataset-overview.component.html index dba577e25..40d668854 100644 --- a/dmp-frontend/src/app/ui/dataset/overview/dataset-overview.component.html +++ b/dmp-frontend/src/app/ui/dataset/overview/dataset-overview.component.html @@ -62,7 +62,8 @@
@@ -143,7 +144,7 @@

{{ roleDisplay(user) }}

- diff --git a/dmp-frontend/src/app/ui/dataset/overview/dataset-overview.component.ts b/dmp-frontend/src/app/ui/dataset/overview/dataset-overview.component.ts index 6e1a22ef4..0f79504df 100644 --- a/dmp-frontend/src/app/ui/dataset/overview/dataset-overview.component.ts +++ b/dmp-frontend/src/app/ui/dataset/overview/dataset-overview.component.ts @@ -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,10 +139,10 @@ export class DatasetOverviewComponent extends BaseComponent implements OnInit { }); } - checkLockStatus(id: string){ - this.lockService.checkLockStatus(id).pipe(takeUntil(this._destroyed)) - .subscribe(lockStatus => this.lockStatus = lockStatus); - } + checkLockStatus(id: string) { + this.lockService.checkLockStatus(id).pipe(takeUntil(this._destroyed)) + .subscribe(lockStatus => this.lockStatus = lockStatus); + } onFetchingDeletedCallbackError(redirectRoot: string) { this.uiNotificationService.snackBarNotification(this.language.instant('DATASET-OVERVIEW.ERROR.DELETED-DATASET'), SnackBarNotificationLevel.Error); @@ -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(); + } + }); + } } diff --git a/dmp-frontend/src/app/ui/dmp/invitation/dmp-invitation.component.html b/dmp-frontend/src/app/ui/dmp/invitation/dmp-invitation.component.html index 48c5bcdc9..e6b43c548 100644 --- a/dmp-frontend/src/app/ui/dmp/invitation/dmp-invitation.component.html +++ b/dmp-frontend/src/app/ui/dmp/invitation/dmp-invitation.component.html @@ -7,19 +7,14 @@

{{'DMP-LISTING.ACTIONS.INVITE-AUTHORS' | translate}}

- - - - {{email}} - cancel - - - + + + + -
+
diff --git a/dmp-frontend/src/app/ui/dmp/invitation/dmp-invitation.component.scss b/dmp-frontend/src/app/ui/dmp/invitation/dmp-invitation.component.scss index cee86fde2..996466d32 100644 --- a/dmp-frontend/src/app/ui/dmp/invitation/dmp-invitation.component.scss +++ b/dmp-frontend/src/app/ui/dmp/invitation/dmp-invitation.component.scss @@ -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; +} diff --git a/dmp-frontend/src/app/ui/dmp/invitation/dmp-invitation.component.ts b/dmp-frontend/src/app/ui/dmp/invitation/dmp-invitation.component.ts index 20936c1c8..ddce6723f 100644 --- a/dmp-frontend/src/app/ui/dmp/invitation/dmp-invitation.component.ts +++ b/dmp-frontend/src/app/ui/dmp/invitation/dmp-invitation.component.ts @@ -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(...(this.formGroup.get('users').value).filter(user => typeof(user) === 'string').map(email => ({ email: email, name: email }))); + invitationObject.users.push(...(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; // }); } + } \ No newline at end of file diff --git a/dmp-frontend/src/app/ui/dmp/overview/dmp-overview.component.html b/dmp-frontend/src/app/ui/dmp/overview/dmp-overview.component.html index c28357438..92357e3fa 100644 --- a/dmp-frontend/src/app/ui/dmp/overview/dmp-overview.component.html +++ b/dmp-frontend/src/app/ui/dmp/overview/dmp-overview.component.html @@ -206,7 +206,7 @@

{{ roleDisplay(user) }}

- diff --git a/dmp-frontend/src/app/ui/dmp/overview/dmp-overview.component.ts b/dmp-frontend/src/app/ui/dmp/overview/dmp-overview.component.ts index fb73baf7b..3b0330271 100644 --- a/dmp-frontend/src/app/ui/dmp/overview/dmp-overview.component.ts +++ b/dmp-frontend/src/app/ui/dmp/overview/dmp-overview.component.ts @@ -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) { @@ -598,6 +619,8 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit { } } + + // advancedClicked() { // const dialogRef = this.dialog.open(ExportMethodDialogComponent, {