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
0
Merge Requests
0
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
Jérome Perrin
gitlab-ce
Commits
9b87e680
Commit
9b87e680
authored
Jul 28, 2017
by
Filipa Lacerda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[ci skip] Find last note in discussion through vue instead of through the DOM
parent
2845dad2
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
11 deletions
+9
-11
app/assets/javascripts/notes/components/issue_note_form.vue
app/assets/javascripts/notes/components/issue_note_form.vue
+8
-10
app/assets/javascripts/notes/stores/getters.js
app/assets/javascripts/notes/stores/getters.js
+1
-1
No files found.
app/assets/javascripts/notes/components/issue_note_form.vue
View file @
9b87e680
<
script
>
import
{
mapGetters
}
from
'
vuex
'
;
import
markdownField
from
'
../../vue_shared/components/markdown/field.vue
'
;
import
eventHub
from
'
../event_hub
'
;
...
...
@@ -19,7 +20,7 @@
default
:
'
Save comment
'
,
},
discussion
:
{
type
:
Array
,
type
:
Object
,
required
:
false
,
}
},
...
...
@@ -38,6 +39,9 @@
markdownField
,
},
computed
:
{
...
mapGetters
([
'
getDiscussionLastNote
'
,
]),
noteHash
()
{
return
`#note_
${
this
.
noteId
}
`
;
},
...
...
@@ -48,17 +52,11 @@
},
editMyLastNote
()
{
if
(
this
.
note
===
''
)
{
// TODO: HANDLE THIS WITHOUTH JQUERY OR QUERYING THE DOM
// FIND the discussion we are in and the last comment on that discussion
const
discussion
=
$
(
this
.
$el
).
closest
(
'
.discussion-notes
'
);
const
myLastNoteId
=
discussion
.
find
(
'
.js-my-note
'
).
last
().
attr
(
'
id
'
);
const
lastNoteInDiscussion
=
this
.
getDiscussionLastNote
(
this
.
discussion
,
window
.
gon
.
current_user_id
);
debugger
;
const
lastNoteInDiscussion
=
this
.
$store
.
getters
.
getDiscussionLastNote
(
this
.
discussion
);
if
(
myLastNoteId
)
{
if
(
lastNoteInDiscussion
)
{
eventHub
.
$emit
(
'
enterEditMode
'
,
{
noteId
:
parseInt
(
myLastNoteId
.
replace
(
'
note_
'
,
''
),
10
)
,
noteId
:
lastNoteInDiscussion
.
id
,
});
}
}
...
...
app/assets/javascripts/notes/stores/getters.js
View file @
9b87e680
...
...
@@ -31,6 +31,6 @@ export const getCurrentUserLastNote = state => userId => reverseNotes(state.note
return
acc
;
},
[]).
filter
(
el
=>
el
!==
undefined
)[
0
];
export
const
getDiscussionLastNote
=
state
=>
(
discussion
,
userId
)
=>
reverseNotes
(
discussion
[
0
]
.
notes
)
export
const
getDiscussionLastNote
=
state
=>
(
discussion
,
userId
)
=>
reverseNotes
(
discussion
.
notes
)
.
find
(
el
=>
isLastNote
(
el
,
userId
));
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