summaryrefslogtreecommitdiffstats
path: root/app/views/imports
diff options
context:
space:
mode:
authorGo MAEDA <maeda@farend.jp>2019-05-09 07:40:06 +0000
committerGo MAEDA <maeda@farend.jp>2019-05-09 07:40:06 +0000
commitb540046ed7084ba50f5ca280f3ffae0751af8142 (patch)
tree4bc946090d4940a219e84f70ca72c5655de5be42 /app/views/imports
parentbcc60805c97104f44a37b92321d7aa1e5c51b622 (diff)
downloadredmine-b540046ed7084ba50f5ca280f3ffae0751af8142.tar.gz
redmine-b540046ed7084ba50f5ca280f3ffae0751af8142.zip
Generalize issues imports (#28234).
Extend import controller to support arbitrary imports based on Import subclasses. This way, we may add other kinds of imports, by providing some views and a custom import class. This may also be done from within plugins. Patch by Gregor Schmidt. git-svn-id: http://svn.redmine.org/redmine/trunk@18145 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/views/imports')
-rw-r--r--app/views/imports/_issues_fields_mapping.html.erb (renamed from app/views/imports/_fields_mapping.html.erb)2
-rw-r--r--app/views/imports/_issues_mapping.html.erb16
-rw-r--r--app/views/imports/_issues_mapping.js.erb1
-rw-r--r--app/views/imports/_issues_saved_objects.html.erb7
-rw-r--r--app/views/imports/_issues_sidebar.html.erb3
-rw-r--r--app/views/imports/mapping.html.erb23
-rw-r--r--app/views/imports/mapping.js.erb2
-rw-r--r--app/views/imports/new.html.erb7
-rw-r--r--app/views/imports/run.html.erb6
-rw-r--r--app/views/imports/settings.html.erb6
-rw-r--r--app/views/imports/show.html.erb14
11 files changed, 42 insertions, 45 deletions
diff --git a/app/views/imports/_fields_mapping.html.erb b/app/views/imports/_issues_fields_mapping.html.erb
index f59350116..542a956ff 100644
--- a/app/views/imports/_fields_mapping.html.erb
+++ b/app/views/imports/_issues_fields_mapping.html.erb
@@ -54,7 +54,7 @@
</p>
<% @custom_fields.each do |field| %>
<p>
- <label for="import_mapping_cf_<% field.id %>"><%= field.name %></label>
+ <label for="import_mapping_cf_<%= field.id %>"><%= field.name %></label>
<%= mapping_select_tag @import, "cf_#{field.id}" %>
</p>
<% end %>
diff --git a/app/views/imports/_issues_mapping.html.erb b/app/views/imports/_issues_mapping.html.erb
new file mode 100644
index 000000000..dc97d9c3a
--- /dev/null
+++ b/app/views/imports/_issues_mapping.html.erb
@@ -0,0 +1,16 @@
+<fieldset class="box tabular">
+ <legend><%= l(:label_fields_mapping) %></legend>
+ <div id="fields-mapping">
+ <%= render :partial => 'issues_fields_mapping' %>
+ </div>
+</fieldset>
+
+<%= javascript_tag do %>
+ $('#fields-mapping').on('change', '#import_mapping_project_id, #import_mapping_tracker', function(){
+ $.ajax({
+ url: '<%= import_mapping_path(@import, :format => 'js') %>',
+ type: 'post',
+ data: $('#import-form').serialize()
+ });
+ });
+<% end %>
diff --git a/app/views/imports/_issues_mapping.js.erb b/app/views/imports/_issues_mapping.js.erb
new file mode 100644
index 000000000..012ccc537
--- /dev/null
+++ b/app/views/imports/_issues_mapping.js.erb
@@ -0,0 +1 @@
+$('#fields-mapping').html('<%= escape_javascript(render :partial => 'issues_fields_mapping') %>');
diff --git a/app/views/imports/_issues_saved_objects.html.erb b/app/views/imports/_issues_saved_objects.html.erb
new file mode 100644
index 000000000..f708a1c23
--- /dev/null
+++ b/app/views/imports/_issues_saved_objects.html.erb
@@ -0,0 +1,7 @@
+<ul id="saved-items">
+ <% saved_objects.each do |issue| %>
+ <li><%= link_to_issue issue %></li>
+ <% end %>
+</ul>
+
+<p><%= link_to l(:label_issue_view_all), issues_path(:set_filter => 1, :status_id => '*', :issue_id => saved_objects.map(&:id).join(',')) %></p>
diff --git a/app/views/imports/_issues_sidebar.html.erb b/app/views/imports/_issues_sidebar.html.erb
new file mode 100644
index 000000000..e098175ec
--- /dev/null
+++ b/app/views/imports/_issues_sidebar.html.erb
@@ -0,0 +1,3 @@
+<% content_for :sidebar do %>
+ <%= render :partial => 'issues/sidebar' %>
+<% end %>
diff --git a/app/views/imports/mapping.html.erb b/app/views/imports/mapping.html.erb
index 2e225d6c2..1822f2802 100644
--- a/app/views/imports/mapping.html.erb
+++ b/app/views/imports/mapping.html.erb
@@ -1,12 +1,7 @@
-<h2><%= l(:label_import_issues) %></h2>
+<h2><%= import_title %></h2>
<%= form_tag(import_mapping_path(@import), :id => "import-form") do %>
- <fieldset class="box tabular">
- <legend><%= l(:label_fields_mapping) %></legend>
- <div id="fields-mapping">
- <%= render :partial => 'fields_mapping' %>
- </div>
- </fieldset>
+ <%= render :partial => "#{import_partial_prefix}_mapping" %>
<div class="autoscroll">
<fieldset class="box">
@@ -28,25 +23,13 @@
</p>
<% end %>
-<% content_for :sidebar do %>
- <%= render :partial => 'issues/sidebar' %>
-<% end %>
-
+<%= render :partial => "#{import_partial_prefix}_sidebar" %>
<%= javascript_tag do %>
$(document).ready(function() {
- $('#fields-mapping').on('change', '#import_mapping_project_id, #import_mapping_tracker', function(){
- $.ajax({
- url: '<%= import_mapping_path(@import, :format => 'js') %>',
- type: 'post',
- data: $('#import-form').serialize()
- });
- });
-
$('#import-form').submit(function(){
$('#import-details').show().addClass('ajax-loading');
$('#import-progress').progressbar({value: 0, max: <%= @import.total_items || 0 %>});
});
-
});
<% end %>
diff --git a/app/views/imports/mapping.js.erb b/app/views/imports/mapping.js.erb
index 8fdf14a36..4a4358427 100644
--- a/app/views/imports/mapping.js.erb
+++ b/app/views/imports/mapping.js.erb
@@ -1 +1 @@
-$('#fields-mapping').html('<%= escape_javascript(render :partial => 'fields_mapping') %>');
+<%= render :partial => "#{import_partial_prefix}_mapping" %>
diff --git a/app/views/imports/new.html.erb b/app/views/imports/new.html.erb
index e20be353a..41b27d6c9 100644
--- a/app/views/imports/new.html.erb
+++ b/app/views/imports/new.html.erb
@@ -1,6 +1,7 @@
-<h2><%= l(:label_import_issues) %></h2>
+<h2><%= import_title %></h2>
<%= form_tag(imports_path, :multipart => true) do %>
+ <%= hidden_field_tag 'type', @import.type %>
<fieldset class="box">
<legend><%= l(:label_select_file_to_import) %> (CSV)</legend>
<p>
@@ -10,6 +11,4 @@
<p><%= submit_tag l(:label_next).html_safe + " &#187;".html_safe, :name => nil %></p>
<% end %>
-<% content_for :sidebar do %>
- <%= render :partial => 'issues/sidebar' %>
-<% end %>
+<%= render :partial => "#{import_partial_prefix}_sidebar" %>
diff --git a/app/views/imports/run.html.erb b/app/views/imports/run.html.erb
index 2a723537e..50b47836d 100644
--- a/app/views/imports/run.html.erb
+++ b/app/views/imports/run.html.erb
@@ -1,12 +1,10 @@
-<h2><%= l(:label_import_issues) %></h2>
+<h2><%= import_title %></h2>
<div id="import-details">
<div id="import-progress"><div id="progress-label">0 / <%= @import.total_items.to_i %></div></div>
</div>
-<% content_for :sidebar do %>
- <%= render :partial => 'issues/sidebar' %>
-<% end %>
+<%= render :partial => "#{import_partial_prefix}_sidebar" %>
<%= javascript_tag do %>
$(document).ready(function() {
diff --git a/app/views/imports/settings.html.erb b/app/views/imports/settings.html.erb
index 6edfb10af..0fbb01857 100644
--- a/app/views/imports/settings.html.erb
+++ b/app/views/imports/settings.html.erb
@@ -1,4 +1,4 @@
-<h2><%= l(:label_import_issues) %></h2>
+<h2><%= import_title %></h2>
<%= form_tag(import_settings_path(@import), :id => "import-form") do %>
<fieldset class="box tabular">
@@ -25,6 +25,4 @@
<p><%= submit_tag l(:label_next).html_safe + " &#187;".html_safe, :name => nil %></p>
<% end %>
-<% content_for :sidebar do %>
- <%= render :partial => 'issues/sidebar' %>
-<% end %>
+<%= render :partial => "#{import_partial_prefix}_sidebar" %>
diff --git a/app/views/imports/show.html.erb b/app/views/imports/show.html.erb
index 19c874c91..ca963ab37 100644
--- a/app/views/imports/show.html.erb
+++ b/app/views/imports/show.html.erb
@@ -1,15 +1,9 @@
-<h2><%= l(:label_import_issues) %></h2>
+<h2><%= import_title %></h2>
<% if @import.saved_items.count > 0 %>
<p><%= l(:notice_import_finished, :count => @import.saved_items.count) %>:</p>
- <ul id="saved-items">
- <% @import.saved_objects.each do |issue| %>
- <li><%= link_to_issue issue %></li>
- <% end %>
- </ul>
-
- <p><%= link_to l(:label_issue_view_all), issues_path(:set_filter => 1, :status_id => '*', :issue_id => @import.saved_objects.map(&:id).join(',')) %></p>
+ <%= render :partial => "#{import_partial_prefix}_saved_objects", :locals => { saved_objects: @import.saved_objects } %>
<% end %>
<% if @import.unsaved_items.count > 0 %>
@@ -33,6 +27,4 @@
</table>
<% end %>
-<% content_for :sidebar do %>
- <%= render :partial => 'issues/sidebar' %>
-<% end %>
+<%= render :partial => "#{import_partial_prefix}_sidebar" %>