Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
91f49069
Commit
91f49069
authored
Jul 04, 2017
by
Fatih Acet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
IssueNotesRefactor: Implement ESC to cancel note form.
parent
15f3362d
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
44 additions
and
17 deletions
+44
-17
app/assets/javascripts/notes/components/issue_discussion.vue
app/assets/javascripts/notes/components/issue_discussion.vue
+11
-2
app/assets/javascripts/notes/components/issue_note.vue
app/assets/javascripts/notes/components/issue_note.vue
+11
-2
app/assets/javascripts/notes/components/issue_note_form.vue
app/assets/javascripts/notes/components/issue_note_form.vue
+9
-2
app/assets/javascripts/notes/components/issue_notes.vue
app/assets/javascripts/notes/components/issue_notes.vue
+5
-1
app/assets/javascripts/notes/services/issue_notes_service.js
app/assets/javascripts/notes/services/issue_notes_service.js
+1
-1
app/assets/javascripts/notes/stores/issue_notes_store.js
app/assets/javascripts/notes/stores/issue_notes_store.js
+7
-9
No files found.
app/assets/javascripts/notes/components/issue_discussion.vue
View file @
91f49069
...
@@ -61,7 +61,15 @@ export default {
...
@@ -61,7 +61,15 @@ export default {
showReplyForm
()
{
showReplyForm
()
{
this
.
isReplying
=
true
;
this
.
isReplying
=
true
;
},
},
cancelReplyForm
()
{
cancelReplyForm
(
shouldConfirm
)
{
if
(
shouldConfirm
&&
this
.
$refs
.
noteForm
.
isDirty
)
{
const
msg
=
'
Are you sure you want to cancel creating this comment?
'
;
const
isConfirmed
=
confirm
(
msg
);
// eslint-disable-line
if
(
!
isConfirmed
)
{
return
;
}
}
this
.
isReplying
=
false
;
this
.
isReplying
=
false
;
},
},
saveReply
({
note
})
{
saveReply
({
note
})
{
...
@@ -139,7 +147,8 @@ export default {
...
@@ -139,7 +147,8 @@ export default {
v-if=
"isReplying"
v-if=
"isReplying"
saveButtonTitle=
"Comment"
saveButtonTitle=
"Comment"
:updateHandler=
"saveReply"
:updateHandler=
"saveReply"
:cancelHandler=
"cancelReplyForm"
/>
:cancelHandler=
"cancelReplyForm"
ref=
"noteForm"
/>
<div
<div
v-if=
"!canReply"
v-if=
"!canReply"
class=
"disabled-comment text-center"
>
class=
"disabled-comment text-center"
>
...
...
app/assets/javascripts/notes/components/issue_note.vue
View file @
91f49069
...
@@ -76,7 +76,15 @@ export default {
...
@@ -76,7 +76,15 @@ export default {
new
Flash
(
'
Something went wrong while editing your comment. Please try again.
'
);
// eslint-disable-line
new
Flash
(
'
Something went wrong while editing your comment. Please try again.
'
);
// eslint-disable-line
});
});
},
},
formCancelHandler
()
{
formCancelHandler
(
shouldConfirm
)
{
if
(
shouldConfirm
&&
this
.
$refs
.
noteBody
.
$refs
.
noteForm
.
isDirty
)
{
const
msg
=
'
Are you sure you want to cancel editing this comment?
'
;
const
isConfirmed
=
confirm
(
msg
);
// eslint-disable-line
if
(
!
isConfirmed
)
{
return
;
}
}
this
.
isEditing
=
false
;
this
.
isEditing
=
false
;
},
},
},
},
...
@@ -115,7 +123,8 @@ export default {
...
@@ -115,7 +123,8 @@ export default {
:note=
"note"
:note=
"note"
:isEditing=
"isEditing"
:isEditing=
"isEditing"
:formUpdateHandler=
"formUpdateHandler"
:formUpdateHandler=
"formUpdateHandler"
:formCancelHandler=
"formCancelHandler"
/>
:formCancelHandler=
"formCancelHandler"
ref=
"noteBody"
/>
</div>
</div>
</div>
</div>
</li>
</li>
...
...
app/assets/javascripts/notes/components/issue_note_form.vue
View file @
91f49069
...
@@ -24,6 +24,7 @@ export default {
...
@@ -24,6 +24,7 @@ export default {
},
},
data
()
{
data
()
{
return
{
return
{
initialNote
:
this
.
noteBody
,
note
:
this
.
noteBody
,
note
:
this
.
noteBody
,
markdownPreviewUrl
:
''
,
markdownPreviewUrl
:
''
,
markdownDocsUrl
:
''
,
markdownDocsUrl
:
''
,
...
@@ -39,6 +40,11 @@ export default {
...
@@ -39,6 +40,11 @@ export default {
});
});
},
},
},
},
computed
:
{
isDirty
()
{
return
this
.
initialNote
!==
this
.
note
;
},
},
mounted
()
{
mounted
()
{
const
issuableDataEl
=
document
.
getElementById
(
'
js-issuable-app-initial-data
'
);
const
issuableDataEl
=
document
.
getElementById
(
'
js-issuable-app-initial-data
'
);
const
issueData
=
JSON
.
parse
(
issuableDataEl
.
innerHTML
.
replace
(
/"/g
,
'
"
'
));
const
issueData
=
JSON
.
parse
(
issuableDataEl
.
innerHTML
.
replace
(
/"/g
,
'
"
'
));
...
@@ -68,7 +74,8 @@ export default {
...
@@ -68,7 +74,8 @@ export default {
ref=
"textarea"
ref=
"textarea"
slot=
"textarea"
slot=
"textarea"
placeholder=
"Write a comment or drag your files here..."
placeholder=
"Write a comment or drag your files here..."
@
keydown.meta.enter=
"handleUpdate"
>
@
keydown.meta.enter=
"handleUpdate"
@
keydown.esc=
"cancelHandler(true)"
>
</textarea>
</textarea>
</markdown-field>
</markdown-field>
<div
class=
"note-form-actions clearfix"
>
<div
class=
"note-form-actions clearfix"
>
...
@@ -79,7 +86,7 @@ export default {
...
@@ -79,7 +86,7 @@ export default {
{{
saveButtonTitle
}}
{{
saveButtonTitle
}}
</button>
</button>
<button
<button
@
click=
"cancelHandler"
@
click=
"cancelHandler
()
"
class=
"btn btn-nr btn-cancel"
class=
"btn btn-nr btn-cancel"
type=
"button"
>
type=
"button"
>
Cancel
Cancel
...
...
app/assets/javascripts/notes/components/issue_notes.vue
View file @
91f49069
...
@@ -39,7 +39,8 @@ export default {
...
@@ -39,7 +39,8 @@ export default {
},
},
},
},
mounted
()
{
mounted
()
{
const
{
discussionsPath
,
notesPath
,
lastFetchedAt
}
=
this
.
$el
.
parentNode
.
dataset
;
const
{
discussionsPath
,
notesPath
,
lastFetchedAt
}
=
this
.
$el
.
parentNode
.
dataset
;
this
.
$store
.
dispatch
(
'
fetchNotes
'
,
discussionsPath
)
this
.
$store
.
dispatch
(
'
fetchNotes
'
,
discussionsPath
)
.
then
(()
=>
{
.
then
(()
=>
{
this
.
isLoading
=
false
;
this
.
isLoading
=
false
;
...
@@ -58,6 +59,9 @@ export default {
...
@@ -58,6 +59,9 @@ export default {
this
.
$store
.
dispatch
(
'
poll
'
,
options
)
this
.
$store
.
dispatch
(
'
poll
'
,
options
)
.
then
((
res
)
=>
{
.
then
((
res
)
=>
{
options
.
lastFetchedAt
=
res
.
last_fetched_at
;
options
.
lastFetchedAt
=
res
.
last_fetched_at
;
})
.
catch
(()
=>
{
new
Flash
(
'
Something went wrong while fetching latest comments.
'
);
// eslint-disable-line
});
});
},
6000
);
},
6000
);
},
},
...
...
app/assets/javascripts/notes/services/issue_notes_service.js
View file @
91f49069
...
@@ -23,7 +23,7 @@ export default {
...
@@ -23,7 +23,7 @@ export default {
const
options
=
{
const
options
=
{
headers
:
{
headers
:
{
'
X-Last-Fetched-At
'
:
lastFetchedAt
,
'
X-Last-Fetched-At
'
:
lastFetchedAt
,
}
}
,
};
};
return
Vue
.
http
.
get
(
endpoint
,
options
);
return
Vue
.
http
.
get
(
endpoint
,
options
);
...
...
app/assets/javascripts/notes/stores/issue_notes_store.js
View file @
91f49069
...
@@ -136,18 +136,16 @@ const actions = {
...
@@ -136,18 +136,16 @@ const actions = {
res
.
notes
.
forEach
((
note
)
=>
{
res
.
notes
.
forEach
((
note
)
=>
{
if
(
notesById
[
note
.
id
])
{
if
(
notesById
[
note
.
id
])
{
context
.
commit
(
'
updateNote
'
,
note
);
context
.
commit
(
'
updateNote
'
,
note
);
}
else
{
}
else
if
(
note
.
type
===
'
DiscussionNote
'
)
{
if
(
note
.
type
===
'
DiscussionNote
'
)
{
const
discussion
=
findNoteObjectById
(
context
.
state
.
notes
,
note
.
discussion_id
);
const
discussion
=
findNoteObjectById
(
context
.
state
.
notes
,
note
.
discussion_id
);
if
(
discussion
)
{
if
(
discussion
)
{
context
.
commit
(
'
addNewReplyToDiscussion
'
,
note
);
context
.
commit
(
'
addNewReplyToDiscussion
'
,
note
);
}
else
{
context
.
commit
(
'
addNewNote
'
,
note
);
}
}
else
{
}
else
{
context
.
commit
(
'
addNewNote
'
,
note
);
context
.
commit
(
'
addNewNote
'
,
note
);
}
}
}
else
{
context
.
commit
(
'
addNewNote
'
,
note
);
}
}
});
});
}
}
...
...
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