fix Dmp Version Clone

remove Dmp Edite And Lock on Final Dmps
This commit is contained in:
Diamantis Tziotzios 2019-02-14 14:14:44 +02:00
parent bbfd5e9812
commit d2b15a2885
4 changed files with 61 additions and 38 deletions

View File

@ -12,12 +12,12 @@
<div class="col"></div>
<div *ngIf="!isNew" class="col-auto">
<div class="row actions-row">
<div class="col-auto" *ngIf="!editMode">
<div class="col-auto" *ngIf="!editMode && formGroup.get('status').value !== 1">
<button mat-icon-button (click)="enableForm()">
<mat-icon class="mat-24">edit</mat-icon>
</button>
</div>
<div class="col-auto" *ngIf="editMode">
<div class="col-auto" *ngIf="editMode && formGroup.get('status').value !== 1">
<button mat-icon-button (click)="disableForm()">
<mat-icon class="mat-24">lock</mat-icon>
</button>

View File

@ -39,6 +39,7 @@ import { AddResearcherComponent } from './add-researcher/add-researcher.componen
import { AvailableProfilesComponent } from './available-profiles/available-profiles.component';
import { DmpEditorModel } from './dmp-editor.model';
import { DmpFinalizeDialogComponent } from './dmp-finalize-dialog/dmp-finalize-dialog.component';
import { DmpProfileStatus } from '../../../core/common/enum/dmp-profile-status';
@Component({
selector: 'app-dmp-editor-component',
@ -65,7 +66,7 @@ export class DmpEditorComponent extends BaseComponent implements OnInit, IBreadC
profilesAutoCompleteConfiguration: MultipleAutoCompleteConfiguration;
organisationsAutoCompleteConfiguration: MultipleAutoCompleteConfiguration;
researchersAutoCompleteConfiguration: MultipleAutoCompleteConfiguration;
dmpProfileAutoCompleteConfiguration:SingleAutoCompleteConfiguration;
dmpProfileAutoCompleteConfiguration: SingleAutoCompleteConfiguration;
createNewVersion;
associatedUsers: Array<UserModel>;
@ -110,7 +111,7 @@ export class DmpEditorComponent extends BaseComponent implements OnInit, IBreadC
titleFn: (item) => item['label']
};
this.dmpProfileAutoCompleteConfiguration= {
this.dmpProfileAutoCompleteConfiguration = {
filterFn: this.dmpProfileSearch.bind(this),
initialItems: (extraData) => this.dmpProfileSearch(''),
displayFn: (item) => item['label'],
@ -185,9 +186,6 @@ export class DmpEditorComponent extends BaseComponent implements OnInit, IBreadC
.subscribe(params => {
this.createNewVersion = params['clone'];
});
}
registerFormEventsForDmpProfile(): void {
@ -217,7 +215,7 @@ export class DmpEditorComponent extends BaseComponent implements OnInit, IBreadC
]);
}
dmpProfileSearch(query: string){
dmpProfileSearch(query: string) {
let fields: Array<string> = new Array();
var request = new DataTableRequest<DmpProfileCriteria>(0, 10, { fields: fields });
request.criteria = new DmpProfileCriteria();
@ -435,15 +433,16 @@ export class DmpEditorComponent extends BaseComponent implements OnInit, IBreadC
if (this.formGroup.get('status').value !== DmpStatus.Finalized) {
this.editMode = true;
this.formGroup.enable();
} else {
this.dmpService.unlock(this.formGroup.get('id').value)
.pipe(takeUntil(this._destroyed))
.subscribe(x => {
this.editMode = true;
this.formGroup.get('status').patchValue(DmpStatus.Draft);
this.formGroup.enable();
});
}
//else {
// this.dmpService.unlock(this.formGroup.get('id').value)
// .pipe(takeUntil(this._destroyed))
// .subscribe(x => {
// this.editMode = true;
// this.formGroup.get('status').patchValue(DmpStatus.Draft);
// this.formGroup.enable();
// });
// }
}
public disableForm() {

View File

@ -46,15 +46,16 @@ export class DmpWizardComponent extends BaseComponent implements OnInit, IBreadC
.pipe(takeUntil(this._destroyed))
.subscribe(data => {
this.dmp = new DmpWizardEditorModel().fromModel(data);
this.isClone = this.route.snapshot.data.clone;
this.formGroup = this.dmp.buildForm();
if (this.route.routeConfig.path.startsWith('new_version/')) {
this.formGroup.get('version').setValue(this.dmp.version + 1);
this.formGroup.get('version').setValue(this.formGroup.get('version').value + 1);
this.formGroup.controls['label'].disable();
this.formGroup.controls['project'].disable();
this.isClone = false;
} else if (this.route.routeConfig.path.startsWith('clone/')) {
this.formGroup.get('label').setValue(this.dmp.label + "New");
this.formGroup.get('label').setValue(this.dmp.label + " New");
this.isClone = true;
}
});
});

View File

