Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Announcements #603

Open
wants to merge 24 commits into
base: live
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
cefe733
add announcement entity
davidbeig Apr 2, 2024
66303e4
add announcement partial and show in home page
davidbeig Apr 2, 2024
f4ebbf6
add template for donation
davidbeig Apr 2, 2024
fd5915c
improve buttons in announcement partials
davidbeig Apr 2, 2024
ad0a367
add close button
davidbeig Apr 2, 2024
eae86f4
add permissions and copies for announcement admin
davidbeig Apr 3, 2024
2993dff
add necessary FormsProcessors and EntityNormalizer to use Entity inst…
davidbeig Apr 16, 2024
86d40fd
add Announcement admin
davidbeig Apr 16, 2024
0459891
fix announcement api controller
davidbeig Apr 16, 2024
c31f877
add slider for announcements
davidbeig Apr 16, 2024
b0309b1
add lang table and some fixes
davidbeig Apr 16, 2024
27f7ff2
add Announcement Model
davidbeig Sep 10, 2024
5d0c80e
change repository to use model instead of entity
davidbeig Sep 10, 2024
765a186
change admin controller and views to use new model
davidbeig Sep 10, 2024
3d67f4e
change use of entity to model in public views of announcements
davidbeig Sep 10, 2024
ce4f5aa
add missing translations
davidbeig Sep 10, 2024
ddc333e
add announcements without donation to projects landing
davidbeig Sep 10, 2024
5d487e1
change to now show announcement and make it appear instead of remove it
davidbeig Sep 13, 2024
a97d1bf
add announcements to channel layouts
davidbeig Sep 13, 2024
4ae1b0c
add announcements to blog
davidbeig Sep 13, 2024
be04afa
change name of localStorage variable
davidbeig Sep 16, 2024
7abc712
remove entity announcement
davidbeig Sep 16, 2024
55ccfd2
update datetime of migration
davidbeig Sep 20, 2024
97adc68
fix error on announcement admin form
davidbeig Sep 20, 2024
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
4 changes: 4 additions & 0 deletions Resources/permissions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,10 @@ admin-module-communication: # Can access to module CommunicationAdminController
model: null
relational: null

admin-module-announcements: # Can access to module AnnouncementAdminController
model: null
relational: null

receive-test-communications: # Can receive test communications
model: null
relational: null
Expand Down
1 change: 1 addition & 0 deletions Resources/roles.yml
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ admin:
- edit-any-matcher # View any editing matcher
- remove-any-matcher # Remove any matcher
- admin-module-channels # Can access to channels admin modules
- admin-module-announcements # Can access to announcements admin modules
level: 70

superadmin:
Expand Down
25 changes: 25 additions & 0 deletions Resources/templates/responsive/admin/announcements/edit.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

$this->layout('admin/announcements/layout');

$this->section('admin-search-box-addons');
?>
<a class="btn btn-cyan" href="/admin/announcement"><i class="fa fa-arrow-circle-left"></i> <?= $this->text('admin-back-list') ?></a>

<?php $this->replace() ?>

<?php $this->section('admin-container-body') ?>

<?php
$id = $this->announcement->getId();
?>

<h4 class="title"><?= $id ? $this->text('admin-announcement-edit', "#{$id}") : $this->text('admin-announcement-add') ?></h4>


<?= $this->form_form($this->raw('form')) ?>

</div>
</div>

<?php $this->replace() ?>
14 changes: 14 additions & 0 deletions Resources/templates/responsive/admin/announcements/layout.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

$this->layout('admin/container');

$this->section('admin-container-head');

?>
<h2><?= $this->text('admin-announcements') ?></h2>

<?= $this->insert('admin/partials/search_box') ?>

<?= $this->supply('admin-announcements-head') ?>

<?php $this->replace() ?>
20 changes: 20 additions & 0 deletions Resources/templates/responsive/admin/announcements/list.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

$this->layout('admin/announcements/layout');

$this->section('admin-search-box-addons');
?>
<a class="btn btn-cyan" href="/admin/announcement/add"><i class="fa fa-plus"></i> <?= $this->text('admin-announcement-add') ?></a>

<?php $this->replace() ?>

<?php $this->section('admin-container-body') ?>

<h5><?= $this->text('admin-list-total', $this->total) ?></h5>

<?= $this->insert('admin/partials/material_table', ['list' => $this->model_list_entries($this->list, ['id', 'title', 'active', 'actions'])]) ?>

</div>
</div>

<?php $this->replace() ?>
1 change: 1 addition & 0 deletions Resources/templates/responsive/layout.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@

<?= $this->supply('header', $this->insert("partials/header")) ?>
<?= $this->supply('search', $this->insert("partials/search")) ?>
<?= $this->supply('announcements', $this->insert("partials/components/announcements")) ?>

<div class="page-wrap">
<?= $this->supply('sidebar', $this->insert("partials/sidebar", ['sidebarMenu' => $sidebar])) ?>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php
$announcements = $this->announcements;
if ($announcements) :
?>
<div class="announcement">
<button class="close" aria-label="Close" onclick="this.parentNode.style.display='none'"><i class="fa fa-close"></i></button>

<div class="container">
<div class="slider-announcements">
<?php foreach ($announcements as $announcement) : ?>
<div class="row">
<div class="col-lg-8 col-md-7 col-md-offset-1 col-sm-offset-2 col-sm-6 col-xs-offset-3 col-xs-9">
<h2 class="announcement-title"><?= $announcement->getTitle() ?></h2>
<p class="announcement-description"><?= $announcement->getDescription() ?></p>
</div>
<div class="cta col-lg-4 col-md-4 col-sm-4 col-xs-12">
<?php $type = $announcement->getType(); ?>
<?= $this->insert("partials/components/announcements/partials/$type", ['announcement' => $announcement]) ?>
</div>
</div>
<?php endforeach; ?>
</div>
</div>
</div>
<?php endif; ?>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php $announcement = $this->announcement; ?>

<div class="grid-donation">
<a href="/donate/payment?amount=5" class="btn btn-lg btn-white"><?= $this->get_currency()?> 5</a>
<a href="/donate/payment?amount=10" class="btn btn-lg btn-white"><?= $this->get_currency()?> 10</a>
<a href="/donate/payment?amount=15" class="btn btn-lg btn-white"><?= $this->get_currency()?> 20</a>
<a href="/donate/payment?amount=20" class="btn btn-lg btn-white"><?= $this->get_currency()?> 50</a>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php $announcement = $this->announcement; ?>

<a href="<?= $announcement->getCtaUrl() ?>" class="btn btn-white btn-lg btn-block"><?= $announcement->getCtaText()?></a>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php $announcement = $this->announcement; ?>

<a href="<?= $announcement->getCtaUrl() ?>" class="btn btn-white btn-lg btn-block"><?= $announcement->getCtaText()?></a>
78 changes: 78 additions & 0 deletions db/migrations/20240328152538_goteo_announcement.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<?php

