OSDN Git Service

Added dropdown menus to issue#show page for assignee and milestone
authorJason Blanchard <jas.blanchard@gmail.com>
Tue, 17 Dec 2013 14:39:39 +0000 (09:39 -0500)
committerJason Blanchard <jas.blanchard@gmail.com>
Tue, 17 Dec 2013 14:39:50 +0000 (09:39 -0500)
CHANGELOG
app/assets/javascripts/issues.js.coffee
app/assets/stylesheets/sections/issues.scss
app/views/projects/issues/_issue_context.html.haml [new file with mode: 0644]
app/views/projects/issues/show.html.haml
app/views/projects/issues/update.js.haml
spec/features/issues_spec.rb

index d311984..8429784 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,6 @@
+v 6.5.0
+  - Dropdown menus on issue#show page for assignee and milestone (Jason Blanchard)
+
 v 6.4.0
   - Added sorting to project issues page (Jason Blanchard)
   - Assembla integration (Carlos Paramio)
index c273ddb..4357140 100644 (file)
@@ -79,3 +79,9 @@
       $("#update_issues_ids").val []
       $(".issues_bulk_update").hide()
       $(".issues-filters").show()
+
+$ ->
+  $('.edit-issue.inline-update input[type="submit"]').hide();
+  $("body").on "change", ".edit-issue.inline-update select", ->
+      $(this).submit()
+
index 792bcef..68e8f3f 100644 (file)
@@ -119,3 +119,8 @@ input.check_all_issues {
     background-color: #f4f4f4;
   }
 }
+
+.edit-issue.inline-update select {
+  width: 100%;
+  max-width: 230px;
+}
diff --git a/app/views/projects/issues/_issue_context.html.haml b/app/views/projects/issues/_issue_context.html.haml
new file mode 100644 (file)
index 0000000..29eb338
--- /dev/null
@@ -0,0 +1,31 @@
+= form_for [@project, @issue], :remote => true, :html => {:class => 'edit-issue inline-update'} do |f|
+  .pull-right
+  Created by #{link_to_member(@project, issue.author)}
+  - if issue.assignee
+    \ and currently assigned to
+
+  - if can?(current_user, :modify_issue, @issue)
+    = link_to profile_path(issue.assignee) do
+      = image_tag(avatar_icon(issue.assignee.email), :class => 'avatar avatar-inline s16 assignee') if issue.assignee
+    = f.select(:assignee_id, @project.team.members.sort_by(&:name).map {|p| [ p.name, p.id ] }, { include_blank: "Assign to user (none):" }, {class: 'chosen'})
+  - elsif issue.assignee
+    = link_to_member(@project, @issue.assignee)
+
+  - if issue.milestone
+    - milestone = issue.milestone
+    %cite.cgray and attached to milestone
+  
+  - if can?(current_user, :modify_issue, @issue)
+    = f.select(:milestone_id, @project.milestones.active.all.collect {|p| [ p.title, p.id ] }, { include_blank: "Select milestone (none):" }, {class: 'chosen'})
+
+    = hidden_field_tag :issue_context
+    = f.submit :class => 'btn'
+  - elsif issue.milestone
+    = link_to issue.milestone.title, project_milestone_path
+
+.pull-right
+  - issue.labels.each do |label|
+    %span{class: "label #{label_css_class(label.name)}"}
+      %i.icon-tag
+      = label.name
+    &nbsp;
index 36ea578..b23e577 100644 (file)
 .back-link
   = link_to project_issues_path(@project) do
     &larr; To issues list
-
+  %span.milestone-nav-link
+    - if @issue.milestone
+      | 
+      = link_to project_milestone_path(@project, @issue.milestone) do
+        <strong>Milestone:</strong>
+        = @issue.milestone.title
 
 .ui-box.ui-box-show
   .ui-box-head
 
   .ui-box-body
     %cite.cgray
