From c07d3dfc042fb795322d28523abd9628eccdf8f9 Mon Sep 17 00:00:00 2001 From: gitlabhq Date: Mon, 7 Nov 2011 10:55:16 -0500 Subject: [PATCH 1/3] issue restyle example --- app/assets/stylesheets/projects.css.scss | 24 +++++++++++++ app/views/issues/_issues.html.haml | 7 +--- app/views/issues/_show.html.haml | 44 +++++++++++++++--------- 3 files changed, 53 insertions(+), 22 deletions(-) diff --git a/app/assets/stylesheets/projects.css.scss b/app/assets/stylesheets/projects.css.scss index e5d39474..3fe6b233 100644 --- a/app/assets/stylesheets/projects.css.scss +++ b/app/assets/stylesheets/projects.css.scss @@ -679,6 +679,30 @@ body.project-page table .commit { } } +#notes-list .note .delete-note { display:none; } +#notes-list .note:hover .delete-note { display:block; } + +#issues-table-holder .issue .action-links { + display:none; + a { + margin-left:10px; + } +} + +.issue-number { + float: left; + border-radius: 5px; + text-shadow: none; + background: rgba(0, 0, 0, 0.12); + text-align: center; + padding: 14px 8px; + width: 40px; + margin-right: 10px; + color: #444; +} + +#issues-table-holder .issue:hover .action-links { display:block; } + body.project-page #notes-list .note {padding: 10px; border-bottom: 1px solid #eee; overflow: hidden; display: block;} body.project-page #notes-list .note {padding: 10px; border-bottom: 1px solid #eee; overflow: hidden; display: block;} body.project-page #notes-list .note img{float: left; margin-right: 10px;} diff --git a/app/views/issues/_issues.html.haml b/app/views/issues/_issues.html.haml index d758fed5..5651883a 100644 --- a/app/views/issues/_issues.html.haml +++ b/app/views/issues/_issues.html.haml @@ -1,11 +1,6 @@ %table.round-borders#issues-table %thead - - if can?(current_user, :admin_issue, @project) && !params[:f] || params[:f] == "0" - %th - %th Assignee - %th ID - %th Title - %th Closed? + %th Issues - @issues.critical.each do |issue| = render(:partial => 'show', :locals => {:issue => issue}) diff --git a/app/views/issues/_show.html.haml b/app/views/issues/_show.html.haml index 72b99b04..9f2e90e2 100644 --- a/app/views/issues/_show.html.haml +++ b/app/views/issues/_show.html.haml @@ -1,26 +1,38 @@ %tr{ :id => dom_id(issue), :class => "issue #{issue.critical ? "critical" : ""}", :url => project_issue_path(@project, issue) } - - if can?(current_user, :admin_issue, @project) && (!params[:f] || params[:f] == "0") + -#- if can?(current_user, :admin_issue, @project) && (!params[:f] || params[:f] == "0") %td = image_tag "move.png" , :class => [:handle, :left] %td - = image_tag gravatar_icon(issue.assignee.email), :class => "left", :width => 40, :style => "padding:0 5px;" - = issue.assignee.name - %td ##{issue.id} - %td + %strong.issue-number= "##{issue.id}" + %span + = truncate(html_escape(issue.title), :length => fixed_mode? ? 100 : 200) + %br + %br + %div.note-author + %strong= issue.assignee.name + %cite.cgray + = time_ago_in_words(issue.updated_at) + ago + - if issue.critical + %span.tag.high critical + - if issue.today? + %span.tag.today today + .right.action-links + - if can? current_user, :write_issue, issue + - if issue.closed + = link_to 'Reopen', project_issue_path(@project, issue, :issue => {:closed => false }, :status_only => true), :method => :put, :class => "cgray", :remote => true + - else + = link_to 'Resolve', project_issue_path(@project, issue, :issue => {:closed => true }, :status_only => true), :method => :put, :class => "cgray", :remote => true + - if can? current_user, :write_issue, issue + = link_to 'Edit', edit_project_issue_path(@project, issue), :class => "cgray", :remote => true + - if can?(current_user, :admin_issue, @project) || issue.author == current_user + = link_to 'Destroy', [@project, issue], :confirm => 'Are you sure?', :method => :delete, :remote => true, :class => "cred delete-issue negative", :id => "destroy_issue_#{issue.id}" + -#%td ##{issue.id} + -#%td = truncate(html_escape(issue.title), :length => 200) %br %br - - if issue.critical - %span.tag.high critical - - if issue.today? - %span.tag.today today - .right - - if can?(current_user, :admin_issue, @project) || issue.author == current_user - = link_to 'Edit', edit_project_issue_path(@project, issue), :class => "cgray", :remote => true - - if can?(current_user, :admin_issue, @project) || issue.author == current_user -   - = link_to 'Destroy', [@project, issue], :confirm => 'Are you sure?', :method => :delete, :remote => true, :class => "cred delete-issue negative", :id => "destroy_issue_#{issue.id}" -#- if issue.author == current_user -#%span.tag.yours yours @@ -28,7 +40,7 @@ -#%span.tag.notes -#= issue.notes.count -#notes - %td + -#%td - if can? current_user, :write_issue, @project = form_for([@project, issue], :remote => true) do |f| = f.check_box :closed, :onclick => "$(this).parent().submit();" From 60f083ad619731e1c959aa5ec15a0469a557b0da Mon Sep 17 00:00:00 2001 From: gitlabhq Date: Mon, 7 Nov 2011 11:31:05 -0500 Subject: [PATCH 2/3] issues table header --- app/views/issues/_issues.html.haml | 12 +++---- app/views/issues/_show.html.haml | 20 ------------ app/views/issues/index.html.haml | 51 ++++++++++++++++-------------- app/views/issues/index.js.haml | 2 +- 4 files changed, 32 insertions(+), 53 deletions(-) diff --git a/app/views/issues/_issues.html.haml b/app/views/issues/_issues.html.haml index 5651883a..eb0cae66 100644 --- a/app/views/issues/_issues.html.haml +++ b/app/views/issues/_issues.html.haml @@ -1,9 +1,5 @@ -%table.round-borders#issues-table - %thead - %th Issues +- @issues.critical.each do |issue| + = render(:partial => 'show', :locals => {:issue => issue}) - - @issues.critical.each do |issue| - = render(:partial => 'show', :locals => {:issue => issue}) - - - @issues.non_critical.each do |issue| - = render(:partial => 'show', :locals => {:issue => issue}) +- @issues.non_critical.each do |issue| + = render(:partial => 'show', :locals => {:issue => issue}) diff --git a/app/views/issues/_show.html.haml b/app/views/issues/_show.html.haml index 9f2e90e2..94df0f53 100644 --- a/app/views/issues/_show.html.haml +++ b/app/views/issues/_show.html.haml @@ -27,23 +27,3 @@ = link_to 'Edit', edit_project_issue_path(@project, issue), :class => "cgray", :remote => true - if can?(current_user, :admin_issue, @project) || issue.author == current_user = link_to 'Destroy', [@project, issue], :confirm => 'Are you sure?', :method => :delete, :remote => true, :class => "cred delete-issue negative", :id => "destroy_issue_#{issue.id}" - -#%td ##{issue.id} - -#%td - = truncate(html_escape(issue.title), :length => 200) - %br - %br - - - -#- if issue.author == current_user - -#%span.tag.yours yours - -#- if issue.notes.count > 0 - -#%span.tag.notes - -#= issue.notes.count - -#notes - -#%td - - if can? current_user, :write_issue, @project - = form_for([@project, issue], :remote => true) do |f| - = f.check_box :closed, :onclick => "$(this).parent().submit();" - = hidden_field_tag :status_only, true - - else - = check_box_tag "closed", 1, issue.closed, :disabled => true diff --git a/app/views/issues/index.html.haml b/app/views/issues/index.html.haml index 21e455b9..355429c3 100644 --- a/app/views/issues/index.html.haml +++ b/app/views/issues/index.html.haml @@ -1,28 +1,31 @@ -%div - .top_panel_issues - - if can? current_user, :write_issue, @project - %div{:class => "left", :style => "margin-right: 10px;" } - = link_to 'New Issue', new_project_issue_path(@project), :remote => true, :class => "lbutton vm" - = form_tag search_project_issues_path(@project), :method => :get, :remote => true, :class => :left, :id => "issue_search_form" do - = hidden_field_tag :project_id, @project.id, { :id => 'project_id' } - = search_field_tag :issue_search, nil, { :placeholder => 'Search', :class => 'issue_search' } +%div#issues-table-holder + %table.round-borders#issues-table + %thead + %th + .top_panel_issues + - if can? current_user, :write_issue, @project + %div{:class => "left", :style => "margin-right: 10px;" } + = link_to 'New Issue', new_project_issue_path(@project), :remote => true, :class => "lbutton vm" + = form_tag search_project_issues_path(@project), :method => :get, :remote => true, :class => :left, :id => "issue_search_form" do + = hidden_field_tag :project_id, @project.id, { :id => 'project_id' } + = search_field_tag :issue_search, nil, { :placeholder => 'Search', :class => 'issue_search' } - .right.issues_filter - = form_tag project_issues_path(@project), :method => :get do - .left - = radio_button_tag :f, 0, (params[:f] || "0") == "0", :onclick => "this.form.submit()", :id => "open_issues", :class => "status" - = label_tag "open_issues","Open" - .left - = radio_button_tag :f, 2, params[:f] == "2", :onclick => "this.form.submit()", :id => "closed_issues", :class => "status" - = label_tag "closed_issues","Closed" - .left - = radio_button_tag :f, 3, params[:f] == "3", :onclick => "this.form.submit()", :id => "my_issues", :class => "status" - = label_tag "my_issues","To Me" - .left - = radio_button_tag :f, 1, params[:f] == "1", :onclick => "this.form.submit()", :id => "all_issues", :class => "status" - = label_tag "all_issues","All" + .right.issues_filter + = form_tag project_issues_path(@project), :method => :get do + .left + = radio_button_tag :f, 0, (params[:f] || "0") == "0", :onclick => "this.form.submit()", :id => "open_issues", :class => "status" + = label_tag "open_issues","Open" + .left + = radio_button_tag :f, 2, params[:f] == "2", :onclick => "this.form.submit()", :id => "closed_issues", :class => "status" + = label_tag "closed_issues","Closed" + .left + = radio_button_tag :f, 3, params[:f] == "3", :onclick => "this.form.submit()", :id => "my_issues", :class => "status" + = label_tag "my_issues","To Me" + .left + = radio_button_tag :f, 1, params[:f] == "1", :onclick => "this.form.submit()", :id => "all_issues", :class => "status" + = label_tag "all_issues","All" - #issues-table-holder= render "issues" + = render "issues" %br :javascript var href = $('.issue_search').parent().attr('action'); @@ -37,7 +40,7 @@ if (terms.length >= 2 || terms.length == 0) { $.get(href, { 'status': status, 'terms': terms, project: project_id }, function(response) { - $('#issues-table').html(response); + $('#issues-table tbody').html(response); setSortable(); }); } diff --git a/app/views/issues/index.js.haml b/app/views/issues/index.js.haml index bc18ac15..a08ffe5a 100644 --- a/app/views/issues/index.js.haml +++ b/app/views/issues/index.js.haml @@ -1,3 +1,3 @@ :plain - $('#issues-table-holder').html("#{escape_javascript(render('issues'))}"); + $('#issues-table tbody').html("#{escape_javascript(render('issues'))}"); setSortable(); From 67b9fa51dcdf3d5954b83f6f162763349d1e662a Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Mon, 7 Nov 2011 22:31:51 +0200 Subject: [PATCH 3/3] fixed tests --- app/controllers/issues_controller.rb | 1 + app/views/issues/_show.html.haml | 2 +- app/views/issues/create.js.haml | 1 + spec/requests/issues_spec.rb | 1 + 4 files changed, 4 insertions(+), 1 deletion(-) diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index 7ff1ccb3..508cfc39 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -47,6 +47,7 @@ class IssuesController < ApplicationController def create @issue = @project.issues.new(params[:issue]) @issue.author = current_user + if @issue.save && @issue.assignee != current_user Notify.new_issue_email(@issue).deliver end diff --git a/app/views/issues/_show.html.haml b/app/views/issues/_show.html.haml index 94df0f53..ebee0bf0 100644 --- a/app/views/issues/_show.html.haml +++ b/app/views/issues/_show.html.haml @@ -24,6 +24,6 @@ - else = link_to 'Resolve', project_issue_path(@project, issue, :issue => {:closed => true }, :status_only => true), :method => :put, :class => "cgray", :remote => true - if can? current_user, :write_issue, issue - = link_to 'Edit', edit_project_issue_path(@project, issue), :class => "cgray", :remote => true + = link_to 'Edit', edit_project_issue_path(@project, issue), :class => "cgray edit-issue-link", :remote => true - if can?(current_user, :admin_issue, @project) || issue.author == current_user = link_to 'Destroy', [@project, issue], :confirm => 'Are you sure?', :method => :delete, :remote => true, :class => "cred delete-issue negative", :id => "destroy_issue_#{issue.id}" diff --git a/app/views/issues/create.js.haml b/app/views/issues/create.js.haml index 3713a8af..b8043290 100644 --- a/app/views/issues/create.js.haml +++ b/app/views/issues/create.js.haml @@ -1,6 +1,7 @@ - if @issue.valid? :plain $("#new_issue_dialog").dialog("close"); + $("#issues-table").prepend("#{escape_javascript(render(:partial => 'show', :locals => {:issue => @issue} ))}"); $.ajax({type: "GET", url: location.href, dataType: "script"}); - else :plain diff --git a/spec/requests/issues_spec.rb b/spec/requests/issues_spec.rb index b5d6f1bc..0dda659b 100644 --- a/spec/requests/issues_spec.rb +++ b/spec/requests/issues_spec.rb @@ -169,6 +169,7 @@ describe "Issues" do :assignee => @user, :project => project visit project_issues_path(project) + page.execute_script("$('.action-links').css('display', 'block');") click_link "Edit" end