Skip to content

Commit

Permalink
handle remote error and petition ui
Browse files Browse the repository at this point in the history
  • Loading branch information
ale-latte committed Nov 26, 2019
1 parent a4a2701 commit 2253d0e
Show file tree
Hide file tree
Showing 15 changed files with 78 additions and 13 deletions.
8 changes: 6 additions & 2 deletions classes/class-p4ct-ajax-handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -422,8 +422,12 @@ private function get_carousel_posts( $tags, $type, $preferences ) {
'filename' => null,
);
$result = wp_remote_get( $url, $args );
$obj = json_decode( $result['body'], true );
$single_update['signatures'] = $obj['rows'][0]['columns'][4]['value'];
if( is_wp_error( $result ) ) {
$single_update['signatures'] = 0;
} else {
$obj = json_decode( $result['body'], true );
$single_update['signatures'] = $obj['rows'][0]['columns'][4]['value'];
}
}

if ( $single_update['engaging_target'] && $single_update['signatures'] ) {
Expand Down
2 changes: 1 addition & 1 deletion frontend/js/components/en-petition-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ export default function() {
if ( 1 == gpeaOptions.showFacebook ) {
const ctaFacebook = document.createElement('button');
ctaFacebook.classList.add('button', 'fb', 'js-sign-facebook');
ctaFacebook.innerHTML = 'Facebook';
ctaFacebook.innerHTML = gpeaOptions.facebook_label;

// cta.parentNode.insertBefore(ctaFacebook, cta);
let formContainer = form.querySelector('.form-container');
Expand Down
54 changes: 50 additions & 4 deletions frontend/scss/_template-petition.scss
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@
background-size: auto 70%;
background-position: 4px center;
@include lessThan('sm') {
width: 50%;
min-width: 50%;
width: auto;
padding-left: 45px;
}
}
}
Expand All @@ -78,7 +80,7 @@
.outer_block_container {
@include ct-container;
padding-top: 0;
padding-bottom: 0;
padding-bottom: 0;

> :last-child:not(.enform-side-style) {
margin-bottom: 145px;
Expand Down Expand Up @@ -129,6 +131,9 @@

.page-template-petition,
.page-template-petition-thankyou {
.outer_block_container {
overflow: visible;
}
footer {
padding-top: 0;

Expand All @@ -137,7 +142,7 @@
}
.footer-lower {
margin-top: 20px;
padding-bottom: 220px;
padding-bottom: 120px;
@include greaterThan('sm') {
padding-bottom: 20px;
}
Expand Down Expand Up @@ -296,6 +301,47 @@
.en__field--emailAddress {
display: block;
}
}
div.thankyou {
background-color: #fff;
.form-group {
display: block;
}
.form-group.social-media {
display: none;
}
header {
display: inline-block;
}
p {
display: block;
}
.formblock-flex {
height: auto;
display: block;
}
a.btn.btn-primary.btn-block {
width: 100%;
}
}
}
div.thankyou {
.form-group {
display: none;
}
header, p {
display: none;
}
.formblock-flex {
display: flex;
height: auto;
max-height: none;
margin-bottom: 0;
align-items: center;
justify-content: center;
}
a.btn.btn-primary.btn-block {
width: auto;
}
}
}
}
2 changes: 1 addition & 1 deletion frontend/scss/organisms/_section-petition.scss
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@
}

.enform.is-open {
transform: translateY(-50vh);
transform: translateY(-45vh);
height: 92vh;

.title-and-description,
Expand Down
Binary file modified languages/gpea_theme-ko_KR.mo
Binary file not shown.
3 changes: 3 additions & 0 deletions languages/gpea_theme-ko_KR.po
Original file line number Diff line number Diff line change
Expand Up @@ -513,3 +513,6 @@ msgstr "전체 보기"

msgid "Any topic"
msgstr "전체 보기"

msgid "Facebook"
msgstr "페이스북으로 로그인"
Binary file modified languages/gpea_theme-zh_HK.mo
Binary file not shown.
3 changes: 3 additions & 0 deletions languages/gpea_theme-zh_HK.po
Original file line number Diff line number Diff line change
Expand Up @@ -518,3 +518,6 @@ msgstr "所有主題"

msgid "Any topic"
msgstr "所有議題"

msgid "Facebook"
msgstr "Facebook"
Binary file modified languages/gpea_theme-zh_TW.mo
Binary file not shown.
3 changes: 3 additions & 0 deletions languages/gpea_theme-zh_TW.po
Original file line number Diff line number Diff line change
Expand Up @@ -513,3 +513,6 @@ msgstr "所有議題"

msgid "Any topic"
msgstr "所有主題"

msgid "Facebook"
msgstr "Facebook"
9 changes: 7 additions & 2 deletions page-templates/petition.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
// extra cta in thanks box
$context['extra_cta_link'] = $page_meta_data['p4-gpea_cta_thanks_link'][0] ?? '';
$context['extra_cta_label'] = $page_meta_data['p4-gpea_cta_thanks_label'][0] ?? '';
$context['facebook_label'] = __( 'Facebook', 'gpea_theme' );


if ( $context['engaging_page_id'] && ! $context['signatures'] ) {
Expand All @@ -109,8 +110,12 @@
'filename' => null,
);
$result = wp_remote_get( $url, $args );
$obj = json_decode( $result['body'], true );
$context['signatures'] = $obj['rows'][0]['columns'][4]['value'];
if( is_wp_error( $result ) ) {
$context['signatures'] = 0;
} else {
$obj = json_decode( $result['body'], true );
$context['signatures'] = $obj['rows'][0]['columns'][4]['value'];
}
}

if ( $context['petition_target'] && $context['signatures'] ) {
Expand Down
2 changes: 1 addition & 1 deletion static/css/style.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion static/css/style.css.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion static/js/script.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions templates/petition.twig
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
<script>
gpeaOptions.petition_thanks_link = '{{ extra_cta_link }}';
gpeaOptions.petition_thanks_label = '{{ extra_cta_label }}';
gpeaOptions.facebook_label = '{{ facebook_label }}';
</script>
{% endif %}
{% endblock %}
Expand Down

0 comments on commit 2253d0e

Please sign in to comment.