@ -4,42 +4,65 @@
<mat-card-content>
<div class="row">
<mat-form-field class="col-md-6">
<input matInput placeholder="{{'DMP-EDITOR.FIELDS.NAME' | translate}}" type="text" name="label" formControlName="label" required>
<mat-error *ngIf="formGroup.get('label').hasError('backendError')">{{formGroup.get('label').getError('backendError').message}}</mat-error>
<mat-error *ngIf="formGroup.get('label').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
<input matInput placeholder="{{'DMP-EDITOR.FIELDS.NAME' | translate}}" type="text" name="label"
formControlName="label" required>
<mat-error *ngIf="formGroup.get('label').hasError('backendError')">
{{formGroup.get('label').getError('backendError').message}}</mat-error>
<mat-error *ngIf="formGroup.get('label').hasError('required')">
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
<mat-form-field class="col-md-6">
<app-single-auto-complete [formControl]="formGroup.get('project')" placeholder="{{this.languageResolverService.getBy('dmpEditor') | translate}}" [configuration]="projectAutoCompleteConfiguration">
<app-single-auto-complete [formControl]="formGroup.get('project')"
placeholder="{{this.languageResolverService.getBy('dmpEditor') | translate}}"
[configuration]="projectAutoCompleteConfiguration">
</app-single-auto-complete>
<mat-error *ngIf="formGroup.get('project').hasError('backendError')">{{formGroup.get('project').getError('backendError').message}}</mat-error>
<mat-error *ngIf="formGroup.get('project').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
<mat-error *ngIf="formGroup.get('project').hasError('backendError')">
{{formGroup.get('project').getError('backendError').message}}</mat-error>
<mat-error *ngIf="formGroup.get('project').hasError('required')">
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
<mat-form-field class="col-md-12">
<textarea matInput class="description-area" placeholder="{{'DMP-EDITOR.FIELDS.DESCRIPTION' | translate}}" formControlName="description" required></textarea>
<mat-error *ngIf="formGroup.get('description').hasError('backendError')">{{formGroup.get('description').getError('backendError').message}}</mat-error>
<mat-error *ngIf="formGroup.get('description').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
<textarea matInput class="description-area"
placeholder="{{'DMP-EDITOR.FIELDS.DESCRIPTION' | translate}}" formControlName="description"
required></textarea>
<mat-error *ngIf="formGroup.get('description').hasError('backendError')">
{{formGroup.get('description').getError('backendError').message}}</mat-error>
<mat-error *ngIf="formGroup.get('description').hasError('required')">
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
<mat-form-field class="col-md-6">
<app-multiple-auto-complete class="col-md-10" [formControl]="formGroup.get('profiles')" placeholder="{{'DMP-EDITOR.FIELDS.PROFILES' | translate}}" [configuration]="profilesAutoCompleteConfiguration">
<app-multiple-auto-complete class="col-md-10" [formControl]="formGroup.get('profiles')"
placeholder="{{'DMP-EDITOR.FIELDS.PROFILES' | translate}}"
[configuration]="profilesAutoCompleteConfiguration">
</app-multiple-auto-complete>
<mat-error *ngIf="formGroup.get('profiles').hasError('backendError')">{{formGroup.get('profiles').getError('backendError').message}}</mat-error>
<mat-error *ngIf="formGroup.get('profiles').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
<mat-error *ngIf="formGroup.get('profiles').hasError('backendError')">
{{formGroup.get('profiles').getError('backendError').message}}</mat-error>
<mat-error *ngIf="formGroup.get('profiles').hasError('required')">
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
<button mat-icon-button matSuffix type="button" (click)="availableProfiles()">
<mat-icon>view_list</mat-icon>
</button>
</mat-form-field>
<mat-form-field class="col-md-6">
<app-multiple-auto-complete [formControl]="formGroup.get('organisations')" placeholder="{{'DMP-EDITOR.FIELDS.ORGANISATIONS' | translate}}" [configuration]="organisationsAutoCompleteConfiguration">
<app-multiple-auto-complete [formControl]="formGroup.get('organisations')"
placeholder="{{'DMP-EDITOR.FIELDS.ORGANISATIONS' | translate}}"
[configuration]="organisationsAutoCompleteConfiguration">
</app-multiple-auto-complete>
<mat-error *ngIf="formGroup.get('organisations').hasError('backendError')">{{formGroup.get('organisations').getError('backendError').message}}</mat-error>
<mat-error *ngIf="formGroup.get('organisations').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
<mat-error *ngIf="formGroup.get('organisations').hasError('backendError')">
{{formGroup.get('organisations').getError('backendError').message}}</mat-error>
<mat-error *ngIf="formGroup.get('organisations').hasError('required')">
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
<mat-form-field class="col-md-6">
<app-multiple-auto-complete [formControl]="formGroup.get('researchers')" placeholder="{{'DMP-EDITOR.FIELDS.RESEARCHERS' | translate}}" [configuration]="researchersAutoCompleteConfiguration">
<app-multiple-auto-complete [formControl]="formGroup.get('researchers')"
placeholder="{{'DMP-EDITOR.FIELDS.RESEARCHERS' | translate}}"
[configuration]="researchersAutoCompleteConfiguration">
</app-multiple-auto-complete>
<mat-error *ngIf="formGroup.get('researchers').hasError('backendError')">{{formGroup.get('researchers').getError('backendError').message}}</mat-error>
<mat-error *ngIf="formGroup.get('researchers').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
<mat-error *ngIf="formGroup.get('researchers').hasError('backendError')">
{{formGroup.get('researchers').getError('backendError').message}}</mat-error>
<mat-error *ngIf="formGroup.get('researchers').hasError('required')">
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
<button mat-icon-button matSuffix type="button" (click)="addResearcher()">
<mat-icon>add_circle</mat-icon>
</button>