Skip to content

Commit edc0cdf

Browse files
mlopezFCpaodb
authored andcommitted
feat: add initial implementation
1 parent 9a0a699 commit edc0cdf

25 files changed

+639
-207
lines changed

README.md

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
1-
[![Published on Vaadin Directory](https://img.shields.io/badge/Vaadin%20Directory-published-00b4f0.svg)](https://vaadin.com/directory/component/template-addon)
2-
[![Stars on vaadin.com/directory](https://img.shields.io/vaadin-directory/star/app-layout-addon.svg)](https://vaadin.com/directory/component/template-addon)
3-
[![Build Status](https://jenkins.flowingcode.com/job/template-addon/badge/icon)](https://jenkins.flowingcode.com/job/template-addon)
1+
[![Published on Vaadin Directory](https://img.shields.io/badge/Vaadin%20Directory-published-00b4f0.svg)](https://vaadin.com/directory/component/extended-login-addon)
2+
[![Stars on vaadin.com/directory](https://img.shields.io/vaadin-directory/star/extended-login-addon.svg)](https://vaadin.com/directory/component/extended-login-addon)
3+
[![Build Status](https://jenkins.flowingcode.com/job/extended-login-addon/badge/icon)](https://jenkins.flowingcode.com/job/extended-login-addon)
44

5-
# Template Add-on
5+
# Extended Login Add-on
66

7-
This is a template project for building new Vaadin 24 add-ons
7+
This is addon extends the Vaadin Login component adding new features
88

99
## Features
1010

11-
* List the features of your add-on in here
11+
* Adds a LoginLayout that allows to create views with the same layout as the LoginOverlay
12+
* Adds an extended LoginOverlay that allows to customize the appearance with more features than the base version
1213

1314
## Online demo
1415

15-
[Online demo here](http://addonsv24.flowingcode.com/template)
16+
[Online demo here](http://addonsv24.flowingcode.com/extended-login)
1617

1718
## Download release
1819

19-
[Available in Vaadin Directory](https://vaadin.com/directory/component/template-addon)
20+
[Available in Vaadin Directory](https://vaadin.com/directory/component/extended-login-addon)
2021

2122
### Maven install
2223

@@ -25,7 +26,7 @@ Add the following dependencies in your pom.xml file:
2526
```xml
2627
<dependency>
2728
<groupId>org.vaadin.addons.flowingcode</groupId>
28-
<artifactId>template-addon</artifactId>
29+
<artifactId>extended-login-addon</artifactId>
2930
<version>X.Y.Z</version>
3031
</dependency>
3132
```
@@ -49,7 +50,7 @@ To see the demo, navigate to http://localhost:8080/
4950

5051
## Release notes
5152

52-
See [here](https://github.com/FlowingCode/TemplateAddon/releases)
53+
See [here](https://github.com/FlowingCode/ExtendedLoginAddon/releases)
5354

5455
## Issue tracking
5556

@@ -74,13 +75,26 @@ Then, follow these steps for creating a contibution:
7475

7576
This add-on is distributed under Apache License 2.0. For license terms, see LICENSE.txt.
7677

77-
TEMPLATE_ADDON is written by Flowing Code S.A.
78+
Extended Login Addon is written by Flowing Code S.A.
7879

7980
# Developer Guide
8081

8182
## Getting started
8283

83-
Add your code samples in this section
84+
### Using the ExtendedLoginOverlay
85+
86+
Just create it in the same way that you would do with original LoginOverlay, but you can call new methods for replacing content:
87+
88+
ExtendedLoginOverlay elo = new ExtendedLoginOverlay();
89+
elo.replaceFormComponents(new TextField("Test", "test"), new ComboBox<String>("Test2"), new Button("Test3"));
90+
elo.replaceHeaderComponent(new Image("/img/LogoChicoGlow.png", "Login image"));
91+
elo.replaceForgotPassword(new Anchor("https://www.flowingcode.com","Flowing Code"));
92+
elo.setOpened(true);
93+
add(elo);
94+
95+
### Using the LoginLayout
96+
97+
The LoginLayout is like a regular RouterLayout that can be extended and then used in your views that you would like to have the same layout as the LoginOverlay. All the content will be inside the vaadin-login-form-wrapper. It also provides the same replace methods as the ExtendedLoginOverlay
8498

8599
## Special configuration when using Spring
86100

assembly/assembly.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
44
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
55
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
6-
<id>flowing-addon</id>
6+
<id>extended-login-addon</id>
77

88
<formats>
99
<format>zip</format>

drivers.xml

Lines changed: 0 additions & 40 deletions
This file was deleted.

pom.xml

Lines changed: 20 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@
55
<modelVersion>4.0.0</modelVersion>
66

77
<groupId>org.vaadin.addons.flowingcode</groupId>
8-
<artifactId>template-addon</artifactId>
8+
<artifactId>extended-login</artifactId>
99
<version>1.0.0-SNAPSHOT</version>
10-
<name>Template Add-on</name>
11-
<description>Template Add-on for Vaadin Flow</description>
10+
<name>Extended Login Add-on</name>
11+
<description>Extended Login Add-on for Vaadin Flow</description>
12+
<url>https://www.flowingcode.com/en/open-source/</url>
1213

1314
<properties>
1415
<vaadin.version>24.1.2</vaadin.version>
@@ -19,7 +20,7 @@
1920
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
2021
<drivers.dir>${project.basedir}/drivers</drivers.dir>
2122
<jetty.version>11.0.12</jetty.version>
22-
<flowingcode.commons.demo.version>3.6.0</flowingcode.commons.demo.version>
23+
<flowingcode.commons.demo.version>3.7.0-SNAPSHOT</flowingcode.commons.demo.version>
2324
<frontend.hotdeploy>true</frontend.hotdeploy>
2425
</properties>
2526

@@ -38,12 +39,20 @@
3839
</licenses>
3940

4041
<scm>
41-
<url>https://github.com/FlowingCode/AddonStarter24</url>
42-
<connection>scm:git:git://github.com/FlowingCode/AddonStarter24.git</connection>
43-
<developerConnection>scm:git:ssh://[email protected]:/FlowingCode/AddonStarter24.git</developerConnection>
42+
<url>https://github.com/FlowingCode/ExtendedLoginAddon</url>
43+
<connection>scm:git:git://github.com/FlowingCode/ExtendedLoginAddon.git</connection>
44+
<developerConnection>scm:git:ssh://[email protected]:/FlowingCode/ExtendedLoginAddon.git</developerConnection>
4445
<tag>master</tag>
4546
</scm>
4647

48+
<developers>
49+
<developer>
50+
<id>flowingcode</id>
51+
<organization>Flowing Code</organization>
52+
<organizationUrl>https://www.flowingcode.com</organizationUrl>
53+
</developer>
54+
</developers>
55+
4756
<dependencyManagement>
4857
<dependencies>
4958
<dependency>
@@ -88,6 +97,10 @@
8897
<id>flowing-releases</id>
8998
<url>https://maven.flowingcode.com/releases</url>
9099
</repository>
100+
<repository>
101+
<id>flowing-snapshots</id>
102+
<url>https://maven.flowingcode.com/snapshots</url>
103+
</repository>
91104
</repositories>
92105

93106
<pluginRepositories>
@@ -206,7 +219,6 @@
206219
<plugin>
207220
<groupId>org.apache.maven.plugins</groupId>
208221
<artifactId>maven-surefire-plugin</artifactId>
209-
<version>2.22.1</version>
210222
<configuration>
211223
<useSystemClassLoader>false</useSystemClassLoader>
212224
</configuration>
@@ -381,34 +393,6 @@
381393
</executions>
382394
</plugin>
383395

384-
<plugin>
385-
<groupId>com.lazerycode.selenium</groupId>
386-
<artifactId>driver-binary-downloader-maven-plugin
387-
</artifactId>
388-
<version>1.0.17</version>
389-
<configuration>
390-
<onlyGetDriversForHostOperatingSystem>
391-
true
392-
</onlyGetDriversForHostOperatingSystem>
393-
<rootStandaloneServerDirectory>
394-
${drivers.dir}/driver
395-
</rootStandaloneServerDirectory>
396-
<downloadedZipFileDirectory>
397-
${drivers.dir}/driver_zips
398-
</downloadedZipFileDirectory>
399-
<customRepositoryMap>
400-
${project.basedir}/drivers.xml
401-
</customRepositoryMap>
402-
</configuration>
403-
<executions>
404-
<execution>
405-
<goals>
406-
<goal>selenium</goal>
407-
</goals>
408-
</execution>
409-
</executions>
410-
</plugin>
411-
412396
<plugin>
413397
<groupId>org.apache.maven.plugins</groupId>
414398
<artifactId>maven-failsafe-plugin</artifactId>
@@ -424,12 +408,6 @@
424408
<configuration>
425409
<trimStackTrace>false</trimStackTrace>
426410
<enableAssertions>true</enableAssertions>
427-
<systemPropertyVariables>
428-
<!-- Pass location of downloaded webdrivers to the tests -->
429-
<webdriver.chrome.driver>
430-
${webdriver.chrome.driver}
431-
</webdriver.chrome.driver>
432-
</systemPropertyVariables>
433411
</configuration>
434412
</plugin>
435413
<plugin>

src/main/java/com/flowingcode/vaadin/addons/template/TemplateAddon.java renamed to src/main/java/com/flowingcode/vaadin/addons/extendedlogin/ExtendedLoginOverlay.java

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/*-
22
* #%L
3-
* Template Add-on
3+
* Extended Login Add-on
44
* %%
5-
* Copyright (C) 2023 Flowing Code
5+
* Copyright (C) 2022 - 2023 Flowing Code
66
* %%
77
* Licensed under the Apache License, Version 2.0 (the "License");
88
* you may not use this file except in compliance with the License.
@@ -17,16 +17,15 @@
1717
* limitations under the License.
1818
* #L%
1919
*/
20+
package com.flowingcode.vaadin.addons.extendedlogin;
2021

21-
package com.flowingcode.vaadin.addons.template;
22-
23-
import com.vaadin.flow.component.Tag;
24-
import com.vaadin.flow.component.dependency.JsModule;
25-
import com.vaadin.flow.component.dependency.NpmPackage;
26-
import com.vaadin.flow.component.html.Div;
22+
import com.vaadin.flow.component.login.LoginOverlay;
2723

24+
/**
25+
* Special LoginOverlay that provides additional methods for replacing specific parts of the contents
26+
*
27+
* @author mlopez
28+
*
29+
*/
2830
@SuppressWarnings("serial")
29-
@NpmPackage(value = "@polymer/paper-input", version = "3.2.1")
30-
@JsModule("@polymer/paper-input/paper-input.js")
31-
@Tag("paper-input")
32-
public class TemplateAddon extends Div {}
31+
public class ExtendedLoginOverlay extends LoginOverlay implements ReplaceableLoginOverlay {}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/*-
2+
* #%L
3+
* Template Add-on
4+
* %%
5+
* Copyright (C) 2022 - 2023 Flowing Code
6+
* %%
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
* #L%
19+
*/
20+
21+
package com.flowingcode.vaadin.addons.extendedlogin;
22+
23+
import com.vaadin.flow.component.AttachEvent;
24+
import com.vaadin.flow.component.HasElement;
25+
import com.vaadin.flow.component.login.LoginOverlay;
26+
import com.vaadin.flow.router.RouterLayout;
27+
28+
/**
29+
* LoginOverlay based Layout that can be used to display views with a similar layout as the LoginOverlay
30+
* It also provides methods for replacing part of the contents of the overlay
31+
*
32+
* @author mlopez
33+
*
34+
*/
35+
@SuppressWarnings("serial")
36+
public class LoginLayout extends LoginOverlay implements RouterLayout, ReplaceableLoginOverlay {
37+
38+
private HasElement content;
39+
40+
@Override
41+
public void showRouterLayoutContent(HasElement content) {
42+
RouterLayout.super.showRouterLayoutContent(content);
43+
this.content = content;
44+
}
45+
46+
@Override
47+
public void removeRouterLayoutContent(HasElement oldContent) {
48+
RouterLayout.super.removeRouterLayoutContent(oldContent);
49+
content = null;
50+
}
51+
52+
@Override
53+
protected void onAttach(AttachEvent attachEvent) {
54+
super.onAttach(attachEvent);
55+
setOpened(true);
56+
this.getElement().executeJs("setTimeout(()=>document.getElementById('vaadinLoginOverlayWrapper').getElementsByTagName('vaadin-login-form-wrapper')[0].replaceChildren())");
57+
this.getElement().appendChild(content.getElement());
58+
content.getElement().setAttribute("slot", "form");
59+
this.content.getElement().executeJs("setTimeout(()=>document.getElementById('vaadinLoginOverlayWrapper').getElementsByTagName('vaadin-login-form-wrapper')[0].appendChild(this))");
60+
}
61+
62+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*-
2+
* #%L
3+
* Extended Login Add-on
4+
* %%
5+
* Copyright (C) 2022 - 2023 Flowing Code
6+
* %%
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
* #L%
19+
*/
20+
package com.flowingcode.vaadin.addons.extendedlogin;
21+
22+
import com.vaadin.flow.component.HasElement;
23+
24+
/**
25+
* Mixin interface providing methods for replacing contents of the LoginOverlay
26+
*
27+
* @author mlopez
28+
*
29+
*/
30+
public interface ReplaceableLoginOverlay extends HasElement {
31+
32+
default void replaceFormComponents(HasElement... withElement) {
33+
this.getElement().executeJs("setTimeout(()=>document.getElementById('vaadinLoginOverlayWrapper').getElementsByTagName('vaadin-login-form-wrapper')[0].getElementsByTagName('form')[0].replaceChildren())");
34+
for (HasElement we : withElement) {
35+
getElement().appendChild(we.getElement());
36+
this.getElement().executeJs("setTimeout(()=>document.getElementById('vaadinLoginOverlayWrapper').getElementsByTagName('vaadin-login-form-wrapper')[0].getElementsByTagName('form')[0].appendChild($0))", we.getElement());
37+
}
38+
}
39+
40+
default void replaceHeaderComponent(HasElement withElement) {
41+
getElement().appendChild(withElement.getElement());
42+
this.getElement().executeJs("setTimeout(()=>document.getElementById('vaadinLoginOverlayWrapper').shadowRoot.querySelector('[part=\"brand\"]').replaceChildren())");
43+
this.getElement().executeJs("setTimeout(()=>document.getElementById('vaadinLoginOverlayWrapper').shadowRoot.querySelector('[part=\"brand\"]').appendChild($0))", withElement);
44+
}
45+
46+
default void replaceForgotPassword(HasElement withElement) {
47+
withElement.getElement().setAttribute("slot", "forgot-password");
48+
getElement().appendChild(withElement.getElement());
49+
this.getElement().executeJs("setTimeout(()=>document.getElementById('vaadinLoginOverlayWrapper').getElementsByTagName('vaadin-login-form-wrapper')[0].querySelector('[slot=\\\"forgot-password\\\"]').remove())");
50+
this.getElement().executeJs("setTimeout(()=>document.getElementById('vaadinLoginOverlayWrapper').getElementsByTagName('vaadin-login-form-wrapper')[0].appendChild($0))", withElement);
51+
}
52+
53+
}

0 commit comments

Comments
 (0)