aboutsummaryrefslogtreecommitdiffstats
path: root/app/views/import_tasks
diff options
context:
space:
mode:
authorLuc Donnet2015-04-22 10:38:49 +0200
committerLuc Donnet2015-04-22 10:38:49 +0200
commit42c570ba88f073d0082b948ced1e3b6f57868afe (patch)
tree9221feb52585362b8ec6a53baef4a7254747e178 /app/views/import_tasks
parent75b5d7d86f6b5a26b7f88eb7c6b788d59163ef5b (diff)
downloadchouette-core-42c570ba88f073d0082b948ced1e3b6f57868afe.tar.bz2
Update import use
Diffstat (limited to 'app/views/import_tasks')
-rw-r--r--app/views/import_tasks/_import_task.erb30
-rw-r--r--app/views/import_tasks/_import_task.html.erb13
-rw-r--r--app/views/import_tasks/_import_tasks.html.erb9
-rw-r--r--app/views/import_tasks/_neptune_import.html.erb1
-rw-r--r--app/views/import_tasks/_results_dashboard.html.erb68
-rw-r--r--app/views/import_tasks/index.html.erb12
-rw-r--r--app/views/import_tasks/index.js.erb1
-rw-r--r--app/views/import_tasks/new.html.erb38
-rw-r--r--app/views/import_tasks/show.html.erb22
-rw-r--r--app/views/import_tasks/show.js.coffee41
10 files changed, 20 insertions, 215 deletions
diff --git a/app/views/import_tasks/_import_task.erb b/app/views/import_tasks/_import_task.erb
deleted file mode 100644
index 7ba2c1058..000000000
--- a/app/views/import_tasks/_import_task.erb
+++ /dev/null
@@ -1,30 +0,0 @@
-<div id="index_item" class="panel panel-default">
- <div class="panel-heading">
- <div class="panel-title clearfix">
- <span class="pull-right">
- <%= link_to referential_import_task_path(@referential, import_task), :method => :delete, :data => {:confirm => t('import_tasks.actions.destroy_confirm')}, :class => "btn btn-danger btn-sm" do %>
- <span class="fa fa-trash-o"></span>
- <% end %>
- </span>
- <h5>
- <%= link_to( referential_import_task_path(@referential, import_task), :class => "preview", :title => "#{ImportTask.model_name.human.capitalize} #{import_task.name}") do %>
- <span class="name">
- <% if import_task.save_requested? %><i class="fa fa-save"></i><% end %> <%= truncate(import_task.name, :length => 20) %>
- </span>
- <% end %>
- </h5>
- </div>
- </div>
- <div class="panel-body">
- <p><%= link_to image_tag("icons/file_#{import_task.file_path_extension}.png") + t("import_tasks.show.imported_file"), file_to_import_referential_import_task_path(@referential, import_task) %></p>
- <% if import_task.compliance_check_task.present? %>
- <p><%= link_to image_tag( compliance_icon( import_task)) + t("import_tasks.compliance_check_task"), referential_compliance_check_task_path(@referential, import_task.compliance_check_task) %></p>
- <% end %>
- </div>
- <div class="panel-footer">
- <%= import_progress_bar_tag(import_task) %>
- <div class="history">
- <%= l import_task.created_at, :format => "%d/%m/%Y %H:%M" %> | <%= import_task.user_name %>
- </div>
- </div>
-</div>
diff --git a/app/views/import_tasks/_import_task.html.erb b/app/views/import_tasks/_import_task.html.erb
new file mode 100644
index 000000000..c277d429a
--- /dev/null
+++ b/app/views/import_tasks/_import_task.html.erb
@@ -0,0 +1,13 @@
+<%= form.input :referential_id, :as => :hidden, :value => @referential.id %>
+<%= form.input :user_id, :as => :hidden, :value => current_user.id %>
+<%= form.input :user_name, :as => :hidden, :value => current_user.name %>
+<%= form.input :format, :as => :hidden %>
+<%= form.input :name %>
+<%= form.input :no_save, :as => :boolean, :collection => [true, false] %>
+<%= form.input :rule_parameter_set_id, :as => :select,
+ :collection => @referential.organisation.rule_parameter_sets.map { |rps| [ rps.name, rps.id ] }, :include_blank => true %>
+<%= form.input :resources, :as => :file %>
+<% unless import_task.references_types.empty? %>
+ <p class="warning"><%= t('.'+import_partial_name(form)+'.warning')%></p>
+ <%= form.input :references_type, :as => :select, :collection => import_task.references_types.map { |c| [ c.model_name.human.capitalize.pluralize, c.name ] }, :include_blank => t(".all") %>
+<% end %>
diff --git a/app/views/import_tasks/_import_tasks.html.erb b/app/views/import_tasks/_import_tasks.html.erb
deleted file mode 100644
index 6e3825817..000000000
--- a/app/views/import_tasks/_import_tasks.html.erb
+++ /dev/null
@@ -1,9 +0,0 @@
-<div class="page_info">
- <span class="search"> <%= t("will_paginate.page_entries_info.search") %></span> <%= page_entries_info @import_tasks %>
-</div>
-<div class="import_tasks paginated_content">
- <%= paginated_content @import_tasks %>
-</div>
-<div class="pagination">
- <%= will_paginate @import_tasks, :container => false, renderer: RemoteBootstrapPaginationLinkRenderer %>
-</div>
diff --git a/app/views/import_tasks/_neptune_import.html.erb b/app/views/import_tasks/_neptune_import.html.erb
new file mode 100644
index 000000000..37f0bddbd
--- /dev/null
+++ b/app/views/import_tasks/_neptune_import.html.erb
@@ -0,0 +1 @@
+<%= yield %>
diff --git a/app/views/import_tasks/_results_dashboard.html.erb b/app/views/import_tasks/_results_dashboard.html.erb
deleted file mode 100644
index bde732f73..000000000
--- a/app/views/import_tasks/_results_dashboard.html.erb
+++ /dev/null
@@ -1,68 +0,0 @@
- <div class="resume">
- <div class="col1">
- <% file_title = (@import_task.file_path_extension=="zip") ? t( "import_tasks.show.graph.files.title_zip") : t( "import_tasks.show.graph.files.title_default", :extension => @import_task.file_path_extension)%>
- <div class="caption"><%= file_title %></div>
- <div id="files_statistics"></div>
- </div>
- <div class="col2">
- <div class="caption"><%= t "import_tasks.show.graph.lines.title" %></div>
- <div id="objects_statistics"></div>
- </div>
- </div>
- <div class="report">
- <div class="files files_error">
- <% @files_list["error"].each_with_index do |error, index| %>
- <% index += 1 %>
- <%= image_tag "icons/file_xml_md.png" %><span class="file_name"><%= truncate(error["name"], :length => 20) %></span> <% if index%4 == 0 %><br><% end %>
- <% end %>
- </div>
- <div class="files files_ignored">
- <% @files_list["ignored"].each_with_index do |ignored, index| %>
- <% index += 1 %>
- <%= image_tag "icons/file_xml_md.png" %><span class="file_name"><%= truncate(ignored["name"], :length => 20) %></span> <% if index%4 == 0 %><br><% end %>
- <% end %>
- </div>
- <div class="files files_ok">
- <% @files_list["ok"].each_with_index do |ok, index| %>
- <% index += 1 %>
- <%= image_tag "icons/file_xml_md.png" %><span class="file_name"><%= truncate(ok["name"], :length => 20) %></span> <% if index%4 == 0 %><br><% end %>
- <% end %>
- </div>
- <div class="lines">
- <table class="table table-hover">
- <thead>
- <tr>
- <th>#</th>
- <th><%= t("import_tasks.show.table.line.name") %></th>
- <th><%= t("import_tasks.show.table.line.save") %></th>
- <th><%= t("import_tasks.show.table.line.routes") %></th>
- <th><%= t("import_tasks.show.table.line.connection_links") %></th>
- <th><%= t("import_tasks.show.table.line.time_tables") %></th>
- <th><%= t("import_tasks.show.table.line.stop_areas") %></th>
- <th><%= t("import_tasks.show.table.line.access_points") %></th>
- <th><%= t("import_tasks.show.table.line.vehicle_journeys") %></th>
- <th><%= t("import_tasks.show.table.line.journey_patterns") %></th>
- </tr>
- </thead>
- <tbody>
- <% @lines_list.each_with_index do |line, index| %>
- <% tr_class = (line["status"]=="saved") ? '' : 'class=\'danger\''%>
- <tr <%= tr_class %>>
- <td><%= index + 1 %></td>
- <td><%= line["name"] %></td>
- <td><%= t("import_tasks.show.table.line." + line["status"] ) %></td>
- <td><%= line["stats"]["route_count"] %></td>
- <td><%= line["stats"]["connection_link_count"] %></td>
- <td><%= line["stats"]["time_table_count"] %></td>
- <td><%= line["stats"]["stop_area_count"] %></td>
- <td><%= line["stats"]["acces_point_count"] %></td>
- <td><%= line["stats"]["vehicle_journey_count"] %></td>
- <td><%= line["stats"]["journey_pattern_count"] %></td>
- </tr>
- <% end %>
- </tbody>
- </table>
- </div>
- </div>
- <%= javascript_include_tag referential_import_task_path(@import_task.referential, @import_task,:format => :js) %>
-
diff --git a/app/views/import_tasks/index.html.erb b/app/views/import_tasks/index.html.erb
deleted file mode 100644
index ce0149f72..000000000
--- a/app/views/import_tasks/index.html.erb
+++ /dev/null
@@ -1,12 +0,0 @@
-<%= title_tag t('.title') %>
-<div class="warning"><%= t('.warning') %> </div>
-
-<div id="import_tasks"><%= render 'import_tasks' %></div>
-
-
-<% content_for :sidebar do %>
-<ul class="actions">
- <li><%= link_to t('import_tasks.actions.new'), new_referential_import_task_path(@referential), :class => "add" %></li>
- <li><%= link_to t('rule_parameter_sets.actions.index'), referential_rule_parameter_sets_path(@referential), :class => "link" %></li>
-</ul>
-<% end %>
diff --git a/app/views/import_tasks/index.js.erb b/app/views/import_tasks/index.js.erb
deleted file mode 100644
index 79679f8ac..000000000
--- a/app/views/import_tasks/index.js.erb
+++ /dev/null
@@ -1 +0,0 @@
-$('#import_tasks').html('<%= escape_javascript(render("import_tasks")) %>'); \ No newline at end of file
diff --git a/app/views/import_tasks/new.html.erb b/app/views/import_tasks/new.html.erb
index 65daee0ca..e1bbe34f8 100644
--- a/app/views/import_tasks/new.html.erb
+++ b/app/views/import_tasks/new.html.erb
@@ -1,37 +1,11 @@
<%= title_tag t(".title") %>
-<%= semantic_form_for([@referential, @import_task], :as => :import_task, :url => new_referential_import_task_path(@referential), :method => :get) do |form| %>
- <%= form.inputs do %>
- <%= form.input :format, :as => :radio, :collection => ImportTask.formats.map { |format| [ ImportTask.format_label(format), format]}, :required => true, :include_blank => false %>
- <% end %>
-<% end %>
-
-<% @available_imports.each do |import_task| %>
- <%= semantic_form_for [@referential, import_task], :as => :import_task, :url => referential_import_tasks_path(@referential), :html => { :id => "#{import_task.format}_new", :style => ('display: none' unless @import_task == import_task)} do |form| %>
-
- <%= form.inputs do %>
- <%= fields_for_import_task_format form %>
- <% end %>
+<%= semantic_form_for [@referential, @neptune_import], :as => :import_task, :url => referential_import_tasks_path(@referential), :html => { :id => "neptune_import_new" }, multipart: true do |form| %>
- <%= form.inputs do %>
- <%= form.input :format, :as => :hidden %>
- <%= form.input :no_save, :as => :boolean, :collection => [true, false] %>
- <%= form.input :rule_parameter_set_id, :as => :select,
- :collection => @referential.rule_parameter_sets.map { |rps| [ rps.name, rps.id ] }, :include_blank => true %>
- <%= form.input :resources, :as => :file %>
-
- <% unless import_task.references_types.empty? %>
- <p class="warning"><%= t('.'+import_partial_name(form)+'.warning')%></p>
- <%= form.input :references_type, :as => :select, :collection => import_task.references_types.map { |c| [ c.model_name.human.capitalize.pluralize, c.name ] }, :include_blank => t(".all") %>
- <% end %>
-
- <% end %>
-
- <%= form.actions do %>
- <%= form.action :submit, :as => :button , :label => t( 'formtastic.import' ) %>
- <%= form.action :cancel, :as => :link %>
- <% end %>
+ <%= render :partial => "import_task", :layout => "neptune_import", :locals => { :import_task => @neptune_import, :form => form } %>
+
+ <%= form.actions do %>
+ <%= form.action :submit, :as => :button , :label => t( 'formtastic.import' ) %>
+ <%= form.action :cancel, :as => :link %>
<% end %>
<% end %>
-
-
diff --git a/app/views/import_tasks/show.html.erb b/app/views/import_tasks/show.html.erb
deleted file mode 100644
index fd167b7ef..000000000
--- a/app/views/import_tasks/show.html.erb
+++ /dev/null
@@ -1,22 +0,0 @@
-<% title = @import_task.save_requested? ? "<i class='fa fa-save'></i>" : "" %>
-<%= title_tag "#{title} #{@import_task.name} <span class='status status_#{@import_task.status}'>#{ t('import_tasks.show.'+@import_task.status) }</span>" %>
-<% @title = "#{@import_task.name}" %>
-
-<div class="import_task_show">
- <div class="links">
- <%= link_to image_tag("icons/file_#{@import_task.file_path_extension}.png") + t("import_tasks.show.imported_file"), file_to_import_referential_import_task_path(@import_task.referential, @import_task) %>
- <% if @import_task.compliance_check_task %>
- <%= link_to image_tag( compliance_icon( @import_task) ) + t("import_tasks.compliance_check_task"), referential_compliance_check_task_path(@import_task.referential, @import_task.compliance_check_task) %>
- <% end %>
- </div>
- <%= render( :partial => "results_dashboard") if @import_task.completed? %>
-</div>
-
-<% content_for :sidebar do %>
-<ul class="actions">
- <li><%= link_to t('import_tasks.actions.destroy'), referential_import_task_path(@referential, @import_task), :method => :delete, :data => {:confirm => t('import_tasks.actions.destroy_confirm')}, :class => "remove" %></li>
-</ul>
-
-<%= history_tag(@import_task) %>
-
-<% end %>
diff --git a/app/views/import_tasks/show.js.coffee b/app/views/import_tasks/show.js.coffee
deleted file mode 100644
index c856154fa..000000000
--- a/app/views/import_tasks/show.js.coffee
+++ /dev/null
@@ -1,41 +0,0 @@
-jQuery ->
-
- get_import_results = (html_container, html_element) ->
- html_container.children().each ->
- if( $( this ).is(html_element) )
- $( this ).show()
- else
- $( this ).hide()
-
- Morris.Donut({
- element: 'files_statistics',
- data: [
- {label: "<%= t 'import_tasks.show.graph.files.error' %>", value: <%= @files_stats["error_count"] %> },
- {label: "<%= t 'import_tasks.show.graph.files.ignored' %>", value: <%= @files_stats["ignored_count"] %> },
- {label: "<%= t 'import_tasks.show.graph.files.ok' %>", value: <%= @files_stats["ok_count"] %> }
- ]
- colors: [ "#e22b1b", "#898e7f", "#8fc861" ]
- }).on('click', update = (i, row) ->
- switch i
- when 0 then get_import_results( $(".report"), $(".files_error"))
- when 1 then get_import_results( $(".report"), $(".files_ignored"))
- when 2 then get_import_results( $(".report"), $(".files_ok"))
- else console.log "Error no other value for donut chart")
-
- Morris.Bar({
- element: 'objects_statistics',
- data: [
- { object: "<%= t("import_tasks.show.graph.lines.lines_stats") %>", value: <%= @lines_stats["line_count"] %> },
- { object: "<%= t("import_tasks.show.graph.lines.routes_stats") %>", value: <%= @lines_stats["route_count"] %> },
- { object: "<%= t("import_tasks.show.graph.lines.connection_links_stats") %>", value: <%= @lines_stats["connection_link_count"] %> },
- { object: "<%= t("import_tasks.show.graph.lines.time_tables_stats") %>", value: <%= @lines_stats["time_table_count"] %> },
- { object: "<%= t("import_tasks.show.graph.lines.stop_areas_stats") %>", value: <%= @lines_stats["stop_area_count"] %> },
- { object: "<%= t("import_tasks.show.graph.lines.access_points_stats") %>", value: <%= @lines_stats["access_point_count"] %> },
- { object: "<%= t("import_tasks.show.graph.lines.vehicle_journeys_stats") %>", value: <%= @lines_stats["vehicle_journey_count"] %> },
- { object: "<%= t("import_tasks.show.graph.lines.journey_patterns_stats") %>", value: <%= @lines_stats["journey_pattern_count"] %> },
- ],
- xkey: 'object',
- ykeys: ['value'],
- labels: ['<%= t "import_tasks.show.graph.lines.objects_label" %>']
- }).on('click', update = (i, row) ->
- get_import_results( $(".report"), $(".lines")) ) \ No newline at end of file