administrate-field-nested_has_many 0.0.1 → 1.3.0
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 +5 -5
- data/.circleci/config.yml +29 -0
- data/.gitignore +4 -0
- data/.ruby-version +1 -0
- data/Appraisals +13 -0
- data/CHANGELOG.md +71 -0
- data/Gemfile +5 -0
- data/README.md +4 -3
- data/Rakefile +24 -0
- data/administrate-field-nested_has_many.gemspec +16 -9
- data/app/assets/stylesheets/administrate-field-nested_has_many/application.css +3 -0
- data/app/assets/stylesheets/administrate-field-nested_has_many/base.scss +14 -0
- data/app/views/fields/nested_has_many/_fields.html.erb +3 -5
- data/app/views/fields/nested_has_many/_form.html.erb +12 -12
- data/app/views/fields/nested_has_many/_show.html.erb +6 -37
- data/app/views/fields/nested_has_many/_show_current.html.erb +44 -0
- data/app/views/fields/nested_has_many/_show_old.html.erb +36 -0
- data/bin/rails +13 -0
- data/config/i18n-tasks.yml +8 -0
- data/config/locales/administrate-field-nested_has_many.en.yml +7 -0
- data/config/locales/administrate-field-nested_has_many.ja.yml +7 -0
- data/config/locales/administrate-field-nested_has_many.pt.yml +7 -0
- data/config/locales/administrate-field-nested_has_many.ru.yml +7 -0
- data/gemfiles/administrate_0.10.gemfile +8 -0
- data/gemfiles/administrate_0.10.gemfile.lock +214 -0
- data/gemfiles/administrate_0.13.gemfile +8 -0
- data/gemfiles/administrate_0.13.gemfile.lock +207 -0
- data/gemfiles/administrate_master.gemfile +8 -0
- data/gemfiles/administrate_master.gemfile.lock +219 -0
- data/lib/administrate/field/nested_has_many.rb +42 -12
- data/spec/dummy/.gitignore +3 -0
- data/spec/dummy/Rakefile +6 -0
- data/spec/dummy/app/assets/config/manifest.js +7 -0
- data/spec/dummy/app/assets/images/.keep +0 -0
- data/spec/dummy/app/assets/javascripts/application.js +14 -0
- data/spec/dummy/app/assets/javascripts/channels/.keep +0 -0
- data/spec/dummy/app/assets/stylesheets/application.css +15 -0
- data/spec/dummy/app/controllers/admin/application_controller.rb +21 -0
- data/spec/dummy/app/controllers/admin/foo/students_controller.rb +21 -0
- data/spec/dummy/app/controllers/admin/schools_controller.rb +21 -0
- data/spec/dummy/app/controllers/application_controller.rb +2 -0
- data/spec/dummy/app/controllers/concerns/.keep +0 -0
- data/spec/dummy/app/dashboards/foo/student_dashboard.rb +51 -0
- data/spec/dummy/app/dashboards/school_dashboard.rb +52 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/mailers/application_mailer.rb +4 -0
- data/spec/dummy/app/models/application_record.rb +3 -0
- data/spec/dummy/app/models/concerns/.keep +0 -0
- data/spec/dummy/app/models/foo/student.rb +3 -0
- data/spec/dummy/app/models/school.rb +4 -0
- data/spec/dummy/app/views/layouts/application.html.erb +15 -0
- data/spec/dummy/app/views/layouts/mailer.html.erb +13 -0
- data/spec/dummy/app/views/layouts/mailer.text.erb +1 -0
- data/spec/dummy/bin/bundle +3 -0
- data/spec/dummy/bin/rails +4 -0
- data/spec/dummy/bin/rake +4 -0
- data/spec/dummy/bin/setup +36 -0
- data/spec/dummy/bin/update +31 -0
- data/spec/dummy/bin/yarn +11 -0
- data/spec/dummy/config.ru +5 -0
- data/spec/dummy/config/application.rb +18 -0
- data/spec/dummy/config/boot.rb +5 -0
- data/spec/dummy/config/cable.yml +10 -0
- data/spec/dummy/config/database.yml +12 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +53 -0
- data/spec/dummy/config/environments/test.rb +36 -0
- data/spec/dummy/config/initializers/application_controller_renderer.rb +8 -0
- data/spec/dummy/config/initializers/assets.rb +14 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/content_security_policy.rb +25 -0
- data/spec/dummy/config/initializers/cookies_serializer.rb +5 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy/config/initializers/inflections.rb +16 -0
- data/spec/dummy/config/initializers/mime_types.rb +4 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +33 -0
- data/spec/dummy/config/puma.rb +34 -0
- data/spec/dummy/config/routes.rb +10 -0
- data/spec/dummy/config/spring.rb +6 -0
- data/spec/dummy/config/storage.yml +34 -0
- data/spec/dummy/db/migrate/20180907104642_create_schools.rb +9 -0
- data/spec/dummy/db/migrate/20180907104703_create_students.rb +10 -0
- data/spec/dummy/db/schema.rb +29 -0
- data/spec/dummy/lib/assets/.keep +0 -0
- data/spec/dummy/package.json +5 -0
- data/spec/dummy/public/404.html +67 -0
- data/spec/dummy/public/422.html +67 -0
- data/spec/dummy/public/500.html +66 -0
- data/spec/dummy/public/apple-touch-icon-precomposed.png +0 -0
- data/spec/dummy/public/apple-touch-icon.png +0 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/storage/.keep +0 -0
- data/spec/factories.rb +9 -0
- data/spec/features/has_many_spec.rb +68 -0
- data/spec/features/landing_spec.rb +10 -0
- data/spec/i18n_spec.rb +29 -0
- data/spec/rails_helper.rb +67 -0
- data/spec/spec_helper.rb +96 -0
- metadata +296 -18
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 9b4e4495fbe9f39dff627f5b1ddf7d82bc89d5e3a05433cc318f12ab7f02d004
|
|
4
|
+
data.tar.gz: f328a1f6dea3d663ee0d80454bf04a4d55530b1d2a520f1c884c1c6d78b714e5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5c1a6222bc8d033f871610444425f7c90b015f5b05c9ff2c47187d1f96b0a787a75dbf4f4442335c5f24788713c33f0f67e5e1d6d2677952e5970524366578d1
|
|
7
|
+
data.tar.gz: cc1b62f1e2eb55ca307c7ed7e1f41d5e6f172d604a8e8a986c98d05c0fa3115bdd3f2603d2a339af8c726a6c7404689fed09c4a483e56a24d513b91e0f733f18
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
---
|
|
2
|
+
version: 2
|
|
3
|
+
jobs:
|
|
4
|
+
build:
|
|
5
|
+
working_directory: ~/administrate-field-nested_has_many
|
|
6
|
+
docker:
|
|
7
|
+
- image: circleci/ruby:2.7.0-node-browsers
|
|
8
|
+
environment:
|
|
9
|
+
PGHOST: localhost
|
|
10
|
+
PGUSER: administrate-field-nested_has_many
|
|
11
|
+
PGPASSWORD: administrate-field-nested_has_many
|
|
12
|
+
RAILS_ENV: test
|
|
13
|
+
- image: postgres:11
|
|
14
|
+
environment:
|
|
15
|
+
POSTGRES_USER: administrate-field-nested_has_many
|
|
16
|
+
POSTGRES_DB: administrate-field-nested_has_many_test
|
|
17
|
+
POSTGRES_PASSWORD: administrate-field-nested_has_many
|
|
18
|
+
steps:
|
|
19
|
+
- checkout
|
|
20
|
+
|
|
21
|
+
- run: bundle install
|
|
22
|
+
- run: bundle exec appraisal install
|
|
23
|
+
|
|
24
|
+
- run: dockerize -wait tcp://localhost:5432 -timeout 1m
|
|
25
|
+
|
|
26
|
+
- run: bundle exec rake db:setup
|
|
27
|
+
|
|
28
|
+
- run: bundle exec rake
|
|
29
|
+
- run: bundle exec appraisal rake
|
data/.gitignore
ADDED
data/.ruby-version
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ruby-2.7.0
|
data/Appraisals
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
appraise "administrate-0.10" do
|
|
4
|
+
gem "administrate", "0.10.0"
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
appraise "administrate-0.13" do
|
|
8
|
+
gem "administrate", "0.13.0"
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
appraise "administrate-master" do
|
|
12
|
+
gem "administrate", git: "https://github.com/thoughtbot/administrate", branch: "master"
|
|
13
|
+
end
|
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# CHANGELOG
|
|
2
|
+
|
|
3
|
+
## 1.3.0
|
|
4
|
+
|
|
5
|
+
* Cover more test cases ([#43][])
|
|
6
|
+
* Update form constructor to avoid undefined method ([#34][])
|
|
7
|
+
* Upgrade Ruby to 2.7.0 ([#27][])
|
|
8
|
+
* We need to use a node-browsers to run features ([#30][])
|
|
9
|
+
* Fix CI by explicitly setting a Postgres password ([#29][])
|
|
10
|
+
|
|
11
|
+
[#43]: https://github.com/nickcharlton/administrate-field-nested_has_many/pull/43
|
|
12
|
+
[#34]: https://github.com/nickcharlton/administrate-field-nested_has_many/pull/34
|
|
13
|
+
[#27]: https://github.com/nickcharlton/administrate-field-nested_has_many/pull/27
|
|
14
|
+
[#30]: https://github.com/nickcharlton/administrate-field-nested_has_many/pull/30
|
|
15
|
+
[#29]: https://github.com/nickcharlton/administrate-field-nested_has_many/pull/29
|
|
16
|
+
|
|
17
|
+
## 1.2.0
|
|
18
|
+
|
|
19
|
+
* Add support for namespaced models ([#24][])
|
|
20
|
+
* Add missing accepts nested attributes to School.
|
|
21
|
+
* Explicitly import administrate and field JS/CSS.
|
|
22
|
+
* Add ru locale ([#26][]).
|
|
23
|
+
* Add pt locale ([#25][]).
|
|
24
|
+
* Add Circle CI.
|
|
25
|
+
* Upgrade Ruby to 2.6.3.
|
|
26
|
+
* Add a dummy test app ([#19][]).
|
|
27
|
+
|
|
28
|
+
[#24]: https://github.com/nickcharlton/administrate-field-nested_has_many/pull/24
|
|
29
|
+
[#26]: https://github.com/nickcharlton/administrate-field-nested_has_many/pull/26
|
|
30
|
+
[#25]: https://github.com/nickcharlton/administrate-field-nested_has_many/pull/25
|
|
31
|
+
[#19]: https://github.com/nickcharlton/administrate-field-nested_has_many/pull/19
|
|
32
|
+
|
|
33
|
+
## 1.1.0
|
|
34
|
+
|
|
35
|
+
* Add a `.ruby-version` file.
|
|
36
|
+
* Adjust to upstream administrate changes.
|
|
37
|
+
* Add Japanese locale.
|
|
38
|
+
|
|
39
|
+
## 1.0.0
|
|
40
|
+
|
|
41
|
+
* Add `rake` for testing and release tools ([#16][]).
|
|
42
|
+
* Fixes for `administrate` 0.9.0 ([#11][]).
|
|
43
|
+
* Ensure current data is injected into nested fields ([#10][]).
|
|
44
|
+
* Remove direct dependency on Rails ([#10][]).
|
|
45
|
+
* Add i18n support ([#10][]).
|
|
46
|
+
* Make styling more consistent with `has_one` form ([#10][]).
|
|
47
|
+
* Add missing Gemfile and missing dependency on RSpec ([#15][]).
|
|
48
|
+
* Update gem location and authors ([#14][]).
|
|
49
|
+
* Avoid circular dependencies by not including the full library in the Gemspec
|
|
50
|
+
([#13][]).
|
|
51
|
+
|
|
52
|
+
[#16]: https://github.com/nickcharlton/administrate-field-nested_has_many/pull/16
|
|
53
|
+
[#15]: https://github.com/nickcharlton/administrate-field-nested_has_many/pull/15
|
|
54
|
+
[#14]: https://github.com/nickcharlton/administrate-field-nested_has_many/pull/14
|
|
55
|
+
[#13]: https://github.com/nickcharlton/administrate-field-nested_has_many/pull/13
|
|
56
|
+
[#11]: https://github.com/nickcharlton/administrate-field-nested_has_many/pull/11
|
|
57
|
+
[#10]: https://github.com/nickcharlton/administrate-field-nested_has_many/pull/10
|
|
58
|
+
|
|
59
|
+
## 0.1.0
|
|
60
|
+
|
|
61
|
+
* Updates for changes in `administrate` 0.2.1.
|
|
62
|
+
* Import JavaScript automatically.
|
|
63
|
+
|
|
64
|
+
## 0.0.2
|
|
65
|
+
|
|
66
|
+
* Add missing import for `cocoon`.
|
|
67
|
+
* Note stop gap fix for missing JavaScript imports.
|
|
68
|
+
|
|
69
|
+
## 0.0.1
|
|
70
|
+
|
|
71
|
+
* Initial Release.
|
data/Gemfile
ADDED
data/README.md
CHANGED
|
@@ -13,14 +13,15 @@ gem "administrate-field-nested_has_many"
|
|
|
13
13
|
Run:
|
|
14
14
|
|
|
15
15
|
```bash
|
|
16
|
-
$bundle install
|
|
16
|
+
$ bundle install
|
|
17
17
|
```
|
|
18
18
|
|
|
19
19
|
Add to your `FooDashboard`:
|
|
20
|
+
|
|
20
21
|
```ruby
|
|
21
|
-
ATTRIBUTE_TYPES =
|
|
22
|
+
ATTRIBUTE_TYPES = {
|
|
22
23
|
bars: Field::NestedHasMany.with_options(skip: :foo),
|
|
23
|
-
|
|
24
|
+
}
|
|
24
25
|
```
|
|
25
26
|
|
|
26
27
|
The `skip` option takes a single symbol or list of symbols.
|
data/Rakefile
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
begin
|
|
2
|
+
require "bundler/setup"
|
|
3
|
+
rescue LoadError
|
|
4
|
+
puts "You must `gem install bundler` and `bundle install` to run rake tasks"
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
require "bundler/gem_tasks"
|
|
8
|
+
|
|
9
|
+
require File.expand_path("../spec/dummy/config/application", __FILE__)
|
|
10
|
+
|
|
11
|
+
Rails.application.load_tasks
|
|
12
|
+
|
|
13
|
+
##
|
|
14
|
+
# Configure the test suite.
|
|
15
|
+
##
|
|
16
|
+
require "rspec/core"
|
|
17
|
+
require "rspec/core/rake_task"
|
|
18
|
+
|
|
19
|
+
RSpec::Core::RakeTask.new
|
|
20
|
+
|
|
21
|
+
##
|
|
22
|
+
# By default, just run the tests.
|
|
23
|
+
##
|
|
24
|
+
task default: :spec
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
$:.push File.expand_path("../lib", __FILE__)
|
|
2
2
|
|
|
3
|
-
require "administrate/field/nested_has_many"
|
|
4
|
-
|
|
5
3
|
Gem::Specification.new do |gem|
|
|
6
4
|
gem.name = "administrate-field-nested_has_many"
|
|
7
|
-
gem.version =
|
|
8
|
-
gem.authors = ["Grayson Wright"]
|
|
9
|
-
gem.email = ["wright.grayson@gmail.com"]
|
|
10
|
-
gem.homepage = "https://github.com/
|
|
5
|
+
gem.version = "1.3.0"
|
|
6
|
+
gem.authors = ["Nick Charlton", "Grayson Wright"]
|
|
7
|
+
gem.email = ["nick@nickcharlton.net", "wright.grayson@gmail.com"]
|
|
8
|
+
gem.homepage = "https://github.com/nickcharlton/" \
|
|
9
|
+
"administrate-field-nested_has_many"
|
|
11
10
|
gem.summary = "Plugin for nested has_many forms in Administrate"
|
|
12
11
|
gem.description = gem.summary
|
|
13
12
|
gem.license = "MIT"
|
|
@@ -16,7 +15,15 @@ Gem::Specification.new do |gem|
|
|
|
16
15
|
gem.files = `git ls-files`.split("\n")
|
|
17
16
|
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
|
18
17
|
|
|
19
|
-
gem.add_dependency "administrate", "
|
|
20
|
-
gem.add_dependency "cocoon", "~> 1.2"
|
|
21
|
-
|
|
18
|
+
gem.add_dependency "administrate", "> 0.8", "< 1"
|
|
19
|
+
gem.add_dependency "cocoon", "~> 1.2", ">= 1.2.11"
|
|
20
|
+
|
|
21
|
+
gem.add_development_dependency "appraisal"
|
|
22
|
+
gem.add_development_dependency "capybara"
|
|
23
|
+
gem.add_development_dependency "selenium-webdriver"
|
|
24
|
+
gem.add_development_dependency "factory_bot"
|
|
25
|
+
gem.add_development_dependency "i18n-tasks"
|
|
26
|
+
gem.add_development_dependency "rake"
|
|
27
|
+
gem.add_development_dependency "rspec-rails"
|
|
28
|
+
gem.add_development_dependency "sqlite3"
|
|
22
29
|
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
@import 'administrate/library/variables';
|
|
2
|
+
@import 'administrate/library/clearfix';
|
|
3
|
+
|
|
4
|
+
.field-unit--nested-has-many {
|
|
5
|
+
.nested-fields {
|
|
6
|
+
@include administrate-clearfix;
|
|
7
|
+
margin-bottom: $base-spacing;
|
|
8
|
+
padding-bottom: $base-spacing;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.remove_fields, .add_fields {
|
|
12
|
+
float: right;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
<div class="nested-fields"
|
|
2
|
-
|
|
3
|
-
<% field.nested_fields.each do |attribute| -%>
|
|
1
|
+
<div class="nested-fields">
|
|
2
|
+
<% field.nested_fields_for_builder(f).each do |attribute| -%>
|
|
4
3
|
<div class="field-unit field-unit--<%= attribute.html_class %>">
|
|
5
4
|
<%= render_field attribute, f: f %>
|
|
6
5
|
</div>
|
|
7
6
|
<% end -%>
|
|
8
7
|
|
|
9
|
-
|
|
10
|
-
<%= link_to_remove_association "Remove #{field.associated_class_name.titleize}", f %>
|
|
8
|
+
<%= link_to_remove_association I18n.t("administrate.fields.nested_has_many.remove", resource: field.associated_class_name.titleize), f %>
|
|
11
9
|
</div>
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
<
|
|
2
|
-
|
|
1
|
+
<fieldset class="field-unit--nested">
|
|
2
|
+
<legend><%= f.label field.attribute %></legend>
|
|
3
3
|
<%= f.fields_for field.association_name do |nested_form| %>
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
4
|
+
<%= render(
|
|
5
|
+
partial: "fields/nested_has_many/fields",
|
|
6
|
+
locals: {
|
|
7
|
+
f: nested_form,
|
|
8
|
+
field: field,
|
|
9
|
+
},
|
|
10
|
+
) %>
|
|
11
11
|
<% end %>
|
|
12
12
|
|
|
13
13
|
<div>
|
|
14
14
|
<%= link_to_add_association(
|
|
15
|
-
|
|
16
|
-
"Add #{field.associated_class_name.titleize}",
|
|
15
|
+
I18n.t("administrate.fields.nested_has_many.add", resource: field.associated_class_name.titleize),
|
|
17
16
|
f,
|
|
18
17
|
field.association_name,
|
|
18
|
+
class: 'button',
|
|
19
19
|
partial: "fields/nested_has_many/fields",
|
|
20
20
|
render_options: { locals: { field: field } },
|
|
21
21
|
) %>
|
|
22
22
|
</div>
|
|
23
|
-
</
|
|
23
|
+
</fieldset>
|
|
@@ -1,40 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
This partial renders a has_many relationship,
|
|
5
|
-
to be displayed on a resource's show page.
|
|
6
|
-
|
|
7
|
-
By default, the relationship is rendered
|
|
8
|
-
as a table of the first few associated resources.
|
|
9
|
-
The columns of the table are taken
|
|
10
|
-
from the associated resource class's dashboard.
|
|
11
|
-
|
|
12
|
-
## Local variables:
|
|
13
|
-
|
|
14
|
-
- `field`:
|
|
15
|
-
An instance of [Administrate::Field::HasMany][1].
|
|
16
|
-
Contains methods to help display a table of associated resources.
|
|
17
|
-
|
|
18
|
-
[1]: http://www.rubydoc.info/gems/administrate/Administrate/Field/HasMany
|
|
1
|
+
<%
|
|
2
|
+
current = Gem::Version.new(Administrate::VERSION)
|
|
3
|
+
v0_10 = Gem::Version.new("0.10")
|
|
19
4
|
%>
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
<%= render(
|
|
23
|
-
"collection",
|
|
24
|
-
collection_presenter: field.associated_collection,
|
|
25
|
-
resources: field.resources
|
|
26
|
-
) %>
|
|
27
|
-
|
|
28
|
-
<% if field.more_than_limit? %>
|
|
29
|
-
<span>
|
|
30
|
-
<%= t(
|
|
31
|
-
'administrate.fields.has_many.more',
|
|
32
|
-
count: field.limit,
|
|
33
|
-
total_count: field.data.count,
|
|
34
|
-
) %>
|
|
35
|
-
</span>
|
|
36
|
-
<% end %>
|
|
37
|
-
|
|
5
|
+
<% if current <= v0_10 %>
|
|
6
|
+
<%= render "fields/nested_has_many/show_old", **local_assigns %>
|
|
38
7
|
<% else %>
|
|
39
|
-
<%=
|
|
8
|
+
<%= render "fields/nested_has_many/show_current", **local_assigns %>
|
|
40
9
|
<% end %>
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
<%#
|
|
2
|
+
# HasMany Show Partial
|
|
3
|
+
|
|
4
|
+
This partial renders a has_many relationship,
|
|
5
|
+
to be displayed on a resource's show page.
|
|
6
|
+
|
|
7
|
+
By default, the relationship is rendered
|
|
8
|
+
as a table of the first few associated resources.
|
|
9
|
+
The columns of the table are taken
|
|
10
|
+
from the associated resource class's dashboard.
|
|
11
|
+
|
|
12
|
+
## Local variables:
|
|
13
|
+
|
|
14
|
+
- `field`:
|
|
15
|
+
An instance of [Administrate::Field::HasMany][1].
|
|
16
|
+
Contains methods to help display a table of associated resources.
|
|
17
|
+
|
|
18
|
+
[1]: http://www.rubydoc.info/gems/administrate/Administrate/Field/HasMany
|
|
19
|
+
%>
|
|
20
|
+
|
|
21
|
+
<% if field.resources.any? %>
|
|
22
|
+
<% order = field.order_from_params(params.fetch(field.name, {})) %>
|
|
23
|
+
<% page_number = params.fetch(field.name, {}).fetch(:page, nil) %>
|
|
24
|
+
<%= render(
|
|
25
|
+
"collection",
|
|
26
|
+
collection_presenter: field.associated_collection(order),
|
|
27
|
+
collection_field_name: field.name,
|
|
28
|
+
page: page,
|
|
29
|
+
resources: field.resources(page_number, order),
|
|
30
|
+
table_title: field.name,
|
|
31
|
+
) %>
|
|
32
|
+
|
|
33
|
+
<% if field.more_than_limit? %>
|
|
34
|
+
<span>
|
|
35
|
+
<%= t(
|
|
36
|
+
'administrate.fields.has_many.more',
|
|
37
|
+
count: field.limit,
|
|
38
|
+
total_count: field.data.count,
|
|
39
|
+
) %>
|
|
40
|
+
</span>
|
|
41
|
+
<% end %>
|
|
42
|
+
<% else %>
|
|
43
|
+
<%= t("administrate.fields.has_many.none", default: "–") %>
|
|
44
|
+
<% end %>
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
<%#
|
|
2
|
+
# HasMany Show Partial
|
|
3
|
+
This partial renders a has_many relationship,
|
|
4
|
+
to be displayed on a resource's show page.
|
|
5
|
+
By default, the relationship is rendered
|
|
6
|
+
as a table of the first few associated resources.
|
|
7
|
+
The columns of the table are taken
|
|
8
|
+
from the associated resource class's dashboard.
|
|
9
|
+
## Local variables:
|
|
10
|
+
- `field`:
|
|
11
|
+
An instance of [Administrate::Field::HasMany][1].
|
|
12
|
+
Contains methods to help display a table of associated resources.
|
|
13
|
+
[1]: http://www.rubydoc.info/gems/administrate/Administrate/Field/HasMany
|
|
14
|
+
%>
|
|
15
|
+
|
|
16
|
+
<% if field.resources.any? %>
|
|
17
|
+
<%= render(
|
|
18
|
+
"collection",
|
|
19
|
+
collection_presenter: field.associated_collection,
|
|
20
|
+
resources: field.resources,
|
|
21
|
+
table_title: field.name
|
|
22
|
+
) %>
|
|
23
|
+
|
|
24
|
+
<% if field.more_than_limit? %>
|
|
25
|
+
<span>
|
|
26
|
+
<%= t(
|
|
27
|
+
'administrate.fields.has_many.more',
|
|
28
|
+
count: field.limit,
|
|
29
|
+
total_count: field.data.count,
|
|
30
|
+
) %>
|
|
31
|
+
</span>
|
|
32
|
+
<% end %>
|
|
33
|
+
|
|
34
|
+
<% else %>
|
|
35
|
+
<%= t("administrate.fields.has_many.none", default: "–") %>
|
|
36
|
+
<% end %>
|
data/bin/rails
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# This command will automatically be run when you run "rails" with Rails gems
|
|
3
|
+
# installed from the root of your application.
|
|
4
|
+
|
|
5
|
+
ENGINE_ROOT = File.expand_path('..', __dir__)
|
|
6
|
+
APP_PATH = File.expand_path('../spec/dummy/config/application', __dir__)
|
|
7
|
+
|
|
8
|
+
# Set up gems listed in the Gemfile.
|
|
9
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
|
|
10
|
+
require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
|
|
11
|
+
|
|
12
|
+
require 'rails/all'
|
|
13
|
+
require 'rails/engine/commands'
|