Skip to content

Commit cc15320

Browse files
ahmad-shahidplup2
authored andcommitted
Resolve "Add acronym functionality for custom menu"
1 parent b25d471 commit cc15320

12 files changed

Lines changed: 97 additions & 19 deletions

File tree

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ public abstract class Constants {
1313

1414
public static final String CACHE_KEY_STATICFILES_PREFIX = "GoC.Template.CacheKey";
1515

16-
public static final String WEB_TEMPLATE_DISTRIBUTION_VERSION = "2.3.2";
16+
public static final String WEB_TEMPLATE_DISTRIBUTION_VERSION = "2.4.0";
1717

18-
public static final String CDTS_DEFAULT_VERSION = "v4_0_44";
18+
public static final String CDTS_DEFAULT_VERSION = "v4_0_45";
1919

2020
public static final String STATIC_FALLBACK_FILES_INTERNAL_PATH = "/goc/webtemplate/StaticFallbackFiles";
2121

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

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,45 @@
66
public class MenuItem extends Link {
77
private ArrayList<MenuItem> subItems = null;
88
private boolean openInNewWindow = false;
9+
private String acronym = null;
910

1011
public MenuItem() {
1112
this.subItems = new ArrayList<MenuItem>();
1213
}
1314

1415
public MenuItem(String href, String text) {
15-
this(href, text, new ArrayList<MenuItem>(), false);
16+
this(href, text, null, new ArrayList<MenuItem>(), false);
17+
}
18+
19+
public MenuItem(String href, String text, String acronym) {
20+
this(href, text, acronym, new ArrayList<MenuItem>(), false);
1621
}
1722

1823
public MenuItem(String href, String text, boolean openInNewWindow) {
19-
this(href, text, new ArrayList<MenuItem>(), openInNewWindow);
24+
this(href, text, null, new ArrayList<MenuItem>(), openInNewWindow);
25+
}
26+
27+
public MenuItem(String href, String text, String acronym, boolean openInNewWindow) {
28+
this(href, text, acronym, new ArrayList<MenuItem>(), openInNewWindow);
2029
}
21-
30+
2231
public MenuItem(String href, String text, ArrayList<MenuItem> subItems) {
23-
this(href, text, subItems, false);
32+
this(href, text, null, subItems, false);
2433
}
2534

2635
public MenuItem(String href, String text, ArrayList<MenuItem> subItems, boolean openInNewWindow) {
36+
this(href, text, null, subItems, openInNewWindow);
37+
}
38+
39+
public MenuItem(String href, String text, String acronym, ArrayList<MenuItem> subItems) {
40+
this(href, text, acronym, subItems, false);
41+
}
42+
43+
public MenuItem(String href, String text, String acronym, ArrayList<MenuItem> subItems, boolean openInNewWindow) {
2744
super(href, text);
2845
this.subItems = subItems;
2946
this.openInNewWindow = openInNewWindow;
47+
this.acronym = acronym;
3048
}
3149

3250
public void setOpenInNewWindow(boolean openInNewWindow) {
@@ -44,4 +62,12 @@ public void setSubItems(ArrayList<MenuItem> subItems) {
4462
public ArrayList<MenuItem> getSubItems() {
4563
return this.subItems;
4664
}
65+
66+
public String getAcronym() {
67+
return acronym;
68+
}
69+
70+
public void setAcronym(String acronym) {
71+
this.acronym = acronym;
72+
}
4773
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ public void setUseHttps(boolean value) {
457457
}
458458

459459
/**
460-
* Returns the version of the CDN files to use to build the page. (e.g v4_0_44)
460+
* Returns the version of the CDN files to use to build the page. (e.g v4_0_45)
461461
*
462462
* Set at application level via "wettemplate_version" property in cdn.properties,
463463
* can be overriden programatically.
@@ -478,7 +478,7 @@ public String getTemplateVersion() {
478478
}
479479

480480
/**
481-
* Sets the version of the CDN files to use to build the page. (e.g v4_0_44)
481+
* Sets the version of the CDN files to use to build the page. (e.g v4_0_45)
482482
*
483483
* Set at application level via "wettemplate_version" property in cdn.properties,
484484
* can be overriden programatically.

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,17 @@ public class SecMenuItem implements Serializable {
2121

2222
private String href;
2323
private String text;
24+
private String acronym;
2425
private Boolean newWindow;
2526
private ArrayList<SecMenuSubItem> subLinks;
2627

2728
public SecMenuItem() {
2829
}
2930

30-
public SecMenuItem(String href, String text, Boolean newWindow, ArrayList<SecMenuSubItem> subLinks) {
31+
public SecMenuItem(String href, String text, String acronym, Boolean newWindow, ArrayList<SecMenuSubItem> subLinks) {
3132
this.href = href;
3233
this.text = text;
34+
this.acronym = acronym;
3335
this.newWindow = newWindow;
3436
this.subLinks = subLinks;
3537
}
@@ -41,13 +43,15 @@ public SecMenuItem(String href, String text, Boolean newWindow, ArrayList<SecMen
4143
public SecMenuItem(Link link) {
4244
this.href = BaseUtil.encodeUrl(link.getHref());
4345
this.text = link.getText();
46+
this.acronym = null;
4447
this.newWindow = null;
4548
this.subLinks = null;
4649

4750
if (link instanceof MenuItem) {
4851
MenuItem mi = (MenuItem)link;
4952

5053
this.newWindow = mi.isOpenInNewWindow();
54+
this.acronym = mi.getAcronym();
5155

5256
if (mi.getSubItems() != null && mi.getSubItems().size() > 0) {
5357
this.subLinks = new ArrayList<SecMenuSubItem>(mi.getSubItems().size());
@@ -87,4 +91,12 @@ public ArrayList<SecMenuSubItem> getSubLinks() {
8791
public void setSubLinks(ArrayList<SecMenuSubItem> subLinks) {
8892
this.subLinks = subLinks;
8993
}
94+
95+
public String getAcronym() {
96+
return acronym;
97+
}
98+
99+
public void setAcronym(String acronym) {
100+
this.acronym = acronym;
101+
}
90102
}

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

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,16 @@ public class SecMenuSubItem implements Serializable {
1919

2020
private String subhref;
2121
private String subtext;
22+
private String acronym;
2223
private boolean newWindow;
2324

2425
public SecMenuSubItem() {
2526
}
2627

27-
public SecMenuSubItem(String subhref, String subtext, boolean newWindow) {
28+
public SecMenuSubItem(String subhref, String subtext, String acronym, boolean newWindow) {
2829
this.subhref = subhref;
2930
this.subtext = subtext;
31+
this.acronym = acronym;
3032
this.newWindow = newWindow;
3133
}
3234

@@ -37,6 +39,7 @@ public SecMenuSubItem(String subhref, String subtext, boolean newWindow) {
3739
public SecMenuSubItem(MenuItem menuItem) {
3840
this.subhref = BaseUtil.encodeUrl(menuItem.getHref());
3941
this.subtext = menuItem.getText();
42+
this.acronym = menuItem.getAcronym();
4043
this.newWindow = menuItem.isOpenInNewWindow();
4144
}
4245

@@ -63,4 +66,12 @@ public boolean isNewWindow() {
6366
public void setNewWindow(boolean newWindow) {
6467
this.newWindow = newWindow;
6568
}
69+
70+
public String getAcronym() {
71+
return acronym;
72+
}
73+
74+
public void setAcronym(String acronym) {
75+
this.acronym = acronym;
76+
}
6677
}

gocwebtemplate-core/gocwebtemplate-core-base/src/main/resources/goc/webtemplate/global/config/CDTSEnvironments.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{
1+
{
22
"//": "This is an unconventional way of adding comments, but this needs to be documented here",
33
"//{0}": "is HTTPS Flag",
44
"//{1}": "is RN/APP Switch",
@@ -20,7 +20,7 @@
2020
},
2121
{
2222
"name": "PROD_SSL",
23-
"path": "https://ssl-templates.services.gc.ca/{1}/cls/wet/{2}/{3}cdts/compiled/",
23+
"path": "https://cdts.service.canada.ca/{1}/cls/WET/{2}/{3}cdts/compiled/",
2424
"theme": "gcintranet",
2525
"cdn": "prod",
2626
"isVersionRnCombined": false,
@@ -33,7 +33,7 @@
3333
},
3434
{
3535
"name": "PROD_SSL_ECCCSUB",
36-
"path": "https://ssl-templates.services.gc.ca/{1}/cls/wet/{2}/{3}cdts/compiled/",
36+
"path": "https://cdts.service.canada.ca/{1}/cls/WET/{2}/{3}cdts/compiled/",
3737
"theme": "gcintranet",
3838
"subTheme": "eccc",
3939
"cdn": "prod",
@@ -47,7 +47,7 @@
4747
},
4848
{
4949
"name": "PROD_UNSECURE",
50-
"path": "http://templates.services.gc.ca/{1}/cls/wet/{2}/{3}cdts/compiled/",
50+
"path": "http://cdts.service.canada.ca/{1}/cls/WET/{2}/{3}cdts/compiled/",
5151
"theme": "gcintranet",
5252
"cdn": "prod",
5353
"isVersionRnCombined": false,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package goc.webtemplate.component.abstractcorebeantest;
2+
3+
import static org.junit.jupiter.api.Assertions.assertTrue;
4+
5+
import java.util.ArrayList;
6+
7+
import org.junit.jupiter.api.Test;
8+
9+
import goc.webtemplate.MenuItem;
10+
11+
public class RenderAppTopTest {
12+
13+
@Test
14+
public void testCustomMenuItem() {
15+
AbstractCoreBeanImpl sut = new AbstractCoreBeanImpl();
16+
17+
ArrayList<MenuItem> menuLinks = new ArrayList<MenuItem>();
18+
MenuItem item = new MenuItem();
19+
item.setText("Custom Menu Link");
20+
item.setHref("https//google.ca");
21+
item.setAcronym("acronym");
22+
menuLinks.add(item);
23+
sut.setMenuLinks(menuLinks);
24+
25+
assertTrue(sut.getRenderAppTop().contains("\"menuLinks\":[{\"href\":\"https//google.ca\",\"text\":\"Custom Menu Link\",\"acronym\":\"acronym\""),
26+
"RenderTop: Custom MenuItem not rendered as expected.");
27+
}
28+
29+
}

gocwebtemplate-core/gocwebtemplate-core-base/src/test/resources/goc/webtemplate/global/config/cdn.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ cdn_localdev_localpath=/loadtesting/app/cls/WET/{0}/{1}/
2929
#(blank values for theme, subtheme and version will use defaults from internal environment configuration)
3030
wettemplate_theme=
3131
wettemplate_subtheme=
32-
wettemplate_version=v4_0_44
32+
wettemplate_version=v4_0_45
3333
wettemplate_loadjqueryfromgoogle=false
3434
webtemplate_usehttps=true
3535
#

gocwebtemplate-core/gocwebtemplate-core-jsp/src/test/resources/goc/webtemplate/global/config/cdn.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ cdn_localdev_localpath=/GoCWebTemplateSampleJSP/loadtesting/app/cls/WET/{0}/{1}/
2929
#(blank values for theme, subtheme and version will use defaults from internal environment configuration)
3030
wettemplate_theme=
3131
wettemplate_subtheme=
32-
wettemplate_version=v4_0_44
32+
wettemplate_version=v4_0_45
3333
wettemplate_loadjqueryfromgoogle=false
3434
webtemplate_usehttps=true
3535
#

gocwebtemplate-sample-jsp/src/main/java/goc/webtemplate/jsp/samplebeans/LeftSideMenuSampleBean.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public void onWebTemplateInitialize() {
2323
leftMenu.getItems().add(new Link("http://www.tsn.ca", "TSN"));
2424

2525
MenuItem item = new MenuItem("", "Sports");
26-
item.getSubItems().add(new MenuItem("http://www.nhl.com", "NHL", null, true));
26+
item.getSubItems().add(new MenuItem("http://www.nhl.com", "NHL", true));
2727
item.getSubItems().add(new MenuItem("http://www.mlb.com", "MLB"));
2828

2929
leftMenu.getItems().add(item);

0 commit comments

Comments
 (0)