Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions Resources/templates/responsive/project/layout.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,7 @@
</div>
<?php endif; ?>

<!-- show rewards of type patreon if active -->
<?php if ($project->isPermanent()):?>
<?php if ($project->isHighlightedRewardsActive()): ?>
<div class="row">
<?= $this->insert('project/partials/highlighted_rewards') ?>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php
$project = $this->project;
?>

<div class="row">
<div class="highlighted-rewards">
<?= $this->insert('project/partials/reward_widget', ['reward' => $this->individual_rewards[0]]) ?>
<?= $this->insert('project/partials/reward_widget', ['reward' => $this->individual_rewards[1]]) ?>
<?= $this->insert('project/partials/reward_widget', ['reward' => $this->individual_rewards[2]]) ?>
</div>
</div>

26 changes: 26 additions & 0 deletions Resources/templates/responsive/project/partials/reward_widget.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php
$project = $this->project;
$reward = $this->reward
?>

<article class="card reward-info">
<div class="card-header">
<h2 title="<?= $reward->reward ?>"><?= $reward->reward ?></h2>
</div>
<div class="card-body">
<div class="amount-box text-center text-uppercase">
<span class="amount"><?= amount_format($reward->amount) ?></span>
</div>

<p>
<?= $this->markdown($reward->description) ?>
</p>
</div>
<div class="card-footer">
<div class="reward-donate text-center">
<a class="btn btn-lg btn-cyan text-uppercase" href="/invest/<?= $project->id ?>/<?= $reward->id ?>">
<?= $this->text('project-regular-support') ?>
</a>
</div>
</div>
</article>
50 changes: 50 additions & 0 deletions db/migrations/20230608111241_goteo_highlighted_rewards.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php
/**
* Migration Task class.
*/
class GoteoHighlightedRewards
{
public function preUp()
{
// add the pre-migration code here
}

public function postUp()
{
// add the post-migration code here
}

public function preDown()
{
// add the pre-migration code here
}

public function postDown()
{
// add the post-migration code here
}

/**
* Return the SQL statements for the Up migration
*
* @return string The SQL string to execute for the Up migration.
*/
public function getUpSQL()
{
return "
ALTER TABLE `project_conf` ADD COLUMN highlighted_rewards TINYINT(1) NOT NULL DEFAULT 0;
";
}

/**
* Return the SQL statements for the Down migration
*
* @return string The SQL string to execute for the Down migration.
*/
public function getDownSQL()
{
return "
ALTER TABLE `project_conf` DROP COLUMN highlighted_rewards;
";
}
}
58 changes: 57 additions & 1 deletion public/assets/sass/layouts/_project.scss
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,63 @@ body.project {
}
}
}

div.highlighted-rewards {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
grid-gap: 1rem;
margin: 2rem 2rem;
grid-row-gap: 2rem;

article.reward-info {
background-color: white;
border: 1px solid $color-light-grey;
border-radius: 1rem;
width: 100%;
min-height: 40rem;
height: 40rem;
padding: 2rem;
font-size: 1.5rem;
overflow: hidden;
text-overflow: ellipsis;

.card-header {
h2 {
overflow: hidden;
text-overflow: ellipsis;
}
}

.card-body {
height: 20rem;
overflow: hidden;
text-overflow: ellipsis;
padding-bottom: 1rem;
}

.amount-box {
color: $color-dark-green;
font-size: 40px;
font-weight: bold;
}

img {
width: 100%;
}

&:hover {
border: $background-light-green 2px solid;
height: fit-content;
transition: 0.5s;

.card-body {
min-height: 20rem;
height: fit-content;
transition: 0.5s;
}
}
}
}
}

}
Expand Down Expand Up @@ -75,7 +132,6 @@ body.project {
}
}


// Impact Calculator landing
&.impact-calculator {
background-color: $background-light-green;
Expand Down
19 changes: 16 additions & 3 deletions src/Goteo/Library/Forms/Model/ProjectCampaignForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public function createForm(): ProjectCampaignForm
$account = $this->getOption('account');

$builder = $this->getBuilder();

$admin = Session::isAdmin();
if ($admin) {
$builder
Expand All @@ -63,6 +64,16 @@ public function createForm(): ProjectCampaignForm
],
'color' => 'cyan',
'required' => false
])
->add('highlighted_rewards', BooleanType::class, [
'label' => 'project-campaign-highlighted-rewards',
'row_class' => 'extra',
'data' => $project->isHighlightedRewardsActive(),
'attr' => [
'help' => Text::get('project-campaign-activate-highlighted-rewards')
],
'color' => 'cyan',
'required' => false
]);
}

Expand Down Expand Up @@ -108,7 +119,6 @@ public function createForm(): ProjectCampaignForm
])
;


return $this;
}

Expand Down Expand Up @@ -171,17 +181,20 @@ public function save(FormInterface $form = null, $force_save = false) {
if (isset($data['type'])) {
$conf->setType($data['type']);
}

$conf->setHighlightedRewards($data['highlighted_rewards']);

$errors = [];
if (!$conf->save($errors)) {
throw new FormModelException(Text::get('form-sent-error', implode(', ', $errors)));
}
} catch (Exception $e) {
throw new FormModelException($e->getMessage());
}
throw new FormModelException($e->getMessage()); }
}

if(!$form->isValid()) throw new FormModelException(Text::get('form-has-errors'));

return $this;
}

}
9 changes: 9 additions & 0 deletions src/Goteo/Model/Project.php
Original file line number Diff line number Diff line change
Expand Up @@ -3628,6 +3628,15 @@ public function isImpactCalcActive():bool
}
}

public function isHighlightedRewardsActive(): bool
{
try {
return ProjectConf::get($this->id)->isHighlightedRewards();
} catch(\Goteo\Core\Exception $e) {
return false;
}
}

/*
* Para saber si un proyecto tiene traducción en cierto idioma
* @return: boolean
Expand Down
38 changes: 31 additions & 7 deletions src/Goteo/Model/Project/Conf.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,10 @@ class Conf extends Model
$help_license,
$mincost_estimation,
$publishing_estimation,
$hide_exhausted_rewards
;
$hide_exhausted_rewards;

private bool $impact_calculator = false;

private bool $highlighted_rewards = false;
private string $type = self::TYPE_CAMPAIGN;

/**
Expand Down Expand Up @@ -96,10 +95,25 @@ public function save(&$errors = array())
if (!$this->validate($errors)) return false;

try {
$sql = "REPLACE INTO project_conf (project, noinvest, watch, days_round1, days_round2, one_round, help_cost, help_license, mincost_estimation, publishing_estimation, hide_exhausted_rewards, impact_calculator, `type`) VALUES(:project, :noinvest, :watch, :round1, :round2, :one, :helpcost, :helplicense, :mincost_estimation, :publishing_estimation, :hide_exhausted_rewards, :impact_calculator, :type)";
$values = [':project' => $this->project, ':noinvest' => $this->noinvest, ':watch' => $this->watch,
':round1' => $this->days_round1, ':round2' => $this->days_round2, ':one' => $this->one_round, ':helpcost' => $this->help_cost, ':helplicense' => $this->help_license, ':mincost_estimation' => $this->mincost_estimation, ':publishing_estimation' => $this->publishing_estimation, ':hide_exhausted_rewards' => $this->hide_exhausted_rewards, ':impact_calculator' => $this->impact_calculator, ':type' => $this->type];
return self::query($sql, $values)?true:false;
$sql = "REPLACE INTO project_conf (project, noinvest, watch, days_round1, days_round2, one_round, help_cost, help_license, mincost_estimation, publishing_estimation, hide_exhausted_rewards, impact_calculator, `type`, highlighted_rewards) VALUES(:project, :noinvest, :watch, :round1, :round2, :one, :helpcost, :helplicense, :mincost_estimation, :publishing_estimation, :hide_exhausted_rewards, :impact_calculator, :type, :highlighted_rewards)";
$values = [
':project' => $this->project,
':noinvest' => $this->noinvest,
':watch' => $this->watch,
':round1' => $this->days_round1,
':round2' => $this->days_round2,
':one' => $this->one_round,
':helpcost' => $this->help_cost,
':helplicense' => $this->help_license,
':mincost_estimation' => $this->mincost_estimation,
':publishing_estimation' => $this->publishing_estimation,
':hide_exhausted_rewards' => $this->hide_exhausted_rewards,
':impact_calculator' => $this->impact_calculator,
':type' => $this->type,
':highlighted_rewards' => $this->highlighted_rewards
];

return (bool)self::query($sql, $values);
} catch (\PDOException $e) {
$errors[] = "La configuración del proyecto no se ha guardado correctamente. Por favor, revise los datos." . $e->getMessage();
return false;
Expand Down Expand Up @@ -376,6 +390,16 @@ public function deactivateImpactCalculator()
$this->impact_calculator = false;
}

public function isHighlightedRewards(): bool
{
return $this->highlighted_rewards;
}

public function setHighlightedRewards(bool $highlighted_rewards): void
{
$this->highlighted_rewards = $highlighted_rewards;
}

public function getType(): string
{
return $this->type;
Expand Down
2 changes: 2 additions & 0 deletions translations/ca/project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@ project-impact-calculator-card-impact-description: "Amb un pressupost de %s aspi
project-create-continue-impact: "Desar i calcular impacte"
project-campaign-impact-calculator: "Calculadora d'Impacte"
project-campaign-activate-impact-calculator: "Al activar la calculadora d'impacte, l'impulsora del projecte podrà accedir al módul de les Dades d'Impacte del Projecte, així com també es veurà el seu impacte a la pàgina principal del projecte."
project-campaign-highlighted-rewards: "Recompenses destacades"
project-campaign-activate-highlighted-rewards: "Al activar les recompenses destacades, la visualització de les recompenses canvia. Es mostraran les recompenses destacades a la part superior de la pàgina del projecte."
project-campaign-type-label: "Escull tipus de campanya"
project-campaign-type-campaign: "Campanya"
project-campaign-type-permanent: "Permanent"
2 changes: 2 additions & 0 deletions translations/en/project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@ project-impact-calculator-card-impact-description: "With a budget of %s we want
project-create-continue-impact: "Save and calculate impact"
project-campaign-impact-calculator: "Impact Calculator"
project-campaign-activate-impact-calculator: "By activating the impact calculator, the project promoter will be able to access the project impact data module, as well as see their impact on the main project page."
project-campaign-highlighted-rewards: "Highlighted rewards"
project-campaign-activate-highlighted-rewards: "When activating the highlighted rewards, the visualization of the rewards will change. The rewards will be shown at the top of the project page."
project-campaign-type-label: "Choose type of Campaign"
project-campaign-type-campaign: "Campaign"
project-campaign-type-permanent: "Permanent"
2 changes: 2 additions & 0 deletions translations/es/project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,8 @@ project-impact-calculator-card-impact-description: "Con un presupuesto de %s asp
project-create-continue-impact: "Guardar y calcular impacto"
project-campaign-impact-calculator: "Calculadora de Impacto"
project-campaign-activate-impact-calculator: "Al activar la calculadora de impacto, la impulsora del proyecto podrá acceder al modulo de los Datos de Impacto del Proyecto, así como también se verá su impacto en la página principal del proyecto."
project-campaign-highlighted-rewards: "Recompensas destacadas"
project-campaign-activate-highlighted-rewards: "Al activar las recompensas destacadas, la visualización de las recompensas cambia. Se mostrarán las recompensas destacadas en la parte superior de la página del proyecto."
project-campaign-type-label: "Escoge tipo de campaña"
project-campaign-type-campaign: "Campaña"
project-campaign-type-permanent: "Permanente"