Dmp Profile Fix And Working And Required And Tested
This commit is contained in:
parent
158e924e78
commit
c9c4de0dc9
|
@ -9,6 +9,10 @@ import { DmpRoutingModule } from './dmp.routing';
|
|||
import { AddResearcherComponent } from './editor/add-researcher/add-researcher.component';
|
||||
import { AvailableProfilesComponent } from './editor/available-profiles/available-profiles.component';
|
||||
import { DmpEditorComponent } from './editor/dmp-editor.component';
|
||||
import { DmpFinalizeDialogComponent } from './editor/dmp-finalize-dialog/dmp-finalize-dialog.component';
|
||||
import { DynamicDmpFieldResolverComponent } from './editor/dynamic-field-resolver/dynamic-dmp-field-resolver.component';
|
||||
import { DynamicFieldProjectComponent } from './editor/dynamic-fields-project/dynamic-field-project/dynamic-field-project.component';
|
||||
import { DynamicFieldsProjectComponent } from './editor/dynamic-fields-project/dynamic-fields-project.component';
|
||||
import { InvitationAcceptedComponent } from './invitation/accepted/dmp-invitation-accepted.component';
|
||||
import { DmpInvitationDialogComponent } from './invitation/dmp-invitation.component';
|
||||
import { DmpCriteriaComponent } from './listing/criteria/dmp-criteria.component';
|
||||
|
@ -16,8 +20,6 @@ import { DmpListingComponent } from './listing/dmp-listing.component';
|
|||
import { DmpWizardComponent } from './wizard/dmp-wizard.component';
|
||||
import { DmpWizardEditorComponent } from './wizard/editor/dmp-wizard-editor.component';
|
||||
import { DmpWizardDatasetListingComponent } from './wizard/listing/dmp-wizard-dataset-listing.component';
|
||||
import { UserDialogComponent } from '../misc/navigation/user-dialog/user-dialog.component';
|
||||
import { DmpFinalizeDialogComponent } from './editor/dmp-finalize-dialog/dmp-finalize-dialog.component';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
|
@ -40,17 +42,15 @@ import { DmpFinalizeDialogComponent } from './editor/dmp-finalize-dialog/dmp-fin
|
|||
DmpWizardDatasetListingComponent,
|
||||
AddResearcherComponent,
|
||||
AvailableProfilesComponent,
|
||||
// DynamicDmpFieldResolverComponent,
|
||||
DmpFinalizeDialogComponent,
|
||||
DynamicDmpFieldResolverComponent,
|
||||
// DynamicFieldsProjectComponent,
|
||||
// DynamicFieldProjectComponent,
|
||||
// DMPFinaliseDialogComponent
|
||||
DmpFinalizeDialogComponent
|
||||
// DynamicFieldProjectComponent
|
||||
],
|
||||
entryComponents: [
|
||||
DmpInvitationDialogComponent,
|
||||
AddResearcherComponent,
|
||||
AvailableProfilesComponent,
|
||||
// DMPFinaliseDialogComponent
|
||||
DmpFinalizeDialogComponent
|
||||
]
|
||||
})
|
||||
|
|
|
@ -58,28 +58,44 @@
|
|||
<mat-card-content>
|
||||
<div class="row">
|
||||
<mat-form-field class="col-md-12">
|
||||
<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-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-single-auto-complete required='true' [formControl]="formGroup.get('project')" placeholder="{{this.languageResolverService.getBy('dmpEditor') | translate}}" [configuration]="projectAutoCompleteConfiguration">
|
||||
<app-single-auto-complete required='true' [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>
|
||||
<!-- <app-dynamic-fields-project [formGroup]="formGroup"></app-dynamic-fields-project> -->
|
||||
<mat-form-field class="col-md-6">
|
||||
<app-multiple-auto-complete required='true' [formControl]="formGroup.get('profiles')" placeholder="{{'DMP-EDITOR.FIELDS.PROFILES' | translate}}" [configuration]="profilesAutoCompleteConfiguration">
|
||||
<app-multiple-auto-complete required='true' [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>
|
||||
<button matSuffix mat-icon-button type="button" [disabled]="formGroup.get('profiles').disabled" (click)="availableProfiles()">
|
||||
<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 matSuffix mat-icon-button type="button" [disabled]="formGroup.get('profiles').disabled"
|
||||
(click)="availableProfiles()">
|
||||
<mat-icon>view_list</mat-icon>
|
||||
</button>
|
||||
</mat-form-field>
|
||||
|
@ -87,35 +103,49 @@
|
|||
|
||||
|
||||
<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>
|
||||
<button matSuffix mat-icon-button [disabled]="formGroup.get('researchers').disabled" type="button" (click)="addResearcher()">
|
||||
<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 matSuffix mat-icon-button [disabled]="formGroup.get('researchers').disabled"
|
||||
type="button" (click)="addResearcher()">
|
||||
<mat-icon>add_circle</mat-icon>
|
||||
</button>
|
||||
</mat-form-field>
|
||||
<!-- <h3 mat-subheader class="col-md-12">{{'DMP-EDITOR.FIELDS.PROFILE' | translate}}</h3>
|
||||
|
||||
<!-- <h4 mat-subheader class="col-12">{{'DMP-EDITOR.FIELDS.PROFILE' | translate}}</h4> -->
|
||||
<mat-form-field class="col-md-6">
|
||||
<input type="text" placeholder="{{'DMP-EDITOR.FIELDS.PROFILE' | translate}}" [formControl]="textCtrl" matInput [matAutocomplete]="auto">
|
||||
<mat-autocomplete #auto="matAutocomplete" [displayWith]="displayWith">
|
||||
<mat-option *ngFor="let option of filteredOptions | async" [value]="option" (click)="selectOption(option)">
|
||||
{{ option.label }}
|
||||
</mat-option>
|
||||
</mat-autocomplete>
|
||||
<app-single-auto-complete required='false' [formControl]="formGroup.get('profile')"
|
||||
placeholder="{{'DMP-EDITOR.FIELDS.PROFILE' | translate}}"
|
||||
[configuration]="dmpProfileAutoCompleteConfiguration">
|
||||
</app-single-auto-complete>
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field class="col-md-6">
|
||||
<input matInput placeholder="Version" disabled
|
||||
[value]="formGroup.get('version').value== undefined ?0 :formGroup.get('version').value">
|
||||
</mat-form-field>
|
||||
<app-dynamic-dmp-field-resolver class="col-md-12" *ngIf="dataManagementPlan.definition" [formGroup]="formGroup" [dataManagementPlanProfile]="dataManagementPlan.definition"></app-dynamic-dmp-field-resolver> -->
|
||||
|
||||
<mat-form-field class="col-md-6">
|
||||
<input matInput placeholder="Version" disabled [value]="formGroup.get('version').value== undefined ?0 :formGroup.get('version').value">
|
||||
</mat-form-field>
|
||||
<!-- <app-dynamic-dmp-field-resolver *ngIf="dmp.definition" class="col-md-12"
|
||||
[formGroup]="formGroup" [dmpProfileDefinition]=dmp.definition></app-dynamic-dmp-field-resolver> -->
|
||||
<app-dynamic-dmp-field-resolver *ngIf="selectedDmpProfileDefinition" class="col-md-12"
|
||||
[formGroup]="formGroup" [dmpProfileDefinition]="selectedDmpProfileDefinition">
|
||||
</app-dynamic-dmp-field-resolver>
|
||||
|
||||
|
||||
<div class="col-md-12">
|
||||
<mat-list *ngIf="associatedUsers?.length" role="list" class="col-md-12">
|
||||
|
@ -129,11 +159,20 @@
|
|||
|
||||
<div class="col-md-12">
|
||||
<div class="row">
|
||||
<div class="col-auto"><button mat-raised-button color="primary" (click)="cancel()" type="button">{{'DMP-EDITOR.ACTIONS.CANCEL' | translate}}</button></div>
|
||||
<div class="col-auto"><button mat-raised-button color="primary" (click)="cancel()"
|
||||
type="button">{{'DMP-EDITOR.ACTIONS.CANCEL'
|
||||
| translate}}</button></div>
|
||||
<div class="col"></div>
|
||||
<div class="col-auto" *ngIf="!isNew && this.formGroup.enabled"><button mat-raised-button color="primary" type="button" (click)="delete()">{{'DMP-EDITOR.ACTIONS.DELETE' | translate}}</button></div>
|
||||
<div class="col-auto" *ngIf="this.formGroup.enabled"><button mat-raised-button color="primary" type="submit">{{'DMP-EDITOR.ACTIONS.SAVE' | translate}}</button></div>
|
||||
<div class="col-auto" *ngIf="dmp.lockable && this.formGroup.enabled"><button type="button" mat-raised-button color="primary" (click)="saveAndFinalize()">{{'DMP-EDITOR.ACTIONS.FINALISE' | translate}}</button></div>
|
||||
<div class="col-auto" *ngIf="!isNew && this.formGroup.enabled"><button mat-raised-button
|
||||
color="primary" type="button"
|
||||
(click)="delete()">{{'DMP-EDITOR.ACTIONS.DELETE' | translate}}</button></div>
|
||||
<div class="col-auto" *ngIf="this.formGroup.enabled"><button mat-raised-button
|
||||
color="primary" type="submit">{{'DMP-EDITOR.ACTIONS.SAVE'
|
||||
| translate}}</button></div>
|
||||
<div class="col-auto" *ngIf="dmp.lockable && this.formGroup.enabled"><button type="button"
|
||||
mat-raised-button color="primary"
|
||||
(click)="saveAndFinalize()">{{'DMP-EDITOR.ACTIONS.FINALISE' | translate}}</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -141,4 +180,4 @@
|
|||
</mat-card>
|
||||
</form>
|
||||
<!-- <div *ngIf="formGroup"> {{ formGroup.value | json }}</div> -->
|
||||
</div>
|
||||
</div>
|
|
@ -10,14 +10,18 @@ import { ValidationErrorModel } from '../../../common/forms/validation/error-mod
|
|||
import { BaseComponent } from '../../../core/common/base/base.component';
|
||||
import { DmpStatus } from '../../../core/common/enum/dmp-status';
|
||||
import { Status } from '../../../core/common/enum/Status';
|
||||
import { DataTableRequest } from '../../../core/model/data-table/data-table-request';
|
||||
import { DatasetListingModel } from '../../../core/model/dataset/dataset-listing';
|
||||
import { DatasetProfileModel } from '../../../core/model/dataset/dataset-profile';
|
||||
import { DmpProfileDefinition } from '../../../core/model/dmp-profile/dmp-profile';
|
||||
import { DmpProfileListing } from '../../../core/model/dmp-profile/dmp-profile-listing';
|
||||
import { DmpModel } from '../../../core/model/dmp/dmp';
|
||||
import { ExternalSourceItemModel } from '../../../core/model/external-sources/external-source-item';
|
||||
import { ProjectListingModel } from '../../../core/model/project/project-listing';
|
||||
import { UserModel } from '../../../core/model/user/user';
|
||||
import { BaseCriteria } from '../../../core/query/base-criteria';
|
||||
import { DatasetProfileCriteria } from '../../../core/query/dataset-profile/dataset-profile-criteria';
|
||||
import { DmpProfileCriteria } from '../../../core/query/dmp/dmp-profile-criteria';
|
||||
import { ProjectCriteria } from '../../../core/query/project/project-criteria';
|
||||
import { RequestItem } from '../../../core/query/request-item';
|
||||
import { DmpProfileService } from '../../../core/services/dmp/dmp-profile.service';
|
||||
|
@ -27,6 +31,7 @@ import { SnackBarNotificationLevel, UiNotificationService } from '../../../core/
|
|||
import { ProjectService } from '../../../core/services/project/project.service';
|
||||
import { MultipleAutoCompleteConfiguration } from '../../../library/auto-complete/multiple/multiple-auto-complete-configuration';
|
||||
import { SingleAutoCompleteConfiguration } from '../../../library/auto-complete/single/single-auto-complete-configuration';
|
||||
import { ConfirmationDialogComponent } from '../../../library/confirmation-dialog/confirmation-dialog.component';
|
||||
import { LanguageResolverService } from '../../../services/language-resolver/language-resolver.service';
|
||||
import { BreadcrumbItem } from '../../misc/breadcrumb/definition/breadcrumb-item';
|
||||
import { IBreadCrumbComponent } from '../../misc/breadcrumb/definition/IBreadCrumbComponent';
|
||||
|
@ -34,7 +39,6 @@ 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 { ConfirmationDialogComponent } from '../../../library/confirmation-dialog/confirmation-dialog.component';
|
||||
|
||||
@Component({
|
||||
selector: 'app-dmp-editor-component',
|
||||
|
@ -47,7 +51,6 @@ export class DmpEditorComponent extends BaseComponent implements OnInit, IBreadC
|
|||
|
||||
breadCrumbs: Observable<BreadcrumbItem[]>;
|
||||
isNew = true;
|
||||
textCtrl = new FormControl();
|
||||
dmp: DmpEditorModel;
|
||||
formGroup: FormGroup = null;
|
||||
|
||||
|
@ -62,10 +65,13 @@ export class DmpEditorComponent extends BaseComponent implements OnInit, IBreadC
|
|||
profilesAutoCompleteConfiguration: MultipleAutoCompleteConfiguration;
|
||||
organisationsAutoCompleteConfiguration: MultipleAutoCompleteConfiguration;
|
||||
researchersAutoCompleteConfiguration: MultipleAutoCompleteConfiguration;
|
||||
dmpProfileAutoCompleteConfiguration:SingleAutoCompleteConfiguration;
|
||||
|
||||
createNewVersion;
|
||||
associatedUsers: Array<UserModel>;
|
||||
// filteredOptions: Observable<DmpProfileListing[]>;
|
||||
filteredOptions: DmpProfileListing[];
|
||||
selectedDmpProfileDefinition: DmpProfileDefinition;
|
||||
DynamicDmpFieldResolverComponent: any;
|
||||
|
||||
constructor(
|
||||
private dmpProfileService: DmpProfileService,
|
||||
|
@ -83,7 +89,6 @@ export class DmpEditorComponent extends BaseComponent implements OnInit, IBreadC
|
|||
private uiNotificationService: UiNotificationService
|
||||
) {
|
||||
super();
|
||||
// this.filteredOptions = dmpProfileService.getAll({ criteria: new DmpProfileCriteria() });
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
|
@ -105,6 +110,13 @@ export class DmpEditorComponent extends BaseComponent implements OnInit, IBreadC
|
|||
titleFn: (item) => item['label']
|
||||
};
|
||||
|
||||
this.dmpProfileAutoCompleteConfiguration= {
|
||||
filterFn: this.dmpProfileSearch.bind(this),
|
||||
initialItems: (extraData) => this.dmpProfileSearch(''),
|
||||
displayFn: (item) => item['label'],
|
||||
titleFn: (item) => item['label']
|
||||
};
|
||||
|
||||
this.profilesAutoCompleteConfiguration = {
|
||||
filterFn: this.filterProfiles.bind(this),
|
||||
initialItems: (excludedItems: any[]) => this.filterProfiles('').map(result => result.filter(resultItem => excludedItems.map(x => x.id).indexOf(resultItem.id) === -1)),
|
||||
|
@ -133,15 +145,15 @@ export class DmpEditorComponent extends BaseComponent implements OnInit, IBreadC
|
|||
.subscribe(async data => {
|
||||
this.dmp = new DmpEditorModel().fromModel(data);
|
||||
this.formGroup = this.dmp.buildForm();
|
||||
this.registerFormEventsForDmpProfile();
|
||||
this.selectedDmpProfileDefinition = this.dmp.definition;
|
||||
if (!this.editMode || this.dmp.status === Status.Inactive) { this.formGroup.disable(); }
|
||||
if (this.formGroup.get('profile') && this.formGroup.get('profile').value) {
|
||||
this.textCtrl.patchValue(this.formGroup.get('profile').value);
|
||||
}
|
||||
|
||||
this.breadCrumbs = Observable.of([
|
||||
{
|
||||
parentComponentName: 'DmpListingComponent',
|
||||
label: 'DMPs',
|
||||
url: 'dmps',
|
||||
url: 'plans',
|
||||
notFoundResolver: [await this.projectService.getSingle(this.dmp.project.id).map(x => ({ label: x.label, url: '/projects/edit/' + x.id }) as BreadcrumbItem).toPromise()]
|
||||
}]
|
||||
);
|
||||
|
@ -155,12 +167,14 @@ export class DmpEditorComponent extends BaseComponent implements OnInit, IBreadC
|
|||
this.dmp = new DmpEditorModel();
|
||||
this.dmp.project = data;
|
||||
this.formGroup = this.dmp.buildForm();
|
||||
this.registerFormEventsForDmpProfile();
|
||||
this.formGroup.get('project').disable();
|
||||
this.registerFormEventsForNewItem();
|
||||
});
|
||||
} else {
|
||||
this.dmp = new DmpEditorModel();
|
||||
this.formGroup = this.dmp.buildForm();
|
||||
this.registerFormEventsForDmpProfile();
|
||||
this.registerFormEventsForNewItem();
|
||||
}
|
||||
});
|
||||
|
@ -171,22 +185,47 @@ export class DmpEditorComponent extends BaseComponent implements OnInit, IBreadC
|
|||
.subscribe(params => {
|
||||
this.createNewVersion = params['clone'];
|
||||
});
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
registerFormEventsForNewItem() {
|
||||
if (this.formGroup.get('profile') && this.formGroup.get('profile').value) {
|
||||
this.textCtrl.patchValue(this.formGroup.get('profile').value);
|
||||
}
|
||||
registerFormEventsForDmpProfile(): void {
|
||||
this.formGroup.get('profile').valueChanges
|
||||
.pipe(takeUntil(this._destroyed))
|
||||
.subscribe(Option => {
|
||||
if (Option instanceof Object) {
|
||||
this.dmpProfileService.getSingle(Option.id)
|
||||
.pipe(takeUntil(this._destroyed))
|
||||
.subscribe(result => {
|
||||
this.selectedDmpProfileDefinition = result.definition;
|
||||
});
|
||||
} else {
|
||||
this.selectedDmpProfileDefinition = null;
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
registerFormEventsForNewItem() {
|
||||
this.breadCrumbs = Observable.of([
|
||||
{
|
||||
parentComponentName: 'DmpListingComponent',
|
||||
label: 'DMPs',
|
||||
url: 'dmps',
|
||||
url: 'plans',
|
||||
}
|
||||
]);
|
||||
}
|
||||
|
||||
dmpProfileSearch(query: string){
|
||||
let fields: Array<string> = new Array();
|
||||
var request = new DataTableRequest<DmpProfileCriteria>(0, 10, { fields: fields });
|
||||
request.criteria = new DmpProfileCriteria();
|
||||
return this.dmpProfileService.getPaged(request).map(x => x.data);
|
||||
}
|
||||
|
||||
|
||||
|
||||
searchProject(query: string) {
|
||||
const projectRequestItem: RequestItem<ProjectCriteria> = new RequestItem();
|
||||
projectRequestItem.criteria = new ProjectCriteria();
|
||||
|
@ -277,8 +316,6 @@ export class DmpEditorComponent extends BaseComponent implements OnInit, IBreadC
|
|||
|
||||
availableProfiles() {
|
||||
const dialogRef = this.dialog.open(AvailableProfilesComponent, {
|
||||
// height: '355px',
|
||||
// width: '700px',
|
||||
data: {
|
||||
profiles: this.formGroup.get('profiles')
|
||||
}
|
||||
|
@ -308,15 +345,15 @@ export class DmpEditorComponent extends BaseComponent implements OnInit, IBreadC
|
|||
});
|
||||
}
|
||||
|
||||
selectOption(option: any) {
|
||||
this.dmp.definition = null;
|
||||
this.formGroup.get('profile').patchValue(option, { emitEvent: false });
|
||||
this.dmpProfileService.getSingle(option.id)
|
||||
.pipe(takeUntil(this._destroyed))
|
||||
.subscribe(result => {
|
||||
this.dmp.definition = result.definition;
|
||||
});
|
||||
}
|
||||
// selectOption(option: any) {
|
||||
// this.dmp.definition = null;
|
||||
// this.formGroup.get('profile').patchValue(option, { emitEvent: false });
|
||||
// this.dmpProfileService.getSingle(option.id)
|
||||
// .pipe(takeUntil(this._destroyed))
|
||||
// .subscribe(result => {
|
||||
// this.selectedDmpProfileDefinition = result.definition;
|
||||
// });
|
||||
// }
|
||||
|
||||
displayWith(item: any) {
|
||||
if (!item) { return null; }
|
||||
|
|
|
@ -72,7 +72,6 @@ export class DmpEditorModel {
|
|||
|
||||
const dynamicFields = new Array<FormGroup>();
|
||||
if (this.dynamicFields) { this.dynamicFields.forEach(item => dynamicFields.push(item.buildForm())); }
|
||||
|
||||
formGroup.addControl('dynamicFields', new FormBuilder().array(dynamicFields));
|
||||
|
||||
return formGroup;
|
||||
|
|
|
@ -1,15 +1,27 @@
|
|||
<div *ngFor="let field of dmpProfileDefinition.fields; let i = index">
|
||||
<div *ngIf="field.type == dmpProfileTypeEnum.Input">
|
||||
<mat-form-field class="full-width" *ngIf="field.dataType == dmpProfileFieldDataTypeEnum.Date">
|
||||
<input matInput [matDatepicker]="picker" [placeholder]="field.label" [formControl]="formGroup.get('properties').get('fields').get(''+i).get('value')">
|
||||
|
||||
<div class="row">
|
||||
<div *ngFor="let field of dmpProfileDefinition?.fields; let i = index" class="col-md-6">
|
||||
<!-- <div *ngIf="field.type == dmpProfileTypeEnum.Input"> -->
|
||||
<mat-form-field class="full-width" *ngIf="field.dataType == dmpProfileFieldDataType.Date">
|
||||
<input matInput [matDatepicker]="picker" [placeholder]="field.label"
|
||||
[formControl]="formGroup.get('properties').get('fields').get(''+i).get('value')" [required]="field.required">
|
||||
<mat-datepicker-toggle matSuffix [for]="picker"></mat-datepicker-toggle>
|
||||
<mat-datepicker #picker></mat-datepicker>
|
||||
<mat-error *ngIf="formGroup.get('properties').get('fields').get(''+i).get('value')['errors']">{{'GENERAL.VALIDATION.REQUIRED'
|
||||
| translate}}</mat-error>
|
||||
</mat-form-field>
|
||||
<mat-form-field class="full-width" *ngIf="field.dataType == dmpProfileFieldDataTypeEnum.Text">
|
||||
<input matInput [placeholder]="field.label" [formControl]="formGroup.get('properties').get('fields').get(''+i).get('value')">
|
||||
<mat-form-field class="full-width" *ngIf="field.dataType == dmpProfileFieldDataType.Text">
|
||||
<input matInput [placeholder]="field.label"
|
||||
[formControl]="formGroup.get('properties').get('fields').get(''+i).get('value')" [required]="field.required">
|
||||
<mat-error *ngIf="formGroup.get('properties').get('fields').get(''+i).get('value')['errors']">{{'GENERAL.VALIDATION.REQUIRED'
|
||||
| translate}}</mat-error>
|
||||
</mat-form-field>
|
||||
<mat-form-field class="full-width" *ngIf="field.dataType == dmpProfileFieldDataTypeEnum.Number">
|
||||
<input matInput type="number" [placeholder]="field.label" [formControl]="formGroup.get('properties').get('fields').get(''+i).get('value')">
|
||||
<mat-form-field class="full-width" *ngIf="field.dataType == dmpProfileFieldDataType.Number">
|
||||
<input matInput type="number" [placeholder]="field.label"
|
||||
[formControl]="formGroup.get('properties').get('fields').get(''+i).get('value')" [required]="field.required">
|
||||
<mat-error *ngIf="formGroup.get('properties').get('fields').get(''+i).get('value')['errors']">{{'GENERAL.VALIDATION.REQUIRED'
|
||||
| translate}}</mat-error>
|
||||
</mat-form-field>
|
||||
<!-- </div> -->
|
||||
</div>
|
||||
</div>
|
|
@ -0,0 +1,3 @@
|
|||
.full-width{
|
||||
width: 100%;
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
import { Component, Input, OnDestroy, OnInit } from '@angular/core';
|
||||
import { Component, Input, OnDestroy, OnInit, SimpleChanges } from '@angular/core';
|
||||
import { FormArray, FormBuilder, FormGroup } from '@angular/forms';
|
||||
import { DmpProfileFieldDataType } from '../../../../core/common/enum/dmp-profile-field-type';
|
||||
import { DmpProfileType } from '../../../../core/common/enum/dmp-profile-type';
|
||||
|
@ -15,22 +15,33 @@ export class DynamicDmpFieldResolverComponent implements OnInit, OnDestroy {
|
|||
dmpProfileFieldDataType = DmpProfileFieldDataType;
|
||||
dmpProfileTypeEnum = DmpProfileType;
|
||||
|
||||
@Input()
|
||||
dmpProfileDefinition: DmpProfileDefinition;
|
||||
|
||||
@Input()
|
||||
formGroup: FormGroup;
|
||||
@Input() dmpProfileDefinition: DmpProfileDefinition;
|
||||
@Input() formGroup: FormGroup;
|
||||
|
||||
ngOnInit(): void {
|
||||
this.formGroup.addControl('properties', new FormBuilder().group([]));
|
||||
(<FormGroup>this.formGroup.get('properties')).addControl('fields', new FormBuilder().array([]));
|
||||
this.createControleFields();
|
||||
}
|
||||
ngOnChanges(changes: SimpleChanges) {
|
||||
if (changes['dmpProfileDefinition'] && !changes['dmpProfileDefinition'].isFirstChange()) {
|
||||
this.createControleFields();
|
||||
}
|
||||
}
|
||||
|
||||
this.dmpProfileDefinition.fields.forEach(item => {
|
||||
(<FormArray>this.formGroup.get('properties').get('fields')).push(new FormBuilder().group({
|
||||
id: [item.id],
|
||||
value: [item.value]
|
||||
}));
|
||||
});
|
||||
createControleFields(): void {
|
||||
if (this.dmpProfileDefinition != null) {
|
||||
const diasableBoolean = this.formGroup.disabled;
|
||||
this.formGroup.addControl('properties', new FormBuilder().group([]));
|
||||
(<FormGroup>this.formGroup.get('properties')).addControl('fields', new FormBuilder().array([]));
|
||||
this.dmpProfileDefinition.fields.forEach(item => {
|
||||
(<FormArray>this.formGroup.get('properties').get('fields')).push(new FormBuilder().group({
|
||||
id: [{ value: item.id, disabled: diasableBoolean }],
|
||||
value: [{ value: item.value, disabled: diasableBoolean }]
|
||||
}));
|
||||
});
|
||||
}
|
||||
if(this.dmpProfileDefinition==null){
|
||||
this.formGroup.removeControl('properties');
|
||||
}
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
|
|
|
@ -16,11 +16,9 @@ export class DynamicFieldProjectComponent implements OnInit {
|
|||
private dmpService: DmpService
|
||||
) { }
|
||||
|
||||
@Input()
|
||||
dependencies: Array<FormGroup>;
|
||||
@Input()dependencies: Array<FormGroup>;
|
||||
|
||||
@Input()
|
||||
formGroup: FormGroup;
|
||||
@Input()formGroup: FormGroup;
|
||||
|
||||
autoCompleteConfiguration: SingleAutoCompleteConfiguration;
|
||||
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
import { Component, Input, OnInit } from '@angular/core';
|
||||
import { FormArray, FormGroup, AbstractControl } from '@angular/forms';
|
||||
import { AbstractControl, FormArray, FormGroup } from '@angular/forms';
|
||||
import { takeUntil } from 'rxjs/operators';
|
||||
import { BaseComponent } from '../../../../../core/common/base/base.component';
|
||||
import { VisibilityRulesService } from '../../visibility-rules/visibility-rules.service';
|
||||
import { FooterRowOutlet } from '@angular/cdk/table';
|
||||
|
||||
@Component({
|
||||
selector: 'app-form-progress-indication',
|
||||
|
@ -31,29 +30,9 @@ export class FormProgressIndicationComponent extends BaseComponent implements On
|
|||
const progressSoFar = this.countFormControlsWithValueForProgress(this.formGroup);
|
||||
const total = this.CountFormControlDepthLengthFotTotal(this.formGroup);
|
||||
const perc = (progressSoFar / total) * 100;
|
||||
// const perc = ((progressSoFar-this.StandarValues) / total) * 100;
|
||||
this.value = Number.parseFloat(perc.toPrecision(this.progressValueAccuracy));
|
||||
}
|
||||
|
||||
// countFormControlsWithValue(form: FormGroup): number {
|
||||
// let valueCurent = 0;
|
||||
// Object.keys(form.controls).forEach(key => {
|
||||
// const control = form.controls[key];
|
||||
// if (control instanceof FormGroup && this.visibilityRulesService.checkElementVisibility(control.value.id)) {
|
||||
// valueCurent += this.countFormControlsWithValue(control);
|
||||
// } else if (control instanceof FormArray) {
|
||||
// const formArray = (<FormArray>control);
|
||||
// for (let i = 0; i < formArray.length; i++) {
|
||||
// if (this.visibilityRulesService.checkElementVisibility(formArray.get('' + i).value.id))
|
||||
// valueCurent += this.countFormControlsWithValue(<FormGroup>formArray.get('' + i));
|
||||
// }
|
||||
// } else if (key === 'value' && control.value != null && control.value !== '' && this.visibilityRulesService.checkElementVisibility(form.controls['id'].value)) {
|
||||
// valueCurent++;
|
||||
// }
|
||||
// });
|
||||
// return valueCurent;
|
||||
// }
|
||||
//
|
||||
countFormControlsWithValueForProgress(formControl: AbstractControl): number {
|
||||
let valueCurent = 0;
|
||||
if (formControl instanceof FormGroup) {
|
||||
|
@ -74,7 +53,6 @@ export class FormProgressIndicationComponent extends BaseComponent implements On
|
|||
valueCurent = valueCurent + this.countFormControlsWithValueForProgress(item);
|
||||
});
|
||||
}
|
||||
|
||||
return valueCurent;
|
||||
}
|
||||
private haseValue(formGroup: FormGroup): boolean {
|
||||
|
@ -113,25 +91,6 @@ export class FormProgressIndicationComponent extends BaseComponent implements On
|
|||
return false;
|
||||
}
|
||||
|
||||
// getFormControlDepthLength(form: FormGroup): number {
|
||||
// let value = 0;
|
||||
// Object.keys(form.controls).forEach(key => {
|
||||
// const control = form.controls[key];
|
||||
// if (control instanceof FormGroup && this.visibilityRulesService.checkElementVisibility(control.value.id)) {
|
||||
// value += this.getFormControlDepthLength(control);
|
||||
// } else if (control instanceof FormArray) {
|
||||
// const formArray = (<FormArray>control);
|
||||
// for (let i = 0; i < formArray.length; i++) {
|
||||
// if (<FormGroup>formArray.get('' + i).value && this.visibilityRulesService.checkElementVisibility(formArray.get('' + i).value.id)) {
|
||||
// value += this.getFormControlDepthLength(<FormGroup>formArray.get('' + i));
|
||||
// }
|
||||
// }
|
||||
// } else if (key === 'value' && this.visibilityRulesService.checkElementVisibility(form.controls['id'].value)) {
|
||||
// value++;
|
||||
// }
|
||||
// });
|
||||
// return value;
|
||||
// }
|
||||
CountFormControlDepthLengthFotTotal(formControl: AbstractControl): number {
|
||||
let valueCurent = 0;
|
||||
if (formControl instanceof FormArray) {
|
||||
|
@ -154,35 +113,16 @@ export class FormProgressIndicationComponent extends BaseComponent implements On
|
|||
return valueCurent;
|
||||
}
|
||||
|
||||
// CountFormControlDepthLengthFotTotal(formControl: AbstractControl): number {
|
||||
// let valueCurent = 0;
|
||||
// if (formControl instanceof FormArray) {
|
||||
// return formControl.controls.map(item => this.CountFormControlDepthLengthFotTotal(item));
|
||||
// } else if (formControl instanceof FormGroup) {
|
||||
// if ((formControl as FormGroup).contains('id') && (formControl as FormGroup).contains('value') && (this.visibilityRulesService.checkElementVisibility((formControl as FormGroup).get('id').value))) {
|
||||
// return 1;
|
||||
// } else if ((formControl as FormGroup).contains('id') && (formControl as FormGroup).contains('fields') && (this.visibilityRulesService.checkElementVisibility((formControl as FormGroup).get('id').value))) {
|
||||
// return this.CountFormControlDepthLengthFotTotal(formControl);
|
||||
// } else {
|
||||
// return formControl.controls.map(item => this.CountFormControlDepthLengthFotTotal(item));
|
||||
// }
|
||||
// }
|
||||
|
||||
// return valueCurent;
|
||||
// }
|
||||
|
||||
private compositeFieldsGetChildsForTotal(formGroup: FormGroup): number {
|
||||
let valueCurent = 0;
|
||||
if (this.visibilityRulesService.checkElementVisibility(formGroup.get('id').value)) {
|
||||
(formGroup.get('fields') as FormArray).controls.forEach((element: FormGroup) => {
|
||||
valueCurent = valueCurent + this.CountFormControlDepthLengthFotTotal(element);
|
||||
});
|
||||
|
||||
(formGroup.get('multiplicityItems') as FormArray).controls.forEach((element: FormGroup) => {
|
||||
valueCurent = valueCurent + this.CountFormControlDepthLengthFotTotal(element);
|
||||
});
|
||||
}
|
||||
return valueCurent;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue