Skip to content

Commit

Permalink
fix(AjaxNodeTree): Removed translationId path param from `nodesTree…
Browse files Browse the repository at this point in the history
…Ajax` route
  • Loading branch information
ambroisemaupate committed Jul 31, 2023
1 parent cdfe832 commit d5e6fe6
Show file tree
Hide file tree
Showing 15 changed files with 18 additions and 36 deletions.
4 changes: 1 addition & 3 deletions lib/RoadizRozierBundle/config/routing/ajax.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,11 @@ nodesStatusesAjax:
_controller: Themes\Rozier\AjaxControllers\AjaxNodesController::statusesAction
_format: json
nodesTreeAjax:
path: /nodes/tree/{translationId}
path: /nodes/tree
methods: [GET]
defaults:
_controller: Themes\Rozier\AjaxControllers\AjaxNodeTreeController::getTreeAction
translationId: null
_format: json
requirements: { translationId : "[0-9]+" }
tagsTreeAjax:
path: /tags/tree
methods: [GET]
Expand Down
1 change: 1 addition & 0 deletions lib/Rozier/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"jms/serializer": "^3.9.0",
"league/flysystem": "^3.0",
"pimple/pimple": "^3.3.1",
"ramsey/uuid": "^4.7",
"roadiz/compat-bundle": "^2.1",
"roadiz/core-bundle": "^2.1",
"roadiz/doc-generator": "^2.1",
Expand Down
4 changes: 2 additions & 2 deletions lib/Rozier/src/AjaxControllers/AjaxNodeTreeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,17 @@ public function __construct(

/**
* @param Request $request
* @param int|null $translationId
*
* @return JsonResponse
* @throws \Twig\Error\LoaderError
* @throws \Twig\Error\RuntimeError
* @throws \Twig\Error\SyntaxError
*/
public function getTreeAction(Request $request, ?int $translationId = null)
public function getTreeAction(Request $request)
{
$this->denyAccessUnlessGranted('ROLE_ACCESS_NODES');

$translationId = $request->get('translationId', null);
if (null === $translationId) {
$translation = $this->em()->getRepository(Translation::class)->findDefault();
} else {
Expand Down
12 changes: 4 additions & 8 deletions lib/Rozier/src/Resources/app/Rozier.js
Original file line number Diff line number Diff line change
Expand Up @@ -348,21 +348,17 @@ export default class Rozier {
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'))
}

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

if ($currentRootTree.length && !translationId) {
translationId = parseInt($currentRootTree.attr('data-translation-id'))
}

let url = this.routes.nodesTreeAjax
if (translationId && translationId > 0) {
url += '/' + translationId
}

$.ajax({
url: url,
Expand Down
4 changes: 1 addition & 3 deletions lib/Rozier/src/Resources/app/widgets/ChildrenNodesField.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,10 @@ export default class ChildrenNodesField {
_action: 'requestNodeTree',
parentNodeId: rootNodeId,
linkedTypes: linkedTypes,
translationId: translationId,
}

let url = window.Rozier.routes.nodesTreeAjax
if (translationId && translationId > 0) {
url += '/' + translationId
}

// Do not abort request for nodes which have multiple
// children node widgets.
Expand Down
12 changes: 1 addition & 11 deletions lib/Rozier/src/Resources/app/widgets/StackNodeTree.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,20 +166,10 @@ export default class StackNodeTree {
stackTree: true,
parentNodeId: rootNodeId,
page: this.getCurrentPage(),
translationId: this.getTranslationId(),
translationId: this.getTranslationId() || translationId,
}

let url = window.Rozier.routes.nodesTreeAjax
if (translationId && translationId > 0) {
postData.translationId = parseInt(translationId)
}

/*
* Add translation id route param manually
*/
if (postData.translationId) {
url += '/' + postData.translationId
}

if (page) {
postData.page = parseInt(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.3d6bf1608c5a8f3962cd.css', 'Rozier') }}" rel="stylesheet">
<link href="{{ asset('css/app.6d6a59aa70c093ba0a8c.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.4f4a09e7e882850e2231.js', 'Rozier') }}" defer type="text/javascript"></script>
<script src="{{ asset('js/vendor.2784169093f7024eaf12.js', 'Rozier') }}" defer type="text/javascript"></script>

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

1 change: 0 additions & 1 deletion lib/Rozier/src/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@
"postcss-import": "^11.0.0",
"postcss-loader": "^2.0.8",
"prettier": "^2.7.1",
"ramsey/uuid": "^4.7",
"resolve-url-loader": "^2.2.0",
"rimraf": "^2.6.0",
"sass-loader": "^6.0.6",
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 d5e6fe6

Please sign in to comment.