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
c7bd77ac
Commit
c7bd77ac
authored
3 years ago
by
Timothee P
Browse files
Options
Downloads
Patches
Plain Diff
validate project creation
parent
c9b6bcc3
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/views/project/Project_edit.vue
+53
-11
53 additions, 11 deletions
src/views/project/Project_edit.vue
with
53 additions
and
11 deletions
src/views/project/Project_edit.vue
+
53
−
11
View file @
c7bd77ac
...
...
@@ -13,8 +13,6 @@
<div
class=
"two fields"
>
<div
class=
"required field"
>
<label
for=
"title"
>
Titre
</label>
<!--
<small>
{{
form
.
title
.
help_text
}}
</small
>
-->
<!-- | safe // ? utile ? -->
<input
type=
"text"
required
...
...
@@ -23,7 +21,11 @@
id=
"title"
v-model=
"form.title"
/>
<!--
{{
form
.
title
.
errors
}}
-->
<ul
id=
"errorlist-title"
class=
"errorlist"
>
<li
v-for=
"error in errors.title"
:key=
"error"
>
{{
error
}}
</li>
</ul>
</div>
<div
class=
"field"
>
<label>
Illustration du projet
</label>
...
...
@@ -80,7 +82,6 @@
/>
<div
class=
"ui label"
>
jour(s)
</div>
</div>
<!--
{{
form
.
archive_feature
.
errors
}}
-->
</div>
<div
class=
"field"
>
<label
for=
"delete_feature"
>
Délai avant suppression
</label>
...
...
@@ -95,7 +96,6 @@
/>
<div
class=
"ui label"
>
jour(s)
</div>
</div>
<!--
{{
form
.
delete_feature
.
errors
}}
-->
</div>
<div
class=
"required field"
>
<label
for=
"access_level_pub_feature"
...
...
@@ -106,6 +106,11 @@
:selected=
"form.access_level_pub_feature.name"
:selection.sync=
"form.access_level_pub_feature"
/>
<ul
id=
"errorlist-access_level_pub_feature"
class=
"errorlist"
>
<li
v-for=
"error in errors.access_level_pub_feature"
:key=
"error"
>
{{
error
}}
</li>
</ul>
</div>
<div
class=
"required field"
>
<label
for=
"access_level_arch_feature"
>
...
...
@@ -116,6 +121,11 @@
:selected=
"form.access_level_arch_feature.name"
:selection.sync=
"form.access_level_arch_feature"
/>
<ul
id=
"errorlist-access_level_arch_feature"
class=
"errorlist"
>
<li
v-for=
"error in errors.access_level_arch_feature"
:key=
"error"
>
{{
error
}}
</li>
</ul>
</div>
</div>
...
...
@@ -179,6 +189,11 @@ export default {
name
:
"
Sélectionner une image ...
"
,
size
:
0
,
},
errors
:
{
title
:
[],
access_level_pub_feature
:
[],
access_level_arch_feature
:
[],
},
form
:
{
title
:
""
,
slug
:
""
,
...
...
@@ -206,7 +221,7 @@ export default {
computed
:
{
...
mapGetters
([
"
project
"
]),
DJANGO_BASE_URL
:
function
()
{
DJANGO_BASE_URL
:
function
()
{
return
this
.
$store
.
state
.
configuration
.
VUE_APP_DJANGO_BASE
;
},
},
...
...
@@ -222,8 +237,8 @@ export default {
}
},
truncate
(
n
,
len
)
{
var
ext
=
n
.
substring
(
n
.
lastIndexOf
(
"
.
"
)
+
1
,
n
.
length
).
toLowerCase
();
var
filename
=
n
.
replace
(
"
.
"
+
ext
,
""
);
let
ext
=
n
.
substring
(
n
.
lastIndexOf
(
"
.
"
)
+
1
,
n
.
length
).
toLowerCase
();
let
filename
=
n
.
replace
(
"
.
"
+
ext
,
""
);
if
(
filename
.
length
<=
len
)
{
return
n
;
}
...
...
@@ -286,7 +301,31 @@ export default {
}
},
checkForm
()
{
for
(
const
key
in
this
.
errors
)
{
console
.
log
(
key
);
console
.
log
(
this
.
form
[
key
]);
console
.
log
(
this
.
form
[
key
].
value
);
if
((
key
===
"
title
"
&&
this
.
form
[
key
])
||
this
.
form
[
key
].
value
)
{
this
.
errors
[
key
]
=
[];
}
else
if
(
!
this
.
errors
[
key
].
length
)
{
this
.
errors
[
key
].
push
(
key
===
"
title
"
?
"
Veuillez compléter ce champ.
"
:
"
Sélectionnez un choix valide. Ce choix ne fait pas partie de ceux disponibles.
"
);
console
.
log
(
`errorlist-
${
key
}
`
);
document
.
getElementById
(
`errorlist-
${
key
}
`
)
.
scrollIntoView
({
block
:
"
end
"
,
inline
:
"
nearest
"
});
return
false
;
}
}
return
true
;
},
async
postForm
()
{
if
(
!
this
.
checkForm
())
return
;
// todo: check form
//let url = `${configuration.VUE_APP_DJANGO_API_BASE}projects/`;
const
projectData
=
{
...
...
@@ -302,13 +341,16 @@ export default {
if
(
this
.
action
===
"
create
"
||
this
.
action
===
"
duplicate
"
)
{
await
axios
.
post
(
`
${
this
.
$store
.
state
.
configuration
.
VUE_APP_DJANGO_API_BASE
}
projects/`
,
projectData
)
.
post
(
`
${
this
.
$store
.
state
.
configuration
.
VUE_APP_DJANGO_API_BASE
}
projects/`
,
projectData
)
.
then
((
response
)
=>
{
if
(
response
&&
response
.
status
===
201
&&
response
.
data
)
{
//* send thumbnail after feature_type was created
if
(
this
.
fileToImport
.
size
>
0
){
if
(
this
.
fileToImport
.
size
>
0
)
{
this
.
postProjectThumbnail
(
response
.
data
.
slug
);
}
else
{
}
else
{
this
.
goBackNrefresh
(
response
.
data
.
slug
);
}
}
...
...
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