Commit 477e9f87e14a8b7a04355453283d49e4e14fcafb

Authored by Dmitriy Zaporozhets
2 parents ff25cb93 da10cad1

Merge branch 'drop_rjs_2' of /home/git/repositories/gitlab/gitlabhq

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/assets/javascripts/notes.js
@@ -6,7 +6,7 @@ var NoteList = { @@ -6,7 +6,7 @@ var NoteList = {
6 target_type: null, 6 target_type: null,
7 7
8 init: function(tid, tt, path) { 8 init: function(tid, tt, path) {
9 - NoteList.notes_path = path + ".js"; 9 + NoteList.notes_path = path + ".json";
10 NoteList.target_id = tid; 10 NoteList.target_id = tid;
11 NoteList.target_type = tt; 11 NoteList.target_type = tt;
12 NoteList.target_params = "target_type=" + NoteList.target_type + "&target_id=" + NoteList.target_id; 12 NoteList.target_params = "target_type=" + NoteList.target_type + "&target_id=" + NoteList.target_id;
@@ -411,7 +411,10 @@ var NoteList = { @@ -411,7 +411,10 @@ var NoteList = {
411 data: NoteList.target_params, 411 data: NoteList.target_params,
412 complete: function(){ $('.js-notes-busy').removeClass("loading")}, 412 complete: function(){ $('.js-notes-busy').removeClass("loading")},
413 beforeSend: function() { $('.js-notes-busy').addClass("loading") }, 413 beforeSend: function() { $('.js-notes-busy').addClass("loading") },
414 - dataType: "script" 414 + success: function(data) {
  415 + NoteList.setContent(data.html);
  416 + },
  417 + dataType: "json"
415 }); 418 });
416 }, 419 },
417 420
@@ -419,7 +422,7 @@ var NoteList = { @@ -419,7 +422,7 @@ var NoteList = {
419 * Called in response to getContent(). 422 * Called in response to getContent().
420 * Replaces the content of #notes-list with the given html. 423 * Replaces the content of #notes-list with the given html.
421 */ 424 */
422 - setContent: function(newNoteIds, html) { 425 + setContent: function(html) {
423 $("#notes-list").html(html); 426 $("#notes-list").html(html);
424 }, 427 },
425 428
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
@@ -14,7 +14,14 @@ class Projects::NotesController < Projects::ApplicationController @@ -14,7 +14,14 @@ class Projects::NotesController < Projects::ApplicationController
14 @discussions = discussions_from_notes 14 @discussions = discussions_from_notes
15 end 15 end
16 16
17 - respond_with(@notes) 17 + respond_to do |format|
  18 + format.html { redirect_to :back }
  19 + format.json do
  20 + render json: {
  21 + html: view_to_html_string("projects/notes/_notes")
  22 + }
  23 + end
  24 + end
18 end 25 end
19 26
20 def create 27 def create
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
@@ -1,4 +0,0 @@ @@ -1,4 +0,0 @@
1 -:plain  
2 - $('.issues-holder').html("#{escape_javascript(render('issues'))}");  
3 - History.replaceState({path: "#{request.url}"}, document.title, "#{request.url}");  
4 - Issues.reload();  
app/views/projects/notes/index.js.haml
@@ -1,4 +0,0 @@ @@ -1,4 +0,0 @@
1 -- unless @notes.blank?  
2 - var notesHtml = "#{escape_javascript(render 'projects/notes/notes')}";  
3 - - new_note_ids = @notes.map(&:id)  
4 - NoteList.setContent(#{new_note_ids}, notesHtml);  
config/initializers/1_settings.rb
@@ -30,7 +30,7 @@ class Settings < Settingslogic @@ -30,7 +30,7 @@ class Settings < Settingslogic
30 gitlab.relative_url_root 30 gitlab.relative_url_root
31 ].join('') 31 ].join('')
32 end 32 end
33 - 33 +
34 # check that values in `current` (string or integer) is a contant in `modul`. 34 # check that values in `current` (string or integer) is a contant in `modul`.
35 def verify_constant_array(modul, current, default) 35 def verify_constant_array(modul, current, default)
36 values = default || [] 36 values = default || []