Minor - update document grid

pull/3064/head
Julio Montoya 5 years ago
parent 1ec116151d
commit 0450fa6ab3
  1. 31
      src/CoreBundle/Controller/ResourceController.php
  2. 3
      src/CoreBundle/Entity/Resource/AbstractResource.php
  3. 2
      src/CourseBundle/Entity/CDocument.php
  4. 4
      src/ThemeBundle/Resources/views/Resource/index.html.twig

@ -10,10 +10,8 @@ use APY\DataGridBundle\Grid\Export\ExcelExport;
use APY\DataGridBundle\Grid\Grid;
use APY\DataGridBundle\Grid\Row;
use APY\DataGridBundle\Grid\Source\Entity;
use Chamilo\CoreBundle\Block\BreadcrumbBlockService;
use Chamilo\CoreBundle\Component\Utils\Glide;
use Chamilo\CoreBundle\Entity\Resource\AbstractResource;
use Chamilo\CoreBundle\Entity\Resource\ResourceFile;
use Chamilo\CoreBundle\Entity\Resource\ResourceLink;
use Chamilo\CoreBundle\Entity\Resource\ResourceNode;
use Chamilo\CoreBundle\Security\Authorization\Voter\ResourceNodeVoter;
@ -26,24 +24,15 @@ use Doctrine\Common\Collections\Criteria;
use Doctrine\ORM\QueryBuilder;
use FOS\CKEditorBundle\Form\Type\CKEditorType;
use League\Flysystem\Filesystem;
use Oneup\UploaderBundle\Uploader\Response\EmptyResponse;
use Sylius\Bundle\ResourceBundle\Event\ResourceControllerEvent;
use Sylius\Component\Resource\Exception\UpdateHandlingException;
use Sylius\Component\Resource\ResourceActions;
use Symfony\Component\Filesystem\Exception\FileNotFoundException;
use Symfony\Component\HttpFoundation\File\Exception\UploadException;
use Symfony\Component\HttpFoundation\File\UploadedFile;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\ResponseHeaderBag;
use Symfony\Component\HttpFoundation\StreamedResponse;
use Symfony\Component\HttpKernel\Exception\HttpException;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Component\Routing\RouterInterface;
use Vich\UploaderBundle\Util\Transliterator;
use ZipStream\Option\Archive;
use ZipStream\ZipStream;
@ -146,6 +135,9 @@ class ResourceController extends AbstractResourceController implements CourseCon
$routeParams = ['tool' => $tool, 'type' => $type, 'cidReq' => $courseIdentifier, 'id'];
// Title link.
$grid->getColumn('title')->setTitle($this->trans('Name'));
$grid->getColumn('filetype')->setTitle($this->trans('Type'));
$grid->getColumn('title')->manipulateRenderCell(
function ($value, Row $row, $router) use ($routeParams) {
/** @var CDocument $entity */
@ -173,6 +165,23 @@ class ResourceController extends AbstractResourceController implements CourseCon
}
);
$grid->getColumn('filetype')->manipulateRenderCell(
function ($value, Row $row, $router) use ($routeParams) {
/** @var CDocument $entity */
$entity = $row->getEntity();
$resourceNode = $entity->getResourceNode();
if ($resourceNode->hasResourceFile()) {
$file = $resourceNode->getResourceFile();
return $file->getMimeType();
}
return $this->trans('Folder');
}
);
$grid->setHiddenColumns(['iid']);
// Delete mass action.
if ($this->isGranted(ResourceNodeVoter::ROLE_CURRENT_COURSE_TEACHER)) {
$deleteMassAction = new MassAction(

@ -3,6 +3,7 @@
namespace Chamilo\CoreBundle\Entity\Resource;
use APY\DataGridBundle\Grid\Mapping as GRID;
use Chamilo\CoreBundle\Entity\Course;
use Chamilo\CoreBundle\Entity\Session;
use Doctrine\Common\Collections\Criteria;
@ -17,6 +18,8 @@ use Sylius\Component\Resource\Model\ResourceInterface;
abstract class AbstractResource implements ResourceInterface
{
/**
* @GRID\Column(field="resourceNode.createdAt", title="Date added", type="datetime")
*
* @ORM\OneToOne(targetEntity="Chamilo\CoreBundle\Entity\Resource\ResourceNode", cascade={"remove"}, orphanRemoval=true)
* @ORM\JoinColumn(name="resource_node_id", referencedColumnName="id", onDelete="CASCADE")
*/

@ -26,7 +26,7 @@ use Doctrine\ORM\Mapping as ORM;
* @ORM\Index(name="idx_cdoc_sid", columns={"session_id"}),
* }
* )
* @GRID\Source(columns="iid, title, filetype", filterable=false)
* @GRID\Source(columns="iid, title, filetype, resourceNode.createdAt", filterable=false)
* @ORM\Entity
*/
class CDocument extends AbstractResource implements ResourceInterface

@ -5,11 +5,11 @@
<div class="actions">
<a class="btn btn-secondary"
href="{{ url('chamilo_core_resource_new_folder', { 'tool': tool, 'type': type, 'cidReq': course.code, 'id': id}) }}">
{{ 'Create folder' | trans }}
{{ 'New folder' | trans }}
</a>
<a class="btn btn-secondary"
href="{{ url('chamilo_core_resource_new', { 'tool': tool, 'type': type, 'cidReq': course.code, 'id': id }) }}">
{{ 'Create document' | trans }}
{{ 'Create new document' | trans }}
</a>
<a class="btn btn-secondary"
href="{{ url('chamilo_core_resource_upload', { 'tool': tool, 'type': type, 'cidReq': course.code, 'id': id }) }}">

Loading…
Cancel
Save