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
8fec8e04
Commit
8fec8e04
authored
5 years ago
by
Bekerle, Patrizio
Committed by
Reiter, Christoph
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Add birth day support
parent
f3ae98f3
No related branches found
No related tags found
Loading
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
packages/person-select/README.md
+3
-0
3 additions, 0 deletions
packages/person-select/README.md
packages/person-select/src/vpu-person-select.js
+23
-6
23 additions, 6 deletions
packages/person-select/src/vpu-person-select.js
with
26 additions
and
6 deletions
packages/person-select/README.md
+
3
−
0
View file @
8fec8e04
...
@@ -19,6 +19,9 @@
...
@@ -19,6 +19,9 @@
-
the
`value`
will also be set automatically when a person is chosen in the selector
-
the
`value`
will also be set automatically when a person is chosen in the selector
-
`data-object`
(read-only): when a person is selected the person object will be set as json string
-
`data-object`
(read-only): when a person is selected the person object will be set as json string
-
example
`<vpu-person-select data-object="{"@id":"/people/testuser", "@type":"http://schema.org/Person", "identifier":"testuser", "givenName":"Hans", "familyName":"Tester", "honorificSuffix":"Ing.", "telephone":"+43 (876) 123-4567", "phoneExtension":"4567", "email":"hans.tester@email.com", "name":"Hans Tester"}"></vpu-person-select>`
-
example
`<vpu-person-select data-object="{"@id":"/people/testuser", "@type":"http://schema.org/Person", "identifier":"testuser", "givenName":"Hans", "familyName":"Tester", "honorificSuffix":"Ing.", "telephone":"+43 (876) 123-4567", "phoneExtension":"4567", "email":"hans.tester@email.com", "name":"Hans Tester"}"></vpu-person-select>`
-
`show-birth-date`
(optional): also shows the birth date of the persons to distinguish people with the same name
-
the currently logged in user needs to have permissions to show the birth date of people
-
example
`<vpu-person-select show-birth-date></vpu-person-select>`
-
`show-reload-button`
(optional): if set a reload button will be viewed next to the select box
-
`show-reload-button`
(optional): if set a reload button will be viewed next to the select box
-
the button triggers a
`change`
event on the web component
-
the button triggers a
`change`
event on the web component
-
the button is disabled if no person is selected
-
the button is disabled if no person is selected
...
...
This diff is collapsed.
Click to expand it.
packages/person-select/src/vpu-person-select.js
+
23
−
6
View file @
8fec8e04
...
@@ -33,6 +33,7 @@ class PersonSelect extends VPULitElementJQuery {
...
@@ -33,6 +33,7 @@ class PersonSelect extends VPULitElementJQuery {
this
.
lastResult
=
{};
this
.
lastResult
=
{};
this
.
showReloadButton
=
false
;
this
.
showReloadButton
=
false
;
this
.
reloadButtonTitle
=
''
;
this
.
reloadButtonTitle
=
''
;
this
.
showBirthDate
=
false
;
}
}
static
get
properties
()
{
static
get
properties
()
{
...
@@ -44,6 +45,7 @@ class PersonSelect extends VPULitElementJQuery {
...
@@ -44,6 +45,7 @@ class PersonSelect extends VPULitElementJQuery {
object
:
{
type
:
Object
,
attribute
:
false
},
object
:
{
type
:
Object
,
attribute
:
false
},
showReloadButton
:
{
type
:
Boolean
,
attribute
:
'
show-reload-button
'
},
showReloadButton
:
{
type
:
Boolean
,
attribute
:
'
show-reload-button
'
},
reloadButtonTitle
:
{
type
:
String
,
attribute
:
'
reload-button-title
'
},
reloadButtonTitle
:
{
type
:
String
,
attribute
:
'
reload-button-title
'
},
showBirthDate
:
{
type
:
Boolean
,
attribute
:
'
show-birth-date
'
},
};
};
}
}
...
@@ -143,13 +145,16 @@ class PersonSelect extends VPULitElementJQuery {
...
@@ -143,13 +145,16 @@ class PersonSelect extends VPULitElementJQuery {
};
};
},
},
processResults
:
function
(
data
)
{
processResults
:
function
(
data
)
{
console
.
log
(
data
);
//
console.log(data);
that
.
lastResult
=
data
;
that
.
lastResult
=
data
;
const
members
=
data
[
"
hydra:member
"
];
let
results
=
[];
members
.
forEach
((
person
)
=>
{
results
.
push
({
id
:
person
[
"
@id
"
],
text
:
that
.
generateOptionText
(
person
)});
});
const
results
=
that
.
jsonld
.
transformMembers
(
data
,
localContext
);
// console.log("results");
// console.log(results);
console
.
log
(
"
results
"
);
console
.
log
(
results
);
return
{
return
{
results
:
results
results
:
results
...
@@ -208,7 +213,7 @@ class PersonSelect extends VPULitElementJQuery {
...
@@ -208,7 +213,7 @@ class PersonSelect extends VPULitElementJQuery {
.
then
((
person
)
=>
{
.
then
((
person
)
=>
{
that
.
object
=
person
;
that
.
object
=
person
;
const
identifier
=
person
[
"
@id
"
];
const
identifier
=
person
[
"
@id
"
];
const
option
=
new
Option
(
person
.
name
,
identifier
,
true
,
true
);
const
option
=
new
Option
(
that
.
generateOptionText
(
person
)
,
identifier
,
true
,
true
);
$this
.
attr
(
"
data-object
"
,
JSON
.
stringify
(
person
));
$this
.
attr
(
"
data-object
"
,
JSON
.
stringify
(
person
));
$this
.
data
(
"
object
"
,
person
);
$this
.
data
(
"
object
"
,
person
);
that
.
$select
.
append
(
option
).
trigger
(
'
change
'
);
that
.
$select
.
append
(
option
).
trigger
(
'
change
'
);
...
@@ -228,6 +233,18 @@ class PersonSelect extends VPULitElementJQuery {
...
@@ -228,6 +233,18 @@ class PersonSelect extends VPULitElementJQuery {
return
true
;
return
true
;
}
}
generateOptionText
(
person
)
{
let
text
=
person
[
"
name
"
];
// add birth date to name if present
if
(
this
.
showBirthDate
&&
(
person
[
"
birthDate
"
]
!==
undefined
)
&&
(
person
[
"
birthDate
"
]
!==
""
))
{
const
date
=
new
Date
(
person
[
"
birthDate
"
]);
text
+=
` (
${
date
.
toLocaleDateString
(
"
de-AT
"
)}
)`
;
}
return
text
;
}
update
(
changedProperties
)
{
update
(
changedProperties
)
{
changedProperties
.
forEach
((
oldValue
,
propName
)
=>
{
changedProperties
.
forEach
((
oldValue
,
propName
)
=>
{
switch
(
propName
)
{
switch
(
propName
)
{
...
...
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