Adds link on button "add dataset" on dmp cards

This commit is contained in:
apapachristou 2020-08-31 19:08:32 +03:00
parent 306dfa7346
commit b2977df4e5
15 changed files with 100 additions and 31 deletions

View File

@ -6,9 +6,9 @@
<h4 class="col-auto heading">1.4 {{'DATASET-EDITOR.FIELDS.TAGS' | translate}}</h4>
</div>
</div>
<!-- <app-external-item-listing *ngIf="formGroup.get('tags') && tagsTemplate && externalSourcesConfiguration" [options]="externalSourcesConfiguration.tags" placeholder="{{'DATASET-EDITOR.FIELDS.TAGS' | translate}}" [parentTemplate]='tagsTemplate' [formArray]="formGroup.get('tags')" [autoCompleteConfiguration]="tagsAutoCompleteConfiguration" (onItemChange)="tagsOnItemChange($event)">
</app-external-item-listing> -->
<div class="tags-form">
<app-external-item-listing *ngIf="formGroup.get('tags') && tagsTemplate && externalSourcesConfiguration" [options]="externalSourcesConfiguration.tags" placeholder="{{'DATASET-EDITOR.FIELDS.TAGS' | translate}}" [parentTemplate]='tagsTemplate' [formArray]="formGroup.get('tags')" [autoCompleteConfiguration]="tagsAutoCompleteConfiguration" (onItemChange)="tagsOnItemChange($event)">
</app-external-item-listing>
<!-- <div class="tags-form">
<mat-form-field appearance="outline">
<mat-chip-list #chipList [disabled]="viewOnly">
<mat-chip *ngFor="let tag of formGroup.get('tags').value" [removable]="true" (removed)="removeTag(tag)">
@ -18,7 +18,7 @@
<input matInput [disabled]="viewOnly" placeholder="{{'DATASET-EDITOR.FIELDS.TAGS' | translate}}" [matChipInputFor]="chipList" [matChipInputSeparatorKeyCodes]="separatorKeysCodes" [matChipInputAddOnBlur]="true" (matChipInputTokenEnd)="addTag($event)">
</mat-chip-list>
</mat-form-field>
</div>
</div> -->
<ng-template #tagsTemplate let-suggestion let-i="index" let-callback="function">
<div class="col-12 row align-items-center">

View File

