Skip to content

Commit 41b8bb9

Browse files
authored
0.14.8. (#54)
1 parent 36795f9 commit 41b8bb9

File tree

11 files changed

+50
-12
lines changed

11 files changed

+50
-12
lines changed

demos/webpack-app/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
"sequential-workflow-model": "^0.2.0",
1919
"sequential-workflow-designer": "^0.21.2",
2020
"sequential-workflow-machine": "^0.4.0",
21-
"sequential-workflow-editor-model": "^0.14.7",
22-
"sequential-workflow-editor": "^0.14.7"
21+
"sequential-workflow-editor-model": "^0.14.8",
22+
"sequential-workflow-editor": "^0.14.8"
2323
},
2424
"devDependencies": {
2525
"ts-loader": "^9.4.2",

demos/webpack-app/src/i18n/app.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,11 @@ const editorDict: Record<string, Record<string, string>> = {
6363
'step.chown.name': 'Uprawnienia',
6464
'step.chown.property:name': 'Nazwa',
6565
'step.chown.property:properties/stringOrNumber': 'Tekst lub liczba',
66-
'step.chown.property:properties/users': 'Użytkownik'
66+
'step.chown.property:properties/users': 'Użytkownik',
67+
'step.chown.property:properties/mode': 'Tryb',
68+
'step.chown.property:properties/mode:choice:Read': 'Odczyt',
69+
'step.chown.property:properties/mode:choice:Write': 'Zapis',
70+
'step.chown.property:properties/mode:choice:Execute': 'Wykonanie'
6771
}
6872
};
6973

demos/webpack-app/src/i18n/definition-model.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import {
22
Dynamic,
33
StringDictionary,
44
createBooleanValueModel,
5+
createChoiceValueModel,
56
createDefinitionModel,
67
createDynamicValueModel,
78
createNumberValueModel,
@@ -24,6 +25,7 @@ export interface ChownStep extends Step {
2425
properties: {
2526
stringOrNumber: Dynamic<string | number>;
2627
users: StringDictionary;
28+
mode: string;
2729
};
2830
}
2931

@@ -64,6 +66,12 @@ export const definitionModel = createDefinitionModel<I18nDefinition>(model => {
6466
uniqueKeys: true
6567
})
6668
);
69+
step.property('mode').value(
70+
createChoiceValueModel({
71+
choices: ['Read', 'Write', 'Execute'],
72+
defaultValue: 'Read'
73+
})
74+
);
6775
})
6876
]);
6977
});

