Skip to content

Commit 53c8656

Browse files
authored
0.2.1. (#5)
1 parent 91e6608 commit 53c8656

File tree

6 files changed

+37
-9
lines changed

6 files changed

+37
-9
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.2.1
2+
3+
Fixed bug with removing a message about an empty list.
4+
15
## 0.2.0
26

37
**Breaking changes:**

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.1.3",
1919
"sequential-workflow-designer": "^0.13.0",
2020
"sequential-workflow-machine": "^0.2.0",
21-
"sequential-workflow-editor-model": "^0.2.0",
22-
"sequential-workflow-editor": "^0.2.0"
21+
"sequential-workflow-editor-model": "^0.2.1",
22+
"sequential-workflow-editor": "^0.2.1"
2323
},
2424
"devDependencies": {
2525
"ts-loader": "^9.4.2",

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.2.0",
3+
"version": "0.2.1",
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.2.0",
49+
"sequential-workflow-editor-model": "^0.2.1",
5050
"sequential-workflow-model": "^0.1.3"
5151
},
5252
"peerDependencies": {
53-
"sequential-workflow-editor-model": "^0.2.0",
53+
"sequential-workflow-editor-model": "^0.2.1",
5454
"sequential-workflow-model": "^0.1.3"
5555
},
5656
"devDependencies": {

editor/src/components/dynamic-list-component.spec.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,23 @@ describe('DynamicListComponent', () => {
2727

2828
expect(component.view.children.length).toBe(0);
2929
});
30+
31+
it('shows empty message, when items appear, then message disappears', () => {
32+
const component = dynamicListComponent({
33+
emptyMessage: 'List is empty'
34+
});
35+
36+
expect(component.view.children.length).toBe(0);
37+
38+
component.set([]);
39+
40+
expect(component.view.children.length).toBe(1);
41+
expect(component.view.children[0].textContent).toBe('List is empty');
42+
43+
const item = Html.element('div');
44+
component.set([{ view: item }]);
45+
46+
expect(component.view.children.length).toBe(1);
47+
expect(component.view.children[0]).toBe(item);
48+
});
3049
});

editor/src/components/dynamic-list-component.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ export function dynamicListComponent<TComponent extends Component>(
1414
configuration?: DynamicListComponentConfiguration
1515
): DynamicListComponent<TComponent> {
1616
function set(set: TComponent[]) {
17+
if (emptyRow) {
18+
view.removeChild(emptyRow);
19+
emptyRow = null;
20+
}
1721
components.forEach(component => view.removeChild(component.view));
1822
components.length = 0;
1923

@@ -23,14 +27,15 @@ export function dynamicListComponent<TComponent extends Component>(
2327
view.appendChild(component.view);
2428
});
2529
} else if (configuration?.emptyMessage) {
26-
const message = Html.element('div', {
30+
emptyRow = Html.element('div', {
2731
class: 'swe-dynamic-list-empty-row'
2832
});
29-
message.innerText = configuration.emptyMessage;
30-
view.appendChild(message);
33+
emptyRow.innerText = configuration.emptyMessage;
34+
view.appendChild(emptyRow);
3135
}
3236
}
3337

38+
let emptyRow: HTMLElement | null = null;
3439
const components: TComponent[] = [];
3540
const view = Html.element('div', {
3641
class: 'swe-dynamic-list'

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.2.0",
3+
"version": "0.2.1",
44
"homepage": "https://nocode-js.com/",
55
"author": {
66
"name": "NoCode JS",

0 commit comments

Comments
 (0)