From e10dd56dffc3a8aca504f30f05a9945d05cc963a Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Mon, 16 Jan 2012 00:10:50 +0600 Subject: [PATCH] [refs #18] refactoring --- app/views/comments/_list.html.haml | 33 ++++++++++++++++++++++++++++ app/views/git/commits/show.html.haml | 26 +--------------------- app/views/issues/show.html.haml | 26 +--------------------- 3 files changed, 35 insertions(+), 50 deletions(-) create mode 100644 app/views/comments/_list.html.haml diff --git a/app/views/comments/_list.html.haml b/app/views/comments/_list.html.haml new file mode 100644 index 000000000..0457e4c34 --- /dev/null +++ b/app/views/comments/_list.html.haml @@ -0,0 +1,33 @@ +%a{ :name => "comments" } +.block#block-list + .content + %h2.title + = t("layout.issues.comments_header") + .inner + %ul.list + - list.each do |comment| + %li + .left + = link_to comment.user.uname, user_path(comment.user.uname) + .item + = comment.body + %br + %br + - if commentable.class == Issue + - edit_path = edit_project_issue_comment_path(project, commentable.id, comment) + - delete_path = project_issue_comment_path(project, commentable.id, comment) + - elsif commentable.class == Grit::Commit + - edit_path = edit_project_commit_comment_path(project, commentable.id, comment) + - delete_path = project_commit_comment_path(project, commentable.id, comment) + = link_to t("layout.edit"), edit_path if can? :update, comment + = link_to image_tag("web-app-theme/icons/cross.png", :alt => t("layout.delete")) + " " + t("layout.delete"), delete_path, :method => "delete", :class => "button", :confirm => t("layout.comments.confirm_delete") if can? :delete, comment + +.block + .content + %h2.title + = t("layout.comments.new_header") + .inner + - new_path = project_issue_comments_path(project, commentable.id) if commentable.class == Issue + - new_path = project_commit_comments_path(project, commentable.id) if commentable.class == Grit::Commit + = form_for :comment, :url => new_path, :method => :post, :html => { :class => :form } do |f| + = render :partial => "comments/form", :locals => {:f => f} diff --git a/app/views/git/commits/show.html.haml b/app/views/git/commits/show.html.haml index 421c5d2e2..8f3ec67f8 100644 --- a/app/views/git/commits/show.html.haml +++ b/app/views/git/commits/show.html.haml @@ -27,28 +27,4 @@ - content_for :sidebar, render(:partial => 'git/shared/sidebar') -%a{ :name => "comments" } -.block#block-list - .content - %h2.title - = t("layout.issues.comments_header") - .inner - %ul.list - - Project.commit_comments(@commit, @project).each do |comment| - %li - .left - = link_to comment.user.uname, user_path(comment.user.uname) - .item - = comment.body - %br - %br - = link_to t("layout.edit"), edit_project_commit_comment_path(@project, @commit.id, comment) if can? :update, comment - = link_to image_tag("web-app-theme/icons/cross.png", :alt => t("layout.delete")) + " " + t("layout.delete"), project_commit_comment_path(@project, @commit.id, comment), :method => "delete", :class => "button", :confirm => t("layout.comments.confirm_delete") if can? :delete, comment - -.block - .content - %h2.title - = t("layout.comments.new_header") - .inner - = form_for :comment, :url => project_commit_comments_path(@project, @commit.id), :method => :post, :html => { :class => :form } do |f| - = render :partial => "comments/form", :locals => {:f => f} += render :partial => "comments/list", :locals => {:list => Project.commit_comments(@commit, @project), :project => @project, :commentable => @commit} diff --git a/app/views/issues/show.html.haml b/app/views/issues/show.html.haml index 2a79e66a3..f246dbfda 100644 --- a/app/views/issues/show.html.haml +++ b/app/views/issues/show.html.haml @@ -29,28 +29,4 @@ - else = link_to t('layout.issues.subscribe_btn'), project_issue_subscribes_path(@project, @issue), :method => :post -%a{ :name => "comments" } -.block#block-list - .content - %h2.title - = t("layout.issues.comments_header") - .inner - %ul.list - - @issue.comments.each do |comment| - %li - .left - = link_to comment.user.uname, user_path(comment.user.uname) - .item - = comment.body - %br - %br - = link_to t("layout.edit"), edit_project_issue_comment_path(@project, @issue.id, comment) if can? :update, comment - = link_to image_tag("web-app-theme/icons/cross.png", :alt => t("layout.delete")) + " " + t("layout.delete"), project_issue_comment_path(@project, @issue.id, comment), :method => "delete", :class => "button", :confirm => t("layout.comments.confirm_delete") if can? :delete, comment - -.block - .content - %h2.title - = t("layout.comments.new_header") - .inner - = form_for :comment, :url => project_issue_comments_path(@project, @issue.id), :method => :post, :html => { :class => :form } do |f| - = render :partial => "comments/form", :locals => {:f => f} += render :partial => "comments/list", :locals => {:list => @issue.comments, :project => @project, :commentable => @issue}