-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Load previous and next issue links asynchronously
- Loading branch information
Showing
7 changed files
with
161 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,4 @@ | ||
Deface::Override.new :virtual_path => 'issues/_action_menu_edit', | ||
:name => 'prevents-render-edit-partial-render-it-only-on-edit-button-click', | ||
:replace => "erb[loud]:contains(\"render :partial => 'edit'\")", | ||
:text => <<-RENDER_PARTIAL | ||
<% unless Setting.plugin_redmine_tiny_features.key?('load_issue_edit_form_asynchronously') %> | ||
<%= render :partial => 'edit' %> | ||
<% else %> | ||
<%# These header tags are not included if the partial is not preloaded %> | ||
<% content_for :header_tags do %> | ||
<%= javascript_include_tag 'attachments' %> | ||
<% end %> | ||
<script> | ||
function loadIssueEditForm(id){ | ||
if ($('#issue-form').length < 1) { | ||
$.ajax({ | ||
url: "<%= render_form_by_ajax_path(@issue.id) %>", | ||
beforeSend: function(){ | ||
$('#ajax-indicator').addClass('bottom'); | ||
}, | ||
success: function(response) { | ||
$('#ajax-indicator').removeClass('bottom'); | ||
if(response){ | ||
$('#update').append(response.html); | ||
$(document).ready(function() { | ||
// for datepicker element, | ||
<% include_calendar_headers_tags %> | ||
// for wikitoolbar element in mode Textile, | ||
setupFileDrop(); | ||
// But for mode visual there is no need to call because it is already called in { $(document).ajaxSuccess/redmine_wysiwyg_editor } | ||
}); | ||
} | ||
},error: function(response) { | ||
$('#ajax-indicator').removeClass('bottom'); | ||
console.error(response); | ||
}, | ||
}); | ||
} | ||
} | ||
$(document).ready(function() { | ||
loadIssueEditForm(); | ||
}); | ||
</script> | ||
<% end %> | ||
RENDER_PARTIAL | ||
Deface::Override.new :virtual_path => 'issues/_action_menu_edit', | ||
:name => 'load-edit-partial-asynchronously', | ||
:replace => "erb[loud]:contains(\"render :partial => 'edit'\")", | ||
:partial => 'issues/load_issue_show_asynchronously' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<% if Setting.plugin_redmine_tiny_features.key?('load_issue_edit_form_asynchronously') == false %> | ||
<%= render :partial => 'edit' %> | ||
<% else %> | ||
<%# These header tags are not included if the partial is not preloaded %> | ||
<% content_for :header_tags do %> | ||
<%= javascript_include_tag 'attachments' %> | ||
<% end %> | ||
<script> | ||
function loadIssueEditForm() { | ||
if ($('#issue-form').length < 1) { | ||
$.ajax({ | ||
url: "<%= render_form_by_ajax_path(@issue.id) %>", | ||
beforeSend: function () { | ||
$('#ajax-indicator').addClass('bottom'); | ||
}, | ||
success: function (response) { | ||
$('#ajax-indicator').removeClass('bottom'); | ||
if (response) { | ||
$('#update').append(response.html); | ||
$(document).ready(function () { | ||
// for datepicker element, | ||
<% include_calendar_headers_tags %> | ||
// for wikitoolbar element in mode Textile, | ||
setupFileDrop(); | ||
// But for mode visual there is no need to call because it is already called in { $(document).ajaxSuccess/redmine_wysiwyg_editor } | ||
}); | ||
} | ||
}, error: function (response) { | ||
$('#ajax-indicator').removeClass('bottom'); | ||
console.error(response); | ||
}, | ||
}); | ||
} | ||
} | ||
|
||
function loadPreviousAndNextIssueIds() { | ||
$.ajax({ | ||
url: "<%= load_previous_and_next_issue_ids_path(@issue.id) %>", | ||
success: function (response) { | ||
if (response) { | ||
$('.issue.details').prepend(response.html); | ||
} | ||
}, error: function (response) { | ||
console.error(response); | ||
}, | ||
}); | ||
} | ||
|
||
$(document).ready(function () { | ||
loadIssueEditForm(); | ||
loadPreviousAndNextIssueIds(); | ||
}); | ||
</script> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<%# Standard Redmine code copied from issues/show.html.erb %> | ||
<%# Must be updated if standard code is updated %> | ||
|
||
<% if @prev_issue_id || @next_issue_id %> | ||
<div class="next-prev-links contextual"> | ||
<%= link_to_if @prev_issue_id, | ||
"\xc2\xab #{l(:label_previous)}", | ||
(@prev_issue_id ? issue_path(@prev_issue_id) : nil), | ||
:title => "##{@prev_issue_id}", | ||
:accesskey => accesskey(:previous) %> | | ||
<% if @issue_position && @issue_count %> | ||
<span class="position"> | ||
<%= link_to_if @query_path, | ||
l(:label_item_position, :position => @issue_position, :count => @issue_count), | ||
@query_path %> | ||
</span> | | ||
<% end %> | ||
<%= link_to_if @next_issue_id, | ||
"#{l(:label_next)} \xc2\xbb", | ||
(@next_issue_id ? issue_path(@next_issue_id) : nil), | ||
:title => "##{@next_issue_id}", | ||
:accesskey => accesskey(:next) %> | ||
</div> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
resources :projects do | ||
put :custom_field_enumerations, :controller => 'project_custom_field_enumerations', action: 'update', as: 'update_custom_field_enumerations' | ||
end | ||
match 'issues/render_form_by_ajax/:id', :controller => 'issues', :action => 'render_form_by_ajax', :via => :get, :as => 'render_form_by_ajax' | ||
match 'queries/author_values_pagination', :controller => 'queries', :action => 'author_values_pagination' , :via => :get, :as => 'author_values_pagination' | ||
match 'queries/assigned_to_values_pagination', :controller => 'queries', :action => 'assigned_to_values_pagination' , :via => :get, :as => 'assigned_to_values_pagination' | ||
get 'issues/render_form_by_ajax/:id', :controller => 'issues', :action => 'render_form_by_ajax', :as => 'render_form_by_ajax' | ||
get 'issues/load_previous_and_next_issue_ids/:id', to: 'issues#load_previous_and_next_issue_ids', as: :load_previous_and_next_issue_ids | ||
get 'queries/author_values_pagination', :controller => 'queries', :action => 'author_values_pagination', :as => 'author_values_pagination' | ||
get 'queries/assigned_to_values_pagination', :controller => 'queries', :action => 'assigned_to_values_pagination', :as => 'assigned_to_values_pagination' | ||
|
||
post 'issues/switch', to: 'issues#switch_display_mode', as: :switch_display_mode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
require 'rails_helper' | ||
|
||
RSpec.describe 'Issues AJAX requests', type: :request do | ||
|
||
fixtures :issues | ||
|
||
let(:issue) { Issue.first } | ||
|
||
describe 'GET /issues/render_form_by_ajax/:id' do | ||
it 'loads the edit form asynchronously' do | ||
get render_form_by_ajax_path(issue.id) | ||
expect(response).to have_http_status(:success) | ||
expect(response.content_type).to include('application/json') | ||
expect(JSON.parse(response.body)).to have_key('html') | ||
end | ||
end | ||
|
||
describe 'GET /issues/load_previous_and_next_issue_ids/:id' do | ||
it 'loads previous and next issue ids asynchronously' do | ||
get load_previous_and_next_issue_ids_path(issue.id) | ||
expect(response).to have_http_status(:success) | ||
expect(response.content_type).to include('application/json') | ||
expect(JSON.parse(response.body)).to have_key('html') | ||
end | ||
end | ||
end |