diff --git a/src/app/dialogs/dialog-model-edit/dialog-model-edit.component.html b/src/app/dialogs/dialog-model-edit/dialog-model-edit.component.html
index adcf217..f977599 100644
--- a/src/app/dialogs/dialog-model-edit/dialog-model-edit.component.html
+++ b/src/app/dialogs/dialog-model-edit/dialog-model-edit.component.html
@@ -5,6 +5,13 @@
Edit model
Id is required
+
+ Version
+
+
+
+ Version must be in format Major.Minor.Patch
+
Title
@@ -37,7 +44,7 @@ Edit model
Permissions ({{this.modelService.numberOfPermissions()}})
diff --git a/src/app/dialogs/dialog-model-edit/dialog-model-edit.component.ts b/src/app/dialogs/dialog-model-edit/dialog-model-edit.component.ts
index f03e57b..b3be492 100644
--- a/src/app/dialogs/dialog-model-edit/dialog-model-edit.component.ts
+++ b/src/app/dialogs/dialog-model-edit/dialog-model-edit.component.ts
@@ -1,11 +1,11 @@
-import {Component, Inject, OnInit} from '@angular/core';
+import {Component, Inject} from '@angular/core';
import {ChangedPetriNet} from './changed-petri-net';
import {MAT_DIALOG_DATA, MatDialog} from '@angular/material/dialog';
import {ModelService} from '../../modeler/services/model/model.service';
import {Router} from '@angular/router';
import {DialogManageRolesComponent, RoleRefType} from '../dialog-manage-roles/dialog-manage-roles.component';
import {DataType} from '@netgrif/petriflow';
-import {FormControl, Validators} from '@angular/forms';
+import {FormControl, ValidatorFn, Validators} from '@angular/forms';
@Component({
selector: 'nab-dialog-model-edit',
@@ -16,6 +16,7 @@ export class DialogModelEditComponent {
public model: ChangedPetriNet;
public idCtrl: FormControl;
+ public versionCtrl: FormControl;
public titleCtrl: FormControl;
public initialsCtrl: FormControl;
@@ -27,6 +28,10 @@ export class DialogModelEditComponent {
) {
this.model = data;
this.idCtrl = new FormControl('', [Validators.required]);
+ this.versionCtrl = new FormControl('', [
+ // Validators.required,
+ this.validVersion()
+ ]);
this.titleCtrl = new FormControl('', [Validators.required]);
this.initialsCtrl = new FormControl('', [Validators.required]);
}
@@ -48,4 +53,17 @@ export class DialogModelEditComponent {
// TODO: NAB-327 open process view
this.router.navigate(['modeler/actions']);
}
+
+ private validVersion(): ValidatorFn {
+ return (fc: FormControl): { [key: string]: any } | null => {
+ const version = fc.value as string;
+ if (!version || version.length === 0) {
+ return null;
+ }
+ if (version.match(/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/)) {
+ return null;
+ }
+ return ({format: true})
+ };
+ }
}
diff --git a/src/app/modeler/edit-mode/context-menu/menu-items/model/edit-model-menu-item.ts b/src/app/modeler/edit-mode/context-menu/menu-items/model/edit-model-menu-item.ts
index 3bba81e..c6f9bd8 100644
--- a/src/app/modeler/edit-mode/context-menu/menu-items/model/edit-model-menu-item.ts
+++ b/src/app/modeler/edit-mode/context-menu/menu-items/model/edit-model-menu-item.ts
@@ -14,7 +14,9 @@ export class EditModelMenuItem extends MenuItem {
width: '50%',
data: new ChangedPetriNet(tool.model.id, tool.model.clone())
}, (changedModel: ChangedPetriNet) => {
- tool.modelService.updateModel(changedModel);
+ if (changedModel != undefined) {
+ tool.modelService.updateModel(changedModel);
+ }
});
}
);
diff --git a/src/app/modeler/services/model/model-config.ts b/src/app/modeler/services/model/model-config.ts
index b421c14..2502f18 100644
--- a/src/app/modeler/services/model/model-config.ts
+++ b/src/app/modeler/services/model/model-config.ts
@@ -1,6 +1,7 @@
export class ModelConfig {
public static FILE_NAME = 'newmodel.xml';
public static IDENTIFIER = 'new_model';
+ public static VERSION = '1.0.0';
public static TITLE = 'New Model';
public static ICON = 'device_hub';
public static INITIALS = 'NEW';
diff --git a/src/app/modeler/services/model/model.service.ts b/src/app/modeler/services/model/model.service.ts
index e0c70ff..d8a5fa1 100644
--- a/src/app/modeler/services/model/model.service.ts
+++ b/src/app/modeler/services/model/model.service.ts
@@ -68,6 +68,7 @@ export class ModelService implements ModelSource {
newModel(): PetriNet {
const model = new PetriNet();
model.id = ModelConfig.IDENTIFIER;
+ model.version = ModelConfig.VERSION;
model.title = new I18nString(ModelConfig.TITLE);
model.initials = ModelConfig.INITIALS;
model.icon = ModelConfig.ICON;
diff --git a/src/assets/mortgage_simple.xml b/src/assets/mortgage_simple.xml
index 1cb7d7e..25e2549 100644
--- a/src/assets/mortgage_simple.xml
+++ b/src/assets/mortgage_simple.xml
@@ -1,6 +1,7 @@
mortgage
+ 1.0.0
MTG
Mortgage
true