Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
hierarchy_manager
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
hierarchy_manager
Commits
0869891a
Commit
0869891a
authored
4 years ago
by
Denis K****
Committed by
Mingsong Hu
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3188871
by dench0, elgandoz, Mingsong: Ajax Links for the dialog opening
parent
d751eebf
No related branches found
No related tags found
1 merge request
!1
Issue #3188871: Ajax Links for the dialog opening.
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
js/Plugin/jstree/hm.jstree.js
+6
-33
6 additions, 33 deletions
js/Plugin/jstree/hm.jstree.js
src/Plugin/HmDisplayPlugin/HmDisplayJstree.php
+10
-0
10 additions, 0 deletions
src/Plugin/HmDisplayPlugin/HmDisplayJstree.php
with
16 additions
and
33 deletions
js/Plugin/jstree/hm.jstree.js
+
6
−
33
View file @
0869891a
...
@@ -103,39 +103,12 @@
...
@@ -103,39 +103,12 @@
}
}
});
});
// Node selected event.
treeContainer
.
on
(
'
ready.jstree
'
,
function
(
event
,
data
)
{
treeContainer
.
on
(
"
select_node.jstree
"
,
function
(
event
,
data
)
{
Drupal
.
attachBehaviors
(
event
.
target
);
var
href
=
data
.
node
.
a_attr
.
href
;
});
if
(
newWindow
)
{
window
.
open
(
href
,
"
_self
"
);
treeContainer
.
on
(
'
open_node.jstree
'
,
function
(
event
,
data
)
{
}
Drupal
.
attachBehaviors
(
event
.
target
);
else
{
Drupal
.
ajax
({
url
:
href
,
success
:
function
(
response
)
{
response
.
forEach
(
function
(
element
)
{
if
(
element
.
command
&&
element
.
data
)
{
if
(
element
.
command
===
'
insert
'
&&
element
.
selector
===
null
)
{
$popDialog
[
offset
]
=
$
(
'
<div>
'
+
element
.
data
+
'
</div>
'
).
appendTo
(
'
body
'
);
}
}
});
if
(
$popDialog
[
offset
])
{
let
margin
=
parseInt
(
offset
*
10
%
40
);
let
options
=
{
title
:
'
Edit
'
+
data
.
node
.
text
,
minWidth
:
600
,
draggable
:
true
,
resizable
:
true
,
autoResize
:
false
,
position
:
{
'
my
'
:
'
right bottom
'
,
'
at
'
:
'
right-
'
+
margin
+
'
bottom-
'
+
margin
},
};
Drupal
.
dialog
(
$popDialog
[
offset
++
],
options
).
show
();
}
}
}).
execute
();
}
});
});
// Search filter box.
// Search filter box.
...
...
This diff is collapsed.
Click to expand it.
src/Plugin/HmDisplayPlugin/HmDisplayJstree.php
+
10
−
0
View file @
0869891a
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
namespace
Drupal\hierarchy_manager\Plugin\HmDisplayPlugin
;
namespace
Drupal\hierarchy_manager\Plugin\HmDisplayPlugin
;
use
Drupal\Component\Serialization\Json
;
use
Drupal\Core\Form\FormStateInterface
;
use
Drupal\Core\Form\FormStateInterface
;
use
Drupal\Core\StringTranslation\StringTranslationTrait
;
use
Drupal\Core\StringTranslation\StringTranslationTrait
;
use
Drupal\hierarchy_manager
\Plugin\HmDisplayPluginInterface
;
use
Drupal\hierarchy_manager
\Plugin\HmDisplayPluginInterface
;
...
@@ -96,9 +97,18 @@ class HmDisplayJstree extends HmDisplayPluginBase implements HmDisplayPluginInte
...
@@ -96,9 +97,18 @@ class HmDisplayJstree extends HmDisplayPluginBase implements HmDisplayPluginInte
if
(
empty
(
$tree_node
[
'parent'
]))
{
if
(
empty
(
$tree_node
[
'parent'
]))
{
$jstree_node
[
'parent'
]
=
'#'
;
$jstree_node
[
'parent'
]
=
'#'
;
}
}
$dialog_options
=
[
'minWidth'
=>
'300'
,
'width'
=>
'960'
,
'title'
=>
$this
->
t
(
'Edit'
)
.
' '
.
$tree_node
[
'text'
],
];
// Custom data
// Custom data
$jstree_node
[
'a_attr'
]
=
[
$jstree_node
[
'a_attr'
]
=
[
'href'
=>
$jstree_node
[
'edit_url'
],
'href'
=>
$jstree_node
[
'edit_url'
],
'class'
=>
'use-ajax'
,
'data-dialog-type'
=>
'modal'
,
'data-dialog-options'
=>
Json
::
encode
(
$dialog_options
),
];
];
unset
(
$jstree_node
[
'edit_url'
]);
unset
(
$jstree_node
[
'edit_url'
]);
// Add this node into the data array.
// Add this node into the data array.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment