Fixes clone functionality not working on published DMPs.
This commit is contained in:
parent
6eaff65ea8
commit
fa22017d48
|
@ -95,7 +95,7 @@ public class DMPs extends BaseController {
|
|||
if (contentType.equals("application/xml") || contentType.equals("application/msword")) {
|
||||
return this.dataManagementPlanManager.getDocument(id, contentType, principal, this.configLoader);
|
||||
} else {
|
||||
eu.eudat.models.data.dmp.DataManagementPlan dataManagementPlan = this.dataManagementPlanManager.getSingle(id, principal, this.dynamicGrantConfiguration);
|
||||
eu.eudat.models.data.dmp.DataManagementPlan dataManagementPlan = this.dataManagementPlanManager.getSingle(id, principal);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataManagementPlan>().status(ApiMessageCode.NO_MESSAGE).payload(dataManagementPlan));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -339,30 +339,24 @@ public class DataManagementPlanManager {
|
|||
return this.datasetManager.convertToPDF(file, environment, fileName);
|
||||
}*/
|
||||
|
||||
public eu.eudat.models.data.dmp.DataManagementPlan getSingle(String id, Principal principal, DynamicGrantConfiguration dynamicGrantConfiguration) throws InstantiationException, IllegalAccessException {
|
||||
public eu.eudat.models.data.dmp.DataManagementPlan getSingle(String id, Principal principal) {
|
||||
DMP dataManagementPlanEntity = databaseRepository.getDmpDao().find(UUID.fromString(id));
|
||||
if (dataManagementPlanEntity.getUsers().stream().filter(userInfo -> userInfo.getUser().getId() == principal.getId()).collect(Collectors.toList()).size() == 0)
|
||||
throw new UnauthorisedException();
|
||||
eu.eudat.models.data.dmp.DataManagementPlan datamanagementPlan = new eu.eudat.models.data.dmp.DataManagementPlan();
|
||||
datamanagementPlan.fromDataModel(dataManagementPlanEntity);
|
||||
if (dataManagementPlanEntity.getUsers().stream().noneMatch(userInfo -> userInfo.getUser().getId() == principal.getId())) {
|
||||
if (!dataManagementPlanEntity.isPublic()) {
|
||||
throw new UnauthorisedException();
|
||||
}
|
||||
}
|
||||
eu.eudat.models.data.dmp.DataManagementPlan dataManagementPlan = new eu.eudat.models.data.dmp.DataManagementPlan();
|
||||
dataManagementPlan.fromDataModel(dataManagementPlanEntity);
|
||||
Map dmpProperties = dataManagementPlanEntity.getDmpProperties() != null ? new org.json.JSONObject(dataManagementPlanEntity.getDmpProperties()).toMap() : null;
|
||||
// datamanagementPlan.setDynamicFields(dynamicGrantConfiguration.getFields().stream().map(item -> {
|
||||
// DynamicFieldWithValue fieldWithValue = new DynamicFieldWithValue();
|
||||
// fieldWithValue.setId(item.getId());
|
||||
// fieldWithValue.setDependencies(item.getDependencies());
|
||||
// fieldWithValue.setName(item.getName());
|
||||
// fieldWithValue.setQueryProperty(item.getQueryProperty());
|
||||
// fieldWithValue.setRequired(item.getRequired());
|
||||
// return fieldWithValue;
|
||||
// }).collect(Collectors.toList()));
|
||||
|
||||
if (dmpProperties != null && datamanagementPlan.getDynamicFields() != null)
|
||||
datamanagementPlan.getDynamicFields().forEach(item -> {
|
||||
if (dmpProperties != null && dataManagementPlan.getDynamicFields() != null)
|
||||
dataManagementPlan.getDynamicFields().forEach(item -> {
|
||||
Map<String, String> properties = (Map<String, String>) dmpProperties.get(item.getId());
|
||||
if (properties != null)
|
||||
item.setValue(new Tuple<>(properties.get("id"), properties.get("label")));
|
||||
});
|
||||
return datamanagementPlan;
|
||||
return dataManagementPlan;
|
||||
}
|
||||
|
||||
public DataManagementPlanOverviewModel getOverviewSingle(String id, Principal principal) throws InstantiationException, IllegalAccessException {
|
||||
|
|
|
@ -19,14 +19,14 @@
|
|||
<i class="material-icons-outlined mr-2">view_agenda</i>
|
||||
{{ 'SIDE-BAR.GENERAL' | translate }}
|
||||
</ng-template>
|
||||
<app-general-tab [formGroup]="formGroup" [isNewVersion]="isNewVersion"></app-general-tab>
|
||||
<app-general-tab [formGroup]="formGroup" [isNewVersion]="isNewVersion" [isClone]="isClone"></app-general-tab>
|
||||
</mat-tab>
|
||||
<mat-tab>
|
||||
<ng-template mat-tab-label>
|
||||
<mat-icon class="mr-2">work_outline</mat-icon>
|
||||
{{ 'DMP-LISTING.COLUMNS.GRANT' | translate }}
|
||||
</ng-template>
|
||||
<app-grant-tab [grantformGroup]="formGroup.get('grant')" [projectFormGroup]="formGroup.get('project')" [funderFormGroup]="formGroup.get('funder')" [isFinalized]="isFinalized" [isNewVersion]="isNewVersion"></app-grant-tab>
|
||||
<app-grant-tab [grantformGroup]="formGroup.get('grant')" [projectFormGroup]="formGroup.get('project')" [funderFormGroup]="formGroup.get('funder')" [isFinalized]="isFinalized" [isNewVersion]="isNewVersion" [isClone]="isClone" [isNew]="isNew"></app-grant-tab>
|
||||
</mat-tab>
|
||||
<mat-tab>
|
||||
<ng-template mat-tab-label>
|
||||
|
|
|
@ -35,6 +35,8 @@ export class DmpCloneComponent extends BaseComponent implements OnInit {
|
|||
selectedTab = 0;
|
||||
parentDmpLabel: string;
|
||||
isNewVersion: boolean = false;
|
||||
isClone: boolean = true;
|
||||
isNew: boolean = false;
|
||||
|
||||
constructor(
|
||||
private route: ActivatedRoute,
|
||||
|
|
|
@ -31,6 +31,7 @@ export class GeneralTabComponent extends BaseComponent implements OnInit {
|
|||
@Input() formGroup: FormGroup = null;
|
||||
@Input() isNewVersion: boolean;
|
||||
@Input() isUserOwner: boolean;
|
||||
@Input() isClone: boolean;
|
||||
|
||||
profilesAutoCompleteConfiguration: MultipleAutoCompleteConfiguration = {
|
||||
filterFn: this.filterProfiles.bind(this),
|
||||
|
@ -82,7 +83,7 @@ export class GeneralTabComponent extends BaseComponent implements OnInit {
|
|||
this.formGroup.get('label').disable();
|
||||
}
|
||||
|
||||
if (!this.isUserOwner) {
|
||||
if (!this.isUserOwner && !this.isClone) {
|
||||
this.formGroup.disable();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
<!-- Toggle Between Add Funder or Use Existing -->
|
||||
<div class="col d-flex">
|
||||
<div class="row" *ngIf="!isFinalized && isUserOwner">
|
||||
<div class="row" *ngIf="showToggleButton()">
|
||||
<div class="col-12 add-entity" *ngIf="isCreateNewFunder" (click)="createFunder()">
|
||||
<mat-icon>settings_backup_restore</mat-icon>
|
||||
<span>{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.ACTIONS.EXIST-FUNDER' | translate}}</span>
|
||||
|
@ -63,7 +63,7 @@
|
|||
|
||||
<!-- Toggle Between Add Grant or Use Existing -->
|
||||
<div class="col d-flex">
|
||||
<div class="row" *ngIf="!isFinalized && isUserOwner">
|
||||
<div class="row" *ngIf="showToggleButton()">
|
||||
<div class="col-12 add-entity" *ngIf="isCreateNew" (click)="createGrant()">
|
||||
<mat-icon>settings_backup_restore</mat-icon>
|
||||
<span>{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.ACTIONS.EXIST-GRANT' | translate}}</span>
|
||||
|
@ -104,7 +104,7 @@
|
|||
|
||||
<!-- Toggle Between Add Project or Use Existing -->
|
||||
<div class="col d-flex">
|
||||
<div class="row" *ngIf="!isFinalized && isUserOwner">
|
||||
<div class="row" *ngIf="showToggleButton()">
|
||||
<div class="col-12 add-entity" *ngIf="isCreateNewProject" (click)="createProject()">
|
||||
<mat-icon>settings_backup_restore</mat-icon>
|
||||
<span>{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.ACTIONS.EXIST-PROJECT' | translate}}</span>
|
||||
|
|
|
@ -27,6 +27,7 @@ export class GrantTabComponent extends BaseComponent implements OnInit {
|
|||
@Input() isNewVersion: boolean;
|
||||
@Input() isNew: boolean;
|
||||
@Input() isUserOwner: boolean;
|
||||
@Input() isClone: boolean;
|
||||
|
||||
isCreateNew = false;
|
||||
isCreateNewProject = false;
|
||||
|
@ -64,7 +65,7 @@ export class GrantTabComponent extends BaseComponent implements OnInit {
|
|||
initialItems: () => this.searchFunder(''),
|
||||
displayFn: (item) => item['label'],
|
||||
titleFn: (item) => item['label'],
|
||||
subtitleFn: (item) => item['source'] ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item['source'] : this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.NO-SOURCE')
|
||||
subtitleFn: (item) => item['source'] ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item['source'] : (item['key'] ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item['key'] : this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.NO-SOURCE'))
|
||||
}
|
||||
|
||||
this.grantAutoCompleteConfiguration = {
|
||||
|
@ -72,7 +73,7 @@ export class GrantTabComponent extends BaseComponent implements OnInit {
|
|||
initialItems: () => this.searchGrant(''),
|
||||
displayFn: (item) => item['label'] + this.getGrantIdText(item),
|
||||
titleFn: (item) => item['label'] + this.getGrantIdText(item),
|
||||
subtitleFn: (item) => item['source'] ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item['source'] : this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.NO-SOURCE')
|
||||
subtitleFn: (item) => item['source'] ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item['source'] : (item['key'] ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item['key'] : this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.NO-SOURCE'))
|
||||
};
|
||||
|
||||
this.projectAutoCompleteConfiguration = {
|
||||
|
@ -80,7 +81,7 @@ export class GrantTabComponent extends BaseComponent implements OnInit {
|
|||
initialItems: () => this.searchProject(''),
|
||||
displayFn: (item) => item['label'],
|
||||
titleFn: (item) => item['label'],
|
||||
subtitleFn: (item) => item['source'] ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item['source'] : this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.NO-SOURCE')
|
||||
subtitleFn: (item) => item['source'] ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item['source'] : (item['key'] ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item['key'] : this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.NO-SOURCE'))
|
||||
}
|
||||
|
||||
this.isCreateNew = (this.grantformGroup.get('label').value != null && this.grantformGroup.get('label').value.length > 0);
|
||||
|
@ -90,7 +91,7 @@ export class GrantTabComponent extends BaseComponent implements OnInit {
|
|||
this.setProjectValidators();
|
||||
this.setFunderValidators();
|
||||
this.registerFormListeners();
|
||||
if (this.isNew) {
|
||||
if (this.isNew && !this.isClone) {
|
||||
this.grantformGroup.reset();
|
||||
this.grantformGroup.disable();
|
||||
}
|
||||
|
@ -144,6 +145,12 @@ export class GrantTabComponent extends BaseComponent implements OnInit {
|
|||
this.grantformGroup.get('existGrant').disable();
|
||||
this.grantformGroup.get('label').enable();
|
||||
this.grantformGroup.get('description').enable();
|
||||
} else if (this.isClone) {
|
||||
this.grantformGroup.get('existGrant').enable();
|
||||
this.grantformGroup.get('label').disable();
|
||||
this.grantformGroup.get('label').reset();
|
||||
this.grantformGroup.get('description').disable();
|
||||
this.grantformGroup.get('description').reset();
|
||||
} else if (this.isFinalized || this.isNewVersion || !this.isUserOwner) {
|
||||
this.grantformGroup.get('existGrant').disable();
|
||||
this.grantformGroup.get('label').disable();
|
||||
|
@ -162,6 +169,12 @@ export class GrantTabComponent extends BaseComponent implements OnInit {
|
|||
this.projectFormGroup.get('existProject').disable();
|
||||
this.projectFormGroup.get('label').enable();
|
||||
this.projectFormGroup.get('description').enable();
|
||||
} else if (this.isClone) {
|
||||
this.projectFormGroup.get('existProject').enable();
|
||||
this.projectFormGroup.get('label').disable()
|
||||
this.projectFormGroup.get('label').reset();
|
||||
this.projectFormGroup.get('description').disable();
|
||||
this.projectFormGroup.get('description').reset();
|
||||
} else if (this.isFinalized || this.isNewVersion || !this.isUserOwner) {
|
||||
this.projectFormGroup.get('existProject').disable();
|
||||
this.projectFormGroup.get('label').disable();
|
||||
|
@ -179,6 +192,14 @@ export class GrantTabComponent extends BaseComponent implements OnInit {
|
|||
if (this.isCreateNewFunder) {
|
||||
this.funderFormGroup.get('existFunder').disable();
|
||||
this.funderFormGroup.get('label').enable();
|
||||
} else if (this.isClone) {
|
||||
if (this.funderFormGroup.get('existFunder')) {
|
||||
this.funderFormGroup.get('existFunder').enable();
|
||||
this.funderFormGroup.get('label').disable();
|
||||
this.funderFormGroup.get('label').reset();
|
||||
} else {
|
||||
this.funderFormGroup.get('label').enable();
|
||||
}
|
||||
} else if (this.isFinalized || this.isNewVersion || !this.isUserOwner) {
|
||||
this.funderFormGroup.get('existFunder').disable();
|
||||
this.funderFormGroup.get('label').disable();
|
||||
|
@ -213,4 +234,8 @@ export class GrantTabComponent extends BaseComponent implements OnInit {
|
|||
isGrantDisabled() {
|
||||
return this.grantformGroup.disabled;
|
||||
}
|
||||
|
||||
showToggleButton() {
|
||||
return (!this.isFinalized && this.isUserOwner) || this.isClone;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue