summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2013-11-29 14:21:26 +0000
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2013-11-29 14:21:26 +0000
commit477e9f87e14a8b7a04355453283d49e4e14fcafb (patch)
tree6cd1c557d9f3ff23c1504cf2db0550a15a69588c
parentff25cb934beac5189f9d80341873bba8d635d537 (diff)
parentda10cad1da7039a346f1f0d32325d8be4c3a1c56 (diff)
downloadgitlab-ce-477e9f87e14a8b7a04355453283d49e4e14fcafb.tar.gz
Merge branch 'drop_rjs_2' of /home/git/repositories/gitlab/gitlabhq
-rw-r--r--app/assets/javascripts/issues.js.coffee13
-rw-r--r--app/assets/javascripts/notes.js9
-rw-r--r--app/controllers/application_controller.rb8
-rw-r--r--app/controllers/projects/issues_controller.rb15
-rw-r--r--app/controllers/projects/notes_controller.rb9
-rw-r--r--app/views/projects/issues/_head.html.haml6
-rw-r--r--app/views/projects/issues/index.js.haml4
-rw-r--r--app/views/projects/notes/index.js.haml4
-rw-r--r--config/initializers/1_settings.rb2
9 files changed, 43 insertions, 27 deletions
diff --git a/app/assets/javascripts/issues.js.coffee b/app/assets/javascripts/issues.js.coffee
index 67d9498c50a..c273ddbd391 100644
--- a/app/assets/javascripts/issues.js.coffee
+++ b/app/assets/javascripts/issues.js.coffee
@@ -22,7 +22,7 @@
backgroundColor: '#DDD'
opacity: .4
)
-
+
reload: ->
Issues.initSelects()
Issues.initChecks()
@@ -54,7 +54,16 @@
unless terms is last_terms
last_terms = terms
if terms.length >= 2 or terms.length is 0
- form.submit()
+ $.ajax
+ type: "GET"
+ url: location.href
+ data: "issue_search=" + terms
+ complete: ->
+ $(".loading").hide()
+ success: (data) ->
+ $('.issues-holder').html(data.html)
+ Issues.reload()
+ dataType: "json"
checkChanged: ->
checked_issues = $(".selected_issue:checked")
diff --git a/app/assets/javascripts/notes.js b/app/assets/javascripts/notes.js
index defbf81f580..e39bfc0f792 100644
--- a/app/assets/javascripts/notes.js
+++ b/app/assets/javascripts/notes.js
@@ -6,7 +6,7 @@ var NoteList = {
target_type: null,
init: function(tid, tt, path) {
- NoteList.notes_path = path + ".js";
+ NoteList.notes_path = path + ".json";
NoteList.target_id = tid;
NoteList.target_type = tt;
NoteList.target_params = "target_type=" + NoteList.target_type + "&target_id=" + NoteList.target_id;
@@ -411,7 +411,10 @@ var NoteList = {
data: NoteList.target_params,
complete: function(){ $('.js-notes-busy').removeClass("loading")},
beforeSend: function() { $('.js-notes-busy').addClass("loading") },
- dataType: "script"
+ success: function(data) {
+ NoteList.setContent(data.html);
+ },
+ dataType: "json"
});
},
@@ -419,7 +422,7 @@ var NoteList = {
* Called in response to getContent().
* Replaces the content of #notes-list with the given html.
*/
- setContent: function(newNoteIds, html) {
+ setContent: function(html) {
$("#notes-list").html(html);
},
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 94ce8e0616c..a83d6dfed8d 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -188,4 +188,12 @@ class ApplicationController < ActionController::Base
count: count
}
end
+
+ def view_to_html_string(partial)
+ render_to_string(
+ partial,
+ layout: false,
+ formats: [:html]
+ )
+ end
end
diff --git a/app/controllers/projects/issues_controller.rb b/app/controllers/projects/issues_controller.rb
index e03d54cddc1..5dcdba5d388 100644
--- a/app/controllers/projects/issues_controller.rb
+++ b/app/controllers/projects/issues_controller.rb
@@ -11,7 +11,7 @@ class Projects::IssuesController < Projects::ApplicationController
# Allow modify issue
before_filter :authorize_modify_issue!, only: [:edit, :update]
- respond_to :js, :html
+ respond_to :html
def index
terms = params['issue_search']
@@ -28,9 +28,13 @@ class Projects::IssuesController < Projects::ApplicationController
respond_to do |format|
- format.html # index.html.erb
- format.js
+ format.html
format.atom { render layout: false }
+ format.json do
+ render json: {
+ html: view_to_html_string("projects/issues/_issues")
+ }
+ end
end
end
@@ -48,10 +52,7 @@ class Projects::IssuesController < Projects::ApplicationController
@target_type = :issue
@target_id = @issue.id
- respond_to do |format|
- format.html
- format.js
- end
+ respond_with(@issue)
end
def create
diff --git a/app/controllers/projects/notes_controller.rb b/app/controllers/projects/notes_controller.rb
index 8214163c315..2738a99459d 100644
--- a/app/controllers/projects/notes_controller.rb
+++ b/app/controllers/projects/notes_controller.rb
@@ -14,7 +14,14 @@ class Projects::NotesController < Projects::ApplicationController
@discussions = discussions_from_notes
end
- respond_with(@notes)
+ respond_to do |format|
+ format.html { redirect_to :back }
+ format.json do
+ render json: {
+ html: view_to_html_string("projects/notes/_notes")
+ }
+ end
+ end
end
def create
diff --git a/app/views/projects/issues/_head.html.haml b/app/views/projects/issues/_head.html.haml
index 8ae9ba57d2a..a44db78a92b 100644
--- a/app/views/projects/issues/_head.html.haml
+++ b/app/views/projects/issues/_head.html.haml
@@ -21,9 +21,5 @@
= 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
%i.icon-plus
New Issue
- = form_tag project_issues_path(@project), method: :get, remote: true, id: "issue_search_form", class: 'pull-right issue-search-form' do
- = hidden_field_tag :status, params[:status], id: 'search_status'
- = hidden_field_tag :assignee_id, params[:assignee_id], id: 'search_assignee_id'
- = hidden_field_tag :milestone_id, params[:milestone_id], id: 'search_milestone_id'
- = hidden_field_tag :label_name, params[:label_name], id: 'search_label_name'
+ = form_tag project_issues_path(@project), method: :get, id: "issue_search_form", class: 'pull-right issue-search-form' do
= 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' }
diff --git a/app/views/projects/issues/index.js.haml b/app/views/projects/issues/index.js.haml
deleted file mode 100644
index 1be6a64f535..00000000000
--- a/app/views/projects/issues/index.js.haml
+++ /dev/null
@@ -1,4 +0,0 @@
-:plain
- $('.issues-holder').html("#{escape_javascript(render('issues'))}");
- History.replaceState({path: "#{request.url}"}, document.title, "#{request.url}");
- Issues.reload();
diff --git a/app/views/projects/notes/index.js.haml b/app/views/projects/notes/index.js.haml
deleted file mode 100644
index 6c4ed203497..00000000000
--- a/app/views/projects/notes/index.js.haml
+++ /dev/null
@@ -1,4 +0,0 @@
-- unless @notes.blank?
- var notesHtml = "#{escape_javascript(render 'projects/notes/notes')}";
- - new_note_ids = @notes.map(&:id)
- NoteList.setContent(#{new_note_ids}, notesHtml);
diff --git a/config/initializers/1_settings.rb b/config/initializers/1_settings.rb
index 06e05714fdf..2b13bb51e02 100644
--- a/config/initializers/1_settings.rb
+++ b/config/initializers/1_settings.rb
@@ -30,7 +30,7 @@ class Settings < Settingslogic
gitlab.relative_url_root
].join('')
end
-
+
# check that values in `current` (string or integer) is a contant in `modul`.
def verify_constant_array(modul, current, default)
values = default || []