Skip to content

Commit 45209db

Browse files
committed
Adding support for new footer
1 parent ef06065 commit 45209db

10 files changed

Lines changed: 314 additions & 14 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
## v2.6.0
66

7+
- **IMPORTANT** The GCWeb site footer has been updated to reflect the changes introduced in WET footer version 4. These changes will be applied automatically. For more information, please visit the WET documentation: https://wet-boew.github.io/GCWeb/sites/footers/footers-en.html
78
- [CDTS](https://github.com/wet-boew/cdts-sgdc/) v4.0.47 & [wet-boew](https://github.com/wet-boew/wet-boew) v4.0.56.5
89
- Updated static fallback files
910
- Bug Fixes
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package goc.webtemplate;
2+
3+
import java.util.List;
4+
5+
public class ContextualFooter {
6+
7+
private String title;
8+
private List<Link> links;
9+
10+
public ContextualFooter() {}
11+
12+
public ContextualFooter(String title, List<Link> links)
13+
{
14+
this.title = title;
15+
this.links = links;
16+
}
17+
18+
public String getTitle() {
19+
return title;
20+
}
21+
22+
public void setTitle(String title) {
23+
this.title = title;
24+
}
25+
26+
public List<Link> getLinks() {
27+
return links;
28+
}
29+
30+
public void setLinks(List<Link> links) {
31+
this.links = links;
32+
}
33+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package goc.webtemplate;
2+
3+
public class FooterLinkContext {
4+
5+
private boolean showFooter;
6+
private FooterLink footerLink;
7+
8+
public FooterLinkContext() {}
9+
10+
public FooterLinkContext(boolean showFooter, FooterLink footerLink) {
11+
this.showFooter = showFooter;
12+
this.footerLink = footerLink;
13+
}
14+
15+
public boolean isShowFooter() {
16+
return showFooter;
17+
}
18+
19+
public void setShowFooter(boolean showFooter) {
20+
this.showFooter = showFooter;
21+
}
22+
23+
public FooterLink getFooterLink() {
24+
return footerLink;
25+
}
26+
27+
public void setFooterLink(FooterLink footerLink) {
28+
this.footerLink = footerLink;
29+
}
30+
}

gocwebtemplate-core/gocwebtemplate-core-base/src/main/java/goc/webtemplate/Link.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
public class Link implements Serializable, Cloneable {
77
private String href = "";
88
private String text = "";
9+
private boolean newWindow;
910

1011
public Link() {}
1112

@@ -15,9 +16,15 @@ public Link(String href)
1516
}
1617

1718
public Link(String href, String text)
19+
{
20+
this(href, text, false);
21+
}
22+
23+
public Link(String href, String text, boolean newWindow)
1824
{
1925
this.href = href;
2026
this.text = text;
27+
this.newWindow = newWindow;
2128
}
2229

2330
public void setHref(String href) { this.href = href; }
@@ -26,6 +33,9 @@ public Link(String href, String text)
2633
public void setText(String text) { this.text = text; }
2734
public String getText() { return this.text; }
2835

36+
public void setNewWindow(boolean value) { this.newWindow = value; }
37+
public boolean getNewWindow() {return this.newWindow; }
38+
2939
public Link clone() {
3040
try {
3141
return (Link)super.clone();

gocwebtemplate-core/gocwebtemplate-core-base/src/main/java/goc/webtemplate/component/AbstractCoreBean.java

Lines changed: 73 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
import goc.webtemplate.Breadcrumb;
1818
import goc.webtemplate.Constants;
19+
import goc.webtemplate.ContextualFooter;
1920
import goc.webtemplate.CustomSearch;
2021
import goc.webtemplate.FooterLink;
2122
import goc.webtemplate.FooterSection;
@@ -154,6 +155,9 @@ private enum Themes { GCWEB, GCINTRANET }
154155
private String footerPath = null;
155156
private boolean hidePlaceholderMenu = false;
156157
private InfoBanner infoBanner = null;
158+
private ContextualFooter contextualFooter = null;
159+
private boolean hideMainFooter = false;
160+
private boolean hideCorporateFooter = false;
157161
//-------------------------------------------------------
158162

159163
//-------------------------------------------------------
@@ -1494,6 +1498,63 @@ public void setInfoBanner(InfoBanner value) {
14941498
this.infoBanner = value;
14951499
}
14961500

1501+
/**
1502+
* Returns whether to display a contextual footer band that can display up to 3 links
1503+
*
1504+
* can be overriden programatically.
1505+
*/
1506+
public ContextualFooter getContextualFooter() {
1507+
this.initializeOnce();
1508+
return this.contextualFooter;
1509+
}
1510+
1511+
/**
1512+
* Sets whether to display a contextual footer band that can display up to 3 links
1513+
*
1514+
* can be overriden programatically.
1515+
*/
1516+
public void setContextualFooter(ContextualFooter value) {
1517+
this.contextualFooter = value;
1518+
}
1519+
1520+
/**
1521+
* Returns whether to hide the main footer
1522+
*
1523+
* can be overriden programatically.
1524+
*/
1525+
public boolean getHideMainFooter() {
1526+
this.initializeOnce();
1527+
return this.hideMainFooter;
1528+
}
1529+
1530+
/**
1531+
* Sets whether to hide the main footer
1532+
*
1533+
* can be overriden programatically.
1534+
*/
1535+
public void setHideMainFooter(boolean value) {
1536+
this.hideMainFooter = value;
1537+
}
1538+
1539+
/**
1540+
* Returns whether to hide corporate footer links
1541+
*
1542+
* can be overriden programatically.
1543+
*/
1544+
public boolean getHideCorporateFooter() {
1545+
this.initializeOnce();
1546+
return this.hideCorporateFooter;
1547+
}
1548+
1549+
/**
1550+
* Sets whether to hide corporate footer links
1551+
*
1552+
* can be overriden programatically.
1553+
*/
1554+
public void setHideCorporateFooter(boolean value) {
1555+
this.hideCorporateFooter = value;
1556+
}
1557+
14971558
/**
14981559
* Returns a copy of the breadcrumb list, ready for JSON serialization
14991560
*/
@@ -2010,9 +2071,12 @@ public String getRenderFooter() {
20102071
true, //showFooter,
20112072
this.getShowFeatures(),
20122073
this.buildContactLinks(),
2013-
null, //privacyLink
2014-
null, //termsLink
2015-
JsonValueUtils.getNonEmptyString(this.getLocalPath())
2074+
JsonValueUtils.getFooterLinkContext(this.getPrivacyLink(), true),
2075+
JsonValueUtils.getFooterLinkContext(this.getTermsConditionsLink(), true),
2076+
JsonValueUtils.getNonEmptyString(this.getLocalPath()),
2077+
this.contextualFooter,
2078+
this.hideMainFooter,
2079+
this.hideCorporateFooter
20162080
));
20172081
}
20182082

@@ -2027,9 +2091,12 @@ public String getRenderTransactionalFooter() {
20272091
false, //showFooter
20282092
this.getShowFeatures(),
20292093
this.buildContactLinks(),
2030-
JsonValueUtils.getNonEmptySingleItemLinkList(this.getPrivacyLink()),
2031-
JsonValueUtils.getNonEmptySingleItemLinkList(this.getTermsConditionsLink()),
2032-
JsonValueUtils.getNonEmptyString(this.getLocalPath())
2094+
JsonValueUtils.getFooterLinkContext(this.getPrivacyLink(), false),
2095+
JsonValueUtils.getFooterLinkContext(this.getTermsConditionsLink(), false),
2096+
JsonValueUtils.getNonEmptyString(this.getLocalPath()),
2097+
null, //contextualFooter
2098+
false, //hideMainFooter
2099+
false //hideCorporateFooter
20332100
));
20342101
}
20352102