/**
* Migration Task class.
*/
class GoteoAnnouncement
{
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 "
CREATE TABLE `announcement` (
`id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
`title` TEXT NOT NULL,
`description` TEXT NOT NULL,
`type` VARCHAR(50) NOT NULL,
`lang` VARCHAR(6) NOT NULL,
`project_id` VARCHAR(50) COLLATE utf8_general_ci DEFAULT NULL,
`cta_url` VARCHAR(255),
`cta_text` VARCHAR(255),
`active` INT(1) NOT NULL DEFAULT 0,
`start_date` date NULL,
`end_date` date NULL,
`created_at` timestamp NOT NULL DEFAULT current_timestamp,
`modified_at` timestamp NOT NULL DEFAULT current_timestamp on update CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
FOREIGN KEY (`project_id`) REFERENCES `project` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
);

CREATE TABLE `announcement_lang` (
`id` BIGINT(20) UNSIGNED NOT NULL,
`title` TEXT NOT NULL,
`description` TEXT NOT NULL,
`lang` VARCHAR(6) NOT NULL,
`cta_url` VARCHAR(255),
`cta_text` VARCHAR(255),
FOREIGN KEY (`id`) REFERENCES `announcement` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
);
";
}

/**
* Return the SQL statements for the Down migration
*
* @return string The SQL string to execute for the Down migration.
*/
public function getDownSQL()
{
return "
DROP TABLE `announcement_lang`;
DROP TABLE `announcement`;
";
}
}
36 changes: 36 additions & 0 deletions public/assets/js/components/announcements.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
@licstart The following is the entire license notice for the
JavaScript code in this page.

Copyright (C) 2010 Goteo Foundation

The JavaScript code in this page is free software: you can
redistribute it and/or modify it under the terms of the GNU
General Public License (GNU GPL) as published by the Free Software
Foundation, either version 3 of the License, or (at your option)
any later version. The code is distributed WITHOUT ANY WARRANTY;
without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU GPL for more details.

As additional permission under GNU GPL version 3 section 7, you
may distribute non-source (e.g., minimized or compacted) forms of
that code without the copy of the GNU GPL normally required by
section 4, provided you include this license notice and a URL
through which recipients can access the Corresponding Source.


@licend The above is the entire license notice
for the JavaScript code in this page.
*/

$(function() {
$(".slider-announcements").slick({
dots: false,
infinite: true,
autoplay: false,
autoplaySpeed: 7000,
speed: 1500,
fade: true,
cssEase: "linear",
});
});
1 change: 1 addition & 0 deletions public/assets/sass/common.scss
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
@import 'components/values';
@import 'components/workshops_slider';
@import 'components/dataset';
@import 'components/announcement';

@import 'misc/misc';
@import 'misc/charts';
Expand Down
44 changes: 44 additions & 0 deletions public/assets/sass/components/_announcement.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
.announcement {
background-color: $background-dark-lilac;
color: $color-white;

h1 {
text-wrap: pretty;
}

p {
text-wrap: balance;
}

button.close {
position: relative;
top: 1em;
right: 1em;
z-index: 1;
opacity: 0.8;
color: $color-white;
}

.container {
margin-top: 1em;
margin-bottom: 1em;

.row {
display: flex;

@media (max-width: $breakpoint-sm) {
display: block;
}
}

.cta {
margin: auto;
}

.grid-donation {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 1em
}
}
}
2 changes: 1 addition & 1 deletion public/templates/responsive/home/partials/javascript.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
<script type="text/javascript" src="<?= SRC_URL ?>/assets/js/home/home.js"></script>
<script type="text/javascript" src="<?= SRC_URL ?>/assets/js/home/projects.js"></script>
<script type="text/javascript" src="<?= SRC_URL ?>/assets/js/components/values.js"></script>
<script type="text/javascript" src="<?= SRC_URL ?>/assets/js/components/announcements.js"></script>
<!-- endbuild -->

2 changes: 2 additions & 0 deletions src/Goteo/Application/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use Goteo\Application\Config\YamlSettingsLoader;
use Goteo\Console\UsersSend;
use Goteo\Controller\Admin\AccountsSubController;
use Goteo\Controller\Admin\AnnouncementAdminController;
use Goteo\Controller\Admin\BannersSubController;
use Goteo\Controller\Admin\BlogAdminController;
use Goteo\Controller\Admin\CategoriesAdminController;
Expand Down Expand Up @@ -346,6 +347,7 @@ static public function addAdminControllers()
AdminController::addSubController(ChannelProjectsAdminController::class);
AdminController::addSubController(ImpactDataAdminController::class);
AdminController::addSubController(SubscriptionsAdminController::class);
AdminController::addSubController(AnnouncementAdminController::class);
}

static public function addLegacyAdminControllers()
Expand Down
Loading
Loading