Merge pull request #5113 from christianbeeznest/GH-3804-2
Document: Add template list and tinyMCE integration - refs #3804pull/5115/head
commit
deb6c3a7ed
@ -0,0 +1,26 @@ |
|||||||
|
<template> |
||||||
|
<div class="template-list"> |
||||||
|
<div |
||||||
|
v-for="template in templates" |
||||||
|
:key="template.id" |
||||||
|
class="template-item" |
||||||
|
@click="selectTemplate(template.content)"> |
||||||
|
<img :src="template.image" /> |
||||||
|
<div>{{ template.title }}</div> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
</template> |
||||||
|
|
||||||
|
<script> |
||||||
|
export default { |
||||||
|
name: 'TemplateList', |
||||||
|
props: { |
||||||
|
templates: [] |
||||||
|
}, |
||||||
|
methods: { |
||||||
|
selectTemplate(content) { |
||||||
|
this.$emit('template-selected', content); |
||||||
|
}, |
||||||
|
} |
||||||
|
} |
||||||
|
</script> |
||||||
@ -0,0 +1,33 @@ |
|||||||
|
<?php |
||||||
|
declare(strict_types=1); |
||||||
|
|
||||||
|
/* For licensing terms, see /license.txt */ |
||||||
|
|
||||||
|
namespace Chamilo\CoreBundle\Controller; |
||||||
|
|
||||||
|
use Chamilo\CoreBundle\Repository\AssetRepository; |
||||||
|
use Chamilo\CoreBundle\Repository\SystemTemplateRepository; |
||||||
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; |
||||||
|
use Symfony\Component\HttpFoundation\JsonResponse; |
||||||
|
use Symfony\Component\Routing\Annotation\Route; |
||||||
|
|
||||||
|
class TemplateController extends AbstractController |
||||||
|
{ |
||||||
|
#[Route('/system-templates', name: 'system-templates')] |
||||||
|
public function getTemplates(SystemTemplateRepository $templateRepository, AssetRepository $assetRepository): JsonResponse |
||||||
|
{ |
||||||
|
$templates = $templateRepository->findAll(); |
||||||
|
|
||||||
|
$data = array_map(function ($template) use ($assetRepository) { |
||||||
|
return [ |
||||||
|
'id' => $template->getId(), |
||||||
|
'title' => $template->getTitle(), |
||||||
|
'comment' => $template->getComment(), |
||||||
|
'content' => $template->getContent(), |
||||||
|
'image' => $template->getImage() ? $assetRepository->getAssetUrl($template->getImage()) : null, |
||||||
|
]; |
||||||
|
}, $templates); |
||||||
|
|
||||||
|
return $this->json($data); |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,19 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
declare(strict_types=1); |
||||||
|
|
||||||
|
/* For licensing terms, see /license.txt */ |
||||||
|
|
||||||
|
namespace Chamilo\CoreBundle\Repository; |
||||||
|
|
||||||
|
use Chamilo\CoreBundle\Entity\SystemTemplate; |
||||||
|
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; |
||||||
|
use Doctrine\Persistence\ManagerRegistry; |
||||||
|
|
||||||
|
class SystemTemplateRepository extends ServiceEntityRepository |
||||||
|
{ |
||||||
|
public function __construct(ManagerRegistry $registry) |
||||||
|
{ |
||||||
|
parent::__construct($registry, SystemTemplate::class); |
||||||
|
} |
||||||
|
} |
||||||
Loading…
Reference in new issue