Modifies new version of dmp
This commit is contained in:
parent
b12261b50b
commit
89c4aac560
|
@ -82,8 +82,8 @@ export class DmpService {
|
|||
return this.http.post<DatasetProfileModel[]>(this.actionUrl + 'datasetprofiles/get', dataSetProfileRequest, { headers: this.headers });
|
||||
}
|
||||
|
||||
newVersion(dataManagementPlanModel: DmpModel, id: String): Observable<DmpModel> {
|
||||
return this.http.post<DmpModel>(this.actionUrl + 'new/' + id, dataManagementPlanModel, { headers: this.headers });
|
||||
newVersion(dataManagementPlanModel: DmpModel, id: String): Observable<String> {
|
||||
return this.http.post<String>(this.actionUrl + 'new/' + id, dataManagementPlanModel, { headers: this.headers });
|
||||
}
|
||||
|
||||
clone(dataManagementPlanModel: DmpModel, id: String): Observable<String> {
|
||||
|
|
|
@ -60,7 +60,7 @@
|
|||
<a class="col-auto border-right pointer" [matMenuTriggerFor]="exportMenu"><span class="material-icons icon-align pr-2">open_in_new</span>{{'DMP-LISTING.ACTIONS.EXPORT' | translate}}</a>
|
||||
<a class="col-auto border-right pointer" *ngIf="isDraftDmp(activity)" [routerLink]="['/new/dataset/' + activity.id]" target="_blank"><span class="material-icons icon-align">add</span>{{'DMP-LISTING.ACTIONS.ADD-DATASET-SHORT' | translate}}</a>
|
||||
<a class="col-auto border-right pointer" *ngIf="isUserOwner(activity)" (click)="openShareDialog(activity.id, activity.title)"><span class="material-icons icon-align pr-2">group_add</span>{{'DMP-LISTING.ACTIONS.INVITE-SHORT' | translate}}</a>
|
||||
<a class="col-auto border-right pointer" *ngIf="isAuthenticated()" (click)="cloneClicked(activity)"><span class="material-icons icon-align pr-2">filter_none</span>{{'DMP-LISTING.ACTIONS.CLONE' | translate}}</a>
|
||||
<a class="col-auto border-right pointer" *ngIf="isAuthenticated()" (click)="cloneOrNewVersionClicked(activity, false)"><span class="material-icons icon-align pr-2">filter_none</span>{{'DMP-LISTING.ACTIONS.CLONE' | translate}}</a>
|
||||
<a class="col-auto pointer" [matMenuTriggerFor]="actionsMenu"><span class="material-icons icon-align pl-2">more_horiz</span></a>
|
||||
</div>
|
||||
|
||||
|
@ -83,7 +83,7 @@
|
|||
</button>
|
||||
</mat-menu>
|
||||
<mat-menu #actionsMenu="matMenu" xPosition="before">
|
||||
<button *ngIf="isUserOwner(activity)" mat-menu-item (click)="newVersion(activity.id, activity.title)">
|
||||
<button *ngIf="isUserOwner(activity)" mat-menu-item (click)="cloneOrNewVersionClicked(activity, true)">
|
||||
<mat-icon>queue</mat-icon>{{'DMP-LISTING.ACTIONS.NEW-VERSION' | translate}}
|
||||
</button>
|
||||
<button mat-menu-item (click)="viewVersions(getGroupId(activity), activity.title, activity)">
|
||||
|
|
|
@ -196,7 +196,7 @@ export class RecentEditedActivityComponent extends BaseComponent implements OnIn
|
|||
});
|
||||
}
|
||||
|
||||
cloneClicked(dmp: RecentActivityModel) {
|
||||
cloneOrNewVersionClicked(dmp: RecentActivityModel, isNewVersion: boolean) {
|
||||
this.dmpService.getSingle(dmp.id).pipe(map(data => data as DmpModel))
|
||||
.pipe(takeUntil(this._destroyed))
|
||||
.subscribe(data => {
|
||||
|
@ -208,30 +208,42 @@ export class RecentEditedActivityComponent extends BaseComponent implements OnIn
|
|||
this.dmpModel.fromModel(data);
|
||||
this.dmpModel.status = DmpStatus.Draft;
|
||||
this.dmpFormGroup = this.dmpModel.buildForm();
|
||||
this.dmpFormGroup.get('label').setValue(dmp.title + " New");
|
||||
|
||||
this.openCloneDialog();
|
||||
if (!isNewVersion) {
|
||||
this.formGroup.get('label').setValue(dmp.title + " New");
|
||||
}
|
||||
this.openCloneDialog(isNewVersion);
|
||||
});
|
||||
}
|
||||
|
||||
openCloneDialog() {
|
||||
openCloneDialog(isNewVersion: boolean) {
|
||||
const dialogRef = this.dialog.open(CloneDialogComponent, {
|
||||
maxWidth: '700px',
|
||||
maxHeight: '80vh',
|
||||
data: {
|
||||
formGroup: this.dmpFormGroup,
|
||||
datasets: this.dmpFormGroup.get('datasets').value,
|
||||
confirmButton: this.language.instant('DMP-EDITOR.CLONE-DIALOG.CLONE'),
|
||||
isNewVersion: isNewVersion,
|
||||
confirmButton: this.language.instant('DMP-EDITOR.CLONE-DIALOG.SAVE'),
|
||||
cancelButton: this.language.instant('DMP-EDITOR.CLONE-DIALOG.CANCEL'),
|
||||
}
|
||||
});
|
||||
dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => {
|
||||
if (result) {
|
||||
this.dmpService.clone(this.dmpFormGroup.getRawValue(), this.dmpFormGroup.get('id').value)
|
||||
.pipe(takeUntil(this._destroyed))
|
||||
.subscribe(
|
||||
complete => this.onCloneCallbackSuccess(complete),
|
||||
error => this.onCloneCallbackError(error)
|
||||
);
|
||||
if (!isNewVersion) {
|
||||
this.dmpService.clone(this.dmpFormGroup.getRawValue(), this.dmpFormGroup.get('id').value)
|
||||
.pipe(takeUntil(this._destroyed))
|
||||
.subscribe(
|
||||
complete => this.onCloneOrNewVersionCallbackSuccess(complete),
|
||||
error => this.onCloneOrNewVersionCallbackError(error)
|
||||
);
|
||||
} else if (isNewVersion) {
|
||||
this.dmpService.newVersion(this.dmpFormGroup.getRawValue(), this.dmpFormGroup.get('id').value)
|
||||
.pipe(takeUntil(this._destroyed))
|
||||
.subscribe(
|
||||
complete => this.onCloneOrNewVersionCallbackSuccess(complete),
|
||||
error => this.onCloneOrNewVersionCallbackError(error)
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -306,12 +318,12 @@ export class RecentEditedActivityComponent extends BaseComponent implements OnIn
|
|||
this.uiNotificationService.snackBarNotification(error.error.message ? error.error.message : this.language.instant('GENERAL.SNACK-BAR.UNSUCCESSFUL-DELETE'), SnackBarNotificationLevel.Error);
|
||||
}
|
||||
|
||||
onCloneCallbackSuccess(cloneId: String): void {
|
||||
onCloneOrNewVersionCallbackSuccess(dmpId: String): void {
|
||||
this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE'), SnackBarNotificationLevel.Success);
|
||||
this.router.navigate(['/plans/edit/', cloneId]);
|
||||
this.router.navigate(['/plans/edit/', dmpId]);
|
||||
}
|
||||
|
||||
onCloneCallbackError(error: any) {
|
||||
onCloneOrNewVersionCallbackError(error: any) {
|
||||
this.uiNotificationService.snackBarNotification(error.error.message ? error.error.message : this.language.instant('GENERAL.SNACK-BAR.UNSUCCESSFUL-CLONE'), SnackBarNotificationLevel.Error);
|
||||
}
|
||||
|
||||
|
@ -491,10 +503,10 @@ export class RecentEditedActivityComponent extends BaseComponent implements OnIn
|
|||
return filename;
|
||||
}
|
||||
|
||||
newVersion(id: String, label: String) {
|
||||
let url = this.router.createUrlTree(['/plans/new_version/', id, { dmpLabel: label }]);
|
||||
window.open(url.toString(), '_blank');
|
||||
}
|
||||
// newVersion(id: String, label: String) {
|
||||
// let url = this.router.createUrlTree(['/plans/new_version/', id, { dmpLabel: label }]);
|
||||
// window.open(url.toString(), '_blank');
|
||||
// }
|
||||
|
||||
viewVersions(rowId: String, rowLabel: String, activity: DmpListingModel) {
|
||||
if (activity.public && !this.isUserOwner(activity)) {
|
||||
|
|
|
@ -54,7 +54,7 @@
|
|||
<a class="col-auto border-right pointer" [matMenuTriggerFor]="exportMenu"><span class="material-icons icon-align pr-2">open_in_new</span>{{'DMP-LISTING.ACTIONS.EXPORT' | translate}}</a>
|
||||
<a class="col-auto border-right pointer" *ngIf="isDraftDmp(activity)" [routerLink]="['/new/dataset/' + activity.id]" target="_blank"><span class="material-icons icon-align">add</span>{{'DMP-LISTING.ACTIONS.ADD-DATASET-SHORT' | translate}}</a>
|
||||
<a class="col-auto border-right pointer" *ngIf="isUserOwner(activity)" (click)="openShareDialog(activity.id, activity.label)"><span class="material-icons icon-align pr-2">group_add</span>{{'DMP-LISTING.ACTIONS.INVITE-SHORT' | translate}}</a>
|
||||
<a class="col-auto border-right pointer" *ngIf="isAuthenticated()" (click)="cloneClicked(activity)"><span class="material-icons icon-align pr-2">filter_none</span>{{'DMP-LISTING.ACTIONS.CLONE' | translate}}</a>
|
||||
<a class="col-auto border-right pointer" *ngIf="isAuthenticated()" (click)="cloneOrNewVersionClicked(activity, false)"><span class="material-icons icon-align pr-2">filter_none</span>{{'DMP-LISTING.ACTIONS.CLONE' | translate}}</a>
|
||||
<a class="col-auto pointer" [matMenuTriggerFor]="actionsMenu"><span class="material-icons icon-align pl-2">more_horiz</span></a>
|
||||
</div>
|
||||
|
||||
|
@ -77,7 +77,7 @@
|
|||
</button>
|
||||
</mat-menu>
|
||||
<mat-menu #actionsMenu="matMenu" xPosition="before">
|
||||
<button *ngIf="isUserOwner(activity)" mat-menu-item (click)="newVersion(activity.id, activity.label)">
|
||||
<button *ngIf="isUserOwner(activity)" mat-menu-item (click)="cloneOrNewVersionClicked(activity, true)">
|
||||
<mat-icon>queue</mat-icon>{{'DMP-LISTING.ACTIONS.NEW-VERSION' | translate}}
|
||||
</button>
|
||||
<button mat-menu-item (click)="viewVersions(activity.groupId, activity.label, activity)">
|
||||
|
|
|
@ -166,7 +166,7 @@ export class RecentEditedDmpActivityComponent extends BaseComponent implements O
|
|||
this.router.navigate(['/plans/edit/' + dmp.id]);
|
||||
}
|
||||
|
||||
cloneClicked(dmp: DmpListingModel) {
|
||||
cloneOrNewVersionClicked(dmp: DmpListingModel, isNewVersion: boolean) {
|
||||
this.dmpService.getSingle(dmp.id).pipe(map(data => data as DmpModel))
|
||||
.pipe(takeUntil(this._destroyed))
|
||||
.subscribe(data => {
|
||||
|
@ -178,30 +178,42 @@ export class RecentEditedDmpActivityComponent extends BaseComponent implements O
|
|||
this.dmpModel.fromModel(data);
|
||||
this.dmpModel.status = DmpStatus.Draft;
|
||||
this.dmpFormGroup = this.dmpModel.buildForm();
|
||||
this.dmpFormGroup.get('label').setValue(dmp.label + " New");
|
||||
|
||||
this.openCloneDialog();
|
||||
if (!isNewVersion) {
|
||||
this.formGroup.get('label').setValue(dmp.label + " New");
|
||||
}
|
||||
this.openCloneDialog(isNewVersion);
|
||||
});
|
||||
}
|
||||
|
||||
openCloneDialog() {
|
||||
openCloneDialog(isNewVersion: boolean) {
|
||||
const dialogRef = this.dialog.open(CloneDialogComponent, {
|
||||
maxWidth: '700px',
|
||||
maxHeight: '80vh',
|
||||
data: {
|
||||
formGroup: this.dmpFormGroup,
|
||||
datasets: this.dmpFormGroup.get('datasets').value,
|
||||
confirmButton: this.language.instant('DMP-EDITOR.CLONE-DIALOG.CLONE'),
|
||||
isNewVersion: isNewVersion,
|
||||
confirmButton: this.language.instant('DMP-EDITOR.CLONE-DIALOG.SAVE'),
|
||||
cancelButton: this.language.instant('DMP-EDITOR.CLONE-DIALOG.CANCEL'),
|
||||
}
|
||||
});
|
||||
dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => {
|
||||
if (result) {
|
||||
this.dmpService.clone(this.dmpFormGroup.getRawValue(), this.dmpFormGroup.get('id').value)
|
||||
.pipe(takeUntil(this._destroyed))
|
||||
.subscribe(
|
||||
complete => this.onCloneCallbackSuccess(complete),
|
||||
error => this.onCloneCallbackError(error)
|
||||
);
|
||||
if (!isNewVersion) {
|
||||
this.dmpService.clone(this.dmpFormGroup.getRawValue(), this.dmpFormGroup.get('id').value)
|
||||
.pipe(takeUntil(this._destroyed))
|
||||
.subscribe(
|
||||
complete => this.onCloneOrNewVersionCallbackSuccess(complete),
|
||||
error => this.onCloneOrNewVersionCallbackError(error)
|
||||
);
|
||||
} else if (isNewVersion) {
|
||||
this.dmpService.newVersion(this.dmpFormGroup.getRawValue(), this.dmpFormGroup.get('id').value)
|
||||
.pipe(takeUntil(this._destroyed))
|
||||
.subscribe(
|
||||
complete => this.onCloneOrNewVersionCallbackSuccess(complete),
|
||||
error => this.onCloneOrNewVersionCallbackError(error)
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -287,13 +299,13 @@ export class RecentEditedDmpActivityComponent extends BaseComponent implements O
|
|||
this.uiNotificationService.snackBarNotification(error.error.message ? error.error.message : this.language.instant('GENERAL.SNACK-BAR.UNSUCCESSFUL-DELETE'), SnackBarNotificationLevel.Error);
|
||||
}
|
||||
|
||||
onCloneCallbackSuccess(cloneId: String): void {
|
||||
onCloneOrNewVersionCallbackSuccess(dmpId: String): void {
|
||||
this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE'), SnackBarNotificationLevel.Success);
|
||||
this.router.navigate(['/plans/edit/', cloneId]);
|
||||
this.router.navigate(['/plans/edit/', dmpId]);
|
||||
}
|
||||
|
||||
onCloneCallbackError(error: any) {
|
||||
this.uiNotificationService.snackBarNotification(error.error.message ? error.error.message : this.language.instant('GENERAL.SNACK-BAR.UNSUCCESSFUL-CLONE'), SnackBarNotificationLevel.Error);
|
||||
onCloneOrNewVersionCallbackError(error: any) {
|
||||
this.uiNotificationService.snackBarNotification(error.error.message ? error.error.message : this.language.instant('GENERAL.SNACK-BAR.UNSUCCESSFUL-UPDATE'), SnackBarNotificationLevel.Error);
|
||||
}
|
||||
|
||||
redirect(id: string) {
|
||||
|
@ -403,10 +415,10 @@ export class RecentEditedDmpActivityComponent extends BaseComponent implements O
|
|||
return filename;
|
||||
}
|
||||
|
||||
newVersion(id: String, label: String) {
|
||||
let url = this.router.createUrlTree(['/plans/new_version/', id, { dmpLabel: label }]);
|
||||
window.open(url.toString(), '_blank');
|
||||
}
|
||||
// newVersion(id: String, label: String) {
|
||||
// let url = this.router.createUrlTree(['/plans/new_version/', id, { dmpLabel: label }]);
|
||||
// window.open(url.toString(), '_blank');
|
||||
// }
|
||||
|
||||
viewVersions(rowId: String, rowLabel: String, activity: DmpListingModel) {
|
||||
if (activity.public && !this.isUserOwner(activity)) {
|
||||
|
|
|
@ -0,0 +1,72 @@
|
|||
<div class="clone-dialog">
|
||||
<div *ngIf="!data.isNewVersion" class="heading-1">{{'DMP-EDITOR.TITLE.CLONE-DMP' | translate}}</div>
|
||||
<div *ngIf="data.isNewVersion" class="heading-1">{{'DMP-EDITOR.TITLE.NEW-VERSION' | translate}}</div>
|
||||
<!-- Title Field -->
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="heading">{{'DMP-EDITOR.FIELDS.NAME' | translate}}*</div>
|
||||
<div class="title-form">
|
||||
<mat-form-field>
|
||||
<input matInput placeholder="{{'DMP-EDITOR.FIELDS.NAME' | translate}}" type="text" name="label" [formControl]="this.data.formGroup.get('label')" required>
|
||||
<mat-error *ngIf="this.data.formGroup.get('label').hasError('backendError')">
|
||||
{{this.data.formGroup.get('label').getError('backendError').message}}</mat-error>
|
||||
<mat-error *ngIf="this.data.formGroup.get('label').hasError('required')">
|
||||
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Description field -->
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="heading">{{'DMP-EDITOR.FIELDS.DESCRIPTION' | translate}}</div>
|
||||
<div class="hint">{{'DMP-EDITOR.MAIN-INFO.HINT' | translate}}</div>
|
||||
<div class="description-form">
|
||||
<mat-form-field>
|
||||
<textarea rows="3" matInput class="description-area" placeholder="{{'DMP-EDITOR.PLACEHOLDER.DESCRIPTION' | translate}}" [formControl]="this.data.formGroup.get('description')"></textarea>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Profiles -->
|
||||
<div class="row" *ngIf="data.isNewVersion">
|
||||
<div class="col-12">
|
||||
<div class="heading">{{'DMP-EDITOR.FIELDS.TEMPLATES' | translate}}</div>
|
||||
<mat-form-field>
|
||||
<app-multiple-auto-complete required='true' [formControl]="this.data.formGroup.get('profiles')" placeholder="{{'DMP-EDITOR.FIELDS.SELECT-TEMPLATE' | translate}}" [configuration]="profilesAutoCompleteConfiguration">
|
||||
</app-multiple-auto-complete>
|
||||
<mat-error *ngIf="data.formGroup.get('profiles').hasError('backendError')">
|
||||
{{data.formGroup.get('profiles').getError('backendError').message}}</mat-error>
|
||||
<mat-error *ngIf="data.formGroup.get('profiles').hasError('required')">
|
||||
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||
<!-- <button matSuffix class="input-btn" [disabled]="data.formGroup.get('profiles').disabled" (click)="allAvailableProfiles($event)">
|
||||
<mat-icon class="icon-btn">view_list</mat-icon>
|
||||
</button> -->
|
||||
</mat-form-field>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Datasets -->
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="heading">{{'DMP-EDITOR.FIELDS.DATASETS' | translate}}</div>
|
||||
<div *ngIf="hasDatasets()">
|
||||
<h5>{{'DATASET-LISTING.SELECT-DATASETS-TO-CLONE' | translate}}</h5>
|
||||
<mat-card class="mat-card">
|
||||
<mat-selection-list #selectedItems (selectionChange)="selectionChanged(selectedItems)">
|
||||
<mat-list-option *ngFor="let dataset of data.datasets;" [value]="dataset.id">
|
||||
{{dataset.label}}
|
||||
</mat-list-option>
|
||||
</mat-selection-list>
|
||||
</mat-card>
|
||||
</div>
|
||||
<div *ngIf="!hasDatasets()">
|
||||
<h5 mat-subheader class="p-3">{{'DATASET-LISTING.SELECT-DATASETS-NONE' | translate}}</h5>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row pt-4">
|
||||
<div class="col"></div>
|
||||
<div class="col-auto"><button mat-raised-button type="button" (click)="cancel()">{{ data.cancelButton }}</button></div>
|
||||
<div class="col-auto"><button mat-raised-button type="button" (click)="confirm()" color="accent">{{ data.confirmButton }}</button></div>
|
||||
</div>
|
||||
</div>
|
|
@ -0,0 +1,21 @@
|
|||
.clone-dialog {
|
||||
.heading {
|
||||
text-align: left;
|
||||
font-weight: 700;
|
||||
font-size: 18px;
|
||||
letter-spacing: 0px;
|
||||
color: #212121;
|
||||
opacity: 0.81;
|
||||
margin-bottom: 0.625rem;
|
||||
}
|
||||
|
||||
.heading-1 {
|
||||
text-align: center;
|
||||
font-weight: 700;
|
||||
font-size: 20px;
|
||||
letter-spacing: 0px;
|
||||
color: #212121;
|
||||
opacity: 0.81;
|
||||
margin-bottom: 0.625rem;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,80 @@
|
|||
import { Component, Inject } from '@angular/core';
|
||||
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
|
||||
import { DmpService } from '@app/core/services/dmp/dmp.service';
|
||||
import { map, takeUntil } from 'rxjs/operators';
|
||||
import { DmpModel } from '@app/core/model/dmp/dmp';
|
||||
import { FormBuilder, FormArray, FormControl } from '@angular/forms';
|
||||
import { DatasetDescriptionFormEditorModel } from '@app/ui/misc/dataset-description-form/dataset-description-form.model';
|
||||
import { MultipleAutoCompleteConfiguration } from '@app/library/auto-complete/multiple/multiple-auto-complete-configuration';
|
||||
import { Observable } from 'rxjs';
|
||||
import { DatasetProfileModel } from '@app/core/model/dataset/dataset-profile';
|
||||
import { DataTableRequest } from '@app/core/model/data-table/data-table-request';
|
||||
import { DatasetProfileCriteria } from '@app/core/query/dataset-profile/dataset-profile-criteria';
|
||||
import { AvailableProfilesComponent } from '../../editor/available-profiles/available-profiles.component';
|
||||
|
||||
@Component({
|
||||
selector: 'app-clone-dialog',
|
||||
templateUrl: './clone-dialog.component.html',
|
||||
styleUrls: ['./clone-dialog.component.scss']
|
||||
})
|
||||
export class CloneDialogComponent {
|
||||
|
||||
agreePrivacyPolicyNames = false;
|
||||
initialItems = [];
|
||||
profilesAutoCompleteConfiguration: MultipleAutoCompleteConfiguration;
|
||||
|
||||
constructor(
|
||||
public dialogRef: MatDialogRef<CloneDialogComponent>,
|
||||
private dmpService: DmpService,
|
||||
@Inject(MAT_DIALOG_DATA) public data: any
|
||||
) {
|
||||
this.selectionChanged(this.initialItems)
|
||||
|
||||
this.profilesAutoCompleteConfiguration = {
|
||||
filterFn: this.filterProfiles.bind(this),
|
||||
initialItems: (excludedItems: any[]) => this.filterProfiles('').pipe(map(result => result.filter(resultItem => (excludedItems || []).map(x => x.id).indexOf(resultItem.id) === -1))),
|
||||
displayFn: (item) => item['label'],
|
||||
titleFn: (item) => item['label'],
|
||||
subtitleFn: (item) => item['description']
|
||||
};
|
||||
|
||||
if (this.data.isNewVersion) {
|
||||
this.data.formGroup.get('label').disable();
|
||||
}
|
||||
}
|
||||
|
||||
close() {
|
||||
this.dialogRef.close(false);
|
||||
}
|
||||
|
||||
cancel() {
|
||||
this.dialogRef.close(false);
|
||||
}
|
||||
|
||||
confirm() {
|
||||
this.dialogRef.close(true);
|
||||
}
|
||||
|
||||
selectionChanged(selectedItems) {
|
||||
this.data.formGroup.removeControl('datasets');
|
||||
this.data.formGroup.addControl('datasets', new FormBuilder().array(new Array<FormControl>()));
|
||||
if (selectedItems && selectedItems.selectedOptions && selectedItems.selectedOptions.selected.length > 0) {
|
||||
selectedItems.selectedOptions.selected.forEach(element => {
|
||||
(<FormArray>this.data.formGroup.get('datasets')).push(new FormBuilder().group({ id: element.value }));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
hasDatasets() {
|
||||
return this.data.datasets.length > 0;
|
||||
}
|
||||
|
||||
filterProfiles(value: string): Observable<DatasetProfileModel[]> {
|
||||
const request = new DataTableRequest<DatasetProfileCriteria>(null, null, { fields: ['+label'] });
|
||||
const criteria = new DatasetProfileCriteria();
|
||||
criteria.like = value;
|
||||
request.criteria = criteria;
|
||||
return this.dmpService.searchDMPProfiles(request);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
import { NgModule } from '@angular/core';
|
||||
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
|
||||
import { CommonUiModule } from '@common/ui/common-ui.module';
|
||||
import { CloneDialogComponent } from './clone-dialog.component';
|
||||
import { AutoCompleteModule } from '@app/library/auto-complete/auto-complete.module';
|
||||
|
||||
@NgModule({
|
||||
imports: [CommonUiModule, FormsModule, ReactiveFormsModule, AutoCompleteModule],
|
||||
declarations: [CloneDialogComponent],
|
||||
exports: [CloneDialogComponent],
|
||||
entryComponents: [CloneDialogComponent]
|
||||
})
|
||||
export class CloneDialogModule {
|
||||
constructor() { }
|
||||
}
|
|
@ -601,6 +601,7 @@ export class DmpEditorComponent extends BaseComponent implements OnInit, IBreadC
|
|||
// openCloneDialog() {
|
||||
// const dialogRef = this.dialog.open(CloneDialogComponent, {
|
||||
// maxWidth: '700px',
|
||||
// maxHeight: '80vh',
|
||||
// data: {
|
||||
// formGroup: this.formGroup,
|
||||
// datasets: this.formGroup.get('datasets').value,
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
<a class="col-auto border-right pointer" [matMenuTriggerFor]="exportMenu"><span class="material-icons icon-align pr-2">open_in_new</span>{{'DMP-LISTING.ACTIONS.EXPORT' | translate}}</a>
|
||||
<a class="col-auto border-right pointer" *ngIf="isDraftDmp(dmp)" [routerLink]="['/new/dataset/' + dmp.id]" target="_blank"><span class="material-icons icon-align">add</span>{{'DMP-LISTING.ACTIONS.ADD-DATASET-SHORT' | translate}}</a>
|
||||
<a class="col-auto border-right pointer" *ngIf="isUserOwner(dmp)" (click)="openShareDialog(dmp.id, dmp.label)"><span class="material-icons icon-align pr-2">group_add</span>{{'DMP-LISTING.ACTIONS.INVITE-SHORT' | translate}}</a>
|
||||
<a class="col-auto border-right pointer" *ngIf="isAuthenticated()" (click)="cloneClicked(dmp)"><span class="material-icons icon-align pr-2">filter_none</span>{{'DMP-LISTING.ACTIONS.CLONE' | translate}}</a>
|
||||
<a class="col-auto border-right pointer" *ngIf="isAuthenticated()" (click)="cloneOrNewVersionClicked(dmp, false)"><span class="material-icons icon-align pr-2">filter_none</span>{{'DMP-LISTING.ACTIONS.CLONE' | translate}}</a>
|
||||
<a class="col-auto pointer" [matMenuTriggerFor]="actionsMenu"><span class="material-icons icon-align pl-2">more_horiz</span></a>
|
||||
</div>
|
||||
|
||||
|
@ -54,7 +54,7 @@
|
|||
</button>
|
||||
</mat-menu>
|
||||
<mat-menu #actionsMenu="matMenu" xPosition="before">
|
||||
<button *ngIf="isUserOwner(dmp)" mat-menu-item (click)="newVersion(dmp.id, dmp.label)">
|
||||
<button *ngIf="isUserOwner(dmp)" mat-menu-item (click)="cloneOrNewVersionClicked(dmp, true)">
|
||||
<mat-icon>queue</mat-icon>{{'DMP-LISTING.ACTIONS.NEW-VERSION' | translate}}
|
||||
</button>
|
||||
<button mat-menu-item (click)="viewVersions(dmp.groupId, dmp.label, dmp)">
|
||||
|
|
|
@ -154,7 +154,7 @@ export class DmpListingItemComponent extends BaseComponent implements OnInit {
|
|||
return isRelated;
|
||||
}
|
||||
|
||||
cloneClicked(dmp: DmpListingModel) {
|
||||
cloneOrNewVersionClicked(dmp: DmpListingModel, isNewVersion: boolean) {
|
||||
this.dmpService.getSingle(dmp.id).pipe(map(data => data as DmpModel))
|
||||
.pipe(takeUntil(this._destroyed))
|
||||
.subscribe(data => {
|
||||
|
@ -166,38 +166,51 @@ export class DmpListingItemComponent extends BaseComponent implements OnInit {
|
|||
this.dmpModel.fromModel(data);
|
||||
this.dmpModel.status = DmpStatus.Draft;
|
||||
this.dmpFormGroup = this.dmpModel.buildForm();
|
||||
this.dmpFormGroup.get('label').setValue(dmp.label + " New");
|
||||
|
||||
this.openCloneDialog();
|
||||
if (!isNewVersion) {
|
||||
this.dmpFormGroup.get('label').setValue(dmp.label + " New");
|
||||
}
|
||||
this.openCloneDialog(isNewVersion);
|
||||
});
|
||||
}
|
||||
|
||||
openCloneDialog() {
|
||||
openCloneDialog(isNewVersion: boolean) {
|
||||
const dialogRef = this.dialog.open(CloneDialogComponent, {
|
||||
maxWidth: '700px',
|
||||
maxHeight: '80vh',
|
||||
data: {
|
||||
formGroup: this.dmpFormGroup,
|
||||
datasets: this.dmpFormGroup.get('datasets').value,
|
||||
confirmButton: this.language.instant('DMP-EDITOR.CLONE-DIALOG.CLONE'),
|
||||
isNewVersion: isNewVersion,
|
||||
confirmButton: this.language.instant('DMP-EDITOR.CLONE-DIALOG.SAVE'),
|
||||
cancelButton: this.language.instant('DMP-EDITOR.CLONE-DIALOG.CANCEL'),
|
||||
}
|
||||
});
|
||||
dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => {
|
||||
if (result) {
|
||||
this.dmpService.clone(this.dmpFormGroup.getRawValue(), this.dmpFormGroup.get('id').value)
|
||||
.pipe(takeUntil(this._destroyed))
|
||||
.subscribe(
|
||||
complete => this.onCloneCallbackSuccess(complete),
|
||||
error => this.onCloneCallbackError(error)
|
||||
);
|
||||
if (!isNewVersion) {
|
||||
this.dmpService.clone(this.dmpFormGroup.getRawValue(), this.dmp.id)
|
||||
.pipe(takeUntil(this._destroyed))
|
||||
.subscribe(
|
||||
complete => this.onCloneOrNewVersionCallbackSuccess(complete),
|
||||
error => this.onCloneOrNewVersionCallbackError(error)
|
||||
);
|
||||
} else if (isNewVersion) {
|
||||
this.dmpService.newVersion(this.dmpFormGroup.getRawValue(), this.dmp.id)
|
||||
.pipe(takeUntil(this._destroyed))
|
||||
.subscribe(
|
||||
complete => this.onCloneOrNewVersionCallbackSuccess(complete),
|
||||
error => this.onCloneOrNewVersionCallbackError(error)
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
newVersion(id: String, label: String) {
|
||||
let url = this.router.createUrlTree(['/plans/new_version/', id, { dmpLabel: label }]);
|
||||
window.open(url.toString(), '_blank');
|
||||
}
|
||||
// newVersion(id: String, label: String) {
|
||||
// let url = this.router.createUrlTree(['/plans/new_version/', id, { dmpLabel: label }]);
|
||||
// window.open(url.toString(), '_blank');
|
||||
// }
|
||||
|
||||
downloadXml(id: string) {
|
||||
this.dmpService.downloadXML(id)
|
||||
|
@ -329,13 +342,13 @@ export class DmpListingItemComponent extends BaseComponent implements OnInit {
|
|||
this.router.navigate(['/plans']);
|
||||
}
|
||||
|
||||
onCloneCallbackSuccess(cloneId: String): void {
|
||||
onCloneOrNewVersionCallbackSuccess(cloneId: String): void {
|
||||
this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE'), SnackBarNotificationLevel.Success);
|
||||
this.router.navigate(['/plans/edit/', cloneId]);
|
||||
}
|
||||
|
||||
onCloneCallbackError(error: any) {
|
||||
this.uiNotificationService.snackBarNotification(error.error.message ? error.error.message : this.language.instant('GENERAL.SNACK-BAR.UNSUCCESSFUL-CLONE'), SnackBarNotificationLevel.Error);
|
||||
onCloneOrNewVersionCallbackError(error: any) {
|
||||
this.uiNotificationService.snackBarNotification(error.error.message ? error.error.message : this.language.instant('GENERAL.SNACK-BAR.UNSUCCESSFUL-UPDATE'), SnackBarNotificationLevel.Error);
|
||||
}
|
||||
|
||||
isUserOwner(activity: DmpListingModel): boolean {
|
||||
|
|
|
@ -51,7 +51,7 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<button *ngIf="isAuthenticated()" (click)="cloneClicked(dmp)" mat-mini-fab class="mr-3 d-flex justify-content-center align-items-center" matTooltip="{{'DMP-LISTING.ACTIONS.CLONE' | translate}}" matTooltipPosition="above">
|
||||
<button *ngIf="isAuthenticated()" (click)="cloneOrNewVersionClicked(dmp, false)" mat-mini-fab class="mr-3 d-flex justify-content-center align-items-center" matTooltip="{{'DMP-LISTING.ACTIONS.CLONE' | translate}}" matTooltipPosition="above">
|
||||
<mat-icon class="mat-mini-fab-icon">content_copy</mat-icon>
|
||||
</button>
|
||||
<button *ngIf="isDraftDmp(dmp) && isUserOwner && !lockStatus" (click)="editClicked(dmp)" mat-mini-fab class="mr-3 d-flex justify-content-center align-items-center" matTooltip="{{'DMP-LISTING.ACTIONS.EDIT' | translate}}" matTooltipPosition="above">
|
||||
|
@ -147,7 +147,7 @@
|
|||
<p class="mb-0 mr-0 pl-2 frame-txt" [matMenuTriggerFor]="exportMenu">
|
||||
{{ 'DMP-LISTING.ACTIONS.EXPORT' | translate }}</p>
|
||||
</div>
|
||||
<div *ngIf="isUserOwner" class="row ml-0 mr-0 pl-4 pb-3 d-flex align-items-center" (click)="newVersion(dmp.id, dmp.label)">
|
||||
<div *ngIf="isUserOwner" class="row ml-0 mr-0 pl-4 pb-3 d-flex align-items-center" (click)="cloneOrNewVersionClicked(dmp, true)">
|
||||
<button mat-mini-fab class="frame-btn">
|
||||
<mat-icon class="mat-mini-fab-icon">add_to_photos</mat-icon>
|
||||
</button>
|
||||
|
|
|
@ -174,7 +174,7 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit {
|
|||
window.open(url.toString(), '_blank');
|
||||
}
|
||||
|
||||
cloneClicked(dmp: DmpOverviewModel) {
|
||||
cloneOrNewVersionClicked(dmp: DmpOverviewModel, isNewVersion: boolean) {
|
||||
this.dmpService.getSingle(this.dmp.id).pipe(map(data => data as DmpModel))
|
||||
.pipe(takeUntil(this._destroyed))
|
||||
.subscribe(data => {
|
||||
|
@ -186,41 +186,53 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit {
|
|||
this.dmpModel.fromModel(data);
|
||||
this.dmpModel.status = DmpStatus.Draft;
|
||||
this.formGroup = this.dmpModel.buildForm();
|
||||
this.formGroup.get('label').setValue(this.dmp.label + " New");
|
||||
|
||||
this.openCloneDialog();
|
||||
if (!isNewVersion) {
|
||||
this.formGroup.get('label').setValue(this.dmp.label + " New");
|
||||
}
|
||||
this.openCloneDialog(isNewVersion);
|
||||
});
|
||||
}
|
||||
|
||||
openCloneDialog() {
|
||||
openCloneDialog(isNewVersion: boolean) {
|
||||
const dialogRef = this.dialog.open(CloneDialogComponent, {
|
||||
maxWidth: '700px',
|
||||
maxWidth: '900px',
|
||||
maxHeight: '80vh',
|
||||
data: {
|
||||
formGroup: this.formGroup,
|
||||
datasets: this.dmp.datasets,
|
||||
confirmButton: this.language.instant('DMP-EDITOR.CLONE-DIALOG.CLONE'),
|
||||
isNewVersion: isNewVersion,
|
||||
confirmButton: this.language.instant('DMP-EDITOR.CLONE-DIALOG.SAVE'),
|
||||
cancelButton: this.language.instant('DMP-EDITOR.CLONE-DIALOG.CANCEL'),
|
||||
}
|
||||
});
|
||||
dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => {
|
||||
if (result) {
|
||||
this.dmpService.clone(this.formGroup.getRawValue(), this.dmp.id)
|
||||
.pipe(takeUntil(this._destroyed))
|
||||
.subscribe(
|
||||
complete => this.onCallbackSuccess(complete),
|
||||
error => this.onCallbackError(error)
|
||||
);
|
||||
if (!isNewVersion) {
|
||||
this.dmpService.clone(this.formGroup.getRawValue(), this.dmp.id)
|
||||
.pipe(takeUntil(this._destroyed))
|
||||
.subscribe(
|
||||
complete => this.onCallbackSuccess(complete),
|
||||
error => this.onCallbackError(error)
|
||||
);
|
||||
} else if (isNewVersion) {
|
||||
this.dmpService.newVersion(this.formGroup.getRawValue(), this.dmp.id)
|
||||
.pipe(takeUntil(this._destroyed))
|
||||
.subscribe(
|
||||
complete => this.onCallbackSuccess(complete),
|
||||
error => this.onCallbackError(error)
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
onCallbackSuccess(cloneId: String): void {
|
||||
onCallbackSuccess(dmpId: String): void {
|
||||
this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE'), SnackBarNotificationLevel.Success);
|
||||
this.router.navigate(['/plans/edit/', cloneId]);
|
||||
this.router.navigate(['/plans/edit/', dmpId]);
|
||||
}
|
||||
|
||||
onCallbackError(error: any) {
|
||||
this.uiNotificationService.snackBarNotification(error.error.message ? error.error.message : this.language.instant('GENERAL.SNACK-BAR.UNSUCCESSFUL-CLONE'), SnackBarNotificationLevel.Error);
|
||||
this.uiNotificationService.snackBarNotification(error.error.message ? error.error.message : this.language.instant('GENERAL.SNACK-BAR.UNSUCCESSFUL-UPDATE'), SnackBarNotificationLevel.Error);
|
||||
}
|
||||
|
||||
grantClicked(grantId: String) {
|
||||
|
@ -588,10 +600,10 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit {
|
|||
});
|
||||
}
|
||||
|
||||
newVersion(id: String, label: String) {
|
||||
let url = this.router.createUrlTree(['/plans/new_version/', id, { dmpLabel: label }])
|
||||
window.open(url.toString(), '_blank')
|
||||
}
|
||||
// newVersion(id: String, label: String) {
|
||||
// let url = this.router.createUrlTree(['/plans/new_version/', id, { dmpLabel: label }])
|
||||
// window.open(url.toString(), '_blank')
|
||||
// }
|
||||
|
||||
viewVersions(rowId: String, rowLabel: String) {
|
||||
if (this.dmp.isPublic && !this.isUserOwner) {
|
||||
|
|
|
@ -763,6 +763,7 @@
|
|||
"ADD-DATASET": "Adding dataset to ",
|
||||
"EDIT-DATASET": "Editing Dataset",
|
||||
"CLONE-DMP": "Clone",
|
||||
"NEW-VERSION": "New Version",
|
||||
"CREATE-DATASET": "Creating Dataset Description",
|
||||
"SUBTITLE": "DOI"
|
||||
},
|
||||
|
@ -855,6 +856,7 @@
|
|||
"CHANGES": "unsaved changes",
|
||||
"CLONE-DIALOG": {
|
||||
"CLONE": "Clone",
|
||||
"SAVE": "Save",
|
||||
"CANCEL": "Cancel"
|
||||
}
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue