Merge branch 'ui-refactoring' of https://gitlab.eudat.eu/dmp/OpenAIRE-EUDAT-DMP-service-pilot into ui-refactoring

This commit is contained in:
Diamantis Tziotzios 2019-02-11 15:46:39 +02:00
commit 61d8fa1181
21 changed files with 136 additions and 95 deletions

View File

@ -18,7 +18,7 @@ import java.util.UUID;
public class DatasetProfile implements DataEntity<DatasetProfile,UUID> { public class DatasetProfile implements DataEntity<DatasetProfile,UUID> {
public enum Status { public enum Status {
ACTIVE((short) 1), INACTIVE((short) 0), DELETED((short) 99); SAVED((short) 0), FINALIZED((short) 1), DELETED((short) 99);
private short value; private short value;
@ -33,9 +33,9 @@ public class DatasetProfile implements DataEntity<DatasetProfile,UUID> {
public static Status fromInteger(int value) { public static Status fromInteger(int value) {
switch (value) { switch (value) {
case 0: case 0:
return INACTIVE; return SAVED;
case 1: case 1:
return ACTIVE; return FINALIZED;
case 99: case 99:
return DELETED; return DELETED;
default: default:

View File

@ -55,6 +55,7 @@ public class Admin extends BaseController {
eu.eudat.data.entities.DatasetProfile modelDefinition = AdminManager.generateViewStyleDefinition(profile, getApiContext()); eu.eudat.data.entities.DatasetProfile modelDefinition = AdminManager.generateViewStyleDefinition(profile, getApiContext());
eu.eudat.data.entities.DatasetProfile datasetprofile = this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(id)); eu.eudat.data.entities.DatasetProfile datasetprofile = this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(id));
datasetprofile.setDefinition(modelDefinition.getDefinition()); datasetprofile.setDefinition(modelDefinition.getDefinition());
datasetprofile.setStatus(modelDefinition.getStatus());
this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao().createOrUpdate(datasetprofile); this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao().createOrUpdate(datasetprofile);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<UUID>().status(ApiMessageCode.NO_MESSAGE)); return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<UUID>().status(ApiMessageCode.NO_MESSAGE));
} }
@ -64,6 +65,7 @@ public class Admin extends BaseController {
eu.eudat.data.entities.DatasetProfile profile = this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(id)); eu.eudat.data.entities.DatasetProfile profile = this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(id));
eu.eudat.models.data.admin.composite.DatasetProfile datasetprofile = AdminManager.generateDatasetProfileModel(profile); eu.eudat.models.data.admin.composite.DatasetProfile datasetprofile = AdminManager.generateDatasetProfileModel(profile);
datasetprofile.setLabel(profile.getLabel()); datasetprofile.setLabel(profile.getLabel());
datasetprofile.setStatus(profile.getStatus());
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DatasetProfile>().status(ApiMessageCode.NO_MESSAGE).payload(datasetprofile)); return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DatasetProfile>().status(ApiMessageCode.NO_MESSAGE).payload(datasetprofile));
} }

View File

@ -26,7 +26,7 @@ public class AdminManager {
String xml = XmlBuilder.generateXml(viewStyleDoc); String xml = XmlBuilder.generateXml(viewStyleDoc);
eu.eudat.data.entities.DatasetProfile datasetProfile = apiContext.getOperationsContext().getBuilderFactory().getBuilder(DatasetProfileBuilder.class).definition(xml).label(profile.getLabel()) eu.eudat.data.entities.DatasetProfile datasetProfile = apiContext.getOperationsContext().getBuilderFactory().getBuilder(DatasetProfileBuilder.class).definition(xml).label(profile.getLabel())
.status((short) 1).created(new Date()) .status(profile.getStatus()).created(new Date())
.build(); .build();
return datasetProfile; return datasetProfile;

View File

@ -10,6 +10,7 @@ public class DatasetProfile {
private String label; private String label;
private List<Section> sections; private List<Section> sections;
private List<Page> pages; private List<Page> pages;
private Short status;
public List<Section> getSections() { public List<Section> getSections() {
return sections; return sections;
@ -35,6 +36,14 @@ public class DatasetProfile {
this.pages = pages; this.pages = pages;
} }
public Short getStatus() {
return status;
}
public void setStatus(Short status) {
this.status = status;
}
public void buildProfile(eu.eudat.models.data.entities.xmlmodels.datasetprofiledefinition.ViewStyleModel viewStyle) { public void buildProfile(eu.eudat.models.data.entities.xmlmodels.datasetprofiledefinition.ViewStyleModel viewStyle) {
this.sections = new ModelBuilder().fromViewStyleDefinition(viewStyle.getSections(), Section.class); this.sections = new ModelBuilder().fromViewStyleDefinition(viewStyle.getSections(), Section.class);
this.pages = new ModelBuilder().fromViewStyleDefinition(viewStyle.getPages(), Page.class); this.pages = new ModelBuilder().fromViewStyleDefinition(viewStyle.getPages(), Page.class);

View File

@ -0,0 +1,5 @@
export enum DatasetProfileEnum {
SAVED = 0,
FINALIZED = 1,
DELETED = 99
}

View File

@ -4,6 +4,7 @@ export interface DatasetProfile {
label: string; label: string;
sections: Section[]; sections: Section[];
pages: Page[]; pages: Page[];
status: number;
} }
export interface Page { export interface Page {

View File

@ -1,13 +1,13 @@
<div class="row"> <div class="row">
<h4 *ngIf="isComposite" style="font-weight: bold" class="col-auto">{{'DATASET-PROFILE-EDITOR.STEPS.FORM.COMPOSITE-FIELD.TITLE' <h4 *ngIf="isComposite" style="font-weight: bold" class="col-auto" >{{'DATASET-PROFILE-EDITOR.STEPS.FORM.COMPOSITE-FIELD.TITLE'
| translate}}</h4> | translate}}</h4>
<h4 *ngIf="!isComposite" style="font-weight: bold" class="col-auto">{{'DATASET-PROFILE-EDITOR.STEPS.FORM.COMPOSITE-FIELD.SIMPLE-FIELD-TITLE' <h4 *ngIf="!isComposite" style="font-weight: bold" class="col-auto">{{'DATASET-PROFILE-EDITOR.STEPS.FORM.COMPOSITE-FIELD.SIMPLE-FIELD-TITLE'
| translate}}</h4> | translate}}</h4>
<mat-checkbox class="col-auto" [(ngModel)]="isComposite" (ngModelChange)="onIsCompositeChange(isComposite)">{{'DATASET-PROFILE-EDITOR.STEPS.FORM.COMPOSITE-FIELD.FIELDS.COMPOSITE-CHECKBOX' <mat-checkbox class="col-auto" [(ngModel)]="isComposite" (ngModelChange)="onIsCompositeChange(isComposite)" [disabled]="viewOnly">{{'DATASET-PROFILE-EDITOR.STEPS.FORM.COMPOSITE-FIELD.FIELDS.COMPOSITE-CHECKBOX'
| translate}}</mat-checkbox> | translate}}</mat-checkbox>
<mat-checkbox class="col-auto" [(ngModel)]="isMultiplicityEnabled" (ngModelChange)="onIsMultiplicityEnabledChange(isMultiplicityEnabled)">{{'DATASET-PROFILE-EDITOR.STEPS.FORM.COMPOSITE-FIELD.FIELDS.MULTIPLICITY-CHECKBOX' <mat-checkbox class="col-auto" [(ngModel)]="isMultiplicityEnabled" (ngModelChange)="onIsMultiplicityEnabledChange(isMultiplicityEnabled)" [disabled]="viewOnly">{{'DATASET-PROFILE-EDITOR.STEPS.FORM.COMPOSITE-FIELD.FIELDS.MULTIPLICITY-CHECKBOX'
| translate}}</mat-checkbox> | translate}}</mat-checkbox>
<mat-checkbox class="col" [formControl]="this.form.get('hasCommentField')">{{'DATASET-PROFILE-EDITOR.STEPS.FORM.COMPOSITE-FIELD.FIELDS.COMMENT-CHECKBOX' <mat-checkbox class="col" [formControl]="this.form.get('hasCommentField')" [disabled]="viewOnly">{{'DATASET-PROFILE-EDITOR.STEPS.FORM.COMPOSITE-FIELD.FIELDS.COMMENT-CHECKBOX'
| translate}}</mat-checkbox> | translate}}</mat-checkbox>
</div> </div>
<div class="row"> <div class="row">
@ -51,7 +51,7 @@
[formControl]="this.form.get('extendedDescription')"></textarea> [formControl]="this.form.get('extendedDescription')"></textarea>
</mat-form-field> </mat-form-field>
<app-dataset-profile-editor-field-component class="col-12" *ngIf="!isComposite" [form]="form.get('fields').get(''+0)" <app-dataset-profile-editor-field-component class="col-12" *ngIf="!isComposite" [form]="form.get('fields').get(''+0)"
[showOrdinal]="false" [indexPath]="indexPath + 'f' + 0"></app-dataset-profile-editor-field-component> [showOrdinal]="false" [indexPath]="indexPath + 'f' + 0" [viewOnly]="viewOnly"></app-dataset-profile-editor-field-component>
</div> </div>
<div *ngIf="isComposite" class="row"> <div *ngIf="isComposite" class="row">
<h4 style="font-weight: bold" class="col-12">{{'DATASET-PROFILE-EDITOR.STEPS.FORM.COMPOSITE-FIELD.SUB-FIELDS-TITLE' | <h4 style="font-weight: bold" class="col-12">{{'DATASET-PROFILE-EDITOR.STEPS.FORM.COMPOSITE-FIELD.SUB-FIELDS-TITLE' |
@ -61,16 +61,16 @@
<mat-expansion-panel-header> <mat-expansion-panel-header>
<mat-panel-title>{{i + 1}}. {{getFieldTile(field, i)}}</mat-panel-title> <mat-panel-title>{{i + 1}}. {{getFieldTile(field, i)}}</mat-panel-title>
<div class="row"> <div class="row">
<button mat-icon-button type="button" class="deleteBtn col-auto" (click)="DeleteField(i);"> <button mat-icon-button type="button" class="deleteBtn col-auto" (click)="DeleteField(i);" [disabled]="viewOnly">
<mat-icon>delete</mat-icon> <mat-icon>delete</mat-icon>
</button> </button>
</div> </div>
</mat-expansion-panel-header> </mat-expansion-panel-header>
<div id="{{indexPath + 'f' + i}}" *ngIf="panel.expanded"> <div id="{{indexPath + 'f' + i}}" *ngIf="panel.expanded">
<app-dataset-profile-editor-field-component [form]="form.get('fields').get(''+i)" [indexPath]="indexPath + 'f' + i"></app-dataset-profile-editor-field-component> <app-dataset-profile-editor-field-component [form]="form.get('fields').get(''+i)" [indexPath]="indexPath + 'f' + i" [viewOnly]="viewOnly"></app-dataset-profile-editor-field-component>
</div> </div>
</mat-expansion-panel> </mat-expansion-panel>
</div> </div>
<div class="col-12"><button mat-button class="full-width" (click)="addNewField()">{{'DATASET-PROFILE-EDITOR.STEPS.FORM.COMPOSITE-FIELD.ACTIONS.ADD-CHILD-FIELD' <div class="col-12"><button mat-button class="full-width" (click)="addNewField()" [disabled]="viewOnly">{{'DATASET-PROFILE-EDITOR.STEPS.FORM.COMPOSITE-FIELD.ACTIONS.ADD-CHILD-FIELD'
| translate}}</button></div> | translate}}</button></div>
</div> </div>

View File

@ -11,6 +11,7 @@ export class DatasetProfileEditorCompositeFieldComponent implements OnInit {
@Input() form: FormGroup; @Input() form: FormGroup;
@Input() indexPath: string; @Input() indexPath: string;
@Input() viewOnly: boolean;
isComposite = false; isComposite = false;
isMultiplicityEnabled = false; isMultiplicityEnabled = false;

View File

@ -1,7 +1,7 @@
<div class="row"> <div class="row">
<mat-form-field class="col"> <mat-form-field class="col">
<input matInput placeholder="{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.ID' | translate}}" type="text" <input matInput placeholder="{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.ID' | translate}}" type="text" [formControl]="this.form.get('id')"
[formControl]="this.form.get('id')" required> required>
<mat-error *ngIf="this.form.get('id').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error> <mat-error *ngIf="this.form.get('id').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
<mat-error *ngIf="this.form.get('id').hasError('pattern')">{{'GENERAL.VALIDATION.PATTERN-_' | translate}}</mat-error> <mat-error *ngIf="this.form.get('id').hasError('pattern')">{{'GENERAL.VALIDATION.PATTERN-_' | translate}}</mat-error>
</mat-form-field> </mat-form-field>
@ -16,18 +16,16 @@
<mat-option [value]="viewStyleEnum.RadioBox">{{enumUtils.toDatasetProfileFieldViewStyleString(viewStyleEnum.RadioBox)}}</mat-option> <mat-option [value]="viewStyleEnum.RadioBox">{{enumUtils.toDatasetProfileFieldViewStyleString(viewStyleEnum.RadioBox)}}</mat-option>
<mat-option [value]="viewStyleEnum.TextArea">{{enumUtils.toDatasetProfileFieldViewStyleString(viewStyleEnum.TextArea)}}</mat-option> <mat-option [value]="viewStyleEnum.TextArea">{{enumUtils.toDatasetProfileFieldViewStyleString(viewStyleEnum.TextArea)}}</mat-option>
</mat-select> </mat-select>
<mat-error *ngIf="this.form.get('viewStyle').get('renderStyle').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' <mat-error *ngIf="this.form.get('viewStyle').get('renderStyle').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
| translate}}</mat-error>
</mat-form-field> </mat-form-field>
<mat-form-field *ngIf="showOrdinal" class="col"> <mat-form-field *ngIf="showOrdinal" class="col">
<input matInput type="number" placeholder="{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.ORDER' | translate}}" <input matInput type="number" placeholder="{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.ORDER' | translate}}" [formControl]="this.form.get('ordinal')">
[formControl]="this.form.get('ordinal')">
</mat-form-field> </mat-form-field>
<!-- Default Value --> <!-- Default Value -->
<app-component-profile-editor-default-value-component *ngIf="form.get('viewStyle').get('renderStyle').value" class="col" <app-component-profile-editor-default-value-component *ngIf="form.get('viewStyle').get('renderStyle').value" class="col"
[viewStyle]="form.get('viewStyle').get('renderStyle').value" [form]="this.form.get('defaultValue').get('value')" [viewStyle]="form.get('viewStyle').get('renderStyle').value" [form]="this.form.get('defaultValue').get('value')" [formArrayOptions]="form.get('data')?.get('options')"
[formArrayOptions]="form.get('data')?.get('options')" [comboBoxType]="this.form.get('data')?.get('type')?.value" [comboBoxType]="this.form.get('data')?.get('type')?.value" placeHolder="{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.DEFAULT-VALUE' | translate}}"
placeHolder="{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.DEFAULT-VALUE' | translate}}" [required]="defaulValueRequired(form.get('viewStyle').get('renderStyle').value)"></app-component-profile-editor-default-value-component> [required]="defaulValueRequired(form.get('viewStyle').get('renderStyle').value)"></app-component-profile-editor-default-value-component>
<mat-form-field class="col" *ngIf="!(defaulValueRequired(form.get('viewStyle').get('renderStyle').value))"> <mat-form-field class="col" *ngIf="!(defaulValueRequired(form.get('viewStyle').get('renderStyle').value))">
@ -48,11 +46,12 @@
<app-dataset-profile-editor-checkbox-field-component *ngSwitchCase="viewStyleEnum.CheckBox" class="col-12" [form]="form"></app-dataset-profile-editor-checkbox-field-component> <app-dataset-profile-editor-checkbox-field-component *ngSwitchCase="viewStyleEnum.CheckBox" class="col-12" [form]="form"></app-dataset-profile-editor-checkbox-field-component>
</div> </div>
<div class="row"> <div class="row">
<h4 class="col-12" style="font-weight: bold">{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.RULES-TITLE' | <h4 class="col-12" style="font-weight: bold">{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.RULES-TITLE' | translate}}
translate}}</h4> </h4>
<app-dataset-profile-editor-rule-component class="col-12" [form]="form.get('visible').get('rules')" <app-dataset-profile-editor-rule-component class="col-12" [form]="form.get('visible').get('rules')" [viewStyleForCheck]="form.get('viewStyle').get('renderStyle').value"
[viewStyleForCheck]="form.get('viewStyle').get('renderStyle').value" [formArrayOptionsForCheck]="this.form.get('data')?.get('options')" [formArrayOptionsForCheck]="this.form.get('data')?.get('options')" [comboBoxTypeForCheck]="this.form.get('data')?.get('type')?.value"
[comboBoxTypeForCheck]="this.form.get('data')?.get('type')?.value"></app-dataset-profile-editor-rule-component> [viewOnly]="viewOnly"></app-dataset-profile-editor-rule-component>
<div class="col-12"><button mat-button class="full-width" (click)="addNewRule()" [disabled]="!form.get('viewStyle').get('renderStyle').value">{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.ACTIONS.ADD-RULE' <div class="col-12" *ngIf="!viewOnly">
| translate}}</button></div> <button mat-button class="full-width" (click)="addNewRule()" [disabled]="!form.get('viewStyle').get('renderStyle').value">{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.ACTIONS.ADD-RULE' | translate}}</button>
</div>
</div> </div>

View File

@ -20,7 +20,7 @@ import { RuleEditorModel } from '../../../admin/rule-editor-model';
styleUrls: ['./dataset-profile-editor-field.component.scss'] styleUrls: ['./dataset-profile-editor-field.component.scss']
}) })
export class DatasetProfileEditorFieldComponent extends BaseComponent implements OnInit { export class DatasetProfileEditorFieldComponent extends BaseComponent implements OnInit {
@Input() viewOnly: boolean;
@Input() form: FormGroup; @Input() form: FormGroup;
@Input() showOrdinal = true; @Input() showOrdinal = true;
@Input() indexPath: string; @Input() indexPath: string;
@ -82,7 +82,7 @@ export class DatasetProfileEditorFieldComponent extends BaseComponent implements
case DatasetProfileFieldViewStyle.BooleanDecision: case DatasetProfileFieldViewStyle.BooleanDecision:
return false; return false;
default: default:
return false; return false;
} }
} }

View File

@ -6,7 +6,7 @@
[formControl]="pageControl.get('title')" required> [formControl]="pageControl.get('title')" required>
<mat-error *ngIf="pageControl.get('title').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error> <mat-error *ngIf="pageControl.get('title').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field> </mat-form-field>
<button mat-icon-button type="button" class="col-auto" (click)="removePage(i)"> <button mat-icon-button type="button" class="col-auto" (click)="removePage(i)" [disabled]="viewOnly">
<mat-icon>delete</mat-icon> <mat-icon>delete</mat-icon>
</button> </button>
</div> </div>

View File

@ -9,6 +9,7 @@ import { FormArray } from '@angular/forms';
export class DatasetProfileEditorPageComponent { export class DatasetProfileEditorPageComponent {
@Input() form: FormArray; @Input() form: FormArray;
@Input() viewOnly: boolean;
removePage(index) { removePage(index) {
(<FormArray>this.form).removeAt(index); (<FormArray>this.form).removeAt(index);

View File

@ -17,7 +17,7 @@
</mat-form-field> </mat-form-field>
<div class="col-auto"><button mat-icon-button type="button" (click)="deleteRule(i);"> <div class="col-auto"><button mat-icon-button type="button" (click)="deleteRule(i);" [disabled]="viewOnly">
<mat-icon>delete</mat-icon> <mat-icon>delete</mat-icon>
</button> </button>
</div> </div>

View File

@ -17,7 +17,7 @@ export class DatasetProfileEditorRuleComponent {
@Input() formControlForCheck: FormControl; @Input() formControlForCheck: FormControl;
@Input() formArrayOptionsForCheck: FormArray; @Input() formArrayOptionsForCheck: FormArray;
@Input() comboBoxTypeForCheck: DatasetProfileComboBoxType; @Input() comboBoxTypeForCheck: DatasetProfileComboBoxType;
@Input() viewOnly: boolean;
targetValidation() { targetValidation() {
//TODO //TODO

View File

@ -35,14 +35,14 @@
<mat-card class="field-card" *ngFor="let fieldControl of form.get('fieldSets')['controls'] let i=index;"> <mat-card class="field-card" *ngFor="let fieldControl of form.get('fieldSets')['controls'] let i=index;">
<div class="row"> <div class="row">
<mat-card-title class="col">{{i + 1}}. {{getFieldTile(fieldControl, i)}}</mat-card-title> <mat-card-title class="col">{{i + 1}}. {{getFieldTile(fieldControl, i)}}</mat-card-title>
<button mat-icon-button type="button" class="deleteBtn col-auto" (click)="deleteFieldSet(i);"> <button mat-icon-button type="button" class="deleteBtn col-auto" (click)="deleteFieldSet(i);" [disabled]="viewOnly">
<mat-icon>delete</mat-icon> <mat-icon>delete</mat-icon>
</button> </button>
<app-dataset-profile-editor-composite-field-component class="col-12" [form]="fieldControl" [indexPath]="indexPath + 'cf' + i"></app-dataset-profile-editor-composite-field-component> <app-dataset-profile-editor-composite-field-component class="col-12" [form]="fieldControl" [indexPath]="indexPath + 'cf' + i" [viewOnly]="viewOnly"></app-dataset-profile-editor-composite-field-component>
</div> </div>
</mat-card> </mat-card>
</div> </div>
<div class="col-12"><button mat-button class="full-width" (click)="addField()">{{'DATASET-PROFILE-EDITOR.STEPS.FORM.SECTION.ACTIONS.ADD-FIELD' <div class="col-12"><button mat-button class="full-width" (click)="addField()" [disabled]="viewOnly">{{'DATASET-PROFILE-EDITOR.STEPS.FORM.SECTION.ACTIONS.ADD-FIELD'
| translate}}</button></div> | translate}}</button></div>
<h4 style="font-weight: bold" class="col-12">{{'DATASET-PROFILE-EDITOR.STEPS.FORM.SECTION.FIELDS.SUB-SECTIONS-TITLE' | <h4 style="font-weight: bold" class="col-12">{{'DATASET-PROFILE-EDITOR.STEPS.FORM.SECTION.FIELDS.SUB-SECTIONS-TITLE' |
translate}}</h4> translate}}</h4>
@ -52,18 +52,18 @@
<mat-panel-title>{{i + 1}}. {{form.get('sections').get(''+i).get('title').value}}</mat-panel-title> <mat-panel-title>{{i + 1}}. {{form.get('sections').get(''+i).get('title').value}}</mat-panel-title>
<div class="row"> <div class="row">
<!-- <span class="col">{{i + 1}}. {{form.get('sections').get(''+i).get('title').value}}</span> --> <!-- <span class="col">{{i + 1}}. {{form.get('sections').get(''+i).get('title').value}}</span> -->
<button mat-icon-button type="button" class="deleteBtn col-auto" (click)="DeleteSectionInSection(i);"> <button mat-icon-button type="button" class="deleteBtn col-auto" (click)="DeleteSectionInSection(i);" [disabled]="viewOnly">
<mat-icon>delete</mat-icon> <mat-icon>delete</mat-icon>
</button> </button>
</div> </div>
</mat-expansion-panel-header> </mat-expansion-panel-header>
<div id="{{indexPath + 's' + i}}" *ngIf="panel.expanded" class="row"> <div id="{{indexPath + 's' + i}}" *ngIf="panel.expanded" class="row">
<app-dataset-profile-editor-section-component class="col-12" [form]="form.get('sections').get(''+i)" [dataModel]="section" <app-dataset-profile-editor-section-component class="col-12" [form]="form.get('sections').get(''+i)" [dataModel]="section"
[indexPath]="indexPath + 's' + i"></app-dataset-profile-editor-section-component> [indexPath]="indexPath + 's' + i" [viewOnly]="viewOnly"></app-dataset-profile-editor-section-component>
</div> </div>
</mat-expansion-panel> </mat-expansion-panel>
</div> </div>
<div class="col-12"><button mat-button class="full-width" (click)="addSectioninSection()">{{'DATASET-PROFILE-EDITOR.STEPS.FORM.SECTION.ACTIONS.ADD-SUB-SECTION' <div class="col-12"><button mat-button class="full-width" (click)="addSectioninSection()" [disabled]="viewOnly">{{'DATASET-PROFILE-EDITOR.STEPS.FORM.SECTION.ACTIONS.ADD-SUB-SECTION'
| translate}}</button></div> | translate}}</button></div>
</div> </div>

View File

@ -17,6 +17,7 @@ export class DatasetProfileEditorSectionComponent extends BaseComponent implemen
@Input() form: FormGroup; @Input() form: FormGroup;
@Input() dataModel: SectionEditorModel; @Input() dataModel: SectionEditorModel;
@Input() indexPath: string; @Input() indexPath: string;
@Input() viewOnly: boolean;
constructor() { super(); } constructor() { super(); }

View File

@ -10,11 +10,13 @@ export class DatasetProfileEditorModel extends BaseFormModel {
public sections: Array<SectionEditorModel> = new Array<SectionEditorModel>(); public sections: Array<SectionEditorModel> = new Array<SectionEditorModel>();
public pages: Array<PageEditorModel> = new Array<PageEditorModel>(); public pages: Array<PageEditorModel> = new Array<PageEditorModel>();
public label: string; public label: string;
public status: number;
fromModel(item: DatasetProfile): DatasetProfileEditorModel { fromModel(item: DatasetProfile): DatasetProfileEditorModel {
if (item.sections) { this.sections = item.sections.map(x => new SectionEditorModel().fromModel(x)); } if (item.sections) { this.sections = item.sections.map(x => new SectionEditorModel().fromModel(x)); }
if (item.pages) { this.pages = item.pages.map(x => new PageEditorModel().fromModel(x)); } if (item.pages) { this.pages = item.pages.map(x => new PageEditorModel().fromModel(x)); }
this.label = item.label; this.label = item.label;
this.status = item.status;
return this; return this;
} }
@ -34,8 +36,8 @@ export class DatasetProfileEditorModel extends BaseFormModel {
pagesFormArray.push(form); pagesFormArray.push(form);
}); });
formGroup.addControl('pages', this.formBuilder.array(pagesFormArray)); formGroup.addControl('pages', this.formBuilder.array(pagesFormArray));
formGroup.addControl('label', new FormControl(this.label, Validators.required)); formGroup.addControl('label', new FormControl(this.label, Validators.required));
formGroup.addControl('status', new FormControl(this.status));
return formGroup; return formGroup;
} }
} }

View File

@ -1,7 +1,6 @@
<div class="container" *ngIf="form" [formGroup]='form' class="dataset-profile-editor"> <div class="container" *ngIf="form" [formGroup]='form' class="dataset-profile-editor">
<mat-form-field class="full-width"> <mat-form-field class="full-width">
<input matInput formControlName="label" placeholder="{{'DATASET-PROFILE-EDITOR.FIELDS.DATASET-TITLE' | translate}}" <input matInput formControlName="label" placeholder="{{'DATASET-PROFILE-EDITOR.FIELDS.DATASET-TITLE' | translate}}" required>
required>
<mat-error *ngIf="form.get('label').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error> <mat-error *ngIf="form.get('label').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field> </mat-form-field>
@ -9,9 +8,10 @@
<mat-step> <mat-step>
<ng-template matStepLabel>{{'DATASET-PROFILE-EDITOR.STEPS.PAGES.TITLE' | translate}}</ng-template> <ng-template matStepLabel>{{'DATASET-PROFILE-EDITOR.STEPS.PAGES.TITLE' | translate}}</ng-template>
<div class="row"> <div class="row">
<app-dataset-profile-editor-page-component class="col-12" [form]="form.get('pages')"></app-dataset-profile-editor-page-component> <app-dataset-profile-editor-page-component class="col-12" [form]="form.get('pages')" [viewOnly]="viewOnly"></app-dataset-profile-editor-page-component>
<div class="col-12"><button mat-button class="full-width" (click)="addPage()">{{'DATASET-PROFILE-EDITOR.ACTIONS.ADD-PAGE' <div class="col-12">
| translate}}</button></div> <button mat-button class="full-width" (click)="addPage()" [disabled]="viewOnly">{{'DATASET-PROFILE-EDITOR.ACTIONS.ADD-PAGE' | translate}}</button>
</div>
</div> </div>
</mat-step> </mat-step>
<mat-step> <mat-step>
@ -21,18 +21,19 @@
<mat-expansion-panel *ngFor="let section of dataModel.sections; let i=index;" #panel> <mat-expansion-panel *ngFor="let section of dataModel.sections; let i=index;" #panel>
<mat-expansion-panel-header> <mat-expansion-panel-header>
<mat-panel-title>{{i + 1}}. {{form.get('sections').get(''+i).get('title').value}}</mat-panel-title> <mat-panel-title>{{i + 1}}. {{form.get('sections').get(''+i).get('title').value}}</mat-panel-title>
<button mat-icon-button type="button" (click)="DeleteSection(i);"> <button mat-icon-button type="button" (click)="DeleteSection(i);" [disabled]="viewOnly">
<mat-icon>delete</mat-icon> <mat-icon>delete</mat-icon>
</button> </button>
</mat-expansion-panel-header> </mat-expansion-panel-header>
<div id="{{'s' + i}}" class="row" *ngIf="panel.expanded"> <div id="{{'s' + i}}" class="row" *ngIf="panel.expanded">
<app-dataset-profile-editor-section-component class="col-12" [form]="form.get('sections').get(''+i)" [dataModel]="section" <app-dataset-profile-editor-section-component class="col-12" [form]="form.get('sections').get(''+i)" [dataModel]="section"
[indexPath]="'s' + i"></app-dataset-profile-editor-section-component> [indexPath]="'s' + i" [viewOnly]="viewOnly"></app-dataset-profile-editor-section-component>
</div> </div>
</mat-expansion-panel> </mat-expansion-panel>
</mat-accordion> </mat-accordion>
<div class="col-12"><button mat-button (click)="addSection()" class="full-width">{{'DATASET-PROFILE-EDITOR.ACTIONS.ADD-SECTION' <div class="col-12">
| translate}}</button></div> <button mat-button (click)="addSection()" class="full-width" [disabled]="viewOnly">{{'DATASET-PROFILE-EDITOR.ACTIONS.ADD-SECTION' | translate}}</button>
</div>
</div> </div>
</mat-step> </mat-step>
<!-- <mat-step> <!-- <mat-step>
@ -44,11 +45,17 @@
</mat-horizontal-stepper> </mat-horizontal-stepper>
<div class="row"> <div class="row">
<!-- SAVE BUTTON --> <!-- SAVE BUTTON -->
<button mat-raised-button color="primary" type="button col-auto" (click)='onSubmit()' [disabled]="!form.valid">Save</button> <div class="col-auto" *ngIf="!viewOnly">
<div class="row">
<button mat-raised-button color="primary" type="button col-auto" (click)='onSubmit()' [disabled]="!form.valid">Save</button>
<div class="col-1"></div>
<button mat-raised-button color="primary" type="button col-auto" (click)='finalize()' [disabled]="!form.valid">Finalize</button>
</div>
</div>
<div class="col"></div> <div class="col"></div>
<!-- DELETE BUTTON --> <!-- DELETE BUTTON -->
<div class="col-auto" *ngIf="!isNew"> <div class="col-auto" *ngIf="!isNew">
<button mat-raised-button (click)="delete()"> <button mat-raised-button color="primary" (click)="delete()">
<mat-icon>delete</mat-icon>{{'DATASET-PROFILE-EDITOR.ACTIONS.DELETE' | translate}} <mat-icon>delete</mat-icon>{{'DATASET-PROFILE-EDITOR.ACTIONS.DELETE' | translate}}
</button> </button>
</div> </div>

View File

@ -15,6 +15,7 @@ import { PageEditorModel } from '../admin/page-editor-model';
import { SectionEditorModel } from '../admin/section-editor-model'; import { SectionEditorModel } from '../admin/section-editor-model';
import { DatasetProfileEditorModel } from './dataset-profile-editor-model'; import { DatasetProfileEditorModel } from './dataset-profile-editor-model';
import { ConfirmationDialogComponent } from '../../../../library/confirmation-dialog/confirmation-dialog.component'; import { ConfirmationDialogComponent } from '../../../../library/confirmation-dialog/confirmation-dialog.component';
import { DatasetProfileEnum } from '../../../../core/common/enum/dataset-profile';
@Component({ @Component({
selector: 'app-dataset-profile-editor-component', selector: 'app-dataset-profile-editor-component',
@ -31,7 +32,7 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn
private datasetProfileId: string; private datasetProfileId: string;
dataWizardModel: DatasetWizardModel; dataWizardModel: DatasetWizardModel;
@ViewChild('stepper') stepper: MatHorizontalStepper; @ViewChild('stepper') stepper: MatHorizontalStepper;
viewOnly = false;
constructor( constructor(
private datasetProfileService: DatasetProfileService, private datasetProfileService: DatasetProfileService,
@ -48,7 +49,6 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn
} }
ngOnInit() { ngOnInit() {
this.route.paramMap.pipe(takeUntil(this._destroyed)).subscribe((paramMap: ParamMap) => { this.route.paramMap.pipe(takeUntil(this._destroyed)).subscribe((paramMap: ParamMap) => {
this.datasetProfileId = paramMap.get('id'); this.datasetProfileId = paramMap.get('id');
const cloneId = paramMap.get('cloneid'); const cloneId = paramMap.get('cloneid');
@ -58,39 +58,48 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn
this.datasetProfileService.getDatasetProfileById(this.datasetProfileId) this.datasetProfileService.getDatasetProfileById(this.datasetProfileId)
.pipe(map(data => data as DatasetProfile), takeUntil(this._destroyed)) .pipe(map(data => data as DatasetProfile), takeUntil(this._destroyed))
.subscribe( .subscribe(
data => { data => {
try { try {
this.dataModel = new DatasetProfileEditorModel().fromModel(data); this.dataModel = new DatasetProfileEditorModel().fromModel(data);
// this.isDeleted = this.masterItem.isActive === IsActive.Inactive; // this.isDeleted = this.masterItem.isActive === IsActive.Inactive;
this.form = this.dataModel.buildForm(); this.form = this.dataModel.buildForm();
this.prepareForm(); if (this.dataModel.status === DatasetProfileEnum.FINALIZED) {
} catch { this.form.disable();
this.logger.error('Could not parse MasterItem: ' + data); this.viewOnly = true;
this.uiNotificationService.snackBarNotification(this.language.instant('NOTIFICATIONS.DEFAULT.ERROR'), SnackBarNotificationLevel.Error);
} }
}, this.prepareForm();
error => this.onCallbackError(error) } catch {
this.logger.error('Could not parse MasterItem: ' + data);
this.uiNotificationService.snackBarNotification(this.language.instant('NOTIFICATIONS.DEFAULT.ERROR'), SnackBarNotificationLevel.Error);
}
},
error => this.onCallbackError(error)
); );
} else if (cloneId != null) { } else if (cloneId != null) {
this.datasetProfileService.clone(cloneId) this.datasetProfileService.clone(cloneId)
.pipe(map(data => data as DatasetProfile), takeUntil(this._destroyed)) .pipe(map(data => data as DatasetProfile), takeUntil(this._destroyed))
.subscribe( .subscribe(
data => { data => {
try { try {
this.dataModel = new DatasetProfileEditorModel().fromModel(data); this.dataModel = new DatasetProfileEditorModel().fromModel(data);
// this.isDeleted = this.masterItem.isActive === IsActive.Inactive; // this.isDeleted = this.masterItem.isActive === IsActive.Inactive;
this.form = this.dataModel.buildForm(); this.dataModel.status = DatasetProfileEnum.SAVED;
this.prepareForm(); this.form = this.dataModel.buildForm();
} catch { this.prepareForm();
this.logger.error('Could not parse MasterItem: ' + data); } catch {
this.uiNotificationService.snackBarNotification(this.language.instant('NOTIFICATIONS.DEFAULT.ERROR'), SnackBarNotificationLevel.Error); this.logger.error('Could not parse MasterItem: ' + data);
} this.uiNotificationService.snackBarNotification(this.language.instant('NOTIFICATIONS.DEFAULT.ERROR'), SnackBarNotificationLevel.Error);
}, }
error => this.onCallbackError(error) },
error => this.onCallbackError(error)
); );
} else { } else {
this.dataModel = new DatasetProfileEditorModel(); this.dataModel = new DatasetProfileEditorModel();
this.form = this.dataModel.buildForm(); this.form = this.dataModel.buildForm();
if (this.dataModel.status === DatasetProfileEnum.FINALIZED) {
this.form.disable();
this.viewOnly = true;
}
this.addSection(); this.addSection();
this.addPage(); this.addPage();
} }
@ -155,6 +164,13 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn
} }
} }
finalize() {
//const data = this.form.value;
this.form.get('status').setValue(DatasetProfileEnum.FINALIZED);
this.onSubmit();
}
isStepActive(step: number) { isStepActive(step: number) {
return this.stepper && this.stepper.selectedIndex === step; return this.stepper && this.stepper.selectedIndex === step;
} }
@ -174,7 +190,6 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn
// } // }
} }
// DELETE Function // DELETE Function
public delete(): void { public delete(): void {
if (this.datasetProfileId && !this.isNew) { if (this.datasetProfileId && !this.isNew) {
@ -190,14 +205,14 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn
this.datasetProfileService.delete(this.datasetProfileId) this.datasetProfileService.delete(this.datasetProfileId)
.pipe(takeUntil(this._destroyed)) .pipe(takeUntil(this._destroyed))
.subscribe( .subscribe(
complete => { complete => {
this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-DATASET-PROFILE-DELETE'), SnackBarNotificationLevel.Success); this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-DATASET-PROFILE-DELETE'), SnackBarNotificationLevel.Success);
this.router.navigate(['/dataset-profiles']); this.router.navigate(['/dataset-profiles']);
}, },
error => { error => {
this.onCallbackError(error); this.onCallbackError(error);
this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.UNSUCCESSFUL-DATASET-PROFILE-DELETE'), SnackBarNotificationLevel.Success); this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.UNSUCCESSFUL-DATASET-PROFILE-DELETE'), SnackBarNotificationLevel.Success);
} }
); );
} }
}); });

