Commit 15fa14f1d62520956f6db156062e7125e6d432f1

Authored by Dmitriy Zaporozhets
1 parent 16bd018f

get rid off modal window for issue create/edit

app/assets/javascripts/issues.js 0 → 100644
@@ -0,0 +1,32 @@ @@ -0,0 +1,32 @@
  1 +function switchToNewIssue(form){
  2 + $("#issues-table-holder").hide("slide", { direction: "left" }, 150, function(){
  3 + $(".project-content").append(form);
  4 + $('select#issue_assignee_id').chosen();
  5 + $("#new_issue_dialog").show("slide", { direction: "right" }, 150);
  6 + });
  7 +}
  8 +
  9 +function switchToEditIssue(form){
  10 + $("#issues-table-holder").hide("slide", { direction: "left" }, 150, function(){
  11 + $(".project-content").append(form);
  12 + $('select#issue_assignee_id').chosen();
  13 + $("#edit_issue_dialog").show("slide", { direction: "right" }, 150);
  14 + });
  15 +}
  16 +
  17 +function switchFromNewIssue(){
  18 + backToIssues();
  19 +}
  20 +
  21 +function switchFromEditIssue(){
  22 + backToIssues();
  23 +}
  24 +
  25 +function backToIssues(){
  26 + $("#edit_issue_dialog, #new_issue_dialog").hide("slide", { direction: "right" }, 150, function(){
  27 + $("#issues-table-holder").show("slide", { direction: "left" }, 150, function() {
  28 + $("#edit_issue_dialog").remove();
  29 + $("#new_issue_dialog").remove();
  30 + });
  31 + });
  32 +}
app/assets/stylesheets/application.css
@@ -40,3 +40,6 @@ @@ -40,3 +40,6 @@
40 .prepend-top-10 { 40 .prepend-top-10 {
41 margin-top:10px; 41 margin-top:10px;
42 } 42 }
  43 +.no-borders {
  44 + border:none;
  45 +}
app/assets/stylesheets/issues.css.scss
@@ -48,3 +48,21 @@ @@ -48,3 +48,21 @@
48 width:100%; 48 width:100%;
49 .data p { font-size:16px } 49 .data p { font-size:16px }
50 } 50 }
  51 +
  52 +#issue_assignee_id {
  53 + width:300px;
  54 +}
  55 +
  56 +.issue-form-holder .ui-box .data {
  57 + margin: 0;
  58 + padding: 0;
  59 +}
  60 +
  61 +body.project-page .issue-form-holder table.no-borders tr,
  62 +body.project-page .issue-form-holder table.no-borders td
  63 +{
  64 + &:hover {
  65 + background:none;
  66 + }
  67 +}
  68 +
app/assets/stylesheets/projects.css.scss
@@ -387,3 +387,10 @@ body.dashboard.project-page .news-feed .project-updates a.project-update span.up @@ -387,3 +387,10 @@ body.dashboard.project-page .news-feed .project-updates a.project-update span.up
387 body.project-page .team_member_new .span-6, .team_member_edit .span-6{ padding:10px 0; } 387 body.project-page .team_member_new .span-6, .team_member_edit .span-6{ padding:10px 0; }
388 388
389 body.projects-page input.text.git-url.project_list_url { width:165px; } 389 body.projects-page input.text.git-url.project_list_url { width:165px; }
  390 +
  391 +
  392 +
  393 +body.project-page table.no-borders tr,
  394 +body.project-page table.no-borders td{
  395 + border:none;
  396 +}
app/views/issues/_form.html.haml
1 -%div  
2 - = form_for [@project, @issue], :remote => "true" do |f|  
3 - -if @issue.errors.any?  
4 - %ul  
5 - - @issue.errors.full_messages.each do |msg|  
6 - %li= msg 1 +%div.issue-form-holder
  2 + .issue-show-holder.ui-box
  3 + %h3
  4 + = @issue.new_record? ? "New issue" : "Edit Issue ##{@issue.id}"
  5 + - unless @issue.new_record?
  6 + .right
  7 + - if @issue.closed
  8 + %span.tag.high Resolved
  9 + - else
  10 + %span.tag.today Open
  11 + = form_for [@project, @issue], :remote => "true" do |f|
  12 + .data
  13 + %table.no-borders
  14 + -if @issue.errors.any?
  15 + %tr
  16 + %td Errors
  17 + %td
  18 + #error_explanation
  19 + - @issue.errors.full_messages.each do |msg|
  20 + %span= msg
  21 + %br
