Skip to content

0.14.8. #54

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.2.0",
"sequential-workflow-designer": "^0.21.2",
"sequential-workflow-machine": "^0.4.0",
"sequential-workflow-editor-model": "^0.14.7",
"sequential-workflow-editor": "^0.14.7"
"sequential-workflow-editor-model": "^0.14.8",
"sequential-workflow-editor": "^0.14.8"
},
"devDependencies": {
"ts-loader": "^9.4.2",
Expand Down
6 changes: 5 additions & 1 deletion demos/webpack-app/src/i18n/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,11 @@ const editorDict: Record<string, Record<string, string>> = {
'step.chown.name': 'Uprawnienia',
'step.chown.property:name': 'Nazwa',
'step.chown.property:properties/stringOrNumber': 'Tekst lub liczba',
'step.chown.property:properties/users': 'Użytkownik'
'step.chown.property:properties/users': 'Użytkownik',
'step.chown.property:properties/mode': 'Tryb',
'step.chown.property:properties/mode:choice:Read': 'Odczyt',
'step.chown.property:properties/mode:choice:Write': 'Zapis',
'step.chown.property:properties/mode:choice:Execute': 'Wykonanie'
}
};

Expand Down
8 changes: 8 additions & 0 deletions demos/webpack-app/src/i18n/definition-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {
Dynamic,
StringDictionary,
createBooleanValueModel,
createChoiceValueModel,
createDefinitionModel,
createDynamicValueModel,
createNumberValueModel,
Expand All @@ -24,6 +25,7 @@ export interface ChownStep extends Step {
properties: {
stringOrNumber: Dynamic<string | number>;
users: StringDictionary;
mode: string;
};
}

Expand Down Expand Up @@ -64,6 +66,12 @@ export const definitionModel = createDefinitionModel<I18nDefinition>(model => {
uniqueKeys: true
})
);
step.property('mode').value(
createChoiceValueModel({
choices: ['Read', 'Write', 'Execute'],
defaultValue: 'Read'
})
);
})
]);
});
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.14.7",
"version": "0.14.8",
"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.14.7",
"sequential-workflow-editor-model": "^0.14.8",
"sequential-workflow-model": "^0.2.0"
},
"peerDependencies": {
"sequential-workflow-editor-model": "^0.14.7",
"sequential-workflow-editor-model": "^0.14.8",
"sequential-workflow-model": "^0.2.0"
},
"devDependencies": {
Expand Down
3 changes: 3 additions & 0 deletions editor/src/core/step-i18n-prefix.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function createStepI18nPrefix(stepType: string | null): string {
return stepType ? `step.${stepType}.property:` : 'root.property:';
}
3 changes: 2 additions & 1 deletion editor/src/property-editor/property-editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { PropertyValidationErrorComponent, propertyValidationErrorComponent } fr
import { Icons } from '../core/icons';
import { PropertyHintComponent, propertyHint } from './property-hint';
import { StackedSimpleEvent } from '../core';
import { createStepI18nPrefix } from '../core/step-i18n-prefix';

export class PropertyEditor implements Component {
public static create(
Expand Down Expand Up @@ -45,7 +46,7 @@ export class PropertyEditor implements Component {
const label = Html.element('h4', {
class: 'swe-property-header-label'
});
const i18nPrefix = stepType ? `step.${stepType}.property:` : 'root.property:';
const i18nPrefix = createStepI18nPrefix(stepType);
label.innerText = editorServices.i18n(i18nPrefix + pathStr, propertyModel.label);

header.appendChild(label);
Expand Down
18 changes: 15 additions & 3 deletions editor/src/value-editors/choice/choice-value-editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { validationErrorComponent } from '../../components/validation-error-comp
import { valueEditorContainerComponent } from '../../components/value-editor-container-component';
import { rowComponent } from '../../components/row-component';
import { selectComponent } from '../../components/select-component';
import { createStepI18nPrefix } from '../../core/step-i18n-prefix';

export const choiceValueEditorId = 'choice';

Expand All @@ -13,16 +14,27 @@ export function choiceValueEditor(context: ValueContext<ChoiceValueModel>): Valu
}

function onSelected(index: number) {
const value = context.model.configuration.choices[index];
const value = choices[index];
context.setValue(value);
validate();
}

const select = selectComponent({
stretched: true
});
select.setValues(context.model.configuration.choices);
const startIndex = context.model.configuration.choices.indexOf(context.getValue());

const stepType = context.tryGetStepType();
const i18nPrefix = createStepI18nPrefix(stepType);

const choices = context.model.configuration.choices;
const translatedChoices = choices.map(choice => {
const pathStr = context.model.path.toString();
const key = `${i18nPrefix}${pathStr}:choice:${choice}`;
return context.i18n(key, choice);
});

select.setValues(translatedChoices);
const startIndex = choices.indexOf(context.getValue());
select.selectIndex(startIndex);
select.onSelected.subscribe(onSelected);

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.14.7",
"version": "0.14.8",
"homepage": "https://nocode-js.com/",
"author": {
"name": "NoCode JS",
Expand Down
10 changes: 9 additions & 1 deletion model/src/context/property-context.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Properties } from 'sequential-workflow-model';
import { Properties, Step } from 'sequential-workflow-model';
import { DefinitionModel, PropertyModel } from '../model';
import { ValueType } from '../types';
import { readPropertyValue } from './read-property-value';
Expand All @@ -18,6 +18,14 @@ export class PropertyContext<TProperties extends Properties = Properties> {
private readonly definitionModel: DefinitionModel
) {}

/**
* @returns the type of the step, or `null` if the object is root.
*/
public readonly tryGetStepType = (): string | null => {
const type = (this.object as Step).type;
return type ? type : null;
};

/**
* Get the value of a property by name.
* @param name The name of the property.
Expand Down
1 change: 1 addition & 0 deletions model/src/context/scoped-property-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export class ScopedPropertyContext<TProperties extends Properties> {
private readonly parentsProvider: ParentsProvider
) {}

public readonly tryGetStepType = this.propertyContext.tryGetStepType;
public readonly getPropertyValue = this.propertyContext.getPropertyValue;
public readonly formatPropertyValue = this.propertyContext.formatPropertyValue;
public readonly getValueTypes = this.propertyContext.getValueTypes;
Expand Down
1 change: 1 addition & 0 deletions model/src/context/value-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export class ValueContext<TValueModel extends ValueModel = ValueModel, TProperti
public readonly scopedPropertyContext: ScopedPropertyContext<TProperties>
) {}

public readonly tryGetStepType = this.scopedPropertyContext.tryGetStepType;
public readonly getPropertyValue = this.scopedPropertyContext.getPropertyValue;
public readonly formatPropertyValue = this.scopedPropertyContext.formatPropertyValue;
public readonly getValueTypes = this.scopedPropertyContext.getValueTypes;
Expand Down