Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
taxonomy_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
taxonomy_manager
Commits
bbf49f22
Commit
bbf49f22
authored
11 months ago
by
Andrii Kocherhin
Committed by
Andriy Khomych
11 months ago
Browse files
Options
Downloads
Patches
Plain Diff
changed bind from 'click' to 'autocompleteselect'
parent
d87ca900
No related branches found
No related tags found
1 merge request
!40
changed bind from 'click' to 'autocompleteselect'
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
js/tree.js
+32
-24
32 additions, 24 deletions
js/tree.js
with
32 additions
and
24 deletions
js/tree.js
+
32
−
24
View file @
bbf49f22
...
...
@@ -20,30 +20,38 @@
$
(
'
.taxonomy-manager-autocomplete-input
'
).
show
();
return
true
;
});
// Handle click on autocomplete suggestion
$
(
once
(
'
input
'
,
'
.ui-autocomplete
'
,
context
)).
on
(
'
click
'
,
function
(
e
)
{
e
.
stopPropagation
();
var
tidMatch
=
$
(
'
input[name="search_terms"]
'
).
val
().
match
(
/
\([
0-9
]
*
\)
/g
)
if
(
tidMatch
.
length
)
{
var
tid
=
parseInt
(
tidMatch
[
0
].
replace
(
/^
[^
0-9
]
+/
,
''
),
10
);
// Request tree keys to activate via ajax.
$
.
ajax
({
url
:
Drupal
.
url
(
'
taxonomy_manager/subtree/child-parents
'
),
dataType
:
'
json
'
,
data
:
{
'
tid
'
:
tid
},
success
:
function
(
termData
)
{
var
$tree
=
$
(
"
#edit-taxonomy-manager-tree
"
).
fancytree
(
"
getTree
"
);
var
path
=
termData
.
path
;
$tree
.
loadKeyPath
(
path
).
progress
(
function
(
keyData
)
{
if
(
keyData
.
status
===
'
ok
'
)
{
$tree
.
activateKey
(
keyData
.
node
.
key
);
}
});
}
});
}
once
(
'
input
'
,
'
input[name="search_terms"]
'
,
context
).
forEach
(
value
=>
{
const
uiAutocomplete
=
$
(
value
);
//Bind the autocomplete widget to the input field
// @see https://api.jqueryui.com/autocomplete/#event-select
uiAutocomplete
.
bind
(
'
autocompleteselect
'
,
(
event
,
ui
)
=>
{
event
.
stopPropagation
();
const
tidMatch
=
ui
.
item
.
value
.
match
(
/
\([
0-9
]
*
\)
/g
)
if
(
tidMatch
.
length
)
{
const
tid
=
parseInt
(
tidMatch
[
0
].
replace
(
/^
[^
0-9
]
+/
,
''
),
10
);
$
.
ajax
({
url
:
Drupal
.
url
(
'
taxonomy_manager/subtree/child-parents
'
),
dataType
:
'
json
'
,
data
:
{
'
tid
'
:
tid
},
success
:
termData
=>
{
const
$tree
=
$
(
"
#edit-taxonomy-manager-tree
"
).
fancytree
(
"
getTree
"
);
const
path
=
termData
.
path
;
$tree
.
loadKeyPath
(
path
).
progress
(
keyData
=>
{
if
(
keyData
.
status
===
'
ok
'
)
{
$tree
.
activateKey
(
keyData
.
node
.
key
);
}
});
},
error
:
(
jqXHR
,
textStatus
,
errorThrown
)
=>
{
console
.
error
(
`Request failed:
${
textStatus
}
,
${
errorThrown
}
`
);
}
});
}
});
});
}
};
...
...
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