From 5b14906bb0bec6a30660aae5253f685fdfc635f2 Mon Sep 17 00:00:00 2001 From: Bart Tadych Date: Thu, 22 Jun 2023 22:52:10 +0200 Subject: [PATCH] 0.4.1. (#10) --- CHANGELOG.md | 5 ++++ demos/webpack-app/package.json | 4 +-- editor/css/editor.css | 18 ++++++------ editor/package.json | 6 ++-- .../any-variable-item-component.ts | 4 ++- model/package.json | 2 +- model/src/validator/model-validator.ts | 29 ++++++++++--------- 7 files changed, 39 insertions(+), 29 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f3c986c..7905ad6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. diff --git a/demos/webpack-app/package.json b/demos/webpack-app/package.json index 654fd98..3593ada 100644 --- a/demos/webpack-app/package.json +++ b/demos/webpack-app/package.json @@ -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", diff --git a/editor/css/editor.css b/editor/css/editor.css index b5c4738..bef94f9 100644 --- a/editor/css/editor.css +++ b/editor/css/editor.css @@ -8,7 +8,7 @@ .swe-editor { margin: 10px 0 0; font-size: 13px; - line-height: 1.3rem; + line-height: 1.3em; } .swe-editor-header { padding: 0 10px 5px; @@ -16,8 +16,8 @@ .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; @@ -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; @@ -94,7 +94,7 @@ border: 1px solid #d9d9d9; background: #fff; outline: none; - padding: 6px 8px; + padding: 8px; border-radius: 5px; } .swe-input:focus { @@ -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; } @@ -125,7 +125,7 @@ background: #d5d5d5; } .swe-button-small { - padding: 2px 5px; + padding: 3px 5px; } .swe-stretched { diff --git a/editor/package.json b/editor/package.json index 67bfa37..38fb213 100644 --- a/editor/package.json +++ b/editor/package.json @@ -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", @@ -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": { diff --git a/editor/src/value-editors/any-variables/any-variable-item-component.ts b/editor/src/value-editors/any-variables/any-variable-item-component.ts index 1eb8776..2c84020 100644 --- a/editor/src/value-editors/any-variables/any-variable-item-component.ts +++ b/editor/src/value-editors/any-variables/any-variable-item-component.ts @@ -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(); diff --git a/model/package.json b/model/package.json index 45bf65b..e3c7071 100644 --- a/model/package.json +++ b/model/package.json @@ -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", diff --git a/model/src/validator/model-validator.ts b/model/src/validator/model-validator.ts index 14fbf93..89877d6 100644 --- a/model/src/validator/model-validator.ts +++ b/model/src/validator/model-validator.ts @@ -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'; @@ -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 { @@ -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;