[#369] pull request page; some fixes, work in progress;

This commit is contained in:
Alexander Machehin 2014-12-25 01:14:03 +05:00
parent a37616b352
commit b42766beb4
7 changed files with 34 additions and 25 deletions

View File

@ -7,11 +7,11 @@ CommentsController = (Comment, Preview, confirmMessage, $scope, compileHTML, $ro
setInlineCommentParams = (params) -> setInlineCommentParams = (params) ->
inlineCommentParams = params inlineCommentParams = params
findInlineComments = (params) -> findInlineComments = ($event, params) ->
if params.in_reply if params.in_reply
$('#comment'+params.in_reply).parents('tr').find('td .line-comment:last') $('#comment'+params.in_reply).parents('tr').find('td .line-comment:last')
else else
$() $($event.target).parent().parent().parent()
vm = this vm = this
@ -96,30 +96,37 @@ CommentsController = (Comment, Preview, confirmMessage, $scope, compileHTML, $ro
else else
return false return false
vm.showInlineForm = (params = {}) -> vm.showInlineForm = ($event, params = {}) ->
line_comments = findInlineComments(params) line_comments = findInlineComments($event, params)
return false if line_comments.count is 0 return false if line_comments.count is 0
vm.new_inline_body = null vm.new_inline_body = null
vm.hideInlineForm() vm.hideInlineForm()
setInlineCommentParams(params) setInlineCommentParams(params)
new_form = new_inline_form.html() if params.in_reply
new_form = compileHTML.run($scope, new_form) new_form = compileHTML.run($scope, new_inline_form.html())
line_comments.append(new_form) line_comments.append(new_form)
line_comments.find('#new_inline_comment').addClass('cloned') 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 true
vm.hideInlineForm = -> vm.hideInlineForm = ->
$('#new_inline_comment.cloned').remove() $('#new_inline_comment.cloned').remove()
inlineCommentParams = {} inlineCommentParams = {}
false false
vm.hideInlineCommentButton = (params = {}) -> vm.hideInlineCommentButton = (params = {}) ->
_.isEqual(inlineCommentParams, params) _.isEqual(inlineCommentParams, params)
vm.addInline = -> vm.addInline = ($event) ->
inline_comments = findInlineComments(inlineCommentParams) inline_comments = findInlineComments($event, inlineCommentParams)
return false if inline_comments.count is 0 return false if inline_comments.count is 0
vm.processing = true vm.processing = true
@ -138,6 +145,7 @@ CommentsController = (Comment, Preview, confirmMessage, $scope, compileHTML, $ro
$rootScope.$on "compile_html", (event, args) -> $rootScope.$on "compile_html", (event, args) ->
html = compileHTML.run($scope, args.html) html = compileHTML.run($scope, args.html)
args.element.html(html) args.element.html(html)
true
vm.init = (project, commentable = {}) -> vm.init = (project, commentable = {}) ->
vm.project = project vm.project = project

View File

@ -88,7 +88,7 @@ PullRequestController = (dataservice, $http, ApiPullRequest, ApiProject, DateTim
sha: vm.pull.from_ref.sha sha: vm.pull.from_ref.sha
vm.getActivity = -> 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 vm.processing = true
promise = ApiPullRequest.get_activity(vm.pull_params) promise = ApiPullRequest.get_activity(vm.pull_params)
@ -102,7 +102,7 @@ PullRequestController = (dataservice, $http, ApiPullRequest, ApiProject, DateTim
false false
vm.getDiff = -> 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 vm.processing = true
promise = ApiPullRequest.get_diff(vm.pull_params) promise = ApiPullRequest.get_diff(vm.pull_params)
@ -116,7 +116,7 @@ PullRequestController = (dataservice, $http, ApiPullRequest, ApiProject, DateTim
false false
vm.getCommits = -> 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 vm.processing = true
promise = ApiPullRequest.get_commits(vm.pull_params) promise = ApiPullRequest.get_commits(vm.pull_params)

View File

@ -132,12 +132,12 @@ module DiffHelper
def nonewlineline(line) def nonewlineline(line)
set_line_number 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}L#{line.old_number}", line.old_number}
#{td_line_link "#{@diff_prefix}-F#{@diff_counter}R#{line.new_number}", line.new_number} #{td_line_link "#{@diff_prefix}-F#{@diff_counter}R#{line.new_number}", line.new_number}
<td class='code modline unmodline'> <td class='code modline unmodline'>
#{line_comment_icon} #{line_comment_icon}
<pre>#{render_line(line)}</pre> <pre ng-non-bindable>#{render_line(line)}</pre>
</td> </td>
</tr> </tr>
#{render_line_comments}" #{render_line_comments}"
@ -232,14 +232,14 @@ module DiffHelper
link_to image_tag('line_comment.png', alt: t('layout.comments.new_header')), link_to image_tag('line_comment.png', alt: t('layout.comments.new_header')),
'#new_inline_comment', '#new_inline_comment',
class: 'add_line-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
end end
def render_line_comments def render_line_comments
unless @no_commit_comment || @in_discussion unless @no_commit_comment || @in_discussion
comments = @line_comments.select do |c| 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 end
tr_line_comments(comments) if comments.count > 0 tr_line_comments(comments) if comments.count > 0
end end
@ -263,7 +263,7 @@ module DiffHelper
res << link_to( t('layout.comments.new_inline'), res << link_to( t('layout.comments.new_inline'),
'#new_inline_comment', '#new_inline_comment',
class: 'btn btn-primary', 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})" ) 'ng-hide' => "commentsCtrl.hideInlineCommentButton(#{new_inline_comment_params.to_json})" )
end end
res << "</td></tr>" res << "</td></tr>"

View File

@ -1,5 +1,5 @@
tabset tabset
tab heading = t('layout.edit') tab.active heading = t('layout.edit')
.offset10 .offset10
- if defined?(ang_model) - if defined?(ang_model)
= f.input :body, label: false, = f.input :body, label: false,

View File

@ -14,6 +14,6 @@
ang_model: 'new_inline_body' ang_model: 'new_inline_body'
hr hr
button.btn.btn-primary[ ng-disabled = 'commentsCtrl.isDisabledNewInlineCommentButton()' button.btn.btn-primary[ ng-disabled = 'commentsCtrl.isDisabledNewInlineCommentButton()'
ng-click = 'commentsCtrl.addInline()' ] ng-click = 'commentsCtrl.addInline($event)' ]
= t('layout.create') = t('layout.create')
=< link_to t('layout.cancel'), '', 'ng-click' => 'commentsCtrl.hideInlineForm()' =< link_to t('layout.cancel'), '', 'ng-click' => 'commentsCtrl.hideInlineForm()'

View File

@ -2,9 +2,10 @@
.file .file
a name = "diff-#{pull_diff_counter}" a name = "diff-#{pull_diff_counter}"
.top .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? - 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) .pull-right= link_to "view file @ #{short_hash_id(commit_id)}", blob_path(@pull.from_project, commit_id, pull_diff.b_path)
.clear .clearfix
-if pull_diff.diff.present? && !(@pull.repo.tree(commit_id) / pull_diff.b_path).binary? -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}"

View File

@ -2,7 +2,7 @@
img alt = 'avatar' src = presenter.image img alt = 'avatar' src = presenter.image
.pull-left .pull-left
strong= presenter.header strong= presenter.header
= datetime_moment(presenter.date, tag: :strong) =< datetime_moment(presenter.date, tag: :strong)
.clearfix .clearfix
span= presenter.caption span= presenter.caption
- if presenter.expandable? && presenter.content? - if presenter.expandable? && presenter.content?