mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-05 07:19:49 +00:00
process review
This commit is contained in:
parent
5be516b14e
commit
09f823ac08
@ -791,48 +791,6 @@ class ChillMainExtension extends Extension implements
|
|||||||
],
|
],
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
/* [
|
|
||||||
'class' => \Chill\MainBundle\Entity\DashboardConfigItem::class,
|
|
||||||
'controller' => \Chill\MainBundle\Controller\DashboardApiController::class,
|
|
||||||
'name' => 'dashboard-config-item',
|
|
||||||
'base_path' => '/api/1.0/main/dashboard-config-item',
|
|
||||||
'base_role' => 'ROLE_USER',
|
|
||||||
'actions' => [
|
|
||||||
'_index' => [
|
|
||||||
'methods' => [
|
|
||||||
Request::METHOD_GET => true,
|
|
||||||
Request::METHOD_HEAD => true,
|
|
||||||
],
|
|
||||||
],
|
|
||||||
'_entity' => [
|
|
||||||
'methods' => [
|
|
||||||
Request::METHOD_GET => true,
|
|
||||||
Request::METHOD_HEAD => true,
|
|
||||||
],
|
|
||||||
],
|
|
||||||
],
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'class' => \Chill\MainBundle\Entity\NewsItem::class,
|
|
||||||
'controller' => \Chill\MainBundle\Controller\NewsItemApiController::class,
|
|
||||||
'name' => 'news-items',
|
|
||||||
'base_path' => '/api/1.0/main/news',
|
|
||||||
'base_role' => 'ROLE_USER',
|
|
||||||
'actions' => [
|
|
||||||
'_index' => [
|
|
||||||
'methods' => [
|
|
||||||
Request::METHOD_GET => true,
|
|
||||||
Request::METHOD_HEAD => true,
|
|
||||||
],
|
|
||||||
],
|
|
||||||
'_entity' => [
|
|
||||||
'methods' => [
|
|
||||||
Request::METHOD_GET => true,
|
|
||||||
Request::METHOD_HEAD => true,
|
|
||||||
],
|
|
||||||
],
|
|
||||||
],
|
|
||||||
],*/
|
|
||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
@ -54,10 +54,10 @@ class DashboardConfigItem
|
|||||||
/**
|
/**
|
||||||
* @ORM\ManyToOne(targetEntity=User::class)
|
* @ORM\ManyToOne(targetEntity=User::class)
|
||||||
*/
|
*/
|
||||||
private User $user;
|
private ?User $user = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\Column(type="json")
|
* @ORM\Column(type="json" "jsonb"=true, options={"default": "[]"})
|
||||||
*
|
*
|
||||||
* @Serializer\Groups({"dashboardConfigItem:read"})
|
* @Serializer\Groups({"dashboardConfigItem:read"})
|
||||||
*/
|
*/
|
||||||
|
@ -12,7 +12,9 @@ declare(strict_types=1);
|
|||||||
namespace Chill\MainBundle\Entity;
|
namespace Chill\MainBundle\Entity;
|
||||||
|
|
||||||
use Chill\MainBundle\Doctrine\Model\TrackCreationInterface;
|
use Chill\MainBundle\Doctrine\Model\TrackCreationInterface;
|
||||||
|
use Chill\MainBundle\Doctrine\Model\TrackCreationTrait;
|
||||||
use Chill\MainBundle\Doctrine\Model\TrackUpdateInterface;
|
use Chill\MainBundle\Doctrine\Model\TrackUpdateInterface;
|
||||||
|
use Chill\MainBundle\Doctrine\Model\TrackUpdateTrait;
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
use Symfony\Component\Serializer\Annotation\Groups;
|
use Symfony\Component\Serializer\Annotation\Groups;
|
||||||
use Symfony\Component\Validator\Constraints as Assert;
|
use Symfony\Component\Validator\Constraints as Assert;
|
||||||
@ -24,6 +26,10 @@ use Symfony\Component\Validator\Constraints as Assert;
|
|||||||
*/
|
*/
|
||||||
class NewsItem implements TrackCreationInterface, TrackUpdateInterface
|
class NewsItem implements TrackCreationInterface, TrackUpdateInterface
|
||||||
{
|
{
|
||||||
|
use TrackCreationTrait;
|
||||||
|
|
||||||
|
use TrackUpdateTrait;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\Id
|
* @ORM\Id
|
||||||
*
|
*
|
||||||
@ -71,78 +77,6 @@ class NewsItem implements TrackCreationInterface, TrackUpdateInterface
|
|||||||
*/
|
*/
|
||||||
private ?\DateTimeImmutable $endDate = null;
|
private ?\DateTimeImmutable $endDate = null;
|
||||||
|
|
||||||
/**
|
|
||||||
* @ORM\Column(type="datetime_immutable", nullable=true)
|
|
||||||
*/
|
|
||||||
private ?\DateTimeInterface $createdAt = null;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ORM\ManyToOne(targetEntity=User::class)
|
|
||||||
*
|
|
||||||
* @ORM\JoinColumn(nullable=true)
|
|
||||||
*/
|
|
||||||
private ?User $createdBy = null;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ORM\Column(type="datetime_immutable", nullable=true)
|
|
||||||
*/
|
|
||||||
private ?\DateTimeInterface $updatedAt = null;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ORM\ManyToOne(targetEntity=User::class)
|
|
||||||
*
|
|
||||||
* @ORM\JoinColumn(nullable=true)
|
|
||||||
*/
|
|
||||||
private ?User $updatedBy = null;
|
|
||||||
|
|
||||||
public function getCreatedAt(): ?\DateTimeInterface
|
|
||||||
{
|
|
||||||
return $this->createdAt;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getCreatedBy(): ?User
|
|
||||||
{
|
|
||||||
return $this->createdBy;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getUpdatedAt(): ?\DateTimeInterface
|
|
||||||
{
|
|
||||||
return $this->updatedAt;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getUpdatedBy(): ?User
|
|
||||||
{
|
|
||||||
return $this->updatedBy;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setCreatedAt(\DateTimeInterface $datetime): self
|
|
||||||
{
|
|
||||||
$this->createdAt = $datetime;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setCreatedBy(User $user): self
|
|
||||||
{
|
|
||||||
$this->createdBy = $user;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setUpdatedAt(\DateTimeInterface $datetime): self
|
|
||||||
{
|
|
||||||
$this->updatedAt = $datetime;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setUpdatedBy(User $user): self
|
|
||||||
{
|
|
||||||
$this->updatedBy = $user;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getTitle(): string
|
public function getTitle(): string
|
||||||
{
|
{
|
||||||
return $this->title;
|
return $this->title;
|
||||||
|
@ -16,12 +16,13 @@ use Doctrine\ORM\EntityManagerInterface;
|
|||||||
use Doctrine\ORM\EntityRepository;
|
use Doctrine\ORM\EntityRepository;
|
||||||
use Doctrine\ORM\QueryBuilder;
|
use Doctrine\ORM\QueryBuilder;
|
||||||
use Doctrine\Persistence\ObjectRepository;
|
use Doctrine\Persistence\ObjectRepository;
|
||||||
|
use Symfony\Component\Clock\ClockInterface;
|
||||||
|
|
||||||
class NewsItemRepository implements ObjectRepository
|
class NewsItemRepository implements ObjectRepository
|
||||||
{
|
{
|
||||||
private readonly EntityRepository $repository;
|
private readonly EntityRepository $repository;
|
||||||
|
|
||||||
public function __construct(EntityManagerInterface $entityManager)
|
public function __construct(EntityManagerInterface $entityManager, private ClockInterface $clock)
|
||||||
{
|
{
|
||||||
$this->repository = $entityManager->getRepository(NewsItem::class);
|
$this->repository = $entityManager->getRepository(NewsItem::class);
|
||||||
}
|
}
|
||||||
@ -58,6 +59,9 @@ class NewsItemRepository implements ObjectRepository
|
|||||||
|
|
||||||
public function findWithDateFilter()
|
public function findWithDateFilter()
|
||||||
{
|
{
|
||||||
|
dump($this->buildQueryWithDateFilter()
|
||||||
|
->getQuery()
|
||||||
|
->getResult());
|
||||||
return $this->buildQueryWithDateFilter()
|
return $this->buildQueryWithDateFilter()
|
||||||
->getQuery()
|
->getQuery()
|
||||||
->getResult();
|
->getResult();
|
||||||
@ -73,13 +77,13 @@ class NewsItemRepository implements ObjectRepository
|
|||||||
|
|
||||||
public function buildQueryWithDateFilter(): QueryBuilder
|
public function buildQueryWithDateFilter(): QueryBuilder
|
||||||
{
|
{
|
||||||
$now = new \DateTime('now');
|
$now = $this->clock->now();
|
||||||
|
|
||||||
$qb = $this->createQueryBuilder('n');
|
$qb = $this->createQueryBuilder('n');
|
||||||
$qb
|
$qb
|
||||||
->where(
|
->where(
|
||||||
$qb->expr()->andX(
|
$qb->expr()->andX(
|
||||||
$qb->expr()->gte('n.startDate', ':now'),
|
$qb->expr()->lte('n.startDate', ':now'),
|
||||||
$qb->expr()->orX(
|
$qb->expr()->orX(
|
||||||
$qb->expr()->lt('n.endDate', ':now'),
|
$qb->expr()->lt('n.endDate', ':now'),
|
||||||
$qb->expr()->isNull('n.endDate')
|
$qb->expr()->isNull('n.endDate')
|
||||||
|
@ -5,8 +5,8 @@
|
|||||||
<li v-for="item in newsItems" :key="item.id">
|
<li v-for="item in newsItems" :key="item.id">
|
||||||
<h2>{{ item.title }}</h2>
|
<h2>{{ item.title }}</h2>
|
||||||
<div class="content" v-if="shouldTruncate(item.content)">
|
<div class="content" v-if="shouldTruncate(item.content)">
|
||||||
<div v-html="truncateMarkdownContent(item.content)"></div>
|
<div v-html="prepareContent(item.content)"></div>
|
||||||
<span class="read-more" @click="() => openModal(item)">Read more</span>
|
<span class="read-more" @click="() => openModal(item)">{{ $t('widget.news.readMore') }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="content" v-else>
|
<div class="content" v-else>
|
||||||
<div v-html="convertMarkdownToHtml(item.content)"></div>
|
<div v-html="convertMarkdownToHtml(item.content)"></div>
|
||||||
@ -64,9 +64,9 @@ const convertMarkdownToHtml = (markdown: string): string => {
|
|||||||
return DOMPurify.sanitize(rawHtml)
|
return DOMPurify.sanitize(rawHtml)
|
||||||
};
|
};
|
||||||
|
|
||||||
const truncateMarkdownContent = (content: string, maxLength = 100): string => {
|
const prepareContent = (content: string, maxLength = 100): string => {
|
||||||
const htmlContent = convertMarkdownToHtml(content);
|
const truncatedContent = truncateContent(content, maxLength);
|
||||||
return truncateContent(htmlContent, maxLength);
|
return convertMarkdownToHtml(truncatedContent);
|
||||||
};
|
};
|
||||||
|
|
||||||
const formatDate = (datetime: { date: string }): string => {
|
const formatDate = (datetime: { date: string }): string => {
|
||||||
@ -76,9 +76,10 @@ const formatDate = (datetime: { date: string }): string => {
|
|||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
makeFetch('GET', '/api/1.0/main/news.json')
|
makeFetch('GET', '/api/1.0/main/news.json')
|
||||||
.then((response: {results: NewsItem[]}) => {
|
.then((response: {results: NewsItem[]}) => {
|
||||||
|
// console.log('news articles', response.results)
|
||||||
newsItems.value = response.results
|
newsItems.value = response.results
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error: string) => {
|
||||||
console.error('Error fetching news items', error);
|
console.error('Error fetching news items', error);
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -41,7 +41,7 @@
|
|||||||
|
|
||||||
<div class="mbloc col col-lg-6 col-lg-4" v-if="this.dashboardItems">
|
<div class="mbloc col col-lg-6 col-lg-4" v-if="this.dashboardItems">
|
||||||
<div v-for="dashboardItem in this.dashboardItems">
|
<div v-for="dashboardItem in this.dashboardItems">
|
||||||
<News v-if="dashboardItem.type ==='news'"/>
|
<News v-if="dashboardItem.type === 'news'"/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -76,7 +76,7 @@ export default {
|
|||||||
mounted() {
|
mounted() {
|
||||||
const elem = document.querySelector('#dashboards');
|
const elem = document.querySelector('#dashboards');
|
||||||
const masonry = new Masonry(elem, {});
|
const masonry = new Masonry(elem, {});
|
||||||
//Fetch the dashboard items configured for user. Currently response is still hardcoded and no user id passed.
|
//Fetch the dashboard items configured for user. Currently response is still hardcoded
|
||||||
makeFetch('GET', '/api/1.0/main/dashboard-config-item.json')
|
makeFetch('GET', '/api/1.0/main/dashboard-config-item.json')
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
this.dashboardItems = response;
|
this.dashboardItems = response;
|
||||||
|
@ -54,7 +54,8 @@ const messages = {
|
|||||||
},
|
},
|
||||||
widget: {
|
widget: {
|
||||||
news: {
|
news: {
|
||||||
title: "Actualités"
|
title: "Actualités",
|
||||||
|
readMore: "Lire la suite"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,6 @@
|
|||||||
|
|
||||||
{% block layout_wvm_content %}
|
{% block layout_wvm_content %}
|
||||||
{% block admin_content %}<!-- block content empty -->
|
{% block admin_content %}<!-- block content empty -->
|
||||||
<h1>{{ 'News configuration' |trans }}</h1>
|
<h1>{{ 'News configuration' | trans }}</h1>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
@ -4,8 +4,8 @@
|
|||||||
{% embed '@ChillMain/CRUD/_index.html.twig' %}
|
{% embed '@ChillMain/CRUD/_index.html.twig' %}
|
||||||
{% block table_entities_thead_tr %}
|
{% block table_entities_thead_tr %}
|
||||||
<th>{{ 'Title'|trans }}</th>
|
<th>{{ 'Title'|trans }}</th>
|
||||||
<th>{{ 'news.startdate'|trans }}</th>
|
<th>{{ 'dashboard.news.startDate'|trans }}</th>
|
||||||
<th>{{ 'news.enddate'|trans }}</th>
|
<th>{{ 'dashboard.news.endDate'|trans }}</th>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% block table_entities_tbody %}
|
{% block table_entities_tbody %}
|
||||||
{% for entity in entities %}
|
{% for entity in entities %}
|
||||||
@ -15,7 +15,7 @@
|
|||||||
{% if entity.endDate is not null %}
|
{% if entity.endDate is not null %}
|
||||||
<td>{{ entity.endDate|date }}</td>
|
<td>{{ entity.endDate|date }}</td>
|
||||||
{% else %}
|
{% else %}
|
||||||
<td>Pas de date de fin</td>
|
<td>{{ 'dashboard.news.noDate'|trans }}</td>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<td>
|
<td>
|
||||||
<ul class="record_actions">
|
<ul class="record_actions">
|
||||||
|
@ -28,7 +28,7 @@ final class Version20231108141141 extends AbstractMigration
|
|||||||
{
|
{
|
||||||
$this->addSql('CREATE SEQUENCE chill_main_dashboard_config_item_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
|
$this->addSql('CREATE SEQUENCE chill_main_dashboard_config_item_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
|
||||||
$this->addSql('CREATE SEQUENCE chill_main_news_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
|
$this->addSql('CREATE SEQUENCE chill_main_news_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
|
||||||
$this->addSql('CREATE TABLE chill_main_dashboard_config_item (id INT NOT NULL, user_id INT DEFAULT NULL, type VARCHAR(255) NOT NULL, position VARCHAR(255) NOT NULL, metadata JSON NOT NULL, PRIMARY KEY(id))');
|
$this->addSql('CREATE TABLE chill_main_dashboard_config_item (id INT NOT NULL, user_id INT DEFAULT NULL, type VARCHAR(255) NOT NULL, position VARCHAR(255) NOT NULL, metadata JSONB DEFAULT \'{}\'::jsonb, PRIMARY KEY(id))');
|
||||||
$this->addSql('CREATE INDEX IDX_CF59DFD6A76ED395 ON chill_main_dashboard_config_item (user_id)');
|
$this->addSql('CREATE INDEX IDX_CF59DFD6A76ED395 ON chill_main_dashboard_config_item (user_id)');
|
||||||
$this->addSql('CREATE TABLE chill_main_news (id INT NOT NULL, title TEXT NOT NULL, content TEXT NOT NULL, startDate DATE NOT NULL, endDate DATE DEFAULT NULL, createdAt TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, updatedAt TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, createdBy_id INT DEFAULT NULL, updatedBy_id INT DEFAULT NULL, PRIMARY KEY(id))');
|
$this->addSql('CREATE TABLE chill_main_news (id INT NOT NULL, title TEXT NOT NULL, content TEXT NOT NULL, startDate DATE NOT NULL, endDate DATE DEFAULT NULL, createdAt TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, updatedAt TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, createdBy_id INT DEFAULT NULL, updatedBy_id INT DEFAULT NULL, PRIMARY KEY(id))');
|
||||||
$this->addSql('CREATE INDEX IDX_96922AFB3174800F ON chill_main_news (createdBy_id)');
|
$this->addSql('CREATE INDEX IDX_96922AFB3174800F ON chill_main_news (createdBy_id)');
|
||||||
|
@ -431,6 +431,12 @@ crud:
|
|||||||
add_new: Ajouter un centre
|
add_new: Ajouter un centre
|
||||||
title_new: Nouveau centre
|
title_new: Nouveau centre
|
||||||
title_edit: Modifier un centre
|
title_edit: Modifier un centre
|
||||||
|
news_item:
|
||||||
|
index:
|
||||||
|
title: Liste des actualités
|
||||||
|
add_new: Créer une nouvelle actualité
|
||||||
|
title_new: Nouvelle actualité
|
||||||
|
title_edit: Modifier une actualité
|
||||||
|
|
||||||
No entities: Aucun élément
|
No entities: Aucun élément
|
||||||
|
|
||||||
@ -672,3 +678,9 @@ admin:
|
|||||||
undefined: non défini
|
undefined: non défini
|
||||||
user: Utilisateur
|
user: Utilisateur
|
||||||
scope: Service
|
scope: Service
|
||||||
|
|
||||||
|
dashboard:
|
||||||
|
news:
|
||||||
|
noDate: Pas de date de fin
|
||||||
|
startDate: Date de début
|
||||||
|
endDate: Date de fin
|
||||||
|
Loading…
x
Reference in New Issue
Block a user