Skip to content

Commit

Permalink
0.4.1. (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
b4rtaz authored Jun 22, 2023
1 parent 60a0c7f commit 5b14906
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 29 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 0.4.1

* The model validator is improved. Now the validator validates the `name` field of the step as well.
* Adjusted CSS styles.

## 0.4.0

* Added new value model: `generatedString` (`generatedStringValueEditor({ ... })`). The new value model allows you to generate a string value for some property, depending on the values of other properties. Mainly this feature is designed to generate a step name automatically.
Expand Down
4 changes: 2 additions & 2 deletions demos/webpack-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
"sequential-workflow-model": "^0.1.3",
"sequential-workflow-designer": "^0.13.3",
"sequential-workflow-machine": "^0.2.0",
"sequential-workflow-editor-model": "^0.4.0",
"sequential-workflow-editor": "^0.4.0"
"sequential-workflow-editor-model": "^0.4.1",
"sequential-workflow-editor": "^0.4.1"
},
"devDependencies": {
"ts-loader": "^9.4.2",
Expand Down
18 changes: 9 additions & 9 deletions editor/css/editor.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@
.swe-editor {
margin: 10px 0 0;
font-size: 13px;
line-height: 1.3rem;
line-height: 1.3em;
}
.swe-editor-header {
padding: 0 10px 5px;
}
.swe-editor-header-title {
margin: 0;
padding: 5px 0 10px;
font-size: 1.4rem;
line-height: 1.3rem;
font-size: 1.4em;
line-height: 1.3em;
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
Expand All @@ -42,8 +42,8 @@
display: block;
padding: 0;
margin: 0;
font-size: 1.05rem;
line-height: 1.3rem;
font-size: 1.05em;
line-height: 1.3em;
}
.swe-property-header-hint-toggle {
display: block;
Expand Down Expand Up @@ -94,7 +94,7 @@
border: 1px solid #d9d9d9;
background: #fff;
outline: none;
padding: 6px 8px;
padding: 8px;
border-radius: 5px;
}
.swe-input:focus {
Expand All @@ -107,14 +107,14 @@
border-style: dashed;
}
.swe-select-small {
padding: 2px 5px;
padding: 3px 5px;
}
.swe-button {
box-sizing: border-box;
border: 1px solid #ccc;
background: #ddd;
outline: none;
padding: 6px;
padding: 8px;
border-radius: 5px;
cursor: pointer;
}
Expand All @@ -125,7 +125,7 @@
background: #d5d5d5;
}
.swe-button-small {
padding: 2px 5px;
padding: 3px 5px;
}

.swe-stretched {
Expand Down
6 changes: 3 additions & 3 deletions editor/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sequential-workflow-editor",
"version": "0.4.0",
"version": "0.4.1",
"type": "module",
"main": "./lib/esm/index.js",
"types": "./lib/index.d.ts",
Expand Down Expand Up @@ -46,11 +46,11 @@
"prettier:fix": "prettier --write ./src ./css"
},
"dependencies": {
"sequential-workflow-editor-model": "^0.4.0",
"sequential-workflow-editor-model": "^0.4.1",
"sequential-workflow-model": "^0.1.3"
},
"peerDependencies": {
"sequential-workflow-editor-model": "^0.4.0",
"sequential-workflow-editor-model": "^0.4.1",
"sequential-workflow-model": "^0.1.3"
},
"devDependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ export function anyVariableItemComponent(variable: AnyVariable): AnyVariableItem
const name = Html.element('span');
name.innerText = formatVariableNameWithType(variable.name, variable.type);

const deleteButton = buttonComponent('Delete');
const deleteButton = buttonComponent('Delete', {
size: 'small'
});
deleteButton.onClick.subscribe(() => onDeleteClicked.forward());

const validation = validationErrorComponent();
Expand Down
2 changes: 1 addition & 1 deletion model/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sequential-workflow-editor-model",
"version": "0.4.0",
"version": "0.4.1",
"homepage": "https://nocode-js.com/",
"author": {
"name": "NoCode JS",
Expand Down
29 changes: 16 additions & 13 deletions model/src/validator/model-validator.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Definition, DefinitionWalker, Step } from 'sequential-workflow-model';
import { DefinitionModel, PropertyModels } from '../model';
import { DefinitionModel, PropertyModel, PropertyModels } from '../model';
import { DefinitionContext, ValueContext } from '../context';
import { CustomValidatorContext } from './custom-validator-context';

Expand All @@ -17,7 +17,8 @@ export class ModelValidator {
if (!stepModel) {
throw new Error(`Cannot find model for step type: ${step.type}`);
}
return this.validateProperties(stepModel.properties, definitionContext);

return this.validateProperty(stepModel.name, definitionContext) && this.validateProperties(stepModel.properties, definitionContext);
}

public validateRoot(definition: Definition): boolean {
Expand All @@ -26,18 +27,20 @@ export class ModelValidator {
}

private validateProperties(properties: PropertyModels, definitionContext: DefinitionContext): boolean {
for (const propertyModel of properties) {
const valueContext = ValueContext.create(propertyModel.value, propertyModel, definitionContext);
if (propertyModel.value.validate(valueContext)) {
return false;
}
return properties.every(propertyModel => this.validateProperty(propertyModel, definitionContext));
}

if (propertyModel.customValidator) {
const validatorContext = CustomValidatorContext.create(propertyModel, definitionContext);
const error = propertyModel.customValidator.validate(validatorContext);
if (error) {
return false;
}
private validateProperty(propertyModel: PropertyModel, definitionContext: DefinitionContext): boolean {
const valueContext = ValueContext.create(propertyModel.value, propertyModel, definitionContext);
if (propertyModel.value.validate(valueContext)) {
return false;
}

if (propertyModel.customValidator) {
const validatorContext = CustomValidatorContext.create(propertyModel, definitionContext);
const error = propertyModel.customValidator.validate(validatorContext);
if (error) {
return false;
}
}
return true;
Expand Down

0 comments on commit 5b14906

Please sign in to comment.