Skip to content

Commit 960551c

Browse files
committed
Fix preview editor
1 parent 3ccf87d commit 960551c

File tree

9 files changed

+50
-33
lines changed

9 files changed

+50
-33
lines changed

package.json

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ngx-dynamic-components",
3-
"version": "15.1.0",
3+
"version": "15.1.1",
44
"description": "NGX Dynamic Components is a configuration based dynamic components library for Angular. That allows you to rapidly create dynamic forms or any other mobile-friendly web layouts.",
55
"author": "FalconSoft Ltd",
66
"repository": {
@@ -28,16 +28,16 @@
2828
"fix": "ng serve --configuration=fix"
2929
},
3030
"dependencies": {
31-
"@angular/animations": "^15.1.0",
31+
"@angular/animations": "^15.1.1",
3232
"@angular/cdk": "^15.1.0",
33-
"@angular/common": "^15.1.0",
34-
"@angular/compiler": "^15.1.0",
35-
"@angular/core": "^15.1.0",
36-
"@angular/forms": "^15.1.0",
33+
"@angular/common": "^15.1.1",
34+
"@angular/compiler": "^15.1.1",
35+
"@angular/core": "^15.1.1",
36+
"@angular/forms": "^15.1.1",
3737
"@angular/material": "^15.1.0",
38-
"@angular/platform-browser": "^15.1.0",
39-
"@angular/platform-browser-dynamic": "^15.1.0",
40-
"@angular/router": "^15.1.0",
38+
"@angular/platform-browser": "^15.1.1",
39+
"@angular/platform-browser-dynamic": "^15.1.1",
40+
"@angular/router": "^15.1.1",
4141
"@ng-select/ng-select": "^10.0.3",
4242
"ace-builds": "^1.14.0",
4343
"angular-resizable-element": "^7.0.2",
@@ -46,24 +46,24 @@
4646
"core-js": "^3.19.3",
4747
"font-awesome": "^4.7.0",
4848
"isomorphic-xml2js": "0.1.3",
49-
"json-formatter-js": "^2.3.3",
49+
"json-formatter-js": "^2.3.4",
5050
"jspython-interpreter": "^2.1.12",
5151
"ngx-bootstrap": "^10.2.0",
52-
"ngx-markdown": "^15.0.0",
52+
"ngx-markdown": "^15.1.0",
5353
"rxjs": "^7.6.0",
5454
"tslib": "^2.4.1",
5555
"zone.js": "~0.12.0"
5656
},
5757
"devDependencies": {
58-
"@angular-devkit/build-angular": "~15.1.0",
58+
"@angular-devkit/build-angular": "~15.1.2",
5959
"@angular-eslint/builder": "^15.1.0",
6060
"@angular-eslint/eslint-plugin": "^15.1.0",
6161
"@angular-eslint/eslint-plugin-template": "^15.1.0",
6262
"@angular-eslint/schematics": "15.1.0",
6363
"@angular-eslint/template-parser": "^15.1.0",
64-
"@angular/cli": "^15.1.0",
65-
"@angular/compiler-cli": "^15.1.0",
66-
"@angular/language-service": "^15.1.0",
64+
"@angular/cli": "^15.1.2",
65+
"@angular/compiler-cli": "^15.1.1",
66+
"@angular/language-service": "^15.1.1",
6767
"@types/eslint": "^8.2.1",
6868
"@types/estree": "^0.0.50",
6969
"@types/jasmine": "~3.7.7",

projects/bootstrap/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@ngx-dynamic-components/bootstrap",
3-
"version": "15.1.0",
3+
"version": "15.1.1",
44
"private": false,
55
"description": "@ngx-dynamic-components/bootstrap is Angular 7+ library what contains a bootstrap interfaces to build a configuration driven web pages and workflows.",
66
"author": "FalconSoft Ltd <[email protected]>",

projects/core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@ngx-dynamic-components/core",
3-
"version": "15.1.0",
3+
"version": "15.1.1",
44
"private": false,
55
"description": "@ngx-dynamic-components/core is Angular 7+ library what contains a core interfaces to build a configuration driven web pages and workflows.",
66
"author": "FalconSoft Ltd <[email protected]>",

projects/core/src/lib/components/base-ui-component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export class BaseUIComponent<T = StyleProperties> extends BaseDynamicComponent<T
1818
@HostBinding('style.max-height') maxHeight?: string;
1919
@HostBinding('style.padding') padding?: string;
2020
@HostBinding('style.margin') margin?: string;
21-
@HostBinding('style.display') display? = 'initial';
21+
@HostBinding('style.display') display?: string;
2222
@HostBinding('style.border-left') borderLeft?: string;
2323
@HostBinding('style.border-top') borderTop?: string;
2424
@HostBinding('style.border-right') borderRight?: string;

projects/core/src/lib/ui-components/input/input.component.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ export class InputComponent extends FormElementComponent<InputProperties> implem
123123
} else if (this.properties.type === 'radio') {
124124
if (input.checked) {
125125
this.componentDataModel = input.value;
126-
this.emitEvent(prop, input.value);
126+
this.emitEvent(prop, this.properties.value);
127127
}
128128
} else {
129129
this.componentDataModel = input.value;
@@ -179,6 +179,13 @@ export class InputProperties extends FormElementProperties {
179179
type: PropTypes.EVENT
180180
})
181181
debouncedInput?: string;
182+
183+
@propDescription({
184+
description: 'Input initial value.',
185+
example: 'option-1',
186+
type: PropTypes.PROPERTY
187+
})
188+
value?: string;
182189
}
183190

