rails_admin_import 2.3.0 → 3.0.1

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: b0b71f8452cd6e451b12a22c3d3afb9418bd9308857e11522007db476f014e29
4
- data.tar.gz: df443cf15365e4c8ad61d81db2f9ba49bb582388cb9022f24ebeaacea2725b83
3
+ metadata.gz: 8729f794b1c8ace3c08caeed84399b2ff8a997aeb7d623b05f132de9ac12ce94
4
+ data.tar.gz: bdb84ea9e8ad25667a74846581d0e34ac5570d76141e446c4d2e9a3752fe3e91
5
5
  SHA512:
6
- metadata.gz: 901d0f3cc189f9a51acf9e7cd492f66f28958a8a205c183f31138367caecb3639b7c6d47c66e866459e7b4739a2b51b93c44b47dc1c23f5d7932fe5563cffa8b
7
- data.tar.gz: f9187fe631aa5e2e0ac0c2fcacc7d4a966d682fff9afefcb047608aaf4e9bb8587b56a615da95de7b429df05e9b9ecdff30c00f7320b0a0e3db090894036ba04
6
+ metadata.gz: 3470647f410a12da9f6b8d5711ba1b2b49d24b9c3a3995dcb96fd8db306fe50a339a4480d46192b786e1053205285382eeac69850cab7bb6fb5f78631253931a
7
+ data.tar.gz: 9e6fba88b0fb93af73c05dd301db9a64ae0874c2d711817279454d3d104d9f3994c4cab12e02767d223defda77945f5e2c147adf78a1e5eb9daa787d1d1bfcd4
data/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # Change Log
2
2
 
3
+ # 3.0.0 / 2022-01-29
4
+
5
+ - BREAKING CHANGE: Templates are now compatible with Rails Admin 3.x. For Rails Admin 2.x, continue using version 2.3.1. Thanks @Wowu
6
+
7
+ # 2.3.1 / 2022-01-29
8
+
9
+ - Mark compatibility to Rails Admin < 3.0
10
+ - Bump Nokogiri in tests
11
+
3
12
  # 2.3.0 / 2021-06-11
4
13
 
5
14
  - Added an option to pass filename for each record. Thanks @waheedi
data/README.md CHANGED
@@ -1,15 +1,21 @@
1
1
  # Rails Admin Import
2
2
 
