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
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
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
11 deletions
+9
-11
issue_note_form.vue
app/assets/javascripts/notes/components/issue_note_form.vue
+8
-10
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
>
<
script
>
import
{
mapGetters
}
from
'vuex'
;
import
markdownField
from
'../../vue_shared/components/markdown/field.vue'
;
import
markdownField
from
'../../vue_shared/components/markdown/field.vue'
;
import
eventHub
from
'../event_hub'
;
import
eventHub
from
'../event_hub'
;
...
@@ -19,7 +20,7 @@
...
@@ -19,7 +20,7 @@
default
:
'Save comment'
,
default
:
'Save comment'
,
},
},
discussion
:
{
discussion
:
{
type
:
Array
,
type
:
Object
,
required
:
false
,
required
:
false
,
}
}
},
},
...
@@ -38,6 +39,9 @@
...
@@ -38,6 +39,9 @@
markdownField
,
markdownField
,
},
},
computed
:
{
computed
:
{
...
mapGetters
([
'getDiscussionLastNote'
,
]),
noteHash
()
{
noteHash
()
{
return
`#note_
${
this
.
noteId
}
`
;
return
`#note_
${
this
.
noteId
}
`
;
},
},
...
@@ -48,17 +52,11 @@
...
@@ -48,17 +52,11 @@
},
},
editMyLastNote
()
{
editMyLastNote
()
{
if
(
this
.
note
===
''
)
{
if
(
this
.
note
===
''
)
{
// TODO: HANDLE THIS WITHOUTH JQUERY OR QUERYING THE DOM
const
lastNoteInDiscussion
=
this
.
getDiscussionLastNote
(
this
.
discussion
,
window
.
gon
.
current_user_id
);
// 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'
);
debugger
;
if
(
lastNoteInDiscussion
)
{
const
lastNoteInDiscussion
=
this
.
$store
.
getters
.
getDiscussionLastNote
(
this
.
discussion
);
if
(
myLastNoteId
)
{
eventHub
.
$emit
(
'enterEditMode'
,
{
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
...
@@ -31,6 +31,6 @@ export const getCurrentUserLastNote = state => userId => reverseNotes(state.note
return
acc
;
return
acc
;
},
[]).
filter
(
el
=>
el
!==
undefined
)[
0
];
},
[]).
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
));
.
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