Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
nghyd
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
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
Show more breadcrumbs
Cassiopée
nghyd
Commits
1df98b3b
Commit
1df98b3b
authored
2 years ago
by
François Grand
Browse files
Options
Downloads
Patches
Plain Diff
fix: modify SelectField.findAndSetDefaultValue() to use nub value for associated property
refs
#592
parent
5894ee91
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!225
Release v4.17.0
,
!199
Resolve "Incohérence dans les fichiers de session"
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/app/formulaire/elements/select/select-field.ts
+19
-4
19 additions, 4 deletions
src/app/formulaire/elements/select/select-field.ts
with
19 additions
and
4 deletions
src/app/formulaire/elements/select/select-field.ts
+
19
−
4
View file @
1df98b3b
...
...
@@ -132,22 +132,37 @@ export abstract class SelectField extends Field {
}
/**
* try to find a default value to select
* Try to find a default value to select.
* Priority order :
* - passed parameter
* - nub value for associated property
* - default value from configuration file
* - first select entry
*/
protected
findAndSetDefaultValue
(
value
?:
string
)
{
// default to first available entry if any
if
(
this
.
_entries
.
length
>
0
)
{
let
val
:
SelectEntry
;
if
(
value
!==
undefined
)
{
val
=
this
.
getEntryFromValue
(
enumValueFromString
(
this
.
_associatedProperty
,
value
));
}
else
if
(
this
.
_configDefaultValue
===
undefined
)
{
val
=
this
.
_entries
[
0
];
}
else
{
if
(
val
===
undefined
)
{
throw
Error
(
"
invalid select default value
"
+
value
+
"
for
"
+
this
.
_associatedProperty
+
"
property
"
);
}
}
else
if
(
this
.
nub
!==
undefined
)
{
val
=
this
.
getEntryFromValue
(
this
.
nub
.
getPropValue
(
this
.
_associatedProperty
));
if
(
val
===
undefined
)
{
throw
Error
(
"
invalid select default value for
"
+
this
.
_associatedProperty
+
"
property
"
);
}
}
else
if
(
this
.
_configDefaultValue
!==
undefined
)
{
val
=
this
.
getEntryFromValue
(
enumValueFromString
(
this
.
_associatedProperty
,
this
.
_configDefaultValue
));
if
(
val
===
undefined
)
{
throw
Error
(
"
invalid select default value
"
+
this
.
_configDefaultValue
+
"
for
"
+
this
.
_associatedProperty
+
"
property
"
);
}
}
else
{
val
=
this
.
_entries
[
0
];
}
if
(
this
.
_multiple
)
{
this
.
setValue
([
val
]);
}
else
{
...
...
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