Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Toolkit
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
digital blueprint
Web Component Framework
Toolkit
Commits
660472d5
Commit
660472d5
authored
5 years ago
by
Reiter, Christoph
Browse files
Options
Downloads
Patches
Plain Diff
Work around select not working when more than one element is used
Looks like something is caching based on ID maybe?
parent
a205176f
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
packages/person-select/src/person-select-demo.js
+7
-1
7 additions, 1 deletion
packages/person-select/src/person-select-demo.js
packages/person-select/src/person-select.js
+8
-3
8 additions, 3 deletions
packages/person-select/src/person-select.js
with
15 additions
and
4 deletions
packages/person-select/src/person-select-demo.js
+
7
−
1
View file @
660472d5
...
...
@@ -40,7 +40,13 @@ class PersonSelectDemo extends LitElement {
<div class="container">
<form>
<div class="field">
<label class="label">Person</label>
<label class="label">Person 1</label>
<div class="control">
<vpu-person-select lang="
${
this
.
lang
}
" entry-point-url="
${
getAPiUrl
()}
"></vpu-person-select>
</div>
</div>
<div class="field">
<label class="label">Person 2</label>
<div class="control">
<vpu-person-select lang="
${
this
.
lang
}
" entry-point-url="
${
getAPiUrl
()}
"></vpu-person-select>
</div>
...
...
This diff is collapsed.
Click to expand it.
packages/person-select/src/person-select.js
+
8
−
3
View file @
660472d5
...
...
@@ -11,6 +11,8 @@ import commonUtils from 'vpu-common/utils';
select2
(
window
,
$
);
var
selectId
=
0
;
class
PersonSelect
extends
VPULitElementJQuery
{
constructor
()
{
...
...
@@ -19,6 +21,8 @@ class PersonSelect extends VPULitElementJQuery {
this
.
entryPointUrl
=
getAPiUrl
();
this
.
jsonld
=
null
;
this
.
$select
=
null
;
// XXX: For some reason using the same ID twice breaks select2
this
.
selectId
=
'
person-select
'
+
selectId
++
;
}
static
get
properties
()
{
...
...
@@ -33,7 +37,7 @@ class PersonSelect extends VPULitElementJQuery {
const
that
=
this
;
this
.
updateComplete
.
then
(()
=>
{
that
.
$select
=
that
.
$
(
'
#person-
select
'
);
that
.
$select
=
$
(
that
.
shadowRoot
.
getElementById
(
that
.
select
Id
)
);
// close the selector on blur of the web component
$
(
that
).
blur
(()
=>
{
...
...
@@ -52,6 +56,7 @@ class PersonSelect extends VPULitElementJQuery {
const
$this
=
$
(
this
);
let
lastResult
=
{};
// find the correct api url for a person
const
apiUrl
=
this
.
jsonld
.
getApiUrlForIdentifier
(
"
http://schema.org/Person
"
);
// const apiUrl = this.jsonld.getApiUrlForEntityName("Event");
...
...
@@ -152,13 +157,13 @@ class PersonSelect extends VPULitElementJQuery {
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bulma/0.7.5/css/bulma.min.css">
<link rel="stylesheet" href="
${
select2CSS
}
">
<style>
#
person-
select {
#
${
this
.
select
Id
}
{
width: 100%;
}
</style>
<!-- https://select2.org-->
<select id="
person-
select" name="person" class="select"></select>
<select id="
${
this
.
select
Id
}
" name="person" class="select"></select>
<div id="person-select-dropdown"></div>
`
;
}
...
...
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