Skip to content

Commit

Permalink
fix(AjaxNodeTreeController): Fixed non-integer translationId
Browse files Browse the repository at this point in the history
  • Loading branch information
ambroisemaupate committed Jul 31, 2023
1 parent b7b042d commit e33762f
Show file tree
Hide file tree
Showing 12 changed files with 28 additions and 25 deletions.
17 changes: 10 additions & 7 deletions lib/Rozier/src/AjaxControllers/AjaxNodeTreeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
use Symfony\Component\HttpFoundation\Request;
use Themes\Rozier\Widgets\NodeTreeWidget;
use Themes\Rozier\Widgets\TreeWidgetFactory;
use Twig\Error\LoaderError;
use Twig\Error\RuntimeError;
use Twig\Error\SyntaxError;

/**
* @package Themes\Rozier\AjaxControllers
Expand All @@ -38,22 +41,22 @@ public function __construct(
* @param Request $request
*
* @return JsonResponse
* @throws \Twig\Error\LoaderError
* @throws \Twig\Error\RuntimeError
* @throws \Twig\Error\SyntaxError
* @throws LoaderError
* @throws RuntimeError
* @throws SyntaxError
*/
public function getTreeAction(Request $request)
public function getTreeAction(Request $request): JsonResponse
{
$this->denyAccessUnlessGranted('ROLE_ACCESS_NODES');

$translationId = $request->get('translationId', null);
if (null === $translationId) {
$translation = $this->em()->getRepository(Translation::class)->findDefault();
} else {
if (\is_numeric($translationId) && $translationId > 0) {
$translation = $this->em()->find(
Translation::class,
$translationId
);
} else {
$translation = $this->em()->getRepository(Translation::class)->findDefault();
}

/** @var NodeTreeWidget|null $nodeTree */
Expand Down
6 changes: 3 additions & 3 deletions lib/Rozier/src/Resources/app/Rozier.js
Original file line number Diff line number Diff line change
Expand Up @@ -343,20 +343,20 @@ export default class Rozier {
/**
* Refresh only main nodeTree.
*
* @param translationId
* @param {Number|null|undefined} translationId
*/
refreshMainNodeTree(translationId) {
let $currentNodeTree = $('#tree-container').find('.nodetree-widget')
let $currentRootTree = $currentNodeTree.find('.root-tree').eq(0)
if ($currentRootTree.length && !translationId) {
translationId = parseInt($currentRootTree.attr('data-translation-id'))
translationId = $currentRootTree.attr('data-translation-id')
}

if ($currentNodeTree.length) {
let postData = {
_token: this.ajaxToken,
_action: 'requestMainNodeTree',
translationId: translationId,
translationId: translationId || null,
}
let url = this.routes.nodesTreeAjax

Expand Down
4 changes: 2 additions & 2 deletions lib/Rozier/src/Resources/app/widgets/ChildrenNodesField.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export default class ChildrenNodesField {
}
const rootNodeId = parseInt($rootTree.attr('data-parent-node-id'))
const linkedTypesRaw = $rootTree.attr('data-linked-types')
let translationId = parseInt($rootTree.attr('data-translation-id'))
let translationId = $rootTree.attr('data-translation-id')
if (linkedTypesRaw) {
linkedTypes = JSON.parse(linkedTypesRaw)
}
Expand All @@ -112,7 +112,7 @@ export default class ChildrenNodesField {
_action: 'requestNodeTree',
parentNodeId: rootNodeId,
linkedTypes: linkedTypes,
translationId: translationId,
translationId: translationId || null,
}

let url = window.Rozier.routes.nodesTreeAjax
Expand Down
10 changes: 5 additions & 5 deletions lib/Rozier/src/Resources/app/widgets/StackNodeTree.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ export default class StackNodeTree {

let $link = $(event.currentTarget)
let parentNodeId = parseInt($link.attr('data-children-parent-node'))
let translationId = parseInt($link.attr('data-translation-id'))
let translationId = $link.attr('data-translation-id')
let tagId = $link.attr('data-filter-tag')
this.refreshNodeTree(parentNodeId, translationId, tagId)
this.refreshNodeTree(parentNodeId, translationId, tagId, 1)
return false
}

Expand Down Expand Up @@ -134,9 +134,9 @@ export default class StackNodeTree {

/**
*
* @param rootNodeId
* @param translationId
* @param tagId
* @param {Number|undefined|null} rootNodeId
* @param {Number|undefined|null} translationId
* @param {Number|undefined|null} tagId
* @param page
*/
refreshNodeTree(rootNodeId, translationId, tagId, page) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

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

<link href="{{ asset('css/app.6d6a59aa70c093ba0a8c.css', 'Rozier') }}" rel="stylesheet">
<link href="{{ asset('css/app.c9045ea8fbedd28c00ed.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.2784169093f7024eaf12.js', 'Rozier') }}" defer type="text/javascript"></script>
<script src="{{ asset('js/vendor.84adcd1151ebc6fc29e9.js', 'Rozier') }}" defer type="text/javascript"></script>

<script src="{{ asset('js/app.2784169093f7024eaf12.js', 'Rozier') }}" defer type="text/javascript"></script>
<script src="{{ asset('js/app.84adcd1151ebc6fc29e9.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.2784169093f7024eaf12.js', 'Rozier') }}" defer type="text/javascript"></script>
<script src="{{ asset('js/simple.84adcd1151ebc6fc29e9.js', 'Rozier') }}" defer type="text/javascript"></script>

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 e33762f

Please sign in to comment.