View File

@ -71,7 +71,6 @@ export class DatasetProfileListingComponent extends BaseComponent implements OnI
getDefaultCriteria(dmpId: String): DatasetProfileCriteria { getDefaultCriteria(dmpId: String): DatasetProfileCriteria {
const defaultCriteria = new DatasetProfileCriteria(); const defaultCriteria = new DatasetProfileCriteria();
return defaultCriteria; return defaultCriteria;
} }
@ -83,7 +82,6 @@ export class DatasetProfileListingComponent extends BaseComponent implements OnI
// debugger; // debugger;
// this.datasetService.makeDatasetPublic(id).pipe(takeUntil(this._destroyed)).subscribe(); // this.datasetService.makeDatasetPublic(id).pipe(takeUntil(this._destroyed)).subscribe();
// } // }
} }
export class DatasetDataSource extends DataSource<DatasetListingModel> { export class DatasetDataSource extends DataSource<DatasetListingModel> {

View File

@ -146,7 +146,7 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, IBr
this.formGroup.disable(); this.formGroup.disable();
this.viewOnly = true; this.viewOnly = true;
} }
if (this.viewOnly) { this.formGroup.disable(); } // if (this.viewOnly) { this.formGroup.disable(); } // For future use, to make Dataset edit like DMP.
this.loadDatasetProfiles(); this.loadDatasetProfiles();
}); });
} else if (dmpId != null) { } else if (dmpId != null) {
@ -191,7 +191,7 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, IBr
this.formGroup.disable(); this.formGroup.disable();
this.viewOnly = true; this.viewOnly = true;
} }
if (this.viewOnly) { this.formGroup.disable(); } //if (this.viewOnly) { this.formGroup.disable(); } // For future use, to make Dataset edit like DMP.
this.formGroup.get('dmp').valueChanges this.formGroup.get('dmp').valueChanges
.pipe(takeUntil(this._destroyed)) .pipe(takeUntil(this._destroyed))
.subscribe(x => { .subscribe(x => {