Initialise contact field on dmp editor
This commit is contained in:
parent
d249eb841a
commit
a05d24b95b
|
@ -114,11 +114,6 @@ export class DmpEditorComponent extends BaseComponent implements OnInit, IBreadC
|
|||
}
|
||||
|
||||
ngOnInit() {
|
||||
// if (this.router.url.toString().includes('/new/dataset')) {
|
||||
// this.isNewDataset = true;
|
||||
// this.stepsBeforeDatasets = 2;
|
||||
// this.maxStep = 2;
|
||||
// };
|
||||
this.route.params
|
||||
.pipe(takeUntil(this._destroyed))
|
||||
.subscribe((params: Params) => {
|
||||
|
@ -284,52 +279,7 @@ export class DmpEditorComponent extends BaseComponent implements OnInit, IBreadC
|
|||
this.formChanged();
|
||||
});
|
||||
});
|
||||
}
|
||||
// else if (this.isNewDataset) {
|
||||
// this.dmp = new DmpEditorModel();
|
||||
// this.dmp.grant = new GrantTabModel();
|
||||
// this.dmp.project = new ProjectFormModel();
|
||||
// this.dmp.funder = new FunderFormModel();
|
||||
// this.dmp.extraProperties = new ExtraPropertiesFormModel();
|
||||
// this.dmp.extraProperties.visible = false;
|
||||
// this.dmp.extraProperties.contact = this.authService.current().id;
|
||||
// this.datasetWizardEditorModel = new DatasetWizardEditorModel();
|
||||
|
||||
// if (dmpId) {
|
||||
// this.hasDmpId = true;
|
||||
// this.dmpService.getSingle(dmpId).pipe(map(data => data as DmpModel))
|
||||
// .pipe(takeUntil(this._destroyed))
|
||||
// .subscribe(data => {
|
||||
// setTimeout(() => {
|
||||
// this.dmpModel = data;
|
||||
// this.datasetWizardEditorModel.dmp = data;
|
||||
// this.dmp.datasets.push(this.datasetWizardEditorModel);
|
||||
// this.formGroup = this.dmp.buildForm();
|
||||
// this.formGroup.get('datasets')['controls'][0].get('dmp').disable();
|
||||
// this.datasets = this.formGroup.get('datasets') as FormArray;
|
||||
// this.formGroupRawValue = JSON.parse(JSON.stringify(this.formGroup.getRawValue()));
|
||||
// this.maxStep = this.formGroup.get('datasets') ? this.maxStep + this.formGroup.get('datasets').value.length - 1 : this.maxStep;
|
||||
// // this.loadDatasetProfiles();
|
||||
// // this.registerFormListeners();
|
||||
// });
|
||||
// });
|
||||
|
||||
// } else {
|
||||
// this.dmp.datasets.push(this.datasetWizardEditorModel);
|
||||
// this.formGroup = this.dmp.buildForm();
|
||||
// this.datasets = this.formGroup.get('datasets') as FormArray;
|
||||
// this.formGroupRawValue = JSON.parse(JSON.stringify(this.formGroup.getRawValue()));
|
||||
// this.maxStep = this.formGroup.get('datasets') ? this.maxStep + this.formGroup.get('datasets').value.length - 1 : this.maxStep;
|
||||
// this.formGroup.valueChanges.pipe(takeUntil(this._destroyed))
|
||||
// .subscribe(x => {
|
||||
// console.log(x);
|
||||
// this.formChanged();
|
||||
// });
|
||||
// }
|
||||
|
||||
// this.registerFormEventsForNewItem();
|
||||
// }
|
||||
else {
|
||||
} else {
|
||||
this.dmp = new DmpEditorModel();
|
||||
this.dmp.grant = new GrantTabModel();
|
||||
this.dmp.project = new ProjectFormModel();
|
||||
|
|
|
@ -20,6 +20,9 @@ import { DmpStatus } from '@app/core/common/enum/dmp-status';
|
|||
import { DmpService } from '@app/core/services/dmp/dmp.service';
|
||||
import { LanguageInfo } from '@app/core/model/language-info';
|
||||
import { LanguageInfoService } from '@app/core/services/culture/language-info-service';
|
||||
import { UserModel } from '@app/core/model/user/user';
|
||||
import { AuthService } from '@app/core/services/auth/auth.service';
|
||||
import { Principal } from '@app/core/model/auth/principal';
|
||||
|
||||
interface Visible {
|
||||
value: boolean;
|
||||
|
@ -38,14 +41,16 @@ export class MainInfoComponent extends BaseComponent implements OnInit {
|
|||
@Input() isNewVersion: boolean;
|
||||
@Input() isUserOwner: boolean;
|
||||
@Input() isClone: boolean;
|
||||
@Output() onFormChanged: EventEmitter<any> = new EventEmitter();
|
||||
|
||||
@Output() onFormChanged: EventEmitter<any> = new EventEmitter();
|
||||
public formControl = new FormControl();
|
||||
visibles: Visible[] = [
|
||||
{ value: true, name: 'DMP-EDITOR.VISIBILITY.PUBLIC' },
|
||||
{ value: false, name: 'DMP-EDITOR.VISIBILITY.RESTRICTED' }
|
||||
]
|
||||
|
||||
private associates: UserModel[] = [];
|
||||
|
||||
organisationsAutoCompleteConfiguration: MultipleAutoCompleteConfiguration = {
|
||||
filterFn: this.filterOrganisations.bind(this),
|
||||
initialItems: (excludedItems: any[]) => this.filterOrganisations('').pipe(map(result => result.filter(resultItem => (excludedItems || []).map(x => x.id).indexOf(resultItem.id) === -1))),
|
||||
|
@ -75,7 +80,8 @@ export class MainInfoComponent extends BaseComponent implements OnInit {
|
|||
private externalSourcesService: ExternalSourcesService,
|
||||
private dmpService: DmpService,
|
||||
private dialog: MatDialog,
|
||||
private languageInfoService: LanguageInfoService
|
||||
private languageInfoService: LanguageInfoService,
|
||||
private authentication: AuthService
|
||||
) {
|
||||
super();
|
||||
}
|
||||
|
@ -95,6 +101,18 @@ export class MainInfoComponent extends BaseComponent implements OnInit {
|
|||
this.formGroup.get('extraProperties').get('publicDate').patchValue(new Date());
|
||||
}
|
||||
|
||||
const principal = this.authentication.current();
|
||||
let associate: UserModel = {
|
||||
id: principal.id,
|
||||
name: principal.name,
|
||||
appRoles: principal.authorities,
|
||||
email: principal.email
|
||||
};
|
||||
this.associates.push(associate);
|
||||
if (isNullOrUndefined(this.formGroup.get('extraProperties').get('contact').value)) {
|
||||
this.formGroup.get('extraProperties').get('contact').patchValue(associate.id);
|
||||
}
|
||||
|
||||
// this.formGroup.valueChanges.pipe(takeUntil(this._destroyed))
|
||||
// .subscribe(x => {
|
||||
// this.onFormChanged.emit();
|
||||
|
@ -189,8 +207,13 @@ export class MainInfoComponent extends BaseComponent implements OnInit {
|
|||
return this.languageInfoService.getLanguageInfoValues();
|
||||
}
|
||||
|
||||
getAssociates(): any[] {
|
||||
let associates: any[] = [];
|
||||
getAssociates(): UserModel[] {
|
||||
let associates: UserModel[];
|
||||
if (this.formGroup.get('associatedUsers').value && this.formGroup.get('associatedUsers').value.length > 0) {
|
||||
associates = [];
|
||||
} else {
|
||||
associates = this.associates;
|
||||
}
|
||||
//associates = (this.formGroup.get('researchers').value as any[]);
|
||||
associates = associates.concat(this.formGroup.get('associatedUsers').value);
|
||||
return associates;
|
||||
|
|
Loading…
Reference in New Issue