7 22
8 - .form-row  
9 - = f.label :title  
10 - = f.text_area :title, :style => "width:450px; height:100px", :maxlength => 255  
11 - .form-row  
12 - = f.label :assignee_id  
13 - = f.select(:assignee_id, @project.users.all.collect {|p| [ p.name, p.id ] }, { :include_blank => "Select user" })  
14 - .form-row  
15 - = f.label :critical, "Critical"  
16 - %br  
17 - = f.check_box :critical  
18 - - unless @issue.new_record?  
19 - .form-row  
20 - = f.label :closed  
21 - %br  
22 - = f.check_box :closed  
23 - .form-row  
24 - = f.submit 'Save', :class => "grey-button" 23 + %tr
  24 + %td= f.label :title
  25 + %td= f.text_area :title, :style => "width:450px; height:100px", :maxlength => 255
  26 +
  27 + %tr
  28 + %td= f.label :assignee_id
  29 + %td= f.select(:assignee_id, @project.users.all.collect {|p| [ p.name, p.id ] }, { :include_blank => "Select user" })
  30 +
  31 + %tr
  32 + %td= f.label :critical, "Critical"
  33 + %td= f.check_box :critical
  34 +
  35 + - unless @issue.new_record?
  36 + %tr
  37 + %td= f.label :closed
  38 + %td= f.check_box :closed
  39 + .buttons
  40 + = f.submit 'Save', :class => "grey-button"
  41 + .right
  42 + - if request.xhr?
  43 + = link_to_function "Back", "backToIssues();", :class => "grey-button"
  44 + - else
  45 + = link_to "Back", [@project, @issue], :class => "grey-button"
app/views/issues/create.js.haml
1 - if @issue.valid? 1 - if @issue.valid?
2 :plain 2 :plain
3 - $("#new_issue_dialog").dialog("close"); 3 + switchFromNewIssue();
4 $("#issues-table").prepend("#{escape_javascript(render(:partial => 'show', :locals => {:issue => @issue} ))}"); 4 $("#issues-table").prepend("#{escape_javascript(render(:partial => 'show', :locals => {:issue => @issue} ))}");
5 $.ajax({type: "GET", url: location.href, dataType: "script"}); 5 $.ajax({type: "GET", url: location.href, dataType: "script"});
6 - else 6 - else
7 :plain 7 :plain
8 $("#new_issue_dialog").empty(); 8 $("#new_issue_dialog").empty();
9 $("#new_issue_dialog").append("#{escape_javascript(render('form'))}"); 9 $("#new_issue_dialog").append("#{escape_javascript(render('form'))}");
10 - $('select#issue_assignee_id').selectmenu({width:300}); 10 + $('select#issue_assignee_id').chosen();
app/views/issues/edit.html.haml
1 -%div.issue-form-holder  
2 - = form_for [@project, @issue] do |f|  
3 - -if @issue.errors.any?  
4 - %ul  
5 - - @issue.errors.full_messages.each do |msg|  
6 - %li= msg  
7 -  
8 - %table  
9 - %thead  
10 - %th Name  
11 - %th Value  
12 - %tr  
13 - %td= f.label :title  
14 - %td= f.text_area :title, :style => "width:450px; height:100px", :maxlength => 255  
15 - %tr  
16 - %td= f.label :assignee_id  
17 - %td= f.select(:assignee_id, @project.users.all.collect {|p| [ p.name, p.id ] }, { :include_blank => "Select user" })  
18 - -#%tr  
19 - %td= f.label :branch_name  
20 - %td= f.select(:branch_name, @project.heads.map(&:name), { :include_blank => "Select git branch" })  
21 - %tr  
22 - %td  
23 - = f.label :critical, "Critical"  
24 - %br  
25 - %td= f.check_box :critical  
26 - - unless @issue.new_record?  
27 - %tr  
28 - %td= f.label :closed  
29 - %td= f.check_box :closed  
30 - = f.submit 'Save', :class => "grey-button" 1 += render "form"
31 2
32 :javascript 3 :javascript
33 $(function(){ 4 $(function(){
34 - $('select#issue_branch_name').selectmenu({width:300});  
35 - $('select#issue_assignee_id').selectmenu({width:300}); 5 + $('select#issue_assignee_id').chosen();
36 }); 6 });
37 7
app/views/issues/edit.js.haml
1 :plain 1 :plain
2 var edit_issue_dialog = $("<div id='edit_issue_dialog'></div>"); 2 var edit_issue_dialog = $("<div id='edit_issue_dialog'></div>");
3 edit_issue_dialog.html("#{escape_javascript(render('form'))}"); 3 edit_issue_dialog.html("#{escape_javascript(render('form'))}");
4 - $(edit_issue_dialog).dialog({  
5 - width: 500,  
6 - resizable: false,  
7 - draggable: false,  
8 - title: "Issue ##{@issue.id} #{"[CLOSED]" if @issue.closed}",  
9 - close: function(event, ui) { $("#edit_issue_dialog").remove();},  
10 - modal: true  
11 - });  
12 - $('select#issue_assignee_id').selectmenu({width:300}); 4 + switchToEditIssue(edit_issue_dialog);
  5 +