184191
type InputComponentConstrutor = new () => InputComponent;
@@ -197,7 +204,8 @@ export const inputDescriptor: ComponentDescriptor<InputComponentConstrutor, Inpu
197204
parseUIModel(xmlRes: XMLResult): UIModel {
198205
const itemProperties: AttributesMap = {
199206
readonly: xmlRes.attrs.readonly === 'true',
200-
list: xmlRes.attrs.list?.split(',').map(o => o.trim())
207+
list: xmlRes.attrs.list?.split(',').map(o => o.trim()),
208+
...xmlRes.attrs
201209
};
202210

203211
return {

projects/core/src/lib/ui-components/input/input.examples.ts

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export const example1: ComponentExample<UIModel<InputProperties>> = {
55
title: 'Text input example',
66
uiModel: `
77
<div class="d-flex flex-column">
8-
8+
99
<div class="form-group">
1010
<label class="col-form-label" width="80px">Name</label>
1111
<input onInput="onNameInput(name)" placeholder="Enter your name" binding="$.name"/>
@@ -18,12 +18,12 @@ export const example1: ComponentExample<UIModel<InputProperties>> = {
1818
1919
<div class="form-group">
2020
<label class="col-form-label" width="80px">Debounced Input</label>
21-
<input
22-
placeholder="Enter text here"
21+
<input
22+
placeholder="Enter text here"
2323
binding="$.text"
24-
debouncedInput="onDebouncedInput(searchText)"
24+
debouncedInput="onDebouncedInput(searchText)"
2525
debounceTime="2000"
26-
/>
26+
/>
2727
<text binding="$.debouncedText" class="ml-2"></text>
2828
</div>
2929
@@ -59,22 +59,27 @@ export const example2: ComponentExample<UIModel<InputProperties>> = {
5959
export const example3: ComponentExample<UIModel<InputProperties>> = {
6060
title: 'Radio group example',
6161
uiModel: `
62-
<div>
62+
<div class="d-flex flex-column">
6363
<div class="form-group form-check mt-5">
64-
<input id="opt1" type="radio" class="form-check-input" name="option" value="option-1" binding="$.option"/>
64+
<input id="opt1" type="radio" class="form-check-input" name="option" onChange="onSelect(val)" value="option-1"/>
6565
<label for="opt1" class="form-check-label" width="80px">Option 1</label>
6666
</div>
6767
<div class="form-group form-check">
68-
<input id="opt2" type="radio" class="form-check-input" name="option" value="option-2" binding="$.option"/>
68+
<input id="opt2" type="radio" class="form-check-input" name="option" onChange="onSelect(val)" value="option-2"/>
6969
<label for="opt2" class="form-check-label" width="80px">Option 2</label>
7070
</div>
7171
<div class="form-group form-check">
72-
<input id="opt3" type="radio" class="form-check-input" name="option" value="option-3" binding="$.option"/>
72+
<input id="opt3" type="radio" class="form-check-input" name="option" onChange="onSelect(val)" value="option-3"/>
7373
<label for="opt3" class="form-check-label" width="80px">Option 3</label>
7474
</div>
7575
</div>
7676
`,
7777
dataModel: {},
78+
scripts: `
79+
def onSelect():
80+
print(val)
81+
dataModel.selected = val
82+
`,
7883
description: 'You can choose one of 3 options.'
7984
};
8085

projects/core/src/lib/ui-components/register.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { textDescriptor } from './text/text.component';
44
import { buttonDescriptor } from './button/button.component';
55
import { inputDescriptor } from './input/input.component';
66
import { iconDescriptor } from './icon/icon.component';
7-
import { radioGroupDescriptor } from './radio-group/radio-group.component';
87
import { textareaDescriptor } from './textarea/textarea.component';
98
import { containerDescriptor, divDescriptor } from './container/container.component';
109
import { linkDescriptor } from './link/link.component';
@@ -27,7 +26,6 @@ export const COMPONENTS_LIST: ComponentDescriptor[] = [
2726
labelDescriptor,
2827
iconDescriptor,
2928
inputDescriptor,
30-
radioGroupDescriptor,
3129
textareaDescriptor,
3230
buttonDescriptor,
3331
linkDescriptor,

projects/tools/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@ngx-dynamic-components/tools",
3-
"version": "15.1.0",
3+
"version": "15.1.1",
44
"private": false,
55
"description": "@ngx-dynamic-components/tools is Angular 7+ library what contains a core interfaces to build a configuration driven web pages.",
66
"author": "FalconSoft Ltd <[email protected]>",

projects/tools/src/lib/components/preview-editor/preview-editor.component.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import type {
1818
NGXDynamicComponent,
1919
UIModel,
2020
} from '@ngx-dynamic-components/core';
21-
import { map } from 'rxjs/operators';
21+
import { debounceTime, map } from 'rxjs/operators';
2222
import { Observable, fromEvent, asyncScheduler } from 'rxjs';
2323
import { Ace, edit } from 'ace-builds';
2424
import { jsPython, Interpreter } from 'jspython-interpreter';
@@ -77,6 +77,9 @@ export class PreviewEditorComponent implements OnInit, AfterViewInit {
7777

7878
if (this.interpreter.hasFunction(this.scripts, eventHandler)) {
7979
try {
80+
if (parameters) {
81+
parameters[parameters.argsKey] = parameters.argsValue;
82+
}
8083
const res = await this.interpreter.evaluate(
8184
this.scripts,
8285
{
@@ -162,7 +165,10 @@ export class PreviewEditorComponent implements OnInit, AfterViewInit {
162165
this.uiModelEl,
163166
this.initUiModel,
164167
'ace/mode/xml'
168+
).pipe(
169+
debounceTime(500)
165170
).subscribe((uiModel) => {
171+
this.dynamicComponent.containerRef.clear();
166172
this.setJSONEditor(uiModel);
167173
this.refreshPreview(uiModel, this.dataModel);
168174
});

0 commit comments

Comments
 (0)