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
externe Matthieu
Géocontrib Frontend
Commits
91711c11
Commit
91711c11
authored
3 years ago
by
Timothee P
Browse files
Options
Downloads
Patches
Plain Diff
prevent sending form if duplicate & empty string in fields
parent
579e06e6
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/components/feature_type/FeatureTypeCustomForm.vue
+18
-27
18 additions, 27 deletions
src/components/feature_type/FeatureTypeCustomForm.vue
src/views/feature_type/Feature_type_edit.vue
+3
-3
3 additions, 3 deletions
src/views/feature_type/Feature_type_edit.vue
with
21 additions
and
30 deletions
src/components/feature_type/FeatureTypeCustomForm.vue
+
18
−
27
View file @
91711c11
...
...
@@ -284,46 +284,37 @@ export default {
},
checkUniqueName
()
{
console
.
log
(
this
.
$store
);
console
.
log
(
this
.
$store
.
state
);
console
.
log
(
this
.
$store
.
state
.
feature_type
);
if
(
this
.
form
.
name
.
value
)
{
const
occurences
=
this
.
$store
.
state
.
feature_type
.
customForms
.
map
((
el
)
=>
el
.
name
)
.
filter
((
el
)
=>
el
===
this
.
form
.
name
.
value
);
console
.
log
(
"
occurences
"
,
occurences
);
console
.
log
(
occurences
.
length
);
if
(
occurences
.
length
>
1
)
{
console
.
log
(
"
duplicate
"
,
this
.
form
.
name
.
value
);
this
.
form
.
name
.
errors
=
[
"
Les champs personnalisés ne peuvent pas avoir des noms similaires.
"
,
];
return
false
;
}
}
this
.
form
.
name
.
errors
=
[];
return
true
;
const
occurences
=
this
.
$store
.
state
.
feature_type
.
customForms
.
map
((
el
)
=>
el
.
name
)
.
filter
((
el
)
=>
el
===
this
.
form
.
name
.
value
);
return
occurences
.
length
===
1
;
},
checkCustomForm
()
{
if
(
this
.
form
.
label
.
value
===
null
)
{
this
.
form
.
label
.
errors
=
[];
this
.
form
.
name
.
errors
=
[];
if
(
!
this
.
form
.
label
.
value
)
{
//* vérifier que le label est renseigné
this
.
form
.
label
.
errors
=
[
"
Veuillez compléter ce champ.
"
];
return
false
;
}
else
if
(
this
.
form
.
name
.
value
===
null
)
{
}
else
if
(
!
this
.
form
.
name
.
value
)
{
//* vérifier que le nom est renseigné
this
.
form
.
name
.
errors
=
[
"
Veuillez compléter ce champ.
"
];
this
.
form
.
label
.
errors
=
[];
return
false
;
}
else
if
(
!
this
.
hasRegularCharacters
(
this
.
form
.
name
.
value
))
{
//* vérifier qu'il n'y a pas de caractères spéciaux
this
.
form
.
name
.
errors
=
[
"
Veuillez utiliser seulement les caratères autorisés.
"
,
];
this
.
form
.
label
.
errors
=
[];
return
false
;
}
else
if
(
this
.
checkUniqueName
())
{
this
.
form
.
label
.
errors
=
[];
this
.
form
.
name
.
errors
=
[];
return
true
;
}
else
if
(
!
this
.
checkUniqueName
())
{
//* vérifier si les noms sont pas dupliqués
this
.
form
.
name
.
errors
=
[
"
Les champs personnalisés ne peuvent pas avoir des noms similaires.
"
,
];
return
false
;
}
return
true
;
},
},
...
...
This diff is collapsed.
Click to expand it.
src/views/feature_type/Feature_type_edit.vue
+
3
−
3
View file @
91711c11
...
...
@@ -153,7 +153,6 @@
<i
class=
"white save icon"
></i>
Créer et importer le(s) signalement(s) du geojson
</button>
</form>
</div>
</div>
...
...
@@ -345,13 +344,14 @@ export default {
},
checkCustomForms
()
{
let
is_valid
=
true
;
if
(
this
.
$refs
.
customForms
)
for
(
const
customForm
of
this
.
$refs
.
customForms
)
{
if
(
customForm
.
checkCustomForm
()
===
false
)
{
return
false
;
is_valid
=
false
;
}
}
return
true
;
//* fallback if all customForms returned true
return
is_valid
;
//* fallback if all customForms returned true
},
checkForms
()
{
...
...
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