Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
hypha
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository 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
ots
hypha
Commits
8efed1bc
Commit
8efed1bc
authored
5 years ago
by
Chris Lawton
Browse files
Options
Downloads
Patches
Plain Diff
handle 404
parent
ba6953c0
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
opentech/static_src/src/javascript/apply/edit-comment.js
+17
-4
17 additions, 4 deletions
opentech/static_src/src/javascript/apply/edit-comment.js
opentech/static_src/src/sass/apply/components/_wrapper.scss
+4
-0
4 additions, 0 deletions
opentech/static_src/src/sass/apply/components/_wrapper.scss
with
21 additions
and
4 deletions
opentech/static_src/src/javascript/apply/edit-comment.js
+
17
−
4
View file @
8efed1bc
...
@@ -9,6 +9,7 @@
...
@@ -9,6 +9,7 @@
const
lastEdited
=
'
.js-last-edited
'
;
const
lastEdited
=
'
.js-last-edited
'
;
const
editButton
=
'
.js-edit-comment
'
;
const
editButton
=
'
.js-edit-comment
'
;
const
feedContent
=
'
.js-feed-content
'
;
const
feedContent
=
'
.js-feed-content
'
;
const
commentError
=
'
.js-comment-error
'
;
const
cancelEditButton
=
'
.js-cancel-edit
'
;
const
cancelEditButton
=
'
.js-cancel-edit
'
;
const
submitEditButton
=
'
.js-submit-edit
'
;
const
submitEditButton
=
'
.js-submit-edit
'
;
...
@@ -50,6 +51,9 @@
...
@@ -50,6 +51,9 @@
showComment
(
this
);
showComment
(
this
);
showEditButton
(
this
);
showEditButton
(
this
);
hidePageDownEditor
(
this
);
hidePageDownEditor
(
this
);
if
((
commentError
).
length
)
{
hideError
();
}
});
});
// handle submit
// handle submit
...
@@ -58,7 +62,6 @@
...
@@ -58,7 +62,6 @@
const
id
=
$
(
commentContainer
).
attr
(
'
data-id
'
);
const
id
=
$
(
commentContainer
).
attr
(
'
data-id
'
);
const
editedComment
=
$
(
this
).
closest
(
pageDown
).
find
(
'
.wmd-preview
'
).
html
();
const
editedComment
=
$
(
this
).
closest
(
pageDown
).
find
(
'
.wmd-preview
'
).
html
();
const
commentMD
=
$
(
this
).
closest
(
editBlock
).
find
(
'
textarea
'
).
val
();
const
commentMD
=
$
(
this
).
closest
(
editBlock
).
find
(
'
textarea
'
).
val
();
$
(
commentContainer
).
attr
(
'
data-comment
'
,
commentMD
);
// TODO - get correct URL
// TODO - get correct URL
const
url
=
`
${
window
.
location
.
origin
}
/apply/api/comments/
${
id
}
/edit/`
;
const
url
=
`
${
window
.
location
.
origin
}
/apply/api/comments/
${
id
}
/edit/`
;
...
@@ -72,8 +75,15 @@
...
@@ -72,8 +75,15 @@
body
:
JSON
.
stringify
({
body
:
JSON
.
stringify
({
message
:
editedComment
message
:
editedComment
})
})
}).
then
(
response
=>
response
.
json
()).
then
(
data
=>
{
}).
then
(
response
=>
{
updateComment
(
commentContainer
,
data
.
id
,
data
.
message
);
if
(
response
.
status
===
404
)
{
$
(
this
).
closest
(
editBlock
).
append
(
'
<p class="wrapper--error js-comment-error"><b>Update unsuccessful</b>. This comment has been edited elsewhere - please refresh to get the latest updates.</p>
'
);
$
(
this
).
attr
(
'
disabled
'
,
true
);
return
;
}
return
response
.
json
();
}).
then
(
data
=>
{
updateComment
(
commentContainer
,
data
.
id
,
data
.
message
,
commentMD
);
updateLastEdited
(
this
,
data
.
edited
);
updateLastEdited
(
this
,
data
.
edited
);
showComment
(
this
);
showComment
(
this
);
showEditButton
(
this
);
showEditButton
(
this
);
...
@@ -106,9 +116,10 @@
...
@@ -106,9 +116,10 @@
$
(
el
).
closest
(
feedContent
).
find
(
lastEdited
).
html
(
`
${
parsedDate
}
${
time
}
`
);
$
(
el
).
closest
(
feedContent
).
find
(
lastEdited
).
html
(
`
${
parsedDate
}
${
time
}
`
);
};
};
const
updateComment
=
(
el
,
id
,
newComment
)
=>
{
const
updateComment
=
(
el
,
id
,
newComment
,
newCommentMD
)
=>
{
$
(
el
).
attr
(
'
data-id
'
,
id
);
$
(
el
).
attr
(
'
data-id
'
,
id
);
$
(
el
).
html
(
newComment
);
$
(
el
).
html
(
newComment
);
$
(
el
).
attr
(
'
data-comment
'
,
newCommentMD
);
};
};
const
closeAllEditors
=
()
=>
{
const
closeAllEditors
=
()
=>
{
...
@@ -117,4 +128,6 @@
...
@@ -117,4 +128,6 @@
$
(
editButton
).
parent
().
show
();
$
(
editButton
).
parent
().
show
();
};
};
const
hideError
=
()
=>
$
(
commentError
).
remove
();
})(
jQuery
);
})(
jQuery
);
This diff is collapsed.
Click to expand it.
opentech/static_src/src/sass/apply/components/_wrapper.scss
+
4
−
0
View file @
8efed1bc
...
@@ -89,6 +89,10 @@
...
@@ -89,6 +89,10 @@
margin
:
0
auto
2rem
;
margin
:
0
auto
2rem
;
background
:
$color--light-pink
;
background
:
$color--light-pink
;
border
:
1px
solid
$color--tomato
;
border
:
1px
solid
$color--tomato
;
.feed
&
{
margin
:
0
0
1rem
;
}
}
}
&
--bottom-space
{
&
--bottom-space
{
...
...
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