gocwebtemplate-core/gocwebtemplate-core-base/src/main/java/goc/webtemplate/component/JsonValueUtils.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import java.util.List;
66

77
import goc.webtemplate.FooterLink;
8+
import goc.webtemplate.FooterLinkContext;
89
import goc.webtemplate.Link;
910
import goc.webtemplate.Utility;
1011

@@ -107,4 +108,12 @@ public static boolean getBooleanValue(String value, boolean defaultValue)
107108
{
108109
return Utility.isNullOrEmpty(value)? defaultValue: Boolean.parseBoolean(value);
109110
}
111+
112+
/**
113+
* Returns FooterLinkContext value depending on the value of showFooter
114+
* If the link href if null, then a null value is returned
115+
*/
116+
public static FooterLinkContext getFooterLinkContext(FooterLink link, boolean showFooter) {
117+
return Utility.isNullOrEmpty(link.getHref())? null: new FooterLinkContext(showFooter, link);
118+
}
110119
}

gocwebtemplate-core/gocwebtemplate-core-base/src/main/java/goc/webtemplate/component/jsonentities/Footer.java

Lines changed: 48 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@
44

55
import java.util.List;
66

7+
import com.google.gson.annotations.JsonAdapter;
8+
9+
import goc.webtemplate.ContextualFooter;
710
import goc.webtemplate.FooterLink;
11+
import goc.webtemplate.FooterLinkContext;
812
import goc.webtemplate.Link;
913

