Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
G
Géocontrib Frontend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Redmine
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
GéoContrib
Géocontrib Frontend
Commits
d93c0a92
Commit
d93c0a92
authored
3 years ago
by
Timothee P
Browse files
Options
Downloads
Patches
Plain Diff
allow filling only one option
parent
1d644223
No related branches found
No related tags found
1 merge request
!118
REDMINE_ISSUE-12064
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/components/feature_type/FeatureTypeCustomForm.vue
+29
-17
29 additions, 17 deletions
src/components/feature_type/FeatureTypeCustomForm.vue
with
29 additions
and
17 deletions
src/components/feature_type/FeatureTypeCustomForm.vue
+
29
−
17
View file @
d93c0a92
...
@@ -231,13 +231,8 @@ export default {
...
@@ -231,13 +231,8 @@ export default {
},
},
// * create an array, because backend expects an array
// * create an array, because backend expects an array
set
(
newValue
)
{
set
(
newValue
)
{
this
.
form
.
options
.
errors
=
[];
this
.
form
.
options
.
value
=
this
.
trimWhiteSpace
(
newValue
).
split
(
"
,
"
);
this
.
form
.
options
.
value
=
this
.
trimWhiteSpace
(
newValue
).
split
(
"
,
"
);
if
(
this
.
hasDuplicates
(
this
.
form
.
options
.
value
))
{
if
(
!
this
.
hasDuplicateOptions
())
{
this
.
form
.
options
.
errors
=
[
"
Veuillez saisir des valeurs différentes
"
,
];
}
else
{
this
.
updateStore
();
this
.
updateStore
();
}
}
},
},
...
@@ -245,8 +240,16 @@ export default {
...
@@ -245,8 +240,16 @@ export default {
},
},
methods
:
{
methods
:
{
hasDuplicates
(
array
)
{
hasDuplicateOptions
()
{
return
new
Set
(
array
).
size
!==
array
.
length
;
this
.
form
.
options
.
errors
=
[];
const
isDup
=
new
Set
(
this
.
form
.
options
.
value
).
size
!==
this
.
form
.
options
.
value
.
length
;
if
(
isDup
)
{
this
.
form
.
options
.
errors
=
[
"
Veuillez saisir des valeurs différentes
"
];
return
true
;
}
return
false
;
},
},
fillCustomFormData
(
customFormData
)
{
fillCustomFormData
(
customFormData
)
{
for
(
let
el
in
customFormData
)
{
for
(
let
el
in
customFormData
)
{
...
@@ -300,15 +303,24 @@ export default {
...
@@ -300,15 +303,24 @@ export default {
return
occurences
.
length
===
1
;
return
occurences
.
length
===
1
;
},
},
checkFilledOptions
()
{
if
(
this
.
form
.
field_type
.
value
===
"
list
"
)
{
if
(
this
.
form
.
options
.
value
.
length
<
1
)
{
return
false
;
}
else
if
(
this
.
form
.
options
.
value
.
length
===
1
&&
this
.
form
.
options
.
value
[
0
]
===
""
)
{
return
false
;
}
}
return
true
;
},
checkCustomForm
()
{
checkCustomForm
()
{
this
.
form
.
label
.
errors
=
[];
this
.
form
.
label
.
errors
=
[];
this
.
form
.
name
.
errors
=
[];
this
.
form
.
name
.
errors
=
[];
this
.
form
.
options
.
errors
=
[];
this
.
form
.
options
.
errors
=
[];
console
.
log
(
this
.
form
.
field_type
.
value
,
this
.
form
.
field_type
.
value
===
"
list
"
,
this
.
form
.
options
.
value
.
length
<
2
);
if
(
!
this
.
form
.
label
.
value
)
{
if
(
!
this
.
form
.
label
.
value
)
{
//* vérifier que le label est renseigné
//* vérifier que le label est renseigné
this
.
form
.
label
.
errors
=
[
"
Veuillez compléter ce champ.
"
];
this
.
form
.
label
.
errors
=
[
"
Veuillez compléter ce champ.
"
];
...
@@ -329,13 +341,13 @@ export default {
...
@@ -329,13 +341,13 @@ export default {
"
Les champs personnalisés ne peuvent pas avoir des noms similaires.
"
,
"
Les champs personnalisés ne peuvent pas avoir des noms similaires.
"
,
];
];
return
false
;
return
false
;
}
else
if
(
}
else
if
(
!
this
.
checkFilledOptions
())
{
this
.
form
.
field_type
.
value
===
"
list
"
&&
this
.
form
.
options
.
value
.
length
<
2
)
{
//* s'il s'agit d'un type liste, vérifier que le champ option est bien renseigné
//* s'il s'agit d'un type liste, vérifier que le champ option est bien renseigné
this
.
form
.
options
.
errors
=
[
"
Veuillez compléter ce champ.
"
];
this
.
form
.
options
.
errors
=
[
"
Veuillez compléter ce champ.
"
];
return
false
;
return
false
;
}
else
if
(
this
.
hasDuplicateOptions
())
{
//* pour le cas d'options dupliqués
return
false
;
}
}
return
true
;
return
true
;
},
},
...
...
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