editor/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "sequential-workflow-editor",
3-
"version": "0.14.7",
3+
"version": "0.14.8",
44
"type": "module",
55
"main": "./lib/esm/index.js",
66
"types": "./lib/index.d.ts",
@@ -46,11 +46,11 @@
4646
"prettier:fix": "prettier --write ./src ./css"
4747
},
4848
"dependencies": {
49-
"sequential-workflow-editor-model": "^0.14.7",
49+
"sequential-workflow-editor-model": "^0.14.8",
5050
"sequential-workflow-model": "^0.2.0"
5151
},
5252
"peerDependencies": {
53-
"sequential-workflow-editor-model": "^0.14.7",
53+
"sequential-workflow-editor-model": "^0.14.8",
5454
"sequential-workflow-model": "^0.2.0"
5555
},
5656
"devDependencies": {

editor/src/core/step-i18n-prefix.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export function createStepI18nPrefix(stepType: string | null): string {
2+
return stepType ? `step.${stepType}.property:` : 'root.property:';
3+
}

editor/src/property-editor/property-editor.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { PropertyValidationErrorComponent, propertyValidationErrorComponent } fr
1313
import { Icons } from '../core/icons';
1414
import { PropertyHintComponent, propertyHint } from './property-hint';
1515
import { StackedSimpleEvent } from '../core';
16+
import { createStepI18nPrefix } from '../core/step-i18n-prefix';
1617

1718
export class PropertyEditor implements Component {
1819
public static create(
@@ -45,7 +46,7 @@ export class PropertyEditor implements Component {
4546
const label = Html.element('h4', {
4647
class: 'swe-property-header-label'
4748
});
48-
const i18nPrefix = stepType ? `step.${stepType}.property:` : 'root.property:';
49+
const i18nPrefix = createStepI18nPrefix(stepType);
4950
label.innerText = editorServices.i18n(i18nPrefix + pathStr, propertyModel.label);
5051

5152
header.appendChild(label);

editor/src/value-editors/choice/choice-value-editor.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { validationErrorComponent } from '../../components/validation-error-comp
44
import { valueEditorContainerComponent } from '../../components/value-editor-container-component';
55
import { rowComponent } from '../../components/row-component';
66
import { selectComponent } from '../../components/select-component';
7+
import { createStepI18nPrefix } from '../../core/step-i18n-prefix';
78

89
export const choiceValueEditorId = 'choice';
910

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

1516
function onSelected(index: number) {
16-
const value = context.model.configuration.choices[index];
17+
const value = choices[index];
1718
context.setValue(value);
1819
validate();
1920
}
2021

2122
const select = selectComponent({
2223
stretched: true
2324
});
24-
select.setValues(context.model.configuration.choices);
25-
const startIndex = context.model.configuration.choices.indexOf(context.getValue());
25+
26+
const stepType = context.tryGetStepType();
27+
const i18nPrefix = createStepI18nPrefix(stepType);
28+
29+
const choices = context.model.configuration.choices;
30+
const translatedChoices = choices.map(choice => {
31+
const pathStr = context.model.path.toString();
32+
const key = `${i18nPrefix}${pathStr}:choice:${choice}`;
33+
return context.i18n(key, choice);
34+
});
35+
36+
select.setValues(translatedChoices);
37+
const startIndex = choices.indexOf(context.getValue());
2638
select.selectIndex(startIndex);
2739
select.onSelected.subscribe(onSelected);
2840

model/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "sequential-workflow-editor-model",
3-
"version": "0.14.7",
3+
"version": "0.14.8",
44
"homepage": "https://nocode-js.com/",
55
"author": {
66
"name": "NoCode JS",

model/src/context/property-context.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Properties } from 'sequential-workflow-model';
1+
import { Properties, Step } from 'sequential-workflow-model';
22
import { DefinitionModel, PropertyModel } from '../model';
33
import { ValueType } from '../types';
44
import { readPropertyValue } from './read-property-value';
@@ -18,6 +18,14 @@ export class PropertyContext<TProperties extends Properties = Properties> {
1818
private readonly definitionModel: DefinitionModel
1919
) {}
2020

21+
/**
22+
* @returns the type of the step, or `null` if the object is root.
23+
*/
24+
public readonly tryGetStepType = (): string | null => {
25+
const type = (this.object as Step).type;
26+
return type ? type : null;
27+
};
28+
2129
/**
2230
* Get the value of a property by name.
2331
* @param name The name of the property.

model/src/context/scoped-property-context.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export class ScopedPropertyContext<TProperties extends Properties> {
2020
private readonly parentsProvider: ParentsProvider
2121
) {}
2222

23+
public readonly tryGetStepType = this.propertyContext.tryGetStepType;
2324
public readonly getPropertyValue = this.propertyContext.getPropertyValue;
2425
public readonly formatPropertyValue = this.propertyContext.formatPropertyValue;
2526
public readonly getValueTypes = this.propertyContext.getValueTypes;

model/src/context/value-context.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export class ValueContext<TValueModel extends ValueModel = ValueModel, TProperti
2525
public readonly scopedPropertyContext: ScopedPropertyContext<TProperties>
2626
) {}
2727

28+
public readonly tryGetStepType = this.scopedPropertyContext.tryGetStepType;
2829
public readonly getPropertyValue = this.scopedPropertyContext.getPropertyValue;
2930
public readonly formatPropertyValue = this.scopedPropertyContext.formatPropertyValue;
3031
public readonly getValueTypes = this.scopedPropertyContext.getValueTypes;

0 commit comments

Comments
 (0)