[#369] pull request page; some fixes, work in progress;
This commit is contained in:
parent
a37616b352
commit
b42766beb4
|
@ -7,11 +7,11 @@ CommentsController = (Comment, Preview, confirmMessage, $scope, compileHTML, $ro
|
|||
setInlineCommentParams = (params) ->
|
||||
inlineCommentParams = params
|
||||
|
||||
findInlineComments = (params) ->
|
||||
findInlineComments = ($event, params) ->
|
||||
if params.in_reply
|
||||
$('#comment'+params.in_reply).parents('tr').find('td .line-comment:last')
|
||||
else
|
||||
$()
|
||||
$($event.target).parent().parent().parent()
|
||||
|
||||
vm = this
|
||||
|
||||
|
@ -96,30 +96,37 @@ CommentsController = (Comment, Preview, confirmMessage, $scope, compileHTML, $ro
|
|||
else
|
||||
return false
|
||||
|
||||
vm.showInlineForm = (params = {}) ->
|
||||
line_comments = findInlineComments(params)
|
||||
vm.showInlineForm = ($event, params = {}) ->
|
||||
line_comments = findInlineComments($event, params)
|
||||
return false if line_comments.count is 0
|
||||
|
||||
vm.new_inline_body = null
|
||||
vm.hideInlineForm()
|
||||
setInlineCommentParams(params)
|
||||
|
||||
new_form = new_inline_form.html()
|
||||
new_form = compileHTML.run($scope, new_form)
|
||||
line_comments.append(new_form)
|
||||
line_comments.find('#new_inline_comment').addClass('cloned')
|
||||
if params.in_reply
|
||||
new_form = compileHTML.run($scope, new_inline_form.html())
|
||||
line_comments.append(new_form)
|
||||
else
|
||||
new_form = "<tr class='inline-comments'><td class='line_numbers' colspan='2'></td><td>" +
|
||||
new_inline_form.html()+"</td></tr>"
|
||||
new_form = compileHTML.run($scope, new_form)
|
||||
line_comments.after(new_form)
|
||||
|
||||
line_comments.parent().find('#new_inline_comment').addClass('cloned')
|
||||
true
|
||||
|
||||
vm.hideInlineForm = ->
|
||||
$('#new_inline_comment.cloned').remove()
|
||||
|
||||
inlineCommentParams = {}
|
||||
false
|
||||
|
||||
vm.hideInlineCommentButton = (params = {}) ->
|
||||
_.isEqual(inlineCommentParams, params)
|
||||
|
||||
vm.addInline = ->
|
||||
inline_comments = findInlineComments(inlineCommentParams)
|
||||
vm.addInline = ($event) ->
|
||||
inline_comments = findInlineComments($event, inlineCommentParams)
|
||||
return false if inline_comments.count is 0
|
||||
|
||||
vm.processing = true
|
||||
|
@ -138,6 +145,7 @@ CommentsController = (Comment, Preview, confirmMessage, $scope, compileHTML, $ro
|
|||
$rootScope.$on "compile_html", (event, args) ->
|
||||
html = compileHTML.run($scope, args.html)
|
||||
args.element.html(html)
|
||||
true
|
||||
|
||||
vm.init = (project, commentable = {}) ->
|
||||
vm.project = project
|
||||
|
|
|
@ -88,7 +88,7 @@ PullRequestController = (dataservice, $http, ApiPullRequest, ApiProject, DateTim
|
|||
sha: vm.pull.from_ref.sha
|
||||
|
||||
vm.getActivity = ->
|
||||
return if vm.pull_updated and vm.is_activity_updated
|
||||
return if vm.is_pull_updated and vm.is_activity_updated
|
||||
vm.processing = true
|
||||
|
||||
promise = ApiPullRequest.get_activity(vm.pull_params)
|
||||
|
@ -102,7 +102,7 @@ PullRequestController = (dataservice, $http, ApiPullRequest, ApiProject, DateTim
|
|||
false
|
||||
|
||||
vm.getDiff = ->
|
||||
return if vm.pull_updated and vm.is_diff_updated
|
||||
return if vm.is_pull_updated and vm.is_diff_updated
|
||||
vm.processing = true
|
||||
|
||||
promise = ApiPullRequest.get_diff(vm.pull_params)
|
||||
|
@ -116,7 +116,7 @@ PullRequestController = (dataservice, $http, ApiPullRequest, ApiProject, DateTim
|
|||
false
|
||||
|
||||
vm.getCommits = ->
|
||||
return if vm.pull_updated and vm.is_commits_updated
|
||||
return if vm.is_pull_updated and vm.is_commits_updated
|
||||
vm.processing = true
|
||||
|
||||
promise = ApiPullRequest.get_commits(vm.pull_params)
|
||||
|
|
|
@ -132,12 +132,12 @@ module DiffHelper
|
|||
|
||||
def nonewlineline(line)
|
||||
set_line_number
|
||||
"<tr class='changes' ng-non-bindable>
|
||||
"<tr class='changes'>
|
||||
#{td_line_link "#{@diff_prefix}-F#{@diff_counter}L#{line.old_number}", line.old_number}
|
||||
#{td_line_link "#{@diff_prefix}-F#{@diff_counter}R#{line.new_number}", line.new_number}
|
||||
<td class='code modline unmodline'>
|
||||
#{line_comment_icon}
|
||||
<pre>#{render_line(line)}</pre>
|
||||
<pre ng-non-bindable>#{render_line(line)}</pre>
|
||||
</td>
|
||||
</tr>
|
||||
#{render_line_comments}"
|
||||
|
@ -232,14 +232,14 @@ module DiffHelper
|
|||
link_to image_tag('line_comment.png', alt: t('layout.comments.new_header')),
|
||||
'#new_inline_comment',
|
||||
class: 'add_line-comment',
|
||||
'ng-click' => "commentsCtrl.showInlineForm(#{new_inline_comment_params.to_json})"
|
||||
'ng-click' => "commentsCtrl.showInlineForm($event, #{new_inline_comment_params.to_json})"
|
||||
end
|
||||
end
|
||||
|
||||
def render_line_comments
|
||||
unless @no_commit_comment || @in_discussion
|
||||
comments = @line_comments.select do |c|
|
||||
c.data.try('[]', :line) == @num_line.to_s && c.actual_inline_comment?
|
||||
c.data.try('[]', :line).to_s == @num_line.to_s && c.actual_inline_comment?
|
||||
end
|
||||
tr_line_comments(comments) if comments.count > 0
|
||||
end
|
||||
|
@ -263,7 +263,7 @@ module DiffHelper
|
|||
res << link_to( t('layout.comments.new_inline'),
|
||||
'#new_inline_comment',
|
||||
class: 'btn btn-primary',
|
||||
'ng-click' => "commentsCtrl.showInlineForm(#{new_inline_comment_params.to_json})",
|
||||
'ng-click' => "commentsCtrl.showInlineForm($event, #{new_inline_comment_params.to_json})",
|
||||
'ng-hide' => "commentsCtrl.hideInlineCommentButton(#{new_inline_comment_params.to_json})" )
|
||||
end
|
||||
res << "</td></tr>"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
tabset
|
||||
tab heading = t('layout.edit')
|
||||
tab.active heading = t('layout.edit')
|
||||
.offset10
|
||||
- if defined?(ang_model)
|
||||
= f.input :body, label: false,
|
||||
|
|
|
@ -14,6 +14,6 @@
|
|||
ang_model: 'new_inline_body'
|
||||
hr
|
||||
button.btn.btn-primary[ ng-disabled = 'commentsCtrl.isDisabledNewInlineCommentButton()'
|
||||
ng-click = 'commentsCtrl.addInline()' ]
|
||||
ng-click = 'commentsCtrl.addInline($event)' ]
|
||||
= t('layout.create')
|
||||
=< link_to t('layout.cancel'), '', 'ng-click' => 'commentsCtrl.hideInlineForm()'
|
||||
|
|
|
@ -2,9 +2,10 @@
|
|||
.file
|
||||
a name = "diff-#{pull_diff_counter}"
|
||||
.top
|
||||
.l= h(pull_diff.renamed_file ? "#{pull_diff.a_path.rtruncate 60}=>#{pull_diff.b_path.rtruncate 60}" : pull_diff.b_path.rtruncate(120))
|
||||
.pull-left= h(pull_diff.renamed_file ? "#{pull_diff.a_path.rtruncate 60}=>#{pull_diff.b_path.rtruncate 60}" : pull_diff.b_path.rtruncate(120))
|
||||
- if @pull.from_project.present?
|
||||
.r= link_to "view file @ #{short_hash_id(commit_id)}", blob_path(@pull.from_project, commit_id, pull_diff.b_path)
|
||||
.clear
|
||||
.pull-right= link_to "view file @ #{short_hash_id(commit_id)}", blob_path(@pull.from_project, commit_id, pull_diff.b_path)
|
||||
.clearfix
|
||||
-if pull_diff.diff.present? && !(@pull.repo.tree(commit_id) / pull_diff.b_path).binary?
|
||||
.diff_data=render_diff(pull_diff, diff_counter: pull_diff_counter, comments: @comments)
|
||||
.diff_data== render_diff(pull_diff, diff_counter: pull_diff_counter, comments: @comments)
|
||||
p= "comments count is #{@comments.count}"
|
|
@ -2,7 +2,7 @@
|
|||
img alt = 'avatar' src = presenter.image
|
||||
.pull-left
|
||||
strong= presenter.header
|
||||
= datetime_moment(presenter.date, tag: :strong)
|
||||
=< datetime_moment(presenter.date, tag: :strong)
|
||||
.clearfix
|
||||
span= presenter.caption
|
||||
- if presenter.expandable? && presenter.content?
|
||||
|
|
Loading…
Reference in New Issue