Skip to content

Commit 766dd8f

Browse files
author
Ville Jyrkkä
committed
Merge pull request #1070 from apinf/hotfix/api-umbrella-methods-sync
Hotfix/Contact form fix
2 parents f5dbc98 + 1691f7e commit 766dd8f

File tree

5 files changed

+47
-13
lines changed

5 files changed

+47
-13
lines changed

client/views/home/body/homeBody.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,22 @@
1+
import { contactEmailValid } from '/lib/helperFunctions/validateSettings';
2+
3+
Template.homeBody.onCreated(function () {
4+
5+
// Subscribe to settings publication
6+
this.subscribe('settings');
7+
});
8+
19
Template.homeBody.rendered = function () {
210
$(".contact-us-link").click(function () {
311
document.getElementById("contact-us").scrollIntoView();
412
});
513
};
14+
15+
Template.homeBody.helpers({
16+
contactDetailsValid () {
17+
18+
const settings = Settings.findOne();
19+
20+
return contactEmailValid(settings);
21+
}
22+
})

client/views/home/body/home_body.html

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -134,18 +134,20 @@ <h2 class="section-heading">{{_ "section3_Heading"}}</h2>
134134
</div>
135135
</div>
136136
</div>
137-
<div id="contact-us" class="container">
138-
<div class="row">
139-
<div class="col-lg-12 text-center">
140-
<h2 class="feature-section-heading">{{_ "section_ContactUs"}}</h2>
141-
<hr class="primary">
142-
<h4 class="text-muted">{{_ "section_ContactUs_Text"}}</h4>
137+
{{ # if contactDetailsValid }}
138+
<div id="contact-us" class="container">
139+
<div class="row">
140+
<div class="col-lg-12 text-center">
141+
<h2 class="feature-section-heading">{{_ "section_ContactUs"}}</h2>
142+
<hr class="primary">
143+
<h4 class="text-muted">{{_ "section_ContactUs_Text"}}</h4>
144+
</div>
143145
</div>
144-
</div>
145-
<div class="row">
146-
<div class="col-lg-6 col-lg-push-3">
147-
{{> contactForm}}
146+
<div class="row">
147+
<div class="col-lg-6 col-lg-push-3">
148+
{{> contactForm}}
149+
</div>
148150
</div>
149151
</div>
150-
</div>
152+
{{ / if }}
151153
</template>

client/views/home/body/home_body.less

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,4 +107,8 @@
107107
.features {
108108
margin-bottom: 3.5em;
109109
}
110+
111+
#contact-us {
112+
margin-bottom: 4.37em;
113+
}
110114
}

client/views/home/footer/home_footer.less

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
/* Footer */
77
footer {
88
background-color: #333;
9-
margin-top: 4.37em;
109
padding-bottom: 1em;
1110
padding-top: 2em;
1211

lib/helperFunctions/validateSettings.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ export function apiUmbrellaSettingsValid (settings) {
3232
// Validates mail configuration settings
3333
export function mailSettingsValid (settings) {
3434

35-
3635
if ((typeof settings !== 'undefined') && settings.mail) {
3736

3837
if (settings.mail.username && settings.mail.password) {
@@ -43,3 +42,16 @@ export function mailSettingsValid (settings) {
4342

4443
return false;
4544
}
45+
46+
// Validate email address setting
47+
export function contactEmailValid (settings) {
48+
// Check all properties in nested structure
49+
if ((typeof settings !== 'undefined') && settings.contactForm) {
50+
if (settings.contactForm.toEmail) {
51+
// Finally return true
52+
return true;
53+
}
54+
}
55+
56+
return false;
57+
}

0 commit comments

Comments
 (0)