Skip to content

Commit 1092b75

Browse files
committed
add named converters editor
1 parent 4b5966b commit 1092b75

3 files changed

Lines changed: 17 additions & 8 deletions

File tree

packages/web-component-designer-visualization-addons/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"description": "web-component-designer addon for visualizations",
33
"name": "@node-projects/web-component-designer-visualization-addons",
4-
"version": "0.1.121",
4+
"version": "0.1.122",
55
"type": "module",
66
"main": "./dist/index.js",
77
"author": "jochen.kuehner@gmx.de",

packages/web-component-designer-visualization-addons/src/components/BindingsEditor.ts

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ export class BindingsEditor extends BaseCustomWebComponentConstructorAppend {
6161
</div>
6262
<div class="vertical-grid" style="margin-top: 10px;">
6363
<div>
64-
<div class="input-headline">
65-
<span>converter</span>:
64+
<div class="input-headline" style="display: flex;align-items: center;">
65+
<span>converter</span>:<input id="namedConverterInput" style="width: 100%; margin-left: 15px;" value="{{?this.convertersString::change}}">
6666
</div>
6767
</div>
6868
</div>
@@ -190,18 +190,19 @@ export class BindingsEditor extends BaseCustomWebComponentConstructorAppend {
190190
public events: string = '';
191191
public invert: boolean = false;
192192
public converters: { key: string, value: any }[] = [];
193+
public convertersString: string;
193194
public objectValueType: string;
194195

195196
protected _property: IProperty;
196-
protected _binding: IBinding & { converter: Record<string, any> };
197+
protected _binding: IBinding & { converter: Record<string, any> | string };
197198
protected _bindingTarget: BindingTarget;
198199
protected _serviceContainer: ServiceContainer;
199200
protected _instanceServiceContainer: InstanceServiceContainer;
200201
protected _shell: VisualizationShell
201202
protected _activeRow: number = -1;
202203
protected _objNmInput: HTMLInputElement;
203204

204-
constructor(property: IProperty, binding: IBinding & { converter: Record<string, any> }, bindingTarget: BindingTarget, serviceContainer: ServiceContainer, instanceServiceContainer: InstanceServiceContainer, shell: VisualizationShell) {
205+
constructor(property: IProperty, binding: IBinding & { converter: Record<string, any> }, bindingTarget: BindingTarget, serviceContainer: ServiceContainer, instanceServiceContainer: InstanceServiceContainer, shell: VisualizationShell, config = { namedConverters: true }) {
205206
super();
206207
super._restoreCachedInititalValues();
207208

@@ -213,6 +214,10 @@ export class BindingsEditor extends BaseCustomWebComponentConstructorAppend {
213214
this._serviceContainer = serviceContainer;
214215
this._instanceServiceContainer = instanceServiceContainer;
215216
this._shell = shell;
217+
218+
if (!config?.namedConverters) {
219+
this._getDomElement<HTMLInputElement>('namedConverterInput').style.display = 'none';
220+
}
216221
}
217222

218223
ready() {
@@ -234,8 +239,12 @@ export class BindingsEditor extends BaseCustomWebComponentConstructorAppend {
234239
if (this._binding.bindableObjectNames)
235240
this.objectNames = this._binding.bindableObjectNames.join(';');
236241
if (this._binding.converter) {
237-
for (let c in this._binding.converter) {
238-
this.converters.push({ key: c, value: this._binding.converter[c] });
242+
if (typeof this._binding.converter === 'string') {
243+
this.convertersString = this._binding.converter;
244+
} else {
245+
for (let c in this._binding.converter) {
246+
this.converters.push({ key: c, value: this._binding.converter[c] });
247+
}
239248
}
240249
}
241250
if (this._binding.changedEvents && this._binding.changedEvents.length)

packages/web-component-designer-visualization-addons/src/helpers/BindingsHelper.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -872,7 +872,7 @@ export class BindingsHelper {
872872
valuesObject[signalVarNames.length - 1] = v;
873873
}
874874
if (binding[1].converter) {
875-
if (binding[1].converter) {
875+
if (typeof binding[1].converter === 'string') {
876876
v = this.namedConverterCallback(<string><never>binding[1].converter, v, element, binding);
877877
} else {
878878
const stringValue = <string>(v != null ? v.toString() : v);

0 commit comments

Comments
 (0)