Commit 988453f7 authored by Michael Iseard's avatar Michael Iseard
Browse files

Change campaign property an array and remove redundant properties

parent cf5cc5df
......@@ -31,55 +31,9 @@ class KudosButton {
*/
private $target_id;
/**
* Modal title
*
* @var string
*/
private $modal_title;
/**
* Modal text
*
* @var string
*/
private $welcome_text;
/**
* Donation amount selection type
*
* @var string
*/
private $amount_type;
/**
* Fixed amount list (5, 10, 15)
*
* @var string
*/
private $fixed_amounts;
/**
* Campaign label
*
* @var string
*/
private $campaign_id;
/**
* @var string
*/
private $campaign_goal;
/**
* @var string
*/
private $campaign_total;
/**
* @var string
*/
private $donation_type;
/**
* @var bool
*/
private $address_enabled;
/**
* @var bool
* @var array
*/
private $address_required;
private $campaign;
/**
* KudosButton constructor.
......@@ -150,16 +104,7 @@ class KudosButton {
$data = [
'modal_id' => $this->target_id,
'modal_title' => $this->modal_title,
'modal_text' => $this->welcome_text,
'amount_type' => $this->amount_type,
'fixed_amounts' => array_slice( explode( ',', $this->fixed_amounts ), 0, 4 ),
'address_enabled' => $this->address_enabled,
'address_required' => $this->address_required,
'donation_type' => $this->donation_type,
'campaign_id' => $this->campaign_id,
'campaign_goal' => $this->campaign_goal,
'campaign_total' => $this->campaign_total,
'campaign' => $this->campaign,
'payment_by' => __( 'Secure payment by', 'kudos-donations' ),
];
......
......@@ -3,12 +3,7 @@
{% set premium = false %}
{% block header %}
{% if campaign_goal > 0 and campaign_total > 0 %}
<div class="kd-w-full kd-mx-5">
{% from "/public/modal/macros/progress.html.twig" import progress %}
{{ progress(campaign_goal, campaign_total) }}
</div>
{% endif %}
{{ header|raw }}
{% endblock header %}
{% block content %}
......@@ -16,22 +11,22 @@
<form class="kudos_form m-0 p-0" action="">
<input required name="return_url" type="hidden" value="{{ return_url }}">
<input name="campaign_id" type="hidden" value="{{ campaign_id }}">
<input name="campaign_id" type="hidden" value="{{ campaign.id }}">
<div class="form-tabs block">
{# INITIAL FIELDS #}
{% embed '/public/modal/embeds/_tab.html.twig' %}
{% block title %}{{ modal_title }}{% endblock %}
{% block text %}{{ modal_text }}{% endblock %}
{% block title %}{{ campaign.modal_title }}{% endblock %}
{% block text %}{{ campaign.welcome_text }}{% endblock %}
{% block body %}
{% from "/public/modal/macros/form.html.twig" import input_group, radio_buttons, text, radio %}
{% if ( amount_type != 'open' ) %}
{{ radio_buttons(fixed_amounts, 'amount-' ~ modal_id ) }}
{% if ( campaign.amount_type != 'open' ) %}
{{ radio_buttons(campaign.fixed_amounts|split(','), 'amount-' ~ modal_id ) }}
{% endif %}
{% if amount_type == 'both' %}
{% if campaign.amount_type == 'both' %}
{{ input_group( '', __('Other', 'kudos-donations'), __('Amount', 'kudos-donations') ~ ' (€)',
{
'input': { 'id': 'value_open-' ~ modal_id,'min': '1', 'data-type': 'currency' }
......@@ -39,16 +34,16 @@
) }}
{% endif %}
{% if amount_type == 'open' %}
{% if campaign.amount_type == 'open' %}
{{ text('value', __('Amount', 'kudos-donations') ~ ' (€)', 'text', true, {'min': '1', 'data-type': 'currency'}) }}
{% endif %}
{{ text('name', __('Name', 'kudos-donations')) }}
{{ text('email_address', __('E-mail address', 'kudos-donations'), 'email') }}
{% if(donation_type == 'oneoff') %}
{% if(campaign.donation_type == 'oneoff') %}
<input required checked type="hidden" name="payment_frequency" value="oneoff"/>
{% elseif(donation_type == 'recurring') %}
{% elseif(campaign.donation_type == 'recurring') %}
<input required checked type="hidden" name="payment_frequency" value="recurring"/>
{% else %}
{{ radio('payment_frequency', {
......
{% macro progress(total, current, height='35px') %}
{% set percent = ((current / total) * 100) | round %}
<div data-percent="{{ percent }}" class="kudos-campaign-progress kd-flex kd-relative kd-shadow-inner kd-my-4 kd-overflow-hidden kd-bg-gray-200 kd-rounded kd-w-full" style="height: {{ height }}">
<div class="kudos-progress-bar kd-transition-transform kd-duration-1000 kd-ease-in-out kd-origin-bottom-left kd-flex kd-px-2 kd-w-full kd-justify-center kd-items-center kd-bg-green-500 kd-text-white kd-text-center" style="transform: scaleX(0%)"></div>
<div class="kd-absolute kd-top-1/2 kd-right-0 kd-mr-2" style="transform: translateY(-50%)">{{ __('Goal', 'kudos-donations') }}: €{{ total }}</div>
</div>
{% endmacro %}
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment