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
19c70481
Commit
19c70481
authored
3 years ago
by
Timothee P
Browse files
Options
Downloads
Patches
Plain Diff
implement comment attachment post
parent
d5b802ae
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/services/feature-api.js
+13
-8
13 additions, 8 deletions
src/services/feature-api.js
src/views/feature/Feature_detail.vue
+17
-4
17 additions, 4 deletions
src/views/feature/Feature_detail.vue
with
30 additions
and
12 deletions
src/services/feature-api.js
+
13
−
8
View file @
19c70481
...
@@ -22,31 +22,36 @@ const featureAPI = {
...
@@ -22,31 +22,36 @@ const featureAPI = {
const
response
=
await
axios
.
post
(
const
response
=
await
axios
.
post
(
`
${
baseUrl
}
features/
${
featureId
}
/comments/`
,
{
comment
}
`
${
baseUrl
}
features/
${
featureId
}
/comments/`
,
{
comment
}
);
);
console
.
log
(
response
)
if
(
if
(
response
.
status
===
200
&&
response
.
status
===
200
&&
response
.
data
response
.
data
)
{
)
{
return
response
.
data
;
return
response
;
}
else
{
}
else
{
return
null
;
return
null
;
}
}
},
},
/* async subscribeProject({ projectSlug, suscribe }) {
async
postCommentAttachment
({
featureId
,
file
,
fileName
,
comment
})
{
const response = await axios.put(
let
formdata
=
new
FormData
();
`${baseUrl}projects/${projectSlug}/subscription/`,
formdata
.
append
(
"
file
"
,
file
,
fileName
);
{ is_suscriber: suscribe }
const
data
=
{
comment
}
formdata
.
append
(
"
data
"
,
JSON
.
stringify
(
data
));
const
response
=
await
axios
.
post
(
`
${
baseUrl
}
features/
${
featureId
}
/attachments/`
,
formdata
);
);
if
(
if
(
response
.
status
===
200
&&
response
.
status
===
200
&&
response
.
data
response
.
data
)
{
)
{
return response
.data
;
return
response
;
}
else
{
}
else
{
return
null
;
return
null
;
}
}
},
*/
},
}
}
export
default
featureAPI
;
export
default
featureAPI
;
This diff is collapsed.
Click to expand it.
src/views/feature/Feature_detail.vue
+
17
−
4
View file @
19c70481
...
@@ -411,6 +411,7 @@ export default {
...
@@ -411,6 +411,7 @@ export default {
attachment_file
:
{
attachment_file
:
{
errors
:
null
,
errors
:
null
,
value
:
null
,
value
:
null
,
file
:
null
,
},
},
title
:
{
title
:
{
id_for_label
:
"
title
"
,
id_for_label
:
"
title
"
,
...
@@ -452,10 +453,21 @@ export default {
...
@@ -452,10 +453,21 @@ export default {
methods
:
{
methods
:
{
postComment
()
{
postComment
()
{
featureAPI
.
postComment
({
featureAPI
featureId
:
this
.
$route
.
params
.
slug_signal
,
.
postComment
({
comment
:
this
.
comment_form
.
comment
.
value
,
featureId
:
this
.
$route
.
params
.
slug_signal
,
});
comment
:
this
.
comment_form
.
comment
.
value
,
})
.
then
((
response
)
=>
{
if
(
response
&&
this
.
comment_form
.
attachment_file
.
file
)
{
featureAPI
.
postCommentAttachment
({
featureId
:
this
.
$route
.
params
.
slug_signal
,
file
:
this
.
comment_form
.
attachment_file
.
file
,
fileName
:
this
.
comment_form
.
title
.
file
,
comment
:
response
.
data
.
id
,
});
}
});
},
},
getAttachmentFileData
(
evt
)
{
getAttachmentFileData
(
evt
)
{
...
@@ -464,6 +476,7 @@ export default {
...
@@ -464,6 +476,7 @@ export default {
const
fileName
=
files
[
0
].
name
.
substring
(
0
,
period
);
const
fileName
=
files
[
0
].
name
.
substring
(
0
,
period
);
const
fileExtension
=
files
[
0
].
name
.
substring
(
period
+
1
);
const
fileExtension
=
files
[
0
].
name
.
substring
(
period
+
1
);
const
shortName
=
fileName
.
slice
(
0
,
10
)
+
"
[...].
"
+
fileExtension
;
const
shortName
=
fileName
.
slice
(
0
,
10
)
+
"
[...].
"
+
fileExtension
;
this
.
comment_form
.
attachment_file
.
file
=
files
[
0
];
this
.
comment_form
.
attachment_file
.
value
=
shortName
;
this
.
comment_form
.
attachment_file
.
value
=
shortName
;
this
.
comment_form
.
title
.
value
=
shortName
;
this
.
comment_form
.
title
.
value
=
shortName
;
},
},
...
...
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