app/views/issues/new.html.haml 0 → 100644
@@ -0,0 +1,7 @@ @@ -0,0 +1,7 @@
  1 += render "form"
  2 +
  3 +:javascript
  4 + $(function(){
  5 + $('select#issue_assignee_id').chosen();
  6 + });
  7 +
app/views/issues/new.js.haml
1 :plain 1 :plain
2 var new_issue_dialog = $("<div id='new_issue_dialog'></div>"); 2 var new_issue_dialog = $("<div id='new_issue_dialog'></div>");
3 new_issue_dialog.html("#{escape_javascript(render('form'))}"); 3 new_issue_dialog.html("#{escape_javascript(render('form'))}");
4 - $(new_issue_dialog).dialog({  
5 - width: 500,  
6 - resizable: false,  
7 - draggable: false,  
8 - title: "Add new issue",  
9 - modala: true,  
10 - close: function(event, ui) { $("#new_issue_dialog").remove();}  
11 - });  
12 - $('select#issue_assignee_id').selectmenu({width:300}); 4 + switchToNewIssue(new_issue_dialog);
app/views/issues/update.js.haml
@@ -5,10 +5,10 @@ @@ -5,10 +5,10 @@
5 - else 5 - else
6 - if @issue.valid? 6 - if @issue.valid?
7 :plain 7 :plain
8 - $("#edit_issue_dialog").dialog("close");  
9 updatePage(); 8 updatePage();
  9 + switchFromEditIssue();
10 - else 10 - else
11 :plain 11 :plain
12 $("#edit_issue_dialog").empty(); 12 $("#edit_issue_dialog").empty();
13 $("#edit_issue_dialog").append("#{escape_javascript(render('form'))}"); 13 $("#edit_issue_dialog").append("#{escape_javascript(render('form'))}");
14 - $('select#issue_assignee_id').selectmenu({width:300}); 14 + $('select#issue_assignee_id').chosen();
spec/requests/issues_spec.rb
@@ -95,18 +95,16 @@ describe &quot;Issues&quot; do @@ -95,18 +95,16 @@ describe &quot;Issues&quot; do
95 click_link "New Issue" 95 click_link "New Issue"
96 end 96 end
97 97
98 - it "should open new issue popup" do  
99 - page.should have_content("Add new issue") 98 + it "should open new issue form" do
  99 + page.should have_content("New issue")
100 end 100 end
101 101
102 describe "fill in" do 102 describe "fill in" do
103 describe 'assign to me' do 103 describe 'assign to me' do
104 before do 104 before do
105 fill_in "issue_title", :with => "bug 345" 105 fill_in "issue_title", :with => "bug 345"
106 - click_link "Select user"  
107 - within "#issue_assignee_id-menu" do  
108 - click_link @user.name  
109 - end 106 + page.execute_script("$('#issue_assignee_id').show();")
  107 + select @user.name, :from => "issue_assignee_id"
110 end 108 end
111 109
112 it { expect { click_button "Save" }.to change {Issue.count}.by(1) } 110 it { expect { click_button "Save" }.to change {Issue.count}.by(1) }
@@ -129,10 +127,8 @@ describe &quot;Issues&quot; do @@ -129,10 +127,8 @@ describe &quot;Issues&quot; do
129 describe 'assign to other' do 127 describe 'assign to other' do
130 before do 128 before do
131 fill_in "issue_title", :with => "bug 345" 129 fill_in "issue_title", :with => "bug 345"
132 - click_link "Select user"  
133 - within "#issue_assignee_id-menu" do  
134 - click_link @user2.name  
135 - end 130 + page.execute_script("$('#issue_assignee_id').show();")
  131 + select @user2.name, :from => "issue_assignee_id"
136 end 132 end
137 133
138 it { expect { click_button "Save" }.to change {Issue.count}.by(1) } 134 it { expect { click_button "Save" }.to change {Issue.count}.by(1) }