BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
e033b9a7
Commit
e033b9a7
authored
Mar 04, 2016
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added discard button to comment form
Also changed the labels on the buttons to better match the action they are completing. Closes #8057
parent
f8c4dc97
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
57 additions
and
17 deletions
+57
-17
notes.js.coffee
app/assets/javascripts/notes.js.coffee
+50
-11
_discussion.html.haml
app/views/projects/issues/_discussion.html.haml
+2
-2
_discussion.html.haml
app/views/projects/merge_requests/_discussion.html.haml
+2
-2
_form.html.haml
app/views/projects/notes/_form.html.haml
+3
-2
No files found.
app/assets/javascripts/notes.js.coffee
View file @
e033b9a7
...
...
@@ -51,6 +51,9 @@ class @Notes
$
(
document
).
on
"ajax:complete"
,
".js-main-target-form"
,
@
reenableTargetFormSubmitButton
$
(
document
).
on
"ajax:success"
,
".js-main-target-form"
,
@
resetMainTargetForm
# reset main target form when clicking discard
$
(
document
).
on
"click"
,
".js-note-discard"
,
@
resetMainTargetForm
# update the file name when an attachment is selected
$
(
document
).
on
"change"
,
".js-note-attachment-input"
,
@
updateFormAttachment
...
...
@@ -85,6 +88,7 @@ class @Notes
$
(
document
).
off
"keyup"
,
".js-note-text"
$
(
document
).
off
"click"
,
".js-note-target-reopen"
$
(
document
).
off
"click"
,
".js-note-target-close"
$
(
document
).
off
"click"
,
".js-note-discard"
$
(
'.note .js-task-list-container'
).
taskList
(
'disable'
)
$
(
document
).
off
'tasklist:changed'
,
'.note .js-task-list-container'
...
...
@@ -219,7 +223,7 @@ class @Notes
Resets text and preview.
Resets buttons.
###
resetMainTargetForm
:
-
>
resetMainTargetForm
:
(
e
)
=
>
form
=
$
(
".js-main-target-form"
)
# remove validation errors
...
...
@@ -231,6 +235,8 @@ class @Notes
form
.
find
(
".js-note-text"
).
data
(
"autosave"
).
reset
()
@
updateTargetButtons
(
e
)
reenableTargetFormSubmitButton
:
->
form
=
$
(
".js-main-target-form"
)
...
...
@@ -274,8 +280,10 @@ class @Notes
form
.
removeClass
"js-new-note-form"
form
.
find
(
'.div-dropzone'
).
remove
()
# hide discard button
form
.
find
(
'.js-note-discard'
).
hide
()
# setup preview buttons
form
.
find
(
".js-md-write-button, .js-md-preview-button"
).
tooltip
placement
:
"left"
previewButton
=
form
.
find
(
".js-md-preview-button"
)
textarea
=
form
.
find
(
".js-note-text"
)
...
...
@@ -561,21 +569,52 @@ class @Notes
updateCloseButton
:
(
e
)
=>
textarea
=
$
(
e
.
target
)
form
=
textarea
.
parents
(
'form'
)
form
.
find
(
'.js-note-target-close'
).
text
(
'Close'
)
closebtn
=
form
.
find
(
'.js-note-target-close'
)
closebtn
.
text
(
closebtn
.
data
(
'original-text'
))
updateTargetButtons
:
(
e
)
=>
textarea
=
$
(
e
.
target
)
form
=
textarea
.
parents
(
'form'
)
reopenbtn
=
form
.
find
(
'.js-note-target-reopen'
)
closebtn
=
form
.
find
(
'.js-note-target-close'
)
discardbtn
=
form
.
find
(
'.js-note-discard'
)
if
textarea
.
val
().
trim
().
length
>
0
form
.
find
(
'.js-note-target-reopen'
).
text
(
'Comment & reopen'
)
form
.
find
(
'.js-note-target-close'
).
text
(
'Comment & close'
)
form
.
find
(
'.js-note-target-reopen'
).
addClass
(
'btn-comment-and-reopen'
)
form
.
find
(
'.js-note-target-close'
).
addClass
(
'btn-comment-and-close'
)
reopentext
=
reopenbtn
.
data
(
'alternative-text'
)
closetext
=
closebtn
.
data
(
'alternative-text'
)
if
reopenbtn
.
text
()
isnt
reopentext
reopenbtn
.
text
(
reopentext
)
if
closebtn
.
text
()
isnt
closetext
closebtn
.
text
(
closetext
)
if
reopenbtn
.
is
(
':not(.btn-comment-and-reopen)'
)
reopenbtn
.
addClass
(
'btn-comment-and-reopen'
)
if
closebtn
.
is
(
':not(.btn-comment-and-close)'
)
closebtn
.
addClass
(
'btn-comment-and-close'
)
if
discardbtn
.
is
(
':hidden'
)
discardbtn
.
show
()
else
form
.
find
(
'.js-note-target-reopen'
).
text
(
'Reopen'
)
form
.
find
(
'.js-note-target-close'
).
text
(
'Close'
)
form
.
find
(
'.js-note-target-reopen'
).
removeClass
(
'btn-comment-and-reopen'
)
form
.
find
(
'.js-note-target-close'
).
removeClass
(
'btn-comment-and-close'
)
reopentext
=
reopenbtn
.
data
(
'original-text'
)
closetext
=
closebtn
.
data
(
'original-text'
)
if
reopenbtn
.
text
()
isnt
reopentext
reopenbtn
.
text
(
reopentext
)
if
closebtn
.
text
()
isnt
closetext
closebtn
.
text
(
closebtn
.
data
(
'original-text'
))
if
reopenbtn
.
is
(
':not(.btn-comment-and-reopen)'
)
reopenbtn
.
removeClass
(
'btn-comment-and-reopen'
)
if
closebtn
.
is
(
':not(.btn-comment-and-close)'
)
closebtn
.
removeClass
(
'btn-comment-and-close'
)
if
discardbtn
.
is
(
':visible'
)
discardbtn
.
hide
()
initTaskList
:
->
@
enableTaskList
()
...
...
app/views/projects/issues/_discussion.html.haml
View file @
e033b9a7
-
content_for
:note_actions
do
-
if
can?
(
current_user
,
:update_issue
,
@issue
)
=
link_to
'Reopen issue'
,
issue_path
(
@issue
,
issue:
{
state_event: :reopen
},
status_only:
true
,
format:
'json'
),
data:
{
no_turbolink:
true
},
class:
"btn btn-nr btn-grouped btn-reopen btn-comment js-note-target-reopen
#{
issue_button_visibility
(
@issue
,
false
)
}
"
,
title:
'Reopen issue'
=
link_to
'Close issue'
,
issue_path
(
@issue
,
issue:
{
state_event: :close
},
status_only:
true
,
format:
'json'
),
data:
{
no_turbolink:
true
},
class:
"btn btn-nr btn-grouped btn-close btn-comment js-note-target-close
#{
issue_button_visibility
(
@issue
,
true
)
}
"
,
title:
'Close issue'
=
link_to
'Reopen issue'
,
issue_path
(
@issue
,
issue:
{
state_event: :reopen
},
status_only:
true
,
format:
'json'
),
data:
{
no_turbolink:
true
,
original_text:
"Reopen issue"
,
alternative_text:
"Comment & reopen issue"
},
class:
"btn btn-nr btn-grouped btn-reopen btn-comment js-note-target-reopen
#{
issue_button_visibility
(
@issue
,
false
)
}
"
,
title:
'Reopen issue'
=
link_to
'Close issue'
,
issue_path
(
@issue
,
issue:
{
state_event: :close
},
status_only:
true
,
format:
'json'
),
data:
{
no_turbolink:
true
,
original_text:
"Close issue"
,
alternative_text:
"Comment & close issue"
},
class:
"btn btn-nr btn-grouped btn-close btn-comment js-note-target-close
#{
issue_button_visibility
(
@issue
,
true
)
}
"
,
title:
'Close issue'
#notes
=
render
'projects/notes/notes_with_form'
app/views/projects/merge_requests/_discussion.html.haml
View file @
e033b9a7
-
content_for
:note_actions
do
-
if
can?
(
current_user
,
:update_merge_request
,
@merge_request
)
-
if
@merge_request
.
open?
=
link_to
'Close
'
,
merge_request_path
(
@merge_request
,
merge_request:
{
state_event: :close
}),
method: :put
,
class:
"btn btn-nr btn-comment btn-grouped btn-close close-mr-link js-note-target-close"
,
title:
"Close merge request"
=
link_to
'Close
merge request'
,
merge_request_path
(
@merge_request
,
merge_request:
{
state_event: :close
}),
method: :put
,
class:
"btn btn-nr btn-comment btn-grouped btn-close close-mr-link js-note-target-close"
,
title:
"Close merge request"
,
data:
{
original_text:
"Close merge request"
,
alternative_text:
"Comment & close merge request"
}
-
if
@merge_request
.
closed?
=
link_to
'Reopen
'
,
merge_request_path
(
@merge_request
,
merge_request:
{
state_event: :reopen
}),
method: :put
,
class:
"btn btn-nr btn-comment btn-grouped btn-reopen reopen-mr-link js-note-target-reopen"
,
title:
"Reopen merge request"
=
link_to
'Reopen
merge request'
,
merge_request_path
(
@merge_request
,
merge_request:
{
state_event: :reopen
}),
method: :put
,
class:
"btn btn-nr btn-comment btn-grouped btn-reopen reopen-mr-link js-note-target-reopen"
,
title:
"Reopen merge request"
,
data:
{
original_text:
"Reopen merge request"
,
alternative_text:
"Comment & reopen merge request"
}
#notes
=
render
"projects/notes/notes_with_form"
app/views/projects/notes/_form.html.haml
View file @
e033b9a7
...
...
@@ -13,6 +13,7 @@
.error-alert
.note-form-actions.clearfix
=
f
.
submit
'
Add
Comment'
,
class:
"btn btn-nr btn-create comment-btn btn-grouped js-comment-button"
=
f
.
submit
'Comment'
,
class:
"btn btn-nr btn-create comment-btn btn-grouped js-comment-button"
=
yield
(
:note_actions
)
%a
.btn.btn-nr.btn-cancel.js-close-discussion-note-form
Cancel
%a
.btn.btn-cancel.js-note-discard
{
role:
"button"
}
Discard draft
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment