ixport 0.3.1 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7010d4338968ec32338a7f02a446a59a091487b0860f955c090f5e180b61d65a
4
- data.tar.gz: 82f2bf80f348f9a308a0c3674efaf62441c0b4865cfe867e599243861b5227fe
3
+ metadata.gz: 03be028cedf3161974f8143be44d6f31d79cc669e0388d266bc787d12a9dcd9e
4
+ data.tar.gz: e7aec59ef0d4d8288a4062e713f0ef87eb7bc23f3bbda19db8e638eabc2872ad
5
5
  SHA512:
6
- metadata.gz: 363acc8c4d91440e255240436d96196607831fd98ebcab6d90fc3c817b94609aa5a2978ac16aab41eb3b6fd4371f9d565367eec0bb08c32596e351c647fdb683
7
- data.tar.gz: cda9b8842119709c211008e76820185f0d36544b831d718b8bfa743f0b681b4a9e79919b341b3a73acf0c600b98d15472a72632861b5d6a51635089bea0d935b
6
+ metadata.gz: 2afc07d8cba3ef5d3272d5e74d4981ffd882c4dafe969d70af85dd85947049acea43356b804b8afc7bc4f3a918027f3a6aecebe990c774686cef254420f3873f
7
+ data.tar.gz: eb1aba5fb3eecb5071f3ce89fd847eea67d0e79bf6270f639fc0d0c24bb92c3216e0ce8924a191622b07c07afae1af004312523db31dcf89436f527ba0897731
data/README.md CHANGED
@@ -81,7 +81,7 @@ To match on several fields, name them all, for example `match_on :happened_on, :
81
81
 
82
82
  From the engine's root page, a person picks a registered import and uploads a CSV for it. The upload is refused, with a message on the upload page, when the file is not UTF-8 text, when its quoting is broken (the message names the line where reading stopped), when it has no header row, or, in an app with no background runner, when it has more rows than `config.inline_row_limit`. A byte order mark at the start of the file is ignored, so the first column keeps its name.
83
83
 
84
- After uploading, the person matches each column of the file's header row to one of the importer's fields, by its label, or skips it. Saving the mapping moves them on to the preview.
84
+ After uploading, the person matches each column of the file's header row to one of the importer's fields, by its label, or skips it. Saving the mapping moves them on to the preview, and going back to the mapping page shows the choices already made.
85
85
 
86
86
  The preview shows how many rows will add a record, update one or be refused, before anything is saved. It lists each row that will update a record and each refused row, by its row number in the file, with the reason the record gives for a refusal. A row is refused when the record it builds is not valid. Viewing the preview saves nothing, and the person can go back from it to change the mapping.
87
87
 
@@ -89,7 +89,7 @@ The preview shows how many rows will add a record, update one or be refused, bef
89
89
 
90
90
  The person runs the import from the preview. With no background runner configured, it runs inside the request. Each row that passes the record's validations is saved, updating the record it matches or adding a new one. Each row that fails them is refused and kept with its row number and reason, and the record it matched is left unchanged.
91
91
 
92
- The import's result page then shows how many rows were added and how many updated, and lists each refused row. It shows the same thing on every later visit. A finished import offers no Run button, its preview leads to its result page, and running it again adds or changes nothing.
92
+ The import's result page then shows its status, how many rows the file had, how many were added and how many updated, and lists each refused row. It shows the same thing on every later visit. A finished import offers no Run button, its preview leads to its result page, and running it again adds or changes nothing.
93
93
 
94
94
  An import belongs to the person and account that uploaded it, and anyone else gets not found when they open it.
95
95
 
@@ -54,6 +54,10 @@ module Ixport
54
54
  Ixport.registration(key).importer.constantize
55
55
  end
56
56
 
57
+ def row_count
58
+ [ CSV.parse(contents).size - 1, 0 ].max
59
+ end
60
+
57
61
  def headers
58
62
  CSV.parse_line(contents) || []
59
63
  end
@@ -15,9 +15,11 @@
15
15
  <%= ui_alert(type: :error, message: tag.span(@import.error_message, data: { import_error: true })) %>
16
16
  <p>Rows saved before it stopped stay saved.</p>
17
17
  <% end %>
18
- <%= ui_grid(cols: { default: 1, sm: 2 }) do %>
18
+ <%= ui_badge(label: tag.span(@import.status.humanize, data: { import_status: true }), variant: @import.failed? ? :danger : :success) %>
19
+ <%= ui_grid(cols: { default: 1, sm: 3 }) do %>
19
20
  <%= ui_stat_card(label: "Added", value: tag.span(@import.added_count, data: { result_count: "added" })) %>
20
21
  <%= ui_stat_card(label: "Updated", value: tag.span(@import.updated_count, data: { result_count: "updated" })) %>
22
+ <%= ui_stat_card(label: "Rows in file", value: tag.span(@import.row_count, data: { result_count: "total" })) %>
21
23
  <% end %>
22
24
  <% if @import.refusals.any? %>
23
25
  <%= ui_section(title: "Refused") do %>
@@ -1,10 +1,14 @@
1
1
  <%= ui_form_page(title: "Match columns", back_url: root_path) %>
2
2
  <%= ui_page(max_width: :md) do %>
3
3
  <%= ui_form(action: import_mapping_path(@import), method: :patch) do %>
4
- <% @import.headers.each_with_index do |header, index| %>
5
- <%= tag.div(data: { column: true }) do %>
6
- <%= tag.span(header, data: { column_name: true }) %>
7
- <%= ui_select(name: "mapping[#{index}]", options: @fields.map { |field| [field.label, field.key] }, include_blank: "Skip") %>
4
+ <%= ui_grid(cols: { default: 1 }, gap: :md) do %>
5
+ <% @import.headers.each_with_index do |header, index| %>
6
+ <%= tag.div(data: { column: true }) do %>
7
+ <%= ui_grid(cols: { default: 1, sm: 2 }, gap: :sm) do %>
8
+ <%= tag.span(header, data: { column_name: true }) %>
9
+ <%= ui_select(name: "mapping[#{index}]", options: @fields.map { |field| [field.label, field.key] }, selected: @import.mapping&.dig(index.to_s), include_blank: "Skip") %>
10
+ <% end %>
11
+ <% end %>
8
12
  <% end %>
9
13
  <% end %>
10
14
  <%= ui_button(label: "Save mapping") %>
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Ixport
4
- VERSION = "0.3.1"
4
+ VERSION = "0.3.2"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ixport
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tyler Schneider