Skip to content

Commit 37945fc

Browse files
ngonzalezpazFCjavier-godoy
authored andcommitted
fix(demo): change notifications position, change getSrcdoc method
1 parent 575983f commit 37945fc

File tree

3 files changed

+16
-38
lines changed

3 files changed

+16
-38
lines changed

src/test/java/com/flowingcode/vaadin/addons/chipfield/BinderDemo.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ public BinderDemo() {
2525
event -> Notification.show(
2626
"Planet: " + p.getName() + ", features: "
2727
+ p.getConfiguration().stream().collect(Collectors.joining(",")),
28-
5000, Position.BOTTOM_END));
28+
5000, Position.BOTTOM_START));
2929
chf5.addValueChangeListener(
30-
newItem -> Notification.show("Items: " + newItem.getValue(), 5000, Position.BOTTOM_END));
30+
newItem -> Notification.show("Items: " + newItem.getValue(), 5000, Position.BOTTOM_START));
3131

3232
add(chf5, show);
3333
}

src/test/java/com/flowingcode/vaadin/addons/chipfield/ChipfieldDemoView.java

Lines changed: 11 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -55,28 +55,28 @@ public ChipfieldDemoView() {
5555
setSizeFull();
5656

5757
tabs.addSelectedChangeListener(e -> {
58-
this.removeAll();
58+
removeAll();
5959
switch (e.getSelectedTab().getLabel()) {
6060
case DATAPROVIDER_DEMO:
61-
iframe.getElement().setAttribute("srcdoc", getSrcdoc(DATAPROVIDER_DEMO));
61+
iframe.getElement().setAttribute("srcdoc", getSrcdoc(DATAPROVIDER_SOURCE));
6262
layout.addToPrimary(new DataProviderDemo());
6363
layout.addToSecondary(iframe);
6464
add(tabs, layout);
6565
break;
66-
case "Restricted":
67-
iframe.getElement().setAttribute("srcdoc", getSrcdoc(RESTRICTED_DEMO));
66+
case RESTRICTED_DEMO:
67+
iframe.getElement().setAttribute("srcdoc", getSrcdoc(RESTRICTED_SOURCE));
6868
layout.addToPrimary(new RestrictedDemo());
6969
layout.addToSecondary(iframe);
7070
add(tabs, layout);
7171
break;
72-
case "Disabled":
73-
iframe.getElement().setAttribute("srcdoc", getSrcdoc(DISABLED_DEMO));
72+
case DISABLED_DEMO:
73+
iframe.getElement().setAttribute("srcdoc", getSrcdoc(DISABLED_SOURCE));
7474
layout.addToPrimary(new DisabledDemo());
7575
layout.addToSecondary(iframe);
7676
add(tabs, layout);
7777
break;
78-
case "Binder":
79-
iframe.getElement().setAttribute("srcdoc", getSrcdoc(BINDER_DEMO));
78+
case BINDER_DEMO:
79+
iframe.getElement().setAttribute("srcdoc", getSrcdoc(BINDER_SOURCE));
8080
layout.addToPrimary(new BinderDemo());
8181
layout.addToSecondary(iframe);
8282
add(tabs, layout);
@@ -88,30 +88,8 @@ public ChipfieldDemoView() {
8888
});
8989
}
9090

91-
private String getSrcdoc(String demo) {
92-
String response;
93-
switch (demo) {
94-
case DATAPROVIDER_DEMO:
95-
response = "<html style=\"overflow-y:hidden; height:100%;\"><body style=\"overflow-y: scroll; height:100%;\"><script src=\"http://gist-it.appspot.com/"
96-
+ DATAPROVIDER_SOURCE + "\"></script></body></html>";
97-
break;
98-
case RESTRICTED_DEMO:
99-
response = "<html style=\"overflow-y:hidden; height:100%;\"><body style=\"overflow-y: scroll; height:100%;\"><script src=\"http://gist-it.appspot.com/"
100-
+ RESTRICTED_SOURCE + "\"></script></body></html>";
101-
break;
102-
case DISABLED_DEMO:
103-
response = "<html style=\"overflow-y:hidden; height:100%;\"><body style=\"overflow-y: scroll; height:100%;\"><script src=\"https://gist-it.appspot.com/"
104-
+ DISABLED_SOURCE + "\"></script></body></html>";
105-
break;
106-
case BINDER_DEMO:
107-
response = "<html style=\"overflow-y:hidden; height:100%;\"><body style=\"overflow-y: scroll; height:100%;\"><script src=\"https://gist-it.appspot.com/"
108-
+ BINDER_SOURCE + "\"></script></body></html>";
109-
break;
110-
default:
111-
response = "<html style=\"overflow-y:hidden; height:100%;\"><body style=\"overflow-y: scroll; height:100%;\"><script src=\"https://gist-it.appspot.com/"
112-
+ DATAPROVIDER_SOURCE + "\"></script></body></html>";
113-
break;
114-
}
115-
return response;
91+
private String getSrcdoc(String sourceUrl) {
92+
return "<html style=\"overflow-y:hidden; height:100%;\"><body style=\"overflow-y: scroll; height:100%;\"><script src=\"https://gist-it.appspot.com/"
93+
+ sourceUrl + "\"></script></body></html>";
11694
}
11795
}

src/test/java/com/flowingcode/vaadin/addons/chipfield/DataProviderDemo.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public DataProviderDemo() {
3030
Button b = new Button("Obtain selected planets");
3131
b.addClickListener(event -> Notification.show(
3232
"Planets: " + chf.getValue().stream().map(planet -> planet.getName()).collect(Collectors.joining(",")),
33-
5000, Position.BOTTOM_END));
33+
5000, Position.BOTTOM_START));
3434

3535
Button b2 = new Button("Add random planet");
3636
b2.addClickListener(event -> {
@@ -42,10 +42,10 @@ public DataProviderDemo() {
4242

4343
chf.addChipCreatedListener(
4444
ev -> Notification.show("Chip: " + ev.getChipLabel() + " Created by client: " + ev.isFromClient() + "!",
45-
5000, Position.BOTTOM_END));
45+
5000, Position.BOTTOM_START));
4646
chf.addChipRemovedListener(
4747
ev -> Notification.show("Chip: " + ev.getChipLabel() + " Removed by client: " + ev.isFromClient() + "!",
48-
5000, Position.BOTTOM_END));
48+
5000, Position.BOTTOM_START));
4949
chf.addChipClickedListener(
5050
ev -> Notification.show("Chip: " + ev.getChipLabel() + " Clicked!", 5000, Position.BOTTOM_END));
5151

0 commit comments

Comments
 (0)