Commit da10cad1da7039a346f1f0d32325d8be4c3a1c56
1 parent
596e64e5
Exists in
master
and in
4 other branches
Drop rjs from Issues#index
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Showing
6 changed files
with
29 additions
and
25 deletions
Show diff stats
app/assets/javascripts/issues.js.coffee
@@ -22,7 +22,7 @@ | @@ -22,7 +22,7 @@ | ||
22 | backgroundColor: '#DDD' | 22 | backgroundColor: '#DDD' |
23 | opacity: .4 | 23 | opacity: .4 |
24 | ) | 24 | ) |
25 | - | 25 | + |
26 | reload: -> | 26 | reload: -> |
27 | Issues.initSelects() | 27 | Issues.initSelects() |
28 | Issues.initChecks() | 28 | Issues.initChecks() |
@@ -54,7 +54,16 @@ | @@ -54,7 +54,16 @@ | ||
54 | unless terms is last_terms | 54 | unless terms is last_terms |
55 | last_terms = terms | 55 | last_terms = terms |
56 | if terms.length >= 2 or terms.length is 0 | 56 | if terms.length >= 2 or terms.length is 0 |
57 | - form.submit() | 57 | + $.ajax |
58 | + type: "GET" | ||
59 | + url: location.href | ||
60 | + data: "issue_search=" + terms | ||
61 | + complete: -> | ||
62 | + $(".loading").hide() | ||
63 | + success: (data) -> | ||
64 | + $('.issues-holder').html(data.html) | ||
65 | + Issues.reload() | ||
66 | + dataType: "json" | ||
58 | 67 | ||
59 | checkChanged: -> | 68 | checkChanged: -> |
60 | checked_issues = $(".selected_issue:checked") | 69 | checked_issues = $(".selected_issue:checked") |
app/controllers/application_controller.rb
@@ -188,4 +188,12 @@ class ApplicationController < ActionController::Base | @@ -188,4 +188,12 @@ class ApplicationController < ActionController::Base | ||
188 | count: count | 188 | count: count |
189 | } | 189 | } |
190 | end | 190 | end |
191 | + | ||
192 | + def view_to_html_string(partial) | ||
193 | + render_to_string( | ||
194 | + partial, | ||
195 | + layout: false, | ||
196 | + formats: [:html] | ||
197 | + ) | ||
198 | + end | ||
191 | end | 199 | end |
app/controllers/projects/issues_controller.rb
@@ -11,7 +11,7 @@ class Projects::IssuesController < Projects::ApplicationController | @@ -11,7 +11,7 @@ class Projects::IssuesController < Projects::ApplicationController | ||
11 | # Allow modify issue | 11 | # Allow modify issue |
12 | before_filter :authorize_modify_issue!, only: [:edit, :update] | 12 | before_filter :authorize_modify_issue!, only: [:edit, :update] |
13 | 13 | ||
14 | - respond_to :js, :html | 14 | + respond_to :html |
15 | 15 | ||
16 | def index | 16 | def index |
17 | terms = params['issue_search'] | 17 | terms = params['issue_search'] |
@@ -28,9 +28,13 @@ class Projects::IssuesController < Projects::ApplicationController | @@ -28,9 +28,13 @@ class Projects::IssuesController < Projects::ApplicationController | ||
28 | 28 | ||
29 | 29 | ||
30 | respond_to do |format| | 30 | respond_to do |format| |
31 | - format.html # index.html.erb | ||
32 | - format.js | 31 | + format.html |
33 | format.atom { render layout: false } | 32 | format.atom { render layout: false } |
33 | + format.json do | ||
34 | + render json: { | ||
35 | + html: view_to_html_string("projects/issues/_issues") | ||
36 | + } | ||
37 | + end | ||
34 | end | 38 | end |
35 | end | 39 | end |
36 | 40 | ||
@@ -48,10 +52,7 @@ class Projects::IssuesController < Projects::ApplicationController | @@ -48,10 +52,7 @@ class Projects::IssuesController < Projects::ApplicationController | ||
48 | @target_type = :issue | 52 | @target_type = :issue |
49 | @target_id = @issue.id | 53 | @target_id = @issue.id |
50 | 54 | ||
51 | - respond_to do |format| | ||
52 | - format.html | ||
53 | - format.js | ||
54 | - end | 55 | + respond_with(@issue) |
55 | end | 56 | end |
56 | 57 | ||
57 | def create | 58 | def create |
app/controllers/projects/notes_controller.rb
@@ -17,14 +17,8 @@ class Projects::NotesController < Projects::ApplicationController | @@ -17,14 +17,8 @@ class Projects::NotesController < Projects::ApplicationController | ||
17 | respond_to do |format| | 17 | respond_to do |format| |
18 | format.html { redirect_to :back } | 18 | format.html { redirect_to :back } |
19 | format.json do | 19 | format.json do |
20 | - html = render_to_string( | ||
21 | - "projects/notes/_notes", | ||
22 | - layout: false, | ||
23 | - formats: [:html] | ||
24 | - ) | ||
25 | - | ||
26 | render json: { | 20 | render json: { |
27 | - html: html, | 21 | + html: view_to_html_string("projects/notes/_notes") |
28 | } | 22 | } |
29 | end | 23 | end |
30 | end | 24 | end |
app/views/projects/issues/_head.html.haml
@@ -21,9 +21,5 @@ | @@ -21,9 +21,5 @@ | ||
21 | = link_to new_project_issue_path(@project, issue: { assignee_id: params[:assignee_id], milestone_id: params[:milestone_id]}), class: "btn btn-new pull-right", title: "New Issue", id: "new_issue_link" do | 21 | = link_to new_project_issue_path(@project, issue: { assignee_id: params[:assignee_id], milestone_id: params[:milestone_id]}), class: "btn btn-new pull-right", title: "New Issue", id: "new_issue_link" do |
22 | %i.icon-plus | 22 | %i.icon-plus |
23 | New Issue | 23 | New Issue |
24 | - = form_tag project_issues_path(@project), method: :get, remote: true, id: "issue_search_form", class: 'pull-right issue-search-form' do | ||
25 | - = hidden_field_tag :status, params[:status], id: 'search_status' | ||
26 | - = hidden_field_tag :assignee_id, params[:assignee_id], id: 'search_assignee_id' | ||
27 | - = hidden_field_tag :milestone_id, params[:milestone_id], id: 'search_milestone_id' | ||
28 | - = hidden_field_tag :label_name, params[:label_name], id: 'search_label_name' | 24 | + = form_tag project_issues_path(@project), method: :get, id: "issue_search_form", class: 'pull-right issue-search-form' do |
29 | = search_field_tag :issue_search, nil, { placeholder: 'Filter by title or description', class: 'input-xpadding issue_search input-xlarge append-right-10 search-text-input' } | 25 | = search_field_tag :issue_search, nil, { placeholder: 'Filter by title or description', class: 'input-xpadding issue_search input-xlarge append-right-10 search-text-input' } |
app/views/projects/issues/index.js.haml