1014
/**
@@ -20,15 +24,25 @@ public class Footer implements Serializable {
2024
private boolean showFooter;
2125
private boolean showFeatures;
2226
private List<Link> contactLinks;
23-
private List<FooterLink> privacyLink;
24-
private List<FooterLink> termsLink;
27+
28+
//NOTE: Custom serialization/adapter because value can be both a footer link and a list of footer links
29+
@JsonAdapter(goc.webtemplate.component.jsonentities.adapters.FooterLinkAdapter.class)
30+
private FooterLinkContext privacyLink;
31+
32+
//NOTE: Custom serialization/adapter because value can be both a footer link and a list of footer links
33+
@JsonAdapter(goc.webtemplate.component.jsonentities.adapters.FooterLinkAdapter.class)
34+
private FooterLinkContext termsLink;
35+
2536
private String localPath;
37+
private ContextualFooter contextualFooter;
38+
private boolean hideFooterMain;
39+
private boolean hideFooterCorporate;
2640

2741
public Footer() {
2842
}
2943

3044
public Footer(String cdnEnv, String subTheme, boolean showFooter, boolean showFeatures, List<Link> contactLinks,
31-
List<FooterLink> privacyLink, List<FooterLink> termsLink, String localPath) {
45+
FooterLinkContext privacyLink, FooterLinkContext termsLink, String localPath, ContextualFooter contextualFooter, boolean hideFooterMain, boolean hideFooterCorporate) {
3246
this.cdnEnv = cdnEnv;
3347
this.subTheme = subTheme;
3448
this.showFooter = showFooter;
@@ -37,6 +51,9 @@ public Footer(String cdnEnv, String subTheme, boolean showFooter, boolean showFe
3751
this.privacyLink = privacyLink;
3852
this.termsLink = termsLink;
3953
this.localPath = localPath;
54+
this.contextualFooter = contextualFooter;
55+
this.hideFooterMain = hideFooterMain;
56+
this.hideFooterCorporate = hideFooterCorporate;
4057
}
4158

4259
public String getCdnEnv() {
@@ -79,19 +96,19 @@ public void setContactLinks(List<Link> contactLinks) {
7996
this.contactLinks = contactLinks;
8097
}
8198

82-
public List<FooterLink> getPrivacyLink() {
99+
public FooterLinkContext getPrivacyLink() {
83100
return privacyLink;
84101
}
85102

86-
public void setPrivacyLink(List<FooterLink> privacyLink) {
103+
public void setPrivacyLink(FooterLinkContext privacyLink) {
87104
this.privacyLink = privacyLink;
88105
}
89106

90-
public List<FooterLink> getTermsLink() {
107+
public FooterLinkContext getTermsLink() {
91108
return termsLink;
92109
}
93110

94-
public void setTermsLink(List<FooterLink> termsLink) {
111+
public void setTermsLink(FooterLinkContext termsLink) {
95112
this.termsLink = termsLink;
96113
}
97114

@@ -102,4 +119,28 @@ public String getLocalPath() {
102119
public void setLocalPath(String localPath) {
103120
this.localPath = localPath;
104121
}
122+
123+
public ContextualFooter getContextualFooter() {
124+
return contextualFooter;
125+
}
126+
127+
public void setContextualFooter(ContextualFooter contextualFooter) {
128+
this.contextualFooter = contextualFooter;
129+
}
130+
131+
public boolean isHideFooterMain() {
132+
return hideFooterMain;
133+
}
134+
135+
public void setHideFooterMain(boolean hideFooterMain) {
136+
this.hideFooterMain = hideFooterMain;
137+
}
138+
139+
public boolean isHideFooterCorporate() {
140+
return hideFooterCorporate;
141+
}
142+
143+
public void setHideFooterCorporate(boolean hideFooterCorporate) {
144+
this.hideFooterCorporate = hideFooterCorporate;
145+
}
105146
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package goc.webtemplate.component.jsonentities.adapters;
2+
3+
import java.io.IOException;
4+
import com.google.gson.TypeAdapter;
5+
import com.google.gson.stream.JsonReader;
6+
import com.google.gson.stream.JsonWriter;
7+
8+
import goc.webtemplate.FooterLinkContext;
9+
10+
/**
11+
* GSON type adapter for serializing the "privacyLink" or "termsLink" parameter to the WET
12+
* function "wet.build.footer". Needed because this parameter can be a footer link
13+
* or an array of footer links depending on if showFooter is true or false.
14+
*/
15+
public class FooterLinkAdapter extends TypeAdapter<FooterLinkContext>{
16+
@Override
17+
public void write(JsonWriter jw, FooterLinkContext obj) throws IOException {
18+
19+
if (obj == null) {
20+
jw.nullValue();
21+
return;
22+
}
23+
24+
//If showFooter is false, render footer link as an array
25+
if (!obj.isShowFooter()) jw.beginArray();
26+
jw.beginObject();
27+
jw.name("href");
28+
jw.value(obj.getFooterLink().getHref());
29+
jw.name("newWindow");
30+
jw.value(obj.getFooterLink().getNewWindow());
31+
jw.endObject();
32+
if (!obj.isShowFooter()) jw.endArray();
33+
}
34+
35+
@Override
36+
public FooterLinkContext read(JsonReader jr) throws IOException {
37+
throw new UnsupportedOperationException("JSON deserialization not supported for type FooterLinkContext.");
38+
}
39+
40+
}

gocwebtemplate-core/gocwebtemplate-core-base/src/test/java/goc/webtemplate/component/abstractcorebeantest/RenderAppTopTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public void testInfoBanner() {
3535
InfoBanner banner = new InfoBanner("Main Text", new Link("google", "Link"), new Link("yahoo", "Button"));
3636
sut.setInfoBanner(banner);
3737

38-
assertTrue(sut.getRenderAppTop().contains("\"infoBanner\":{\"mainHTML\":\"Main Text\",\"link\":{\"href\":\"google\",\"text\":\"Link\"},\"button\":{\"href\":\"yahoo\",\"text\":\"Button\"}"),
38+
assertTrue(sut.getRenderAppTop().contains("\"infoBanner\":{\"mainHTML\":\"Main Text\",\"link\":{\"href\":\"google\",\"text\":\"Link\",\"newWindow\":false},\"button\":{\"href\":\"yahoo\",\"text\":\"Button\",\"newWindow\":false}"),
3939
"\"RenderTop: InfoBanner not rendered as expected.\"");
4040
}
4141

0 commit comments

Comments
 (0)