dmp blueprint fixes
This commit is contained in:
parent
6b7a33c0b4
commit
29e0d032ca
|
@ -17,6 +17,7 @@ import { ConfigurationService } from '../configuration/configuration.service';
|
|||
import { BaseHttpV2Service } from '../http/base-http-v2.service';
|
||||
import { DmpBlueprintStatus } from '@app/core/common/enum/dmp-blueprint-status';
|
||||
import { error } from 'console';
|
||||
import { DmpBlueprintVersionStatus } from '@app/core/common/enum/dmp-blueprint-version-status';
|
||||
|
||||
@Injectable()
|
||||
export class DmpBlueprintService {
|
||||
|
@ -135,6 +136,7 @@ export class DmpBlueprintService {
|
|||
]
|
||||
};
|
||||
lookup.order = { items: [nameof<DmpBlueprint>(x => x.label)] };
|
||||
lookup.versionStatuses = [DmpBlueprintVersionStatus.Current];
|
||||
if (like) { lookup.like = this.filterService.transformLike(like); }
|
||||
return lookup;
|
||||
}
|
||||
|
|
|
@ -183,7 +183,7 @@
|
|||
<div class="col-12 col-xl-auto">
|
||||
<div class="row">
|
||||
<div class="col-auto section-field" *ngIf="field.get('category').value != null">
|
||||
<mat-checkbox [disabled]="field.get('systemFieldType')?.value === dmpBlueprintSystemFieldType.Title || field.get('systemFieldType')?.value === dmpBlueprintSystemFieldType.Description" [formControl]="field.get('required')"><span>{{'DMP-BLUEPRINT-EDITOR.FIELDS.FIELD-REQUIRED' | translate}}</span></mat-checkbox>
|
||||
<mat-checkbox [disabled]="alwaysRequiredSystemFieldTypes.includes(field.get('systemFieldType')?.value)" [checked]="field.get('required').value" (change)="field.get('required').setValue($event.checked)"><span>{{'DMP-BLUEPRINT-EDITOR.FIELDS.FIELD-REQUIRED' | translate}}</span></mat-checkbox>
|
||||
<mat-error *ngIf="field.get('required').hasError('backendError')">{{field.get('required').getError('backendError').message}}</mat-error>
|
||||
<mat-error *ngIf="field.get('required').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||
</div>
|
||||
|
|
|
@ -10,19 +10,24 @@ import { EnumUtils } from '@app/core/services/utilities/enum-utils.service';
|
|||
import { CdkDragDrop, moveItemInArray } from '@angular/cdk/drag-drop';
|
||||
import { DatePipe } from '@angular/common';
|
||||
import { MatCheckboxChange } from '@angular/material/checkbox';
|
||||
import { MatSelectChange } from '@angular/material/select';
|
||||
import { DmpBlueprintFieldCategory } from '@app/core/common/enum/dmp-blueprint-field-category';
|
||||
import { DmpBlueprintExtraFieldDataType } from '@app/core/common/enum/dmp-blueprint-field-type';
|
||||
import { DmpBlueprintStatus } from '@app/core/common/enum/dmp-blueprint-status';
|
||||
import { DmpBlueprintSystemFieldType } from '@app/core/common/enum/dmp-blueprint-system-field-type';
|
||||
import { IsActive } from '@app/core/common/enum/is-active.enum';
|
||||
import { LockTargetType } from '@app/core/common/enum/lock-target-type';
|
||||
import { AppPermission } from '@app/core/common/enum/permission.enum';
|
||||
import { DescriptionTemplate } from '@app/core/model/description-template/description-template';
|
||||
import { DmpBlueprint, DmpBlueprintPersist, NewVersionDmpBlueprintPersist, SystemFieldInSection } from '@app/core/model/dmp-blueprint/dmp-blueprint';
|
||||
import { AuthService } from '@app/core/services/auth/auth.service';
|
||||
import { ConfigurationService } from '@app/core/services/configuration/configuration.service';
|
||||
import { DescriptionTemplateService } from '@app/core/services/description-template/description-template.service';
|
||||
import { LockService } from '@app/core/services/lock/lock.service';
|
||||
import { LoggingService } from '@app/core/services/logging/logging-service';
|
||||
import { MatomoService } from '@app/core/services/matomo/matomo-service';
|
||||
import { PrefillingSourceService } from '@app/core/services/prefilling-source/prefilling-source.service';
|
||||
import { ReferenceTypeService } from '@app/core/services/reference-type/reference-type.service';
|
||||
import { SemanticsService } from '@app/core/services/semantic/semantics.service';
|
||||
import { FileUtils } from '@app/core/services/utilities/file-utils.service';
|
||||
import { QueryParamsService } from '@app/core/services/utilities/query-params.service';
|
||||
import { SingleAutoCompleteConfiguration } from '@app/library/auto-complete/single/single-auto-complete-configuration';
|
||||
|
@ -37,15 +42,9 @@ import { TranslateService } from '@ngx-translate/core';
|
|||
import * as FileSaver from 'file-saver';
|
||||
import { map, takeUntil } from 'rxjs/operators';
|
||||
import { DescriptionTemplatePreviewDialogComponent } from '../../description-template/description-template-preview/description-template-preview-dialog.component';
|
||||
import { DmpBlueprintEditorModel } from './dmp-blueprint-editor.model';
|
||||
import { DmpBlueprintEditorModel, FieldInSectionEditorModel } from './dmp-blueprint-editor.model';
|
||||
import { DmpBlueprintEditorResolver } from './dmp-blueprint-editor.resolver';
|
||||
import { DmpBlueprintEditorService } from './dmp-blueprint-editor.service';
|
||||
import { ReferenceTypeService } from '@app/core/services/reference-type/reference-type.service';
|
||||
import { SemanticsService } from '@app/core/services/semantic/semantics.service';
|
||||
import { PrefillingSourceService } from '@app/core/services/prefilling-source/prefilling-source.service';
|
||||
import { ConfigurationService } from '@app/core/services/configuration/configuration.service';
|
||||
import { LockService } from '@app/core/services/lock/lock.service';
|
||||
import { LockTargetType } from '@app/core/common/enum/lock-target-type';
|
||||
|
||||
|
||||
@Component({
|
||||
|
@ -375,6 +374,10 @@ export class DmpBlueprintEditorComponent extends BaseEditor<DmpBlueprintEditorMo
|
|||
(this.formGroup.get('definition').get('sections') as FormArray).at(sectionIndex).get('fields').markAsDirty();
|
||||
}
|
||||
|
||||
get alwaysRequiredSystemFieldTypes(): DmpBlueprintSystemFieldType[] {
|
||||
return FieldInSectionEditorModel.alwaysRequiredSystemFieldTypes;
|
||||
}
|
||||
|
||||
|
||||
dropFields(event: CdkDragDrop<string[]>, sectionIndex: number) {
|
||||
const fieldsFormArray = ((this.formGroup.get('definition').get('sections') as FormArray).at(sectionIndex).get('fields') as FormArray);
|
||||
|
|
|
@ -105,7 +105,7 @@ export class DmpBlueprintDefinitionEditorModel implements DmpBlueprintDefinition
|
|||
|
||||
public fromModel(item: DmpBlueprintDefinition): DmpBlueprintDefinitionEditorModel {
|
||||
if (item) {
|
||||
if (item.sections) { item.sections.map(x => this.sections.push(new DmpBlueprintDefinitionSectionEditorModel(this.validationErrorModel).fromModel(x))); }
|
||||
if (item.sections) { item.sections.sort((a,b) => a.ordinal - b.ordinal).map(x => this.sections.push(new DmpBlueprintDefinitionSectionEditorModel(this.validationErrorModel).fromModel(x))); }
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
@ -189,7 +189,7 @@ export class DmpBlueprintDefinitionSectionEditorModel implements DmpBlueprintDef
|
|||
this.description = item.description;
|
||||
this.ordinal = item.ordinal;
|
||||
this.hasTemplates = item.hasTemplates;
|
||||
if (item.fields) { item.fields.map(x => this.fields.push(new FieldInSectionEditorModel(this.validationErrorModel).fromModel(x))); }
|
||||
if (item.fields) { item.fields.sort((a,b) => a.ordinal - b.ordinal).map(x => this.fields.push(new FieldInSectionEditorModel(this.validationErrorModel).fromModel(x))); }
|
||||
if (item.descriptionTemplates) { item.descriptionTemplates.map(x => this.descriptionTemplates.push(new DescriptionTemplatesInSectionEditorModel(this.validationErrorModel).fromModel(x))); }
|
||||
if (item.prefillingSources) this.prefillingSourcesIds = item.prefillingSources.map(x => x.id);
|
||||
}
|
||||
|
@ -309,6 +309,10 @@ export class FieldInSectionEditorModel implements FieldInSectionPersist {
|
|||
public systemFieldType: DmpBlueprintSystemFieldType;
|
||||
public referenceTypeId: Guid;
|
||||
|
||||
static get alwaysRequiredSystemFieldTypes(): DmpBlueprintSystemFieldType[] {
|
||||
return [DmpBlueprintSystemFieldType.Title, DmpBlueprintSystemFieldType.Description, DmpBlueprintSystemFieldType.Language, DmpBlueprintSystemFieldType.AccessRights];
|
||||
}
|
||||
|
||||
protected formBuilder: UntypedFormBuilder = new UntypedFormBuilder();
|
||||
|
||||
constructor(
|
||||
|
@ -327,6 +331,9 @@ export class FieldInSectionEditorModel implements FieldInSectionPersist {
|
|||
|
||||
if (this.category == DmpBlueprintFieldCategory.System) {
|
||||
this.systemFieldType = (item as SystemFieldInSection).systemFieldType;
|
||||
if (FieldInSectionEditorModel.alwaysRequiredSystemFieldTypes.includes(this.systemFieldType)) {
|
||||
this.required = true;
|
||||
}
|
||||
} else if (this.category == DmpBlueprintFieldCategory.Extra) {
|
||||
this.dataType = (item as ExtraFieldInSection).dataType;
|
||||
} else if (this.category == DmpBlueprintFieldCategory.ReferenceType) {
|
||||
|
|
Loading…
Reference in New Issue