3
- [![Build Status](https://github.com/monkbroc/rails_admin_import/actions/workflows/ruby.yml/badge.svg)](https://github.com/monkbroc/rails_admin_import/actions/workflows/ruby.yml)
3
+ [![Build Status](https://github.com/stephskardal/rails_admin_import/actions/workflows/ruby.yml/badge.svg)](https://github.com/stephskardal/rails_admin_import/actions/workflows/ruby.yml)
4
4
 
5
5
  Plugin functionality to add generic import to Rails Admin from CSV, JSON and XLSX files
6
6
 
7
+ ## Versions
8
+
9
+ Rails Admin Import 3.x is compatible with Rails Admin 3.x.
10
+
11
+ If you're still using Rails Admin 2.x, use Rails Admin Import 2.3.1
12
+
7
13
  ## Installation
8
14
 
9
15
  * First, add to Gemfile:
10
16
 
11
17
  ```ruby
12
- gem "rails_admin_import", "~> 2.3"
18
+ gem "rails_admin_import", "~> 3.0"
13
19
  ```
14
20
 
15
21
  * Define configuration in `config/initializers/rails_admin_import.rb`:
@@ -395,7 +401,7 @@ Since the import functionality is rarely used in many applications, some gems ar
395
401
  If you prefer to eager load all dependecies at boot, use this line in your `Gemfile`.
396
402
 
397
403
  ```ruby
398
- gem "rails_admin_import", "~> 1.2.0", require: "rails_admin_import/eager_load"
404
+ gem "rails_admin_import", "~> 3.0", require: "rails_admin_import/eager_load"
399
405
  ```
400
406
 
401
407
  ## Import error due to Rails class reloading
@@ -408,16 +414,22 @@ Another suggestion is to set `config.cache_classes = true` to true in your `deve
408
414
 
409
415
  ## Customize the UI
410
416
 
411
- If you want to hide all the advanced fields from the import UI, you can copy [`app/views/rails_admin/main/import.html.haml`](app/views/rails_admin/main/import.html.haml) to your project at the same path. Add `.hidden` at the end of lines you want to hide.
417
+ If you want to hide all the advanced fields from the import UI, you can copy [`app/views/rails_admin/main/import.html.haml`](app/views/rails_admin/main/import.html.erb) to your project at the same path. Add `hidden` class to elements you want to hide.
412
418
 
413
419
  For example:
414
420
 
415
- ```haml
416
- .form-group.control-group.hidden
417
- %label.col-sm-2.control-label= t("admin.import.update_if_exists")
418
- .col-sm-10.controls
419
- = check_box_tag :update_if_exists, '1', true, :class => "form-control"
420
- %p.help-block= t('admin.import.help.update_if_exists')
421
+ ```erb
422
+ <div class="form-group control-group hidden">
423
+ <label class="col-sm-2 control-label">
424
+ <%= t("admin.import.update_if_exists") %>
425
+ </label>
426
+ <div class="col-sm-10 controls">
427
+ <%= check_box_tag :update_if_exists, '1', RailsAdminImport.config.update_if_exists, :class => "form-control" %>
428
+ <p class="help-block">
429
+ <%= t('admin.import.help.update_if_exists') %>
430
+ </p>
431
+ </div>
432
+ </div>
421
433
  ```
422
434
 
423
435
  ## Upgrading
@@ -0,0 +1,35 @@
1
+ <% if @results && @results[:success].any? %>
2
+ <div class="alert alert-success form-horizontal denser">
3
+ <fieldset>
4
+ <legend>
5
+ <i class="fas fa-chevron-right"></i>
6
+ <%= @results[:success_message] %>
7
+ </legend>
8
+ <ul class="control-group" style="display: none">
9
+ <% @results[:success].each do |message| %>
10
+ <li>
11
+ <%= message %>
12
+ </li>
13
+ <% end %>
14
+ </ul>
15
+ </fieldset>
16
+ </div>
17
+ <% end %>
18
+
19
+ <% if @results && @results[:error].any? %>
20
+ <div class="alert alert-danger form-horizontal denser">
21
+ <fieldset>
22
+ <legend>
23
+ <i class="fas fa-chevron-down"></i>
24
+ <%= @results[:error_message] %>
25
+ </legend>
26
+ <ul class="control-group">
27
+ <% @results[:error].each do |message| %>
28
+ <li>
29
+ <%= message %>
30
+ </li>
31
+ <% end %>
32
+ </ul>
33
+ </fieldset>
34
+ </div>
35
+ <% end %>
@@ -0,0 +1,21 @@
1
+ <% if fields.any? %>
2
+ <div class="form-group control-group">
3
+ <label class="col-sm-2 control-label">
4
+ <%= t("admin.import.#{section}") %>
5
+ </label>
6
+ <div class="col-sm-10 controls">
7
+ <ul class="list-unstyled">
8
+ <% fields.each do |field| %>
9
+ <li>
10
+ <label>
11
+ <%= field.label %>
12
+ </label>
13
+ </li>
14
+ <% end %>
15
+ </ul>
16
+ <p class="help-block">
17
+ <%= t("admin.import.help.#{section}") %>
18
+ </p>
19
+ </div>
20
+ </div>
21
+ <% end %>
@@ -0,0 +1,102 @@
1
+ <%
2
+ translations = {
3
+ add: t('admin.import.enumeration.add'),
4
+ chooseAll: t('admin.import.enumeration.choose_all'),
5
+ clearAll: t('admin.import.enumeration.clear_all'),
6
+ down: t('admin.import.enumeration.down'),
7
+ remove: t('admin.import.enumeration.remove'),
8
+ search: t('admin.import.enumeration.search'),
9
+ up: t('admin.import.enumeration.up')
10
+ }
11
+ %>
12
+
13
+ <%= render "results" %>
14
+ <%= form_tag import_path(@abstract_model), :multipart => true, class: 'form-horizontal denser' do %>
15
+ <input name="send_data" type="hidden" value="true">/</input>
16
+ <fieldset>
17
+ <legend>
18
+ <i class="fas fa-chevron-down"></i>
19
+ <%= t('admin.import.legend.fields') %>
20
+ </legend>
21
+ <%= render "section", section: "model_fields", fields: @import_model.model_fields %>
22
+ <%= render "section", section: "association_fields", fields: @import_model.association_fields %>
23
+ </fieldset>
24
+ <fieldset>
25
+ <legend>
26
+ <i class="fas fa-chevron-down"></i>
27
+ <%= t('admin.import.legend.upload') %>
28
+ </legend>
29
+ <div class="form-group control-group">
30
+ <label class="col-sm-2 control-label" for="file">
31
+ <%= t("admin.import.file") %>
32
+ </label>
33
+ <div class="col-sm-10 controls">
34
+ <%= file_field_tag :file, :class => "form-control" %>
35
+ <p class="help-block">
36
+ <%= t('admin.import.help.file_limit', limit: RailsAdminImport.config.line_item_limit) %>
37
+ </p>
38
+ </div>
39
+ </div>
40
+ <div class="form-group control-group">
41
+ <label class="col-sm-2 control-label" for="encoding">
42
+ <%= t("admin.import.encoding") %>
43
+ </label>
44
+ <div class="col-sm-10 controls">
45
+ <%= select_tag 'encoding', options_for_select(Encoding.name_list.sort), include_blank: true, data: { enumeration: true, options: { regional: translations } } %>
46
+ <p class="help-block">
47
+ <%= t('admin.import.help.encoding', name: 'UTF-8') %>
48
+ </p>
49
+ </div>
50
+ </div>
51
+ <div class="form-group control-group">
52
+ <label class="col-sm-2 control-label">
53
+ <%= t("admin.import.update_if_exists") %>
54
+ </label>
55
+ <div class="col-sm-10 controls">
56
+ <%= check_box_tag :update_if_exists, '1', RailsAdminImport.config.update_if_exists, :class => "form-control" %>
57
+ <p class="help-block">
58
+ <%= t('admin.import.help.update_if_exists') %>
59
+ </p>
60
+ </div>
61
+ </div>
62
+ <div class="form-group control-group">
63
+ <label class="col-sm-2 control-label" for="update_lookup">
64
+ <%= t("admin.import.update_lookup") %>
65
+ </label>
66
+ <div class="col-sm-10 controls">
67
+ <%= select_tag 'update_lookup', options_for_select(@import_model.update_lookup_field_names, Array.wrap(@import_model.config.mapping_key).map(&:to_s)), multiple: true, data: { enumeration: true, options: { regional: translations } } %>
68
+ </div>
69
+ </div>
70
+ </fieldset>
71
+ <% unless @import_model.association_fields.empty? %>
72
+ <fieldset>
73
+ <legend>
74
+ <i class="fas fa-chevron-down"></i>
75
+ <%= t('admin.import.legend.mapping') %>
76
+ </legend>
77
+ <% @import_model.association_fields.each do |field| %>
78
+ <div class="form-group control-group">
79
+ <label class="col-sm-2 control-label">
80
+ <%= field.label %>
81
+ <%= t("admin.import.mapping") %>
82
+ </label>
83
+ <div class="col-sm-10 controls">
84
+ <%= select_tag "associations[#{field.name}]", options_for_select(@import_model.associated_model_fields(field), Array.wrap(@import_model.associated_config(field).mapping_key).first.to_s), data: { enumeration: true, options: { regional: translations } } %>
85
+ </div>
86
+ </div>
87
+ <% end %>
88
+ </fieldset>
89
+ <% end %>
90
+ <br/>
91
+ <div class="form-actions">
92
+ <input name="return_to" type="<%= :hidden %>" value="<%= (request.params[:return_to].presence || request.referer) %>"></input>
93
+ <button class="btn btn-primary" data_disable_with="Uploading..." name="commit" type="submit">
94
+ <i class="fas fa-check"></i>
95
+ <%= t("admin.form.save") %>
96
+ </button>
97
+ <button class="btn" name="_continue" type="submit">
98
+ <i class="fas fa-times"></i>
99
+ <%= t("admin.form.cancel") %>
100
+ </button>
101
+ </div>
102
+ <% end %>
@@ -38,7 +38,7 @@ module RailsAdmin
38
38
  end
39
39
 
40
40
  register_instance_option :link_icon do
41
- "icon-folder-open"
41
+ "fas fa-folder-open"
42
42
  end
43
43
  end
44
44
  end
@@ -66,7 +66,7 @@ module RailsAdminImport
66
66
  if @config.mapping_key_list.present?
67
67
  @update_lookup_field_names = @config.mapping_key_list
68
68
  else
69
- @update_lookup_field_names ||= model_fields.map(&:name) + belongs_to_fields.map(&:foreign_key)
69
+ @update_lookup_field_names ||= model_fields.map(&:name) + belongs_to_fields.map(&:associated_primary_key)
70
70
  end
71
71
  end
72
72
 
@@ -205,10 +205,10 @@ module RailsAdminImport
205
205
 
206
206
  if object.nil?
207
207
  object = model.new
208
- perform_model_callback(object, :before_import_attributes, record)
208
+ perform_model_callback(object, :before_import_attributes, new_attrs)
209
209
  object.attributes = new_attrs
210
210
  else
211
- perform_model_callback(object, :before_import_attributes, record)
211
+ perform_model_callback(object, :before_import_attributes, new_attrs)
212
212
  object.attributes = new_attrs.except(update.map(&:to_sym))
213
213
  end
214
214
  object
@@ -1,3 +1,3 @@
1
1
  module RailsAdminImport
2
- VERSION = "2.3.0"
2
+ VERSION = "3.0.1"
3
3
  end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_admin_import
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.0
4
+ version: 3.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steph Skardal
8
8
  - Julien Vanier
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2021-06-12 00:00:00.000000000 Z
12
+ date: 2022-04-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -31,14 +31,14 @@ dependencies:
31
31
  requirements:
32
32
  - - ">="
33
33
  - !ruby/object:Gem::Version
34
- version: 0.6.6
34
+ version: 3.0.0.beta
35
35
  type: :runtime
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
39
  - - ">="
40
40
  - !ruby/object:Gem::Version
41
- version: 0.6.6
41
+ version: 3.0.0.beta
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: charlock_holmes
44
44
  requirement: !ruby/object:Gem::Requirement
@@ -67,7 +67,7 @@ dependencies:
67
67
  - - "~>"
68
68
  - !ruby/object:Gem::Version
69
69
  version: '1.0'
70
- description:
70
+ description:
71
71
  email:
72
72
  - steph@endpoint.com
73
73
  - jvanier@gmail.com
@@ -79,9 +79,9 @@ files:
79
79
  - MIT-LICENSE
80
80
  - README.md
81
81
  - Rakefile
82
- - app/views/rails_admin/main/_results.html.haml
83
- - app/views/rails_admin/main/_section.html.haml
84
- - app/views/rails_admin/main/import.html.haml
82
+ - app/views/rails_admin/main/_results.html.erb
83
+ - app/views/rails_admin/main/_section.html.erb
84
+ - app/views/rails_admin/main/import.html.erb
85
85
  - config/locales/README.md
86
86
  - config/locales/import.en.yml
87
87
  - lib/rails_admin_import.rb
@@ -106,7 +106,7 @@ homepage: https://github.com/stephskardal/rails_admin_import
106
106
  licenses:
107
107
  - MIT
108
108
  metadata: {}
109
- post_install_message:
109
+ post_install_message:
110
110
  rdoc_options: []
111
111
  require_paths:
112
112
  - lib
@@ -121,8 +121,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
121
121
  - !ruby/object:Gem::Version
122
122
  version: '0'
123
123
  requirements: []
124
- rubygems_version: 3.2.15
125
- signing_key:
124
+ rubygems_version: 3.1.6
125
+ signing_key:
126
126
  specification_version: 4
127
127
  summary: Import functionality for Rails Admin
128
128
  test_files: []
@@ -1,18 +0,0 @@
1
- - if @results && @results[:success].any?
2
- .alert.alert-success.form-horizontal.denser
3
- %fieldset
4
- %legend
5
- %i.icon-chevron-right
6
- = @results[:success_message]
7
- %ul.control-group{style: 'display: none'}
8
- - @results[:success].each do |message|
9
- %li= message
10
- - if @results && @results[:error].any?
11
- .alert.alert-danger.form-horizontal.denser
12
- %fieldset
13
- %legend
14
- %i.icon-chevron-down
15
- = @results[:error_message]
16
- %ul.control-group
17
- - @results[:error].each do |message|
18
- %li= message
@@ -1,10 +0,0 @@
1
- - if fields.any?
2
- .form-group.control-group
3
- %label.col-sm-2.control-label= t("admin.import.#{section}")
4
- .col-sm-10.controls
5
- %ul.list-unstyled
6
- - fields.each do |field|
7
- %li
8
- %label= capitalize_first_letter(field.label)
9
- %p.help-block= t("admin.import.help.#{section}")
10
-
@@ -1,80 +0,0 @@
1
- :ruby
2
- translations = {
3
- add: t('admin.import.enumeration.add'),
4
- chooseAll: t('admin.import.enumeration.choose_all'),
5
- clearAll: t('admin.import.enumeration.clear_all'),
6
- down: t('admin.import.enumeration.down'),
7
- remove: t('admin.import.enumeration.remove'),
8
- search: t('admin.import.enumeration.search'),
9
- up: t('admin.import.enumeration.up')
10
- }
11
-
12
- = render "results"
13
-
14
- = form_tag import_path(@abstract_model), :multipart => true, class: 'form-horizontal denser' do
15
-
16
- %input{name: "send_data", type: "hidden", value: "true"}/
17
- %fieldset
18
- %legend
19
- %i.icon-chevron-down
20
- = t('admin.import.legend.fields')
21
-
22
- = render "section", section: "model_fields", fields: @import_model.model_fields
23
- = render "section", section: "association_fields", fields: @import_model.association_fields
24
-
25
- %fieldset
26
- %legend
27
- %i.icon-chevron-down
28
- = t('admin.import.legend.upload')
29
- .form-group.control-group
30
- %label.col-sm-2.control-label{for: "file"}= t("admin.import.file")
31
- .col-sm-10.controls
32
- = file_field_tag :file, :class => "form-control"
33
- %p.help-block= t('admin.import.help.file_limit', limit: RailsAdminImport.config.line_item_limit)
34
- .form-group.control-group
35
- %label.col-sm-2.control-label{for: "encoding"}= t("admin.import.encoding")
36
- .col-sm-10.controls
37
- = select_tag 'encoding',
38
- options_for_select(Encoding.name_list.sort),
39
- include_blank: true, data: { enumeration: true, options: { regional: translations } }
40
- %p.help-block= t('admin.import.help.encoding', name: 'UTF-8')
41
- .form-group.control-group
42
- %label.col-sm-2.control-label= t("admin.import.update_if_exists")
43
- .col-sm-10.controls
44
- = check_box_tag :update_if_exists, '1', RailsAdminImport.config.update_if_exists, :class => "form-control"
45
- %p.help-block= t('admin.import.help.update_if_exists')
46
- .form-group.control-group
47
- %label.col-sm-2.control-label{for: "update_lookup"}= t("admin.import.update_lookup")
48
- .col-sm-10.controls
49
- = select_tag 'update_lookup',
50
- options_for_select(@import_model.update_lookup_field_names,
51
- Array.wrap(@import_model.config.mapping_key).map(&:to_s)),
52
- multiple: true,
53
- data: { enumeration: true, options: { regional: translations } }
54
-
55
- - unless @import_model.association_fields.empty?
56
- %fieldset
57
- %legend
58
- %i.icon-chevron-down
59
- = t('admin.import.legend.mapping')
60
-
61
- - @import_model.association_fields.each do |field|
62
- .form-group.control-group
63
- %label.col-sm-2.control-label
64
- = capitalize_first_letter(field.label)
65
- = t("admin.import.mapping")
66
- .col-sm-10.controls
67
- = select_tag "associations[#{field.name}]",
68
- options_for_select(@import_model.associated_model_fields(field),
69
- Array.wrap(@import_model.associated_config(field).mapping_key).first.to_s),
70
- data: { enumeration: true, options: { regional: translations } }
71
-
72
- %br
73
- .form-actions
74
- %input{type: :hidden, name: 'return_to', value: (request.params[:return_to].presence || request.referer)}
75
- %button.btn.btn-primary{type: "submit", name: "commit", data: {disable_with: "Uploading..."} }
76
- %i.icon-white.icon-ok
77
- = t("admin.form.save")
78
- %button.btn{type: "submit", name: "_continue"}
79
- %i.icon-remove
80
- = t("admin.form.cancel")