Skip to content

Commit

Permalink
Merge branch 'hotfix/v2.4.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
ambroisemaupate committed Dec 11, 2024
2 parents 6ebbb9a + f61d6e0 commit d011337
Show file tree
Hide file tree
Showing 16 changed files with 119 additions and 151 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

All notable changes to Roadiz will be documented in this file.

## [2.4.1](https://github.com/roadiz/core-bundle-dev-app/compare/v2.4.0...v2.4.1) - 2024-12-11

### Bug Fixes

- Fixed back-office quick search using ExplorerItemFactory to support other data than NodesSources - ([26f540c](https://github.com/roadiz/core-bundle-dev-app/commit/26f540cdeaef4578b5bd8df3d54c96fd52fae654))

## [2.4.0](https://github.com/roadiz/core-bundle-dev-app/compare/v2.3.31...v2.4.0) - 2024-12-05

### ⚠ Breaking changes
Expand Down
2 changes: 1 addition & 1 deletion lib/RoadizCoreBundle/config/services.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
parameters:
roadiz_core.cms_version: '2.4.0'
roadiz_core.cms_version: '2.4.1'
roadiz_core.cms_version_prefix: 'main'
env(APP_NAMESPACE): "roadiz"
env(APP_VERSION): "0.1.0"
Expand Down
6 changes: 3 additions & 3 deletions lib/RoadizRozierBundle/config/routing/ajax.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ nodeAjaxEdit:
controller: Themes\Rozier\AjaxControllers\AjaxNodesController::editAction
format: json
requirements: { nodeId : "[0-9]+" }
searchNodesSourcesAjax:
path: /nodes-sources/search
searchAjax:
path: /search
methods: [GET]
defaults:
_controller: Themes\Rozier\AjaxControllers\AjaxSearchNodesSourcesController::searchAction
_controller: Themes\Rozier\AjaxControllers\AjaxSearchController::searchAction
_format: json
nodesStatusesAjax:
path: /nodes/statuses
Expand Down
91 changes: 91 additions & 0 deletions lib/Rozier/src/AjaxControllers/AjaxSearchController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
<?php

declare(strict_types=1);

namespace Themes\Rozier\AjaxControllers;

use RZ\Roadiz\Core\AbstractEntities\PersistableInterface;
use RZ\Roadiz\CoreBundle\Entity\NodesSources;
use RZ\Roadiz\CoreBundle\Explorer\ExplorerItemFactoryInterface;
use RZ\Roadiz\CoreBundle\SearchEngine\GlobalNodeSourceSearchHandler;
use RZ\Roadiz\CoreBundle\Security\Authorization\Voter\NodeVoter;
use Symfony\Bundle\SecurityBundle\Security;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
use Symfony\Component\Serializer\SerializerInterface;

final class AjaxSearchController extends AbstractAjaxController
{
public const RESULT_COUNT = 10;

public function __construct(
private readonly Security $security,
private readonly ExplorerItemFactoryInterface $explorerItemFactory,
SerializerInterface $serializer,
) {
parent::__construct($serializer);
}

/**
* Handle AJAX edition requests for Node
* such as coming from node-tree widgets.
*
* @return Response JSON response
*/
public function searchAction(Request $request): Response
{
$this->denyAccessUnlessGranted(NodeVoter::SEARCH);

if (!$request->query->has('searchTerms') || '' == $request->query->get('searchTerms')) {
throw new BadRequestHttpException('searchTerms parameter is missing.');
}

$searchHandler = new GlobalNodeSourceSearchHandler($this->em());
$searchHandler->setDisplayNonPublishedNodes(true);

/** @var array $nodesSources */
$nodesSources = $searchHandler->getNodeSourcesBySearchTerm(
$request->get('searchTerms'),
self::RESULT_COUNT
);

if (0 === count($nodesSources)) {
return new JsonResponse([
'statusCode' => Response::HTTP_OK,
'status' => 'success',
'data' => [],
'responseText' => 'No results found.',
]);
}

$data = [];

foreach ($nodesSources as $source) {
$uniqueKey = null;
if ($source instanceof NodesSources) {
$uniqueKey = 'n_' . $source->getNode()->getId();
if (!$this->security->isGranted(NodeVoter::READ, $source)) {
continue;
}
} elseif ($source instanceof PersistableInterface) {
$uniqueKey = 'p_' . $source->getId();
}
if (key_exists($uniqueKey, $data)) {
continue;
}

$data[$uniqueKey] = $this->explorerItemFactory->createForEntity($source)->toArray();
}

$data = array_values($data);

return $this->createSerializedResponse([
'status' => 'confirm',
'statusCode' => 200,
'data' => $data,
'count' => count($data),
]);
}
}
128 changes: 0 additions & 128 deletions lib/Rozier/src/AjaxControllers/AjaxSearchNodesSourcesController.php

This file was deleted.

2 changes: 1 addition & 1 deletion lib/Rozier/src/Resources/app/api/NodesSourceSearchApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export function getNodesSourceFromSearch(searchTerms) {

return request({
method: 'GET',
url: window.RozierRoot.routes.searchNodesSourcesAjax,
url: window.RozierRoot.routes.searchAjax,
params: postData,
})
.then((response) => {
Expand Down
2 changes: 1 addition & 1 deletion lib/Rozier/src/Resources/views/base.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@
'providerAjaxExplorer' : '{{ path('providerAjaxExplorerPage') }}',
'providerAjaxByArray' : '{{ path('providerAjaxByArray') }}',
'customFormsAjaxExplorer' : '{{ path('customFormsAjaxExplorerPage') }}',
'searchNodesSourcesAjax': '{{ path('searchNodesSourcesAjax') }}',
'searchAjax': '{{ path('searchAjax') }}',
'nodesStatusesAjax' : '{{ path('nodesStatusesAjax') }}',
'nodesTreeAjax' : '{{ path('nodesTreeAjax') }}',
'tagsTreeAjax' : '{{ path('tagsTreeAjax') }}',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

<link href="{{ asset('css/vendor.9b59501e29a05f532c3c.css', 'Rozier') }}" rel="stylesheet">

<link href="{{ asset('css/app.f8fcd31a684be65ed09b.css', 'Rozier') }}" rel="stylesheet">
<link href="{{ asset('css/app.527fdff666ecb3971c76.css', 'Rozier') }}" rel="stylesheet">



Expand Down
4 changes: 2 additions & 2 deletions lib/Rozier/src/Resources/views/partials/js-inject.html.twig
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

<script src="{{ asset('js/vendor.84fa83ed0cd290364ef4.js', 'Rozier') }}" defer type="text/javascript"></script>
<script src="{{ asset('js/vendor.48b3bf2e8eb28e9948b2.js', 'Rozier') }}" defer type="text/javascript"></script>

<script src="{{ asset('js/app.84fa83ed0cd290364ef4.js', 'Rozier') }}" defer type="text/javascript"></script>
<script src="{{ asset('js/app.48b3bf2e8eb28e9948b2.js', 'Rozier') }}" defer type="text/javascript"></script>

Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@

<script src="{{ asset('js/simple.84fa83ed0cd290364ef4.js', 'Rozier') }}" defer type="text/javascript"></script>
<script src="{{ asset('js/simple.48b3bf2e8eb28e9948b2.js', 'Rozier') }}" defer type="text/javascript"></script>

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{{isActive}}
<div id="nodes-sources-search" v-bind:class="{ 'focus-on': isFocus }">
<form id="nodes-sources-search-form"
v-on:submit.prevent action="{{ path('searchNodesSourcesAjax') }}"
v-on:submit.prevent action="{{ path('searchAjax') }}"
method="GET"
class="uk-form">
<div class="uk-form-icon">
Expand All @@ -24,21 +24,20 @@
<transition name="fade">
<ul id="nodes-sources-search-results" v-if="isFocus" v-cloak>
<li v-for="item in items">
<ajax-link class="nodes-sources-search-results-item" :href="item.url" :title="item.title" :type-color="item.typeColor">
<ajax-link class="nodes-sources-search-results-item" :href="item.editItem" :title="item.displayable" :type-color="item.color">
<span class="image-container">
<picture v-if="item.thumbnail">
<source v-if="!item.thumbnail.endsWith('svg') && !item.thumbnail.endsWith('webp')"
:srcset="item.thumbnail + '.webp'"
<picture v-if="item.thumbnail && item.thumbnail.processable">
<source v-if="!item.thumbnail.url.endsWith('svg') && !item.thumbnail.url.endsWith('webp')"
:srcset="item.thumbnail.url + '.webp'"
type="image/webp">
<img width="60" height="60" loading="lazy" :src="item.thumbnail">
<img width="60" height="60" loading="lazy" :src="item.thumbnail.url">
</picture>
</span>
<span class="texts">
<span class="texts-header">
<span class="parent">${item.parent}</span>
<span class="type">${item.typeName}</span>
<span class="texts-header" v-if="item.classname">
<span class="parent">${item.classname}</span>
</span>
<span class="title">${item.title}</span>
<span class="title">${item.displayable}</span>
</span>
</ajax-link>
</li>
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

0 comments on commit d011337

Please sign in to comment.