-      Created by #{link_to_member(@project, @issue.author)}
-      - if @issue.assignee
-        \ and currently assigned to #{link_to_member(@project, @issue.assignee)}
-
-    - if @issue.milestone
-      - milestone = @issue.milestone
-      %cite.cgray and attached to milestone
-      %strong= link_to_gfm truncate(milestone.title, length: 20), project_milestone_path(milestone.project, milestone)
-
-    .pull-right
-      - @issue.labels.each do |label|
-        %span{class: "label #{label_css_class(label.name)}"}
-          %i.icon-tag
-          = label.name
-        &nbsp;
+      = render partial: 'issue_context', locals: { issue: @issue }
 
   - if @issue.description.present?
     .ui-box-bottom
@@ -73,4 +64,4 @@
   - @issue.participants.each do |participant|
     = link_to_member(@project, participant, name: false, size: 24)
 
-.voting_notes#notes= render "projects/notes/notes_with_form"
\ No newline at end of file
+.voting_notes#notes= render "projects/notes/notes_with_form"
index 7f66022..eb27faa 100644 (file)
@@ -2,3 +2,12 @@
   - if @issue.valid?
     :plain
       $("##{dom_id(@issue)}").fadeOut();
+- elsif params[:issue_context]
+  $('.ui-box-body').html("#{escape_javascript(render partial: 'issue_context', locals: { issue: @issue })}");
+  $('.ui-box-body').effect('highlight');
+  $('.chosen').chosen();
+  $('.edit-issue.inline-update input[type="submit"]').hide();
+  - if @issue.milestone
+    $('.milestone-nav-link').replaceWith("#{escape_javascript(link_to "| #{@issue.milestone.title}", project_milestone_path(@issue.project, @issue.milestone), :class => 'milestone-nav-link')}")
+  - else
+    $('.milestone-nav-link').html('')
index bb0c4db..e33684e 100644 (file)
@@ -175,6 +175,84 @@ describe "Issues" do
     end
   end
 
+  describe 'update assignee from issue#show' do
+    let(:issue) { create(:issue, project: project, author: @user) }
+
+    context 'by autorized user' do
+
+      it 'with dropdown menu' do
+        visit project_issue_path(project, issue)
+
+        find('.edit-issue.inline-update').select(project.team.members.first.name, from: 'issue_assignee_id')
+        click_button 'Update Issue'
+
+        page.should have_content "currently assigned to"
+        page.has_select?('issue_assignee_id', :selected => project.team.members.first.name)
+      end
+    end
+
+    context 'by unauthorized user' do
+    
+      let(:guest) { create(:user) }
+      
+      before :each do
+        project.team << [[guest], :guest]
+        issue.assignee = @user
+        issue.save
+      end
+
+      it 'shows assignee text' do
+        logout
+        login_with guest
+
+        visit project_issue_path(project, issue)
+        page.should have_content "currently assigned to #{issue.assignee.name}"
+
+      end
+    end
+
+  end
+
+  describe 'update milestone from issue#show' do
+    let!(:issue) { create(:issue, project: project, author: @user) }
+    let!(:milestone) { create(:milestone, project: project) }
+
+    context 'by authorized user' do
+
+      it 'with dropdown menu' do
+        visit project_issue_path(project, issue)
+
+        p find('.edit-issue.inline-update').text
+
+        find('.edit-issue.inline-update').select(milestone.title, from: 'issue_milestone_id')
+        click_button 'Update Issue'
+
+        page.should have_content "and attached to milestone"
+        page.has_select?('issue_assignee_id', :selected => milestone.title)
+      end
+    end
+
+    context 'by unauthorized user' do
+      
+      let(:guest) { create(:user) }
+      
+      before :each do
+        project.team << [[guest], :guest]
+        issue.milestone = milestone
+        issue.save
+      end
+
+      it 'shows milestone text' do
+        logout
+        login_with guest
+
+        visit project_issue_path(project, issue)
+
+        page.should have_content "attached to milestone #{milestone.title}"
+      end
+    end
+  end
+
   def first_issue
     all("ul.issues-list li").first.text
   end