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
959b7781
Commit
959b7781
authored
3 years ago
by
Timothee P
Browse files
Options
Downloads
Patches
Plain Diff
add loader to feature edition
parent
143e227e
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/store/modules/feature.js
+20
-12
20 additions, 12 deletions
src/store/modules/feature.js
with
20 additions
and
12 deletions
src/store/modules/feature.js
+
20
−
12
View file @
959b7781
...
@@ -99,9 +99,12 @@ const feature = {
...
@@ -99,9 +99,12 @@ const feature = {
});
});
},
},
SEND_FEATURE
({
state
,
rootState
,
dispatch
},
routeName
)
{
SEND_FEATURE
({
state
,
rootState
,
commit
,
dispatch
},
routeName
)
{
commit
(
"
DISPLAY_LOADER
"
,
"
Le signalement est en cours de création
"
,
{
root
:
true
})
const
message
=
routeName
===
"
editer-signalement
"
?
"
Le signalement a été mis à jour
"
:
"
Le signalement a été crée
"
;
const
message
=
routeName
===
"
editer-signalement
"
?
"
Le signalement a été mis à jour
"
:
"
Le signalement a été crée
"
;
function
redirect
(
featureId
)
{
function
redirect
(
featureId
)
{
commit
(
"
DISCARD_LOADER
"
,
null
,
{
root
:
true
})
router
.
push
({
router
.
push
({
name
:
"
details-signalement
"
,
name
:
"
details-signalement
"
,
params
:
{
params
:
{
...
@@ -111,12 +114,14 @@ const feature = {
...
@@ -111,12 +114,14 @@ const feature = {
},
},
});
});
}
}
async
function
handleOtherForms
(
featureId
)
{
async
function
handleOtherForms
(
featureId
)
{
await
dispatch
(
"
SEND_ATTACHMENTS
"
,
featureId
)
await
dispatch
(
"
SEND_ATTACHMENTS
"
,
featureId
)
await
dispatch
(
"
PUT_LINKED_FEATURES
"
,
featureId
)
await
dispatch
(
"
PUT_LINKED_FEATURES
"
,
featureId
)
redirect
(
featureId
);
redirect
(
featureId
);
}
}
//* prepare feature data to send
let
extraFormObject
=
{};
//* prepare an object to be flatten in properties of geojson
let
extraFormObject
=
{};
//* prepare an object to be flatten in properties of geojson
for
(
const
field
of
state
.
extra_form
)
{
for
(
const
field
of
state
.
extra_form
)
{
extraFormObject
[
field
.
name
]
=
field
.
value
;
extraFormObject
[
field
.
name
]
=
field
.
value
;
...
@@ -134,12 +139,13 @@ const feature = {
...
@@ -134,12 +139,13 @@ const feature = {
...
extraFormObject
...
extraFormObject
}
}
}
}
if
(
routeName
===
"
editer-signalement
"
)
{
if
(
routeName
===
"
editer-signalement
"
)
{
axios
return
axios
.
put
(
`
${
rootState
.
configuration
.
VUE_APP_DJANGO_API_BASE
}
features/
${
state
.
form
.
feature_id
}
/?`
+
.
put
(
`
${
rootState
.
configuration
.
VUE_APP_DJANGO_API_BASE
}
features/
${
state
.
form
.
feature_id
}
/?`
+
`feature_type__slug=
${
rootState
.
feature_type
.
current_feature_type_slug
}
`
+
`feature_type__slug=
${
rootState
.
feature_type
.
current_feature_type_slug
}
`
+
`&project__slug=
${
rootState
.
project_slug
}
`
`&project__slug=
${
rootState
.
project_slug
}
`
,
geojson
)
,
geojson
)
.
then
((
response
)
=>
{
.
then
((
response
)
=>
{
if
(
response
.
status
===
200
&&
response
.
data
)
{
if
(
response
.
status
===
200
&&
response
.
data
)
{
if
(
state
.
attachmentFormset
.
length
>
0
||
state
.
linkedFormset
.
length
>
0
)
{
if
(
state
.
attachmentFormset
.
length
>
0
||
state
.
linkedFormset
.
length
>
0
)
{
...
@@ -150,10 +156,11 @@ const feature = {
...
@@ -150,10 +156,11 @@ const feature = {
}
}
})
})
.
catch
((
error
)
=>
{
.
catch
((
error
)
=>
{
commit
(
"
DISCARD_LOADER
"
,
null
,
{
root
:
true
})
throw
error
;
throw
error
;
});
});
}
else
{
}
else
{
axios
return
axios
.
post
(
`
${
rootState
.
configuration
.
VUE_APP_DJANGO_API_BASE
}
features/`
,
geojson
)
.
post
(
`
${
rootState
.
configuration
.
VUE_APP_DJANGO_API_BASE
}
features/`
,
geojson
)
.
then
((
response
)
=>
{
.
then
((
response
)
=>
{
if
(
response
.
status
===
201
&&
response
.
data
)
{
if
(
response
.
status
===
201
&&
response
.
data
)
{
...
@@ -165,6 +172,7 @@ const feature = {
...
@@ -165,6 +172,7 @@ const feature = {
}
}
})
})
.
catch
((
error
)
=>
{
.
catch
((
error
)
=>
{
commit
(
"
DISCARD_LOADER
"
,
null
,
{
root
:
true
})
throw
error
;
throw
error
;
});
});
}
}
...
@@ -189,7 +197,7 @@ const feature = {
...
@@ -189,7 +197,7 @@ const feature = {
console
.
error
(
error
);
console
.
error
(
error
);
return
error
return
error
});
});
}
}
}
}
...
@@ -203,7 +211,7 @@ const feature = {
...
@@ -203,7 +211,7 @@ const feature = {
if
(
attachment
.
title
)
if
(
attachment
.
title
)
data
[
'
info
'
]
=
attachment
.
info
data
[
'
info
'
]
=
attachment
.
info
formdataToUpdate
.
append
(
"
data
"
,
JSON
.
stringify
(
data
));
formdataToUpdate
.
append
(
"
data
"
,
JSON
.
stringify
(
data
));
let
payload
=
{
let
payload
=
{
'
attachmentsId
'
:
attachment
.
id
,
'
attachmentsId
'
:
attachment
.
id
,
'
featureId
'
:
featureId
,
'
featureId
'
:
featureId
,
'
formdataToUpdate
'
:
formdataToUpdate
'
formdataToUpdate
'
:
formdataToUpdate
...
@@ -213,7 +221,7 @@ const feature = {
...
@@ -213,7 +221,7 @@ const feature = {
}
}
function
deleteAttachement
(
attachmentsId
,
featureId
)
{
function
deleteAttachement
(
attachmentsId
,
featureId
)
{
let
payload
=
{
let
payload
=
{
'
attachmentsId
'
:
attachmentsId
,
'
attachmentsId
'
:
attachmentsId
,
'
featureId
'
:
featureId
'
featureId
'
:
featureId
}
}
...
@@ -224,7 +232,7 @@ const feature = {
...
@@ -224,7 +232,7 @@ const feature = {
...
state
.
attachmentFormset
.
map
((
attachment
)
=>
postAttachement
(
attachment
)),
...
state
.
attachmentFormset
.
map
((
attachment
)
=>
postAttachement
(
attachment
)),
...
state
.
attachmentsToPut
.
map
((
attachments
)
=>
putAttachement
(
attachments
,
featureId
)),
...
state
.
attachmentsToPut
.
map
((
attachments
)
=>
putAttachement
(
attachments
,
featureId
)),
...
state
.
attachmentsToDelete
.
map
((
attachmentsId
)
=>
deleteAttachement
(
attachmentsId
,
featureId
))
...
state
.
attachmentsToDelete
.
map
((
attachmentsId
)
=>
deleteAttachement
(
attachmentsId
,
featureId
))
]
]
);
);
state
.
attachmentsToDelete
=
[]
state
.
attachmentsToDelete
=
[]
state
.
attachmentsToPut
=
[]
state
.
attachmentsToPut
=
[]
...
@@ -280,8 +288,8 @@ const feature = {
...
@@ -280,8 +288,8 @@ const feature = {
DELETE_FEATURE
({
state
,
rootState
},
feature_id
)
{
DELETE_FEATURE
({
state
,
rootState
},
feature_id
)
{
console
.
log
(
"
Deleting feature:
"
,
feature_id
,
state
)
console
.
log
(
"
Deleting feature:
"
,
feature_id
,
state
)
const
url
=
`
${
rootState
.
configuration
.
VUE_APP_DJANGO_API_BASE
}
features/
${
feature_id
}
/?`
+
const
url
=
`
${
rootState
.
configuration
.
VUE_APP_DJANGO_API_BASE
}
features/
${
feature_id
}
/?`
+
`feature_type__slug=
${
rootState
.
feature_type
.
current_feature_type_slug
}
`
+
`feature_type__slug=
${
rootState
.
feature_type
.
current_feature_type_slug
}
`
+
`&project__slug=
${
rootState
.
project_slug
}
`
;
`&project__slug=
${
rootState
.
project_slug
}
`
;
return
axios
return
axios
.
delete
(
url
)
.
delete
(
url
)
.
then
((
response
)
=>
response
)
.
then
((
response
)
=>
response
)
...
...
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