Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
2845dad2
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
2845dad2
编写于
7月 28, 2017
作者:
F
Filipa Lacerda
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Find last note created by current user through vue instead of querying the DOM
上级
7a251207
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
48 addition
and
22 deletion
+48
-22
app/assets/javascripts/notes/components/issue_comment_form.vue
...ssets/javascripts/notes/components/issue_comment_form.vue
+10
-7
app/assets/javascripts/notes/components/issue_discussion.vue
app/assets/javascripts/notes/components/issue_discussion.vue
+3
-2
app/assets/javascripts/notes/components/issue_note.vue
app/assets/javascripts/notes/components/issue_note.vue
+2
-1
app/assets/javascripts/notes/components/issue_note_body.vue
app/assets/javascripts/notes/components/issue_note_body.vue
+1
-9
app/assets/javascripts/notes/components/issue_note_form.vue
app/assets/javascripts/notes/components/issue_note_form.vue
+10
-1
app/assets/javascripts/notes/components/issue_notes_app.vue
app/assets/javascripts/notes/components/issue_notes_app.vue
+9
-2
app/assets/javascripts/notes/stores/getters.js
app/assets/javascripts/notes/stores/getters.js
+13
-0
未找到文件。
app/assets/javascripts/notes/components/issue_comment_form.vue
浏览文件 @
2845dad2
<
script
>
/* global Flash */
import
{
mapActions
}
from
'
vuex
'
;
import
{
mapActions
,
mapGetters
}
from
'
vuex
'
;
import
userAvatarLink
from
'
../../vue_shared/components/user_avatar/user_avatar_link.vue
'
;
import
markdownField
from
'
../../vue_shared/components/markdown/field.vue
'
;
import
issueNoteSignedOutWidget
from
'
./issue_note_signed_out_widget.vue
'
;
...
...
@@ -30,6 +30,9 @@
issueNoteSignedOutWidget
,
},
computed
:
{
...
mapGetters
([
'
getCurrentUserLastNote
'
,
]),
isLoggedIn
()
{
return
window
.
gon
.
current_user_id
;
},
...
...
@@ -126,13 +129,13 @@
setNoteType
(
type
)
{
this
.
noteType
=
type
;
},
edit
My
LastNote
()
{
edit
CurrentUser
LastNote
()
{
if
(
this
.
note
===
''
)
{
const
myLastNoteId
=
$
(
'
.js-my-note
'
).
last
().
attr
(
'
id
'
);
debugger
;
if
(
myLastNoteId
)
{
const
lastNote
=
this
.
getCurrentUserLastNote
(
window
.
gon
.
current_user_id
);
console
.
log
(
lastNote
)
if
(
lastNote
)
{
eventHub
.
$emit
(
'
enterEditMode
'
,
{
noteId
:
parseInt
(
myLastNoteId
.
replace
(
'
note_
'
,
''
),
10
)
,
noteId
:
lastNote
.
id
,
});
}
}
...
...
@@ -185,7 +188,7 @@
ref=
"textarea"
slot=
"textarea"
placeholder=
"Write a comment or drag your files here..."
@
keydown.up=
"edit
MyLastNote
"
@
keydown.up=
"edit
CurrentUserLastNote()
"
@
keydown.meta.enter=
"handleSave()"
>
</textarea>
</markdown-field>
...
...
app/assets/javascripts/notes/components/issue_discussion.vue
浏览文件 @
2845dad2
...
...
@@ -164,8 +164,9 @@
<issue-note-form
v-if=
"isReplying"
saveButtonTitle=
"Comment"
:update-handler=
"saveReply"
:cancel-handler=
"cancelReplyForm"
:discussion=
"note"
@
handleFormUpdate=
"saveReply"
@
cancelFormEdition=
"cancelReplyForm"
ref=
"noteForm"
/>
<issue-note-signed-out-widget
v-if=
"!canReply"
/>
...
...
app/assets/javascripts/notes/components/issue_note.vue
浏览文件 @
2845dad2
...
...
@@ -118,7 +118,8 @@
<li
class=
"note timeline-entry"
:id=
"noteAnchorId"
:class=
"classNameBindings"
>
:class=
"classNameBindings"
:note-id=
"note.id"
>
<div
class=
"timeline-entry-inner"
>
<div
class=
"timeline-icon"
>
<user-avatar-link
...
...
app/assets/javascripts/notes/components/issue_note_body.vue
浏览文件 @
2845dad2
...
...
@@ -19,14 +19,6 @@
required
:
false
,
default
:
false
,
},
formUpdateHandler
:
{
type
:
Function
,
required
:
true
,
},
formCancelHandler
:
{
type
:
Function
,
required
:
true
,
},
},
components
:
{
issueNoteEditedText
,
...
...
@@ -93,7 +85,7 @@
v-if=
"note.last_edited_by"
:edited-at=
"note.last_edited_at"
:edited-by=
"note.last_edited_by"
action
T
ext=
"Edited"
action
-t
ext=
"Edited"
/>
<issue-note-awards-list
v-if=
"note.award_emoji.length"
...
...
app/assets/javascripts/notes/components/issue_note_form.vue
浏览文件 @
2845dad2
...
...
@@ -18,6 +18,10 @@
required
:
false
,
default
:
'
Save comment
'
,
},
discussion
:
{
type
:
Array
,
required
:
false
,
}
},
data
()
{
const
{
getIssueData
,
getNotesData
}
=
this
.
$store
.
getters
;
...
...
@@ -44,9 +48,14 @@
},
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
'
);
debugger
;
const
lastNoteInDiscussion
=
this
.
$store
.
getters
.
getDiscussionLastNote
(
this
.
discussion
);
if
(
myLastNoteId
)
{
eventHub
.
$emit
(
'
enterEditMode
'
,
{
noteId
:
parseInt
(
myLastNoteId
.
replace
(
'
note_
'
,
''
),
10
),
...
...
@@ -116,7 +125,7 @@
{{
saveButtonTitle
}}
</button>
<button
@
click=
"cancelHandler"
@
click=
"cancelHandler
()
"
class=
"btn btn-nr btn-cancel note-edit-cancel"
type=
"button"
>
Cancel
...
...
app/assets/javascripts/notes/components/issue_notes_app.vue
浏览文件 @
2845dad2
...
...
@@ -60,6 +60,7 @@
setNotesData
:
'
setNotesData
'
,
setIssueData
:
'
setIssueData
'
,
setUserData
:
'
setUserData
'
,
setLastFetchedAt
:
'
setLastFetchedAt
'
}),
getComponentName
(
note
)
{
if
(
note
.
isPlaceholderNote
)
{
...
...
@@ -86,7 +87,10 @@
this
.
checkLocationHash
();
});
})
.
catch
(()
=>
Flash
(
'
Something went wrong while fetching issue comments. Please try again.
'
));
.
catch
((
error
)
=>
{
console
.
log
(
error
)
Flash
(
'
Something went wrong while fetching issue comments. Please try again.
'
)
});
},
initPolling
()
{
this
.
setLastFetchedAt
(
this
.
getNotesDataByProp
(
'
lastFetchedAt
'
));
...
...
@@ -98,7 +102,10 @@
.
then
((
res
)
=>
{
this
.
setLastFetchedAt
(
res
.
lastFetchedAt
);
})
.
catch
(()
=>
Flash
(
'
Something went wrong while fetching latest comments.
'
));
.
catch
((
error
)
=>
{
console
.
log
(
error
)
Flash
(
'
Something went wrong while fetching latest comments.
'
)
}
);
},
15000
);
},
bindEventHubListeners
()
{
...
...
app/assets/javascripts/notes/stores/getters.js
浏览文件 @
2845dad2
...
...
@@ -21,3 +21,16 @@ export const notesById = (state) => {
return
notesByIdObject
;
};
const
reverseNotes
=
array
=>
array
.
slice
(
0
).
reverse
();
const
isLastNote
=
(
note
,
userId
)
=>
!
note
.
system
&&
note
.
author
.
id
===
userId
;
export
const
getCurrentUserLastNote
=
state
=>
userId
=>
reverseNotes
(
state
.
notes
)
.
reduce
((
acc
,
note
)
=>
{
acc
.
push
(
reverseNotes
(
note
.
notes
).
find
(
el
=>
isLastNote
(
el
,
userId
)));
return
acc
;
},
[]).
filter
(
el
=>
el
!==
undefined
)[
0
];
export
const
getDiscussionLastNote
=
state
=>
(
discussion
,
userId
)
=>
reverseNotes
(
discussion
[
0
].
notes
)
.
find
(
el
=>
isLastNote
(
el
,
userId
));
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录