rails_admin_import 2.3.1 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fed24bf8ccc152d3b45b68e56600ba77160a707794228cd8828ce7e289003056
4
- data.tar.gz: 3135d1461ba3b1e6ac4a3eb0c13cc85c1c3cda432aeaad1759bfa5e49114bdeb
3
+ metadata.gz: 83c7b4f8595f9938d575df4a7550537d04eaa6d1dd52e9bf0d1adbbabd09df4e
4
+ data.tar.gz: 1b74f9a44d0cffb8062d5efd7e016989ac2003b804329c9adfcb931320944178
5
5
  SHA512:
6
- metadata.gz: 669291db9c194aaaf47a5f7f75e5d6fb252615a5d0e01b87160f1afc3bbf8150ed8f223fcfbb33629f78ae47c2cb0034bbf8548f4fa80cec30c92d25eb31eac5
7
- data.tar.gz: 297247a8340a59c5364b6ab01208eaad4275aea4f2290362037117010c250063e2748a6d1fb9bfc3583ec89cf4d645597ec45acf57da5b07add65471832e0244
6
+ metadata.gz: 50d6d0ef870a078688946f7615eb863886e807a4375b4ea62471a64e13a60b12a91a5b6944b22eddd1d0d5809003ff37c64d330eed310285bb6e744430dc1096
7
+ data.tar.gz: 0fc377a823623ca96162234f8604de9a71a03a527ac7929aaa49a6dc5a294a520d9bee1acda219b91c40b320556bdc5246cdc8823eb36d57b6a400f1aedb797e
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
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
+
3
7
  # 2.3.1 / 2022-01-29
4
8
 
5
9
  - Mark compatibility to Rails Admin < 3.0
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
@@ -1,3 +1,3 @@
1
1
  module RailsAdminImport
2
- VERSION = "2.3.1"
2
+ VERSION = "3.0.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_admin_import
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.1
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steph Skardal
@@ -30,9 +30,6 @@ dependencies:
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
32
  - - ">="
33
- - !ruby/object:Gem::Version
34
- version: 0.6.6
35
- - - "<"
36
33
  - !ruby/object:Gem::Version
37
34
  version: 3.0.0.beta
38
35
  type: :runtime
@@ -40,9 +37,6 @@ dependencies:
40
37
  version_requirements: !ruby/object:Gem::Requirement
41
38
  requirements:
42
39
  - - ">="
43
- - !ruby/object:Gem::Version
44
- version: 0.6.6
45
- - - "<"
46
40
  - !ruby/object:Gem::Version
47
41
  version: 3.0.0.beta
48
42
  - !ruby/object:Gem::Dependency
@@ -85,9 +79,9 @@ files:
85
79
  - MIT-LICENSE
86
80
  - README.md
87
81
  - Rakefile
88
- - app/views/rails_admin/main/_results.html.haml
89
- - app/views/rails_admin/main/_section.html.haml
90
- - 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
91
85
  - config/locales/README.md
92
86
  - config/locales/import.en.yml
93
87
  - lib/rails_admin_import.rb
@@ -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")