@ -1,4 +1,4 @@
import { Component, Input, OnInit } from '@angular/core';
import { Component, Input, OnInit, Output, EventEmitter } from '@angular/core';
import { FormArray, FormGroup } from '@angular/forms';
import { MatDialog } from '@angular/material/dialog';
import { Router } from '@angular/router';
@ -39,6 +39,7 @@ export class DatasetExternalReferencesEditorComponent extends BaseComponent impl
@Input() formGroup: FormGroup = null;
@Input() viewOnly = false;
@Output() formChanged: EventEmitter<any> = new EventEmitter();
readonly separatorKeysCodes: number[] = [ENTER, COMMA];
@ -47,7 +48,7 @@ export class DatasetExternalReferencesEditorComponent extends BaseComponent impl
initialItems: (type) => this.searchDatasetExternalDatasets('', type),//.filter(resultItem => (excludedItems || []).map(x => x.id).indexOf(resultItem.id) === -1),
displayFn: (item) => item ? item.name : null,
titleFn: (item) => item ? item.name : null,
subtitleFn: (item) => item.source ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item.source : item.tag ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item.tag : this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.NO-SOURCE')
subtitleFn: (item) => item.source ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item.source : item.tag ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item.tag : this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.NO-SOURCE')
};
registriesAutoCompleteConfiguration: SingleAutoCompleteConfiguration = {
@ -63,7 +64,7 @@ export class DatasetExternalReferencesEditorComponent extends BaseComponent impl
initialItems: (type) => this.searchDatasetExternalDataRepositories('', type),
displayFn: (item) => item ? item.name : null,
titleFn: (item) => item ? item.name : null,
subtitleFn: (item) => item.source ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item.source : item.tag ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item.tag : this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.NO-SOURCE')
subtitleFn: (item) => item.source ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item.source : item.tag ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item.tag : this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.NO-SOURCE')
};
servicesAutoCompleteConfiguration: SingleAutoCompleteConfiguration = {
@ -109,11 +110,17 @@ export class DatasetExternalReferencesEditorComponent extends BaseComponent impl
this.externalSourcesConfiguration.registries.push({ key: '', label: 'All' });
this.externalSourcesConfiguration.services.push({ key: '', label: 'All' });
if (!isNullOrUndefined(this.externalSourcesConfiguration.tags)) {
this.externalSourcesConfiguration.tags.push({ key: '', label: 'All' });
this.externalSourcesConfiguration.tags.push({ key: '', label: 'All' });
} else {
this.externalSourcesConfiguration.tags = [{ key: '', label: 'All' }];
}
});
this.formGroup.valueChanges
.pipe(takeUntil(this._destroyed))
.subscribe(val => {
this.formChanged.emit(val);
});
}
public cancel(): void {

View File

@ -51,8 +51,8 @@
</div>
</div>
</div>
<app-dataset-external-references-editor-component [formGroup]="formGroup" [viewOnly]="viewOnly"></app-dataset-external-references-editor-component>
<app-dataset-description [form]="formGroup.get('datasetProfileDefinition')" [datasetProfileId]="formGroup.get('profile').value"></app-dataset-description>
<app-dataset-external-references-editor-component (formChanged)="onFormChanged($event)" [formGroup]="formGroup" [viewOnly]="viewOnly"></app-dataset-external-references-editor-component>
<app-dataset-description [form]="formGroup.get('datasetProfileDefinition')" [datasetProfileId]="formGroup.get('profile').value" (formChanged)="onFormChanged($event)"></app-dataset-description>
<!-- <app-dataset-description [form]="formGroup.get('datasetProfileDefinition')" [visibilityRules]="formGroup.get('datasetProfileDefinition').get('rules')" [datasetProfileId]="formGroup.get('profile').value">
</app-dataset-description> -->

View File

@ -223,6 +223,10 @@ export class DatasetEditorDetailsComponent extends BaseComponent implements OnIn
});
}
onFormChanged(event) {
this.formChanged.emit(event);
}
getDefinition(profileId: string) {
// if (this.formGroup.invalid) { setTimeout(() => this.stepper.selectedIndex = 0); return; }
this.datasetWizardService.getDefinition(profileId)

View File

@ -17,7 +17,7 @@ import { DmpProfileDefinition } from '@app/core/model/dmp-profile/dmp-profile';
import { DmpProfileService } from '@app/core/services/dmp/dmp-profile.service';
import { AvailableProfilesComponent } from '../available-profiles/available-profiles.component';
import { DmpEditorModel } from '../dmp-editor.model';
import { Router } from '@angular/router';
import { Router, Params, ActivatedRoute } from '@angular/router';
import { RequestItem } from '@app/core/query/request-item';
import { DatasetWizardService } from '@app/core/services/dataset-wizard/dataset-wizard.service';
import { DatasetDescriptionFormEditorModel } from '@app/ui/misc/dataset-description-form/dataset-description-form.model';
@ -35,6 +35,7 @@ export class DatasetInfoComponent extends BaseComponent implements OnInit {
// @Input() datasetFormGroup: FormGroup = null;
@Input() isUserOwner: boolean;
@Input() dmp: DmpEditorModel;
@Input() hasDmpId: boolean;
@Input() isPublic: boolean;
@Input() isFinalized: boolean;
@Input() isNewVersion: boolean;
@ -57,7 +58,8 @@ export class DatasetInfoComponent extends BaseComponent implements OnInit {
private dialog: MatDialog,
private _service: DmpService,
private dmpProfileService: DmpProfileService,
private router: Router
private router: Router,
private route: ActivatedRoute
) {
super();
}
@ -85,6 +87,16 @@ export class DatasetInfoComponent extends BaseComponent implements OnInit {
this.formGroup.get('extraProperties').get('publicDate').patchValue(new Date());
}
if (this.hasDmpId) {
this.loadDatasetProfiles();
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.formGroup.get('datasets')['controls'][0]) {
this.formGroup.get('datasets')['controls'][0].get('dmp').valueChanges.pipe(takeUntil(this._destroyed))
.subscribe(x => {

View File

@ -47,7 +47,8 @@
</div>
</div>
<div class="col info" *ngIf="isNewDataset">
<div class="dataset-title">{{'DMP-EDITOR.TITLE.CREATE-DATASET' | translate}}</div>
<div *ngIf="!hasDmpId" class="dataset-title">{{'DMP-EDITOR.TITLE.CREATE-DATASET' | translate}}</div>
<div *ngIf="hasDmpId" class="dataset-title">{{'DMP-EDITOR.TITLE.ADD-DATASET' | translate}} {{formGroup.get('datasets')['controls'][0].get('dmp').value.label}}</div>
</div>
<div class="row">
<div class="col-auto d-flex align-items-center p-0">
@ -110,11 +111,11 @@
<funding-info *ngIf="!isNewDataset" [hidden]="this.step !== 1" [formGroup]="formGroup" [grantformGroup]="formGroup.get('grant')" [projectFormGroup]="formGroup.get('project')" [funderFormGroup]="formGroup.get('funder')" [isFinalized]="isFinalized || lockStatus" [isNew]="isNew" [isUserOwner]="isUserOwner" (onFormChanged)="formChanged()"></funding-info>
<dataset-info *ngIf="!isNewDataset" [hidden]="this.step !== 2" [formGroup]="formGroup" [dmp]="dmp" [isPublic]="isPublic" [isFinalized]="isFinalized || lockStatus" [isUserOwner]="isUserOwner" [isNewDataset]="isNewDataset" (onFormChanged)="formChanged()"></dataset-info>
<dataset-info *ngIf="isNewDataset" [hidden]="this.step !== 1" [formGroup]="formGroup" [dmp]="dmp" [isPublic]="isPublic" [isFinalized]="isFinalized || lockStatus" [isUserOwner]="isUserOwner" [isNewDataset]="isNewDataset" (onFormChanged)="formChanged()"></dataset-info>
<dataset-info *ngIf="!isNewDataset" [hidden]="this.step !== 2" [formGroup]="formGroup" [dmp]="dmp" [isPublic]="isPublic" [isFinalized]="isFinalized || lockStatus" [isUserOwner]="isUserOwner" [isNewDataset]="isNewDataset" [hasDmpId]="hasDmpId" (onFormChanged)="formChanged()"></dataset-info>
<dataset-info *ngIf="isNewDataset" [hidden]="this.step !== 1" [formGroup]="formGroup" [dmp]="dmp" [isPublic]="isPublic" [isFinalized]="isFinalized || lockStatus" [isUserOwner]="isUserOwner" [isNewDataset]="isNewDataset" [hasDmpId]="hasDmpId" (onFormChanged)="formChanged()"></dataset-info>
<div *ngFor="let dataset of datasets.controls; let i = index" [hidden]="this.step !== i + stepsBeforeDatasets">
<dataset-editor-details [formGroup]="dataset" [isNewDataset]="isNewDataset" [dmpId]="formGroup.get('id').value" (formChanged)="datasetFormChanged($event)"></dataset-editor-details>
<dataset-editor-details [formGroup]="dataset" [isNewDataset]="isNewDataset" [dmpId]="formGroup.get('id').value" (formChanged)="formChanged($event)"></dataset-editor-details>
</div>
</div>
</div>

View File

@ -1,6 +1,6 @@
import { Component, OnInit, SimpleChanges } from '@angular/core';
import { FormGroup, AbstractControl, FormControl, FormArray } from '@angular/forms';
import { FormGroup, AbstractControl, FormControl, FormArray, FormBuilder } from '@angular/forms';
import { MatDialog } from '@angular/material/dialog';
import { ActivatedRoute, Params, Router } from '@angular/router';
import { DmpStatus } from '@app/core/common/enum/dmp-status';
@ -65,6 +65,7 @@ export class DmpEditorComponent extends BaseComponent implements OnInit, IBreadC
hasChanges = false;
isDiscarded = false;
isNewDataset = false;
hasDmpId = false;
isUserOwner: boolean = true;
dmp: DmpEditorModel;
@ -73,6 +74,7 @@ export class DmpEditorComponent extends BaseComponent implements OnInit, IBreadC
formGroupRawValue: any;
datasetId: string = null;
datasets = new FormArray([]);
datasetWizardEditorModel: DatasetWizardEditorModel;
createNewVersion;
associatedUsers: Array<UserModel>;
@ -108,7 +110,7 @@ export class DmpEditorComponent extends BaseComponent implements OnInit, IBreadC
}
ngOnInit() {
if (this.router.url.toString().localeCompare('/new/dataset') === 0) {
if (this.router.url.toString().includes('/new/dataset')) {
this.isNewDataset = true;
this.stepsBeforeDatasets = 2;
this.maxStep = 2;
@ -120,6 +122,7 @@ export class DmpEditorComponent extends BaseComponent implements OnInit, IBreadC
const publicId = params['publicId'];
const queryParams = this.route.snapshot.queryParams;
const tabToNav = queryParams['tab'];
const dmpId = params['dmpId'];
this.datasetId = queryParams['dataset'];
// if (queryParams['step']) { this.step = queryParams['step']; }
@ -273,17 +276,34 @@ export class DmpEditorComponent extends BaseComponent implements OnInit, IBreadC
this.dmp.extraProperties = new ExtraPropertiesFormModel();
this.dmp.extraProperties.visible = false;
this.dmp.extraProperties.contact = this.authService.current().id;
const datasetWizardEditorModel = new DatasetWizardEditorModel();
// this.datasetFormGroup = datasetWizardEditorModel.buildForm();
this.datasetWizardEditorModel = new DatasetWizardEditorModel();
// datasetWizardEditorModel.datasetProfileDefinition = new DatasetDescriptionFormEditorModel();
this.dmp.datasets.push(datasetWizardEditorModel);
this.formGroup = this.dmp.buildForm();
if (dmpId) {
this.hasDmpId = true;
this.dmpService.getSingle(dmpId).pipe(map(data => data as DmpModel))
.pipe(takeUntil(this._destroyed))
.subscribe(data => {
setTimeout(() => {
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.formGroupRawValue = JSON.parse(JSON.stringify(this.formGroup.get('datasets')['controls'][0].getRawValue()));
this.maxStep = this.formGroup.get('datasets') ? this.maxStep + this.formGroup.get('datasets').value.length - 1 : this.maxStep;
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.registerFormEventsForNewItem();
} else {
@ -742,11 +762,20 @@ export class DmpEditorComponent extends BaseComponent implements OnInit, IBreadC
public discardChanges() {
this.isDiscarded = true;
this.hasChanges = false;
if (this.isNewDataset) {
if (this.isNewDataset && !this.hasDmpId) {
this.formGroup.get('datasets')['controls'].forEach(element => {
element.removeControl('datasetProfileDefinition');
});
this.formGroup.reset();
} else if (this.hasDmpId) {
Object.keys(this.formGroup.get('datasets')['controls'][0].controls).forEach((key: string) => {
if (key === 'datasetProfileDefinition') {
this.formGroup.get('datasets')['controls'][0].removeControl(key);
}
if (key !== 'dmp' && key !== 'datasetProfileDefinition') {
this.formGroup.get('datasets')['controls'][0].get(key).reset();
}
});
} else {
this.formGroup.patchValue(JSON.parse(JSON.stringify(this.formGroupRawValue)));
}

View File

@ -29,7 +29,8 @@
</a>
<div class="dmp-card-actions">
<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]="['/datasets/new/' + 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="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="isDraftDmp(dmp)" [routerLink]="['/datasets/new/' + 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()" [routerLink]="['/plans/clone/' + dmp.id]" target="_blank"><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>

View File

@ -29,6 +29,7 @@
[isChild]="true" [showDelete]="true"></app-form-composite-field>
</div>
</div>
{{compositeFieldFormGroup.get('multiplicity').value | json}}
<div *ngIf="(compositeFieldFormGroup.get('multiplicity').value.max - 1) > (compositeFieldFormGroup.get('multiplicityItems').length)"
class="col-12 addOneFieldButton">
<button mat-icon-button color="primary" (click)="addMultipleField(i)" [disabled]="compositeFieldFormGroup.disabled" matTooltip="{{'DATASET-PROFILE-EDITOR.STEPS.FORM.COMPOSITE-FIELD.FIELDS.MULTIPLICITY-ADD-ONE-FIELD' | translate}}">

View File

@ -1,10 +1,11 @@
import { AfterViewInit, Component, Input, OnChanges, OnInit, SimpleChanges, ViewChild } from '@angular/core';
import { AfterViewInit, Component, Input, OnChanges, OnInit, SimpleChanges, ViewChild, Output, EventEmitter } from '@angular/core';
import { FormGroup } from '@angular/forms';
import { MatHorizontalStepper } from '@angular/material/stepper';
import { Rule } from '@app/core/model/dataset-profile-definition/rule';
import { LinkToScroll } from '@app/ui/misc/dataset-description-form/tableOfContentsMaterial/table-of-contents';
import { VisibilityRulesService } from '@app/ui/misc/dataset-description-form/visibility-rules/visibility-rules.service';
import { BaseComponent } from '@common/base/base.component';
import { takeUntil } from 'rxjs/operators';
@Component({
selector: 'app-dataset-description',
@ -19,6 +20,7 @@ export class DatasetDescriptionComponent extends BaseComponent implements OnInit
@Input() visibilityRules: Rule[] = [];
@Input() datasetProfileId: String;
@Input() linkToScroll: LinkToScroll;
@Output() formChanged: EventEmitter<any> = new EventEmitter();
constructor(
private visibilityRulesService: VisibilityRulesService,
@ -28,6 +30,13 @@ export class DatasetDescriptionComponent extends BaseComponent implements OnInit
ngOnInit() {
this.visibilityRulesService.buildVisibilityRules(this.visibilityRules, this.form);
if (this.form) {
this.form.valueChanges
.pipe(takeUntil(this._destroyed))
.subscribe(val => {
this.formChanged.emit(val);
});
}
}
ngOnChanges(changes: SimpleChanges) {

View File

@ -691,6 +691,7 @@
"NEW": "Neuer Datenmanagementplan",
"EDIT": "Bearbeiten",
"SUBTITLE": "DOI",
"ADD-DATASET": "Adding dataset to ",
"EDIT-DATASET": "Editing Dataset",
"CREATE-DATASET": "Creating Dataset Description"
},

View File

@ -760,6 +760,7 @@
"NEW": "New Data Management Plan",
"EDIT": "Edit",
"EDIT-DMP": "Editing DMP",
"ADD-DATASET": "Adding dataset to ",
"EDIT-DATASET": "Editing Dataset",
"CREATE-DATASET": "Creating Dataset Description",
"SUBTITLE": "DOI"

View File

@ -538,7 +538,7 @@
},
"MESSAGES": {
"DATASET-NOT-FOUND": "No existe la descripción del dataset",
"DATASET-NOT-ALLOWED": "No tiene acceso a la descricipción de este dataset",
"DATASET-NOT-ALLOWED": "No tiene acceso a la descricipción de este dataset",
"SUCCESS-UPDATE-DATASET-PROFILE": "Plantilla de descripción del dataset actualizada correctamente"
},
"UPLOAD": {
@ -760,6 +760,7 @@
"NEW": "Nuevo Plan de Gestión de Datos",
"EDIT": "Editar",
"EDIT-DMP": "Editando PGD",
"ADD-DATASET": "Adding dataset to ",
"EDIT-DATASET": "Editing Dataset",
"CREATE-DATASET": "Creating Dataset Description",
"SUBTITLE": "DOI"

View File

@ -755,6 +755,7 @@
"NEW": "Νέα Σχέδιο Διαχείρισης Δεδομένων",
"EDIT": "Επεξεργασία",
"EDIT-DMP": "Editing DMP",
"ADD-DATASET": "Adding dataset to ",
"EDIT-DATASET": "Editing Dataset",
"SUBTITLE": "Μονοσήμαντο Αναγνωριστικό Ψηφιακού Αντικειμένου (DOI)"
},

View File

@ -749,6 +749,7 @@
"NEW": "Yeni Veri Yönetim Planı",
"EDIT": "Düzenle",
"EDIT-DMP": " VYP'yi düzenleme",
"ADD-DATASET": "Adding dataset to ",
"SUBTITLE": "DOI"
},
"FIELDS": {