plutonium 0.10.2 → 0.11.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 +4 -4
- data/README.md +1 -0
- data/Rakefile +1 -2
- data/app/assets/application.js.bk +31419 -0
- data/app/assets/plutonium-logo-original.png +0 -0
- data/app/assets/plutonium-logo-white.png +0 -0
- data/app/assets/plutonium-logo.png +0 -0
- data/app/assets/plutonium.css +1 -0
- data/app/assets/plutonium.ico +0 -0
- data/app/assets/plutonium.js +12416 -0
- data/app/assets/plutonium.js.map +7 -0
- data/app/assets/plutonium.min.js +39 -0
- data/app/assets/plutonium.min.js.map +7 -0
- data/app/views/application/_flash_alerts.html.erb +5 -2
- data/app/views/application/_flash_toasts.html.erb +2 -0
- data/app/views/application/_resource_header.html.erb +263 -697
- data/app/views/application/_resource_sidebar.html.erb +14 -12
- data/app/views/components/action_button/action_button_component.rb +3 -3
- data/app/views/components/attributes.rb +184 -0
- data/app/views/components/base.rb +19 -40
- data/app/views/components/block/block_component.html.erb +1 -1
- data/app/views/components/block/block_component.rb +11 -7
- data/app/views/components/breadcrumbs/breadcrumbs_component.rb +3 -3
- data/app/views/components/button/button_component.html.erb +2 -2
- data/app/views/components/button/button_component.rb +10 -5
- data/app/views/components/dyna_frame_content/dyna_frame_content_component.html.erb +1 -0
- data/app/views/components/dyna_frame_content/dyna_frame_content_component.rb +3 -3
- data/app/views/components/dyna_frame_host/dyna_frame_host_component.html.erb +1 -2
- data/app/views/components/dyna_frame_host/dyna_frame_host_component.rb +12 -5
- data/app/views/components/empty_card/empty_card_component.rb +3 -3
- data/app/views/components/form/form_builder.rb +1 -1
- data/app/views/components/form/form_component.rb +3 -3
- data/app/views/components/has_many_panel/has_many_panel_component.html.erb +25 -0
- data/app/views/components/has_many_panel/has_many_panel_component.rb +16 -0
- data/app/views/components/header/header_component.rb +3 -3
- data/app/views/components/interactive_action_form/interactive_action_form_component.rb +3 -3
- data/app/views/components/nav_grid_menu/nav_grid_menu_component.html.erb +24 -0
- data/app/views/components/nav_grid_menu/nav_grid_menu_component.rb +23 -0
- data/app/views/components/nav_grid_menu_item/nav_grid_menu_item_component.html.erb +4 -0
- data/app/views/components/nav_grid_menu_item/nav_grid_menu_item_component.rb +20 -0
- data/app/views/components/nav_user/nav_user_component.html.erb +50 -0
- data/app/views/components/nav_user/nav_user_component.rb +32 -0
- data/app/views/components/nav_user_link/nav_user_link_component.html.erb +7 -0
- data/app/views/components/nav_user_link/nav_user_link_component.rb +23 -0
- data/app/views/components/nav_user_section/nav_user_section_component.html.erb +7 -0
- data/app/views/components/nav_user_section/nav_user_section_component.rb +18 -0
- data/app/views/components/nested_resource_form_fields/nested_resource_form_fields_component.html.erb +1 -3
- data/app/views/components/nested_resource_form_fields/nested_resource_form_fields_component.rb +11 -5
- data/app/views/components/pagination/pagination_component.html.erb +1 -1
- data/app/views/components/pagination/pagination_component.rb +10 -7
- data/app/views/components/panel/panel_component.html.erb +13 -6
- data/app/views/components/panel/panel_component.rb +11 -5
- data/app/views/components/resource_header/resource_header_component.html.erb +81 -0
- data/app/views/components/resource_header/resource_header_component.rb +20 -0
- data/app/views/components/resource_layout/resource_layout_component.html.erb +32 -0
- data/app/views/components/resource_layout/resource_layout_component.rb +39 -0
- data/app/views/components/sidebar/sidebar_component.html.erb +3 -33
- data/app/views/components/sidebar/sidebar_component.rb +3 -3
- data/app/views/components/sidebar_menu/sidebar_menu_component.html.erb +4 -2
- data/app/views/components/sidebar_menu/sidebar_menu_component.rb +10 -6
- data/app/views/components/sidebar_menu_item/sidebar_menu_item_component.html.erb +63 -71
- data/app/views/components/sidebar_menu_item/sidebar_menu_item_component.rb +27 -8
- data/app/views/components/skeleton/table/table_component.html.erb +1 -1
- data/app/views/components/skeleton/table/table_component.rb +3 -3
- data/app/views/components/table/table_component.html.erb +40 -89
- data/app/views/components/table/table_component.rb +124 -28
- data/app/views/components/table_search_input/table_search_input_component.html.erb +1 -1
- data/app/views/components/table_search_input/table_search_input_component.rb +11 -6
- data/app/views/components/table_toolbar/table_toolbar_component.html.erb +1 -1
- data/app/views/components/table_toolbar/table_toolbar_component.rb +11 -3
- data/app/views/components/toolbar/toolbar_component.html.erb +2 -2
- data/app/views/components/toolbar/toolbar_component.rb +16 -8
- data/app/views/layouts/resource.html copy.erb +2 -2
- data/app/views/layouts/resource.html.erb +21 -37
- data/app/views/layouts/rodauth.html.erb +32 -25
- data/app/views/resource/_interactive_resource_action_form.html.erb +1 -1
- data/app/views/resource/_resource_details.html.erb +8 -5
- data/app/views/resource/_resource_table.html.erb +70 -1
- data/app/views/resource/interactive_resource_collection_action.html.erb +1 -0
- data/app/views/resource/interactive_resource_record_action.html.erb +1 -0
- data/app/views/resource/interactive_resource_recordless_action.html.erb +1 -0
- data/app/views/resource/new.html.erb +1 -0
- data/app/views/rodauth/add_recovery_codes.html.erb +8 -7
- data/app/views/rodauth/otp_auth.html.erb +1 -1
- data/app/views/rodauth/otp_setup.html.erb +10 -8
- data/config/initializers/simple_form.rb +22 -2
- data/esbuild.config.js +35 -31
- data/lib/generators/pu/core/assets/assets_generator.rb +41 -0
- data/lib/generators/pu/core/assets/templates/tailwind.config.js +18 -0
- data/lib/generators/pu/core/install/templates/config/initializers/plutonium.rb +3 -0
- data/lib/generators/pu/core/ruby/ruby_generator.rb +30 -0
- data/lib/generators/pu/core/ruby/templates/.keep +0 -0
- data/lib/generators/pu/docker/install/install_generator.rb +35 -0
- data/lib/generators/pu/docker/install/templates/.keep +0 -0
- data/lib/generators/pu/docker/install/templates/Dockerfile.dev.tt +30 -0
- data/lib/generators/pu/docker/install/templates/Dockerfile.tt +75 -0
- data/lib/generators/pu/docker/install/templates/bin/console +3 -0
- data/lib/generators/pu/docker/install/templates/bin/restart +3 -0
- data/lib/generators/pu/docker/install/templates/bin/shell +3 -0
- data/lib/generators/pu/docker/install/templates/docker-compose.yml +29 -0
- data/lib/generators/pu/gem/dotenv/dotenv_generator.rb +32 -0
- data/lib/generators/pu/gem/dotenv/templates/.env +6 -0
- data/lib/generators/pu/gem/dotenv/templates/.env.local +5 -0
- data/lib/generators/pu/gem/dotenv/templates/.env.local.template +5 -0
- data/lib/generators/pu/gem/dotenv/templates/.env.template +6 -0
- data/lib/generators/pu/gem/dotenv/templates/.keep +0 -0
- data/lib/generators/pu/gem/dotenv/templates/config/initializers/001_ensure_required_env.rb +21 -0
- data/lib/generators/pu/gem/redis/redis_generator.rb +22 -0
- data/lib/generators/pu/gem/redis/templates/.keep +0 -0
- data/lib/generators/pu/gen/component/component_generator.rb +13 -10
- data/lib/generators/pu/gen/component/templates/component.html.erb.tt +1 -1
- data/lib/generators/pu/gen/component/templates/component.rb.tt +10 -4
- data/lib/generators/pu/lib/plutonium_generators/concerns/actions.rb +154 -32
- data/lib/generators/pu/lib/plutonium_generators/generator.rb +6 -6
- data/lib/generators/pu/lib/plutonium_generators/installer.rb +1 -1
- data/lib/generators/pu/pkg/app/app_generator.rb +4 -4
- data/lib/generators/pu/pkg/app/templates/app/controllers/concerns/controller.rb.tt +28 -0
- data/lib/generators/pu/pkg/app/templates/app/controllers/controller.rb.tt +5 -0
- data/lib/generators/pu/pkg/app/templates/app/controllers/dashboard_controller.rb.tt +1 -1
- data/lib/generators/pu/res/conn/conn_generator.rb +4 -4
- data/lib/generators/pu/res/conn/templates/app/controllers/resource_controller.rb.tt +1 -1
- data/lib/generators/pu/res/model/model_generator.rb +3 -3
- data/lib/generators/pu/res/scaffold/templates/policy.rb.tt +6 -0
- data/lib/generators/pu/rodauth/account_generator.rb +10 -10
- data/lib/generators/pu/rodauth/install_generator.rb +9 -2
- data/lib/generators/pu/rodauth/migration/sequel/audit_logging.erb +2 -2
- data/lib/generators/pu/rodauth/migration_generator.rb +1 -1
- data/lib/generators/pu/rodauth/templates/app/{misc → rodauth}/account_rodauth_plugin.rb.tt +2 -2
- data/lib/generators/pu/rodauth/templates/app/{misc → rodauth}/rodauth_plugin.rb.tt +0 -3
- data/lib/generators/pu/rodauth/templates/db/migrate/install_rodauth.rb.tt +5 -0
- data/lib/generators/pu/service/postgres/postgres_generator.rb +61 -0
- data/lib/generators/pu/service/postgres/templates/.keep +0 -0
- data/lib/generators/pu/service/postgres/templates/bin/initdb.d/create-multiple-postgresql-databases.sh +22 -0
- data/lib/generators/pu/service/postgres/templates/database.yml.tt +93 -0
- data/lib/generators/pu/service/sidekiq/sidekiq_generator.rb +57 -0
- data/lib/generators/pu/service/sidekiq/templates/.keep +0 -0
- data/lib/generators/pu/service/sidekiq/templates/app/sidekiq/sidekiq_job.rb +3 -0
- data/lib/generators/pu/service/sidekiq/templates/config/initializers/sidekiq.rb +53 -0
- data/lib/generators/pu/service/sidekiq/templates/config/sidekiq.yml +6 -0
- data/lib/plutonium/config.rb +2 -9
- data/lib/plutonium/core/associations/renderers/basic_renderer.rb +28 -0
- data/lib/plutonium/core/associations/renderers/factory.rb +36 -0
- data/lib/plutonium/core/associations/renderers/has_many_renderer.rb +16 -0
- data/lib/plutonium/core/autodiscovery/association_renderer_discoverer.rb +31 -0
- data/lib/plutonium/core/controllers/authorizable.rb +13 -17
- data/lib/plutonium/core/controllers/base.rb +3 -7
- data/lib/plutonium/core/controllers/entity_scoping.rb +3 -3
- data/lib/plutonium/core/controllers/presentable.rb +6 -1
- data/lib/plutonium/core/definers/association_renderer_definer.rb +33 -0
- data/lib/plutonium/core/fields/inputs/checkbox_input.rb +13 -0
- data/lib/plutonium/core/fields/inputs/factory.rb +1 -0
- data/lib/plutonium/core/fields/inputs/polymorphic_belongs_to_association_input.rb +1 -1
- data/lib/plutonium/core/ui/detail.rb +1 -0
- data/lib/plutonium/helpers/application_helper.rb +8 -9
- data/lib/plutonium/helpers/assets_helper.rb +33 -0
- data/lib/plutonium/helpers/display_helper.rb +13 -0
- data/lib/plutonium/helpers/form_helper.rb +1 -1
- data/lib/plutonium/helpers.rb +1 -0
- data/lib/plutonium/icons.rb +12 -5
- data/lib/plutonium/pkg/app.rb +10 -0
- data/lib/plutonium/pundit/context.rb +18 -0
- data/lib/plutonium/pundit/policy_finder.rb +25 -0
- data/lib/plutonium/railtie.rb +24 -8
- data/lib/plutonium/reloader.rb +18 -7
- data/lib/plutonium/resource/controller.rb +5 -0
- data/lib/plutonium/resource/policy.rb +69 -47
- data/lib/plutonium/resource/presenter.rb +1 -0
- data/lib/plutonium/resource/query_object.rb +139 -130
- data/lib/plutonium/rodauth/controller_methods.rb +7 -3
- data/lib/plutonium/version.rb +1 -1
- data/lib/plutonium.rb +10 -54
- data/lib/tasks/create_rodauth_admin.rake +16 -0
- data/package-lock.json +782 -17
- data/package.json +31 -8
- data/postcss.config.js +17 -7
- data/src/.npmignore +2 -0
- data/src/js/controllers/color_mode_controller.js +41 -0
- data/src/js/controllers/frame_navigator_controller.js +99 -0
- data/src/js/controllers/has_many_panel_controller.js +8 -0
- data/src/js/controllers/nav_grid_menu_controller.js +8 -0
- data/src/js/controllers/nav_grid_menu_item_controller.js +8 -0
- data/{app/views/components/tab_bar/tab_bar_controller.js → src/js/controllers/nav_user_controller.js} +2 -2
- data/src/js/controllers/nav_user_link_controller.js +8 -0
- data/src/js/controllers/nav_user_section_controller.js +8 -0
- data/src/js/controllers/register_controllers.js +45 -0
- data/{app/assets/javascripts → src/js}/controllers/resource_dismiss_controller.js +2 -0
- data/{app/assets/javascripts → src/js}/controllers/resource_drop_down_controller.js +2 -0
- data/src/js/controllers/resource_header_controller.js +8 -0
- data/src/js/controllers/resource_layout_controller.js +8 -0
- data/src/js/controllers/sidebar_menu_controller.js +8 -0
- data/src/js/controllers/sidebar_menu_item_controller.js +8 -0
- data/src/js/core.js +4 -0
- data/{app/assets/javascripts/plutonium-app.js → src/js/plutonium.js} +1 -1
- data/{app/assets/javascripts → src/js}/turbo/turbo_debug.js +2 -4
- data/tailwind.config.js +85 -84
- metadata +106 -41
- data/app/assets/build/plutonium.js +0 -5122
- data/app/assets/javascripts/controllers/index.js +0 -34
- data/app/assets/javascripts/plutonium.js +0 -1
- data/app/views/application/_color_modes.html.erb +0 -57
- data/app/views/components/tab_bar/tab_bar_component.html.erb +0 -11
- data/app/views/components/tab_bar/tab_bar_component.rb +0 -9
- data/app/views/resource/_nav_user.html.erb +0 -4
- data/app/views/resource/_tab_menu.html.erb +0 -13
- data/css.manifest +0 -3
- data/js.manifest +0 -4
- data/lib/generators/pu/pkg/app/templates/app/controllers/app_controller.rb.tt +0 -5
- data/lib/generators/pu/pkg/app/templates/app/controllers/package_controller.rb.tt +0 -26
- data/public/plutonium-assets/application.css +0 -25086
- data/public/plutonium-assets/plutonium-app-36KN5FVJ.js +0 -6
- data/public/plutonium-assets/plutonium-app-36KN5FVJ.js.map +0 -7
- data/public/plutonium-assets/plutonium-app-6WILQCTT.js +0 -39
- data/public/plutonium-assets/plutonium-app-6WILQCTT.js.map +0 -7
- data/public/plutonium-assets/plutonium.2d4f0c333cd000051d3b.css +0 -3424
- data/public/plutonium-assets/plutonium.50232e35b5495f5ad90d.css +0 -3415
- /data/{app/assets/build → lib/generators/pu/core/assets/templates}/.keep +0 -0
- /data/lib/generators/pu/rodauth/templates/app/{misc → rodauth}/rodauth_app.rb.tt +0 -0
- /data/{app/assets/stylesheets → src/css}/plutonium.css +0 -0
- /data/{app/views/components/form → src/js/controllers}/form_controller.js +0 -0
- /data/{app/views/components/interactive_action_form → src/js/controllers}/interactive_action_form_controller.js +0 -0
- /data/{app/views/components/nested_resource_form_fields → src/js/controllers}/nested_resource_form_fields_controller.js +0 -0
- /data/{app/views/components/table → src/js/controllers}/table_controller.js +0 -0
- /data/{app/views/components/table_search_input → src/js/controllers}/table_search_input_controller.js +0 -0
- /data/{app/views/components/table_toolbar → src/js/controllers}/table_toolbar_controller.js +0 -0
- /data/{app/views/components/toolbar → src/js/controllers}/toolbar_controller.js +0 -0
- /data/{app/assets/javascripts → src/js}/turbo/index.js +0 -0
- /data/{app/assets/javascripts → src/js}/turbo/turbo_actions.js +0 -0
- /data/{app/assets/javascripts → src/js}/turbo/turbo_frame_monkey_patch.js +0 -0
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
module Plutonium
|
|
2
2
|
module Resource
|
|
3
|
-
# Policy class to define permissions and attributes for a resource
|
|
3
|
+
# Policy class to define permissions and attributes for a resource.
|
|
4
|
+
# This class provides methods to check permissions for various actions
|
|
5
|
+
# and to retrieve permitted attributes for these actions.
|
|
4
6
|
class Policy
|
|
5
7
|
include Plutonium::Policy::Initializer
|
|
6
8
|
|
|
9
|
+
# Scope class to define the scope of the policy.
|
|
7
10
|
class Scope < Plutonium::Policy::Scope
|
|
8
11
|
end
|
|
9
12
|
|
|
10
|
-
# Sends a method and raises an error if the method is not implemented
|
|
11
|
-
#
|
|
13
|
+
# Sends a method and raises an error if the method is not implemented.
|
|
14
|
+
#
|
|
15
|
+
# @param method [Symbol] The method to send.
|
|
12
16
|
def send_with_report(method)
|
|
13
17
|
unless respond_to?(method)
|
|
14
18
|
raise NotImplementedError, "#{self.class.name} does not implement the required #{method}"
|
|
@@ -19,66 +23,76 @@ module Plutonium
|
|
|
19
23
|
|
|
20
24
|
# Core actions
|
|
21
25
|
|
|
22
|
-
# Checks if the create action is permitted
|
|
23
|
-
#
|
|
26
|
+
# Checks if the create action is permitted.
|
|
27
|
+
#
|
|
28
|
+
# @return [Boolean] false by default.
|
|
24
29
|
def create?
|
|
25
30
|
false
|
|
26
31
|
end
|
|
27
32
|
|
|
28
|
-
# Checks if the read action is permitted
|
|
29
|
-
#
|
|
33
|
+
# Checks if the read action is permitted.
|
|
34
|
+
#
|
|
35
|
+
# @return [Boolean] false by default.
|
|
30
36
|
def read?
|
|
31
37
|
false
|
|
32
38
|
end
|
|
33
39
|
|
|
34
|
-
# Checks if the update action is permitted
|
|
35
|
-
#
|
|
40
|
+
# Checks if the update action is permitted.
|
|
41
|
+
#
|
|
42
|
+
# @return [Boolean] Delegates to create?.
|
|
36
43
|
def update?
|
|
37
44
|
create?
|
|
38
45
|
end
|
|
39
46
|
|
|
40
|
-
# Checks if the destroy action is permitted
|
|
41
|
-
#
|
|
47
|
+
# Checks if the destroy action is permitted.
|
|
48
|
+
#
|
|
49
|
+
# @return [Boolean] Delegates to create?.
|
|
42
50
|
def destroy?
|
|
43
51
|
create?
|
|
44
52
|
end
|
|
45
53
|
|
|
46
54
|
# Inferred actions
|
|
47
55
|
|
|
48
|
-
# Checks if the index action is permitted
|
|
49
|
-
#
|
|
56
|
+
# Checks if the index action is permitted.
|
|
57
|
+
#
|
|
58
|
+
# @return [Boolean] Delegates to read?.
|
|
50
59
|
def index?
|
|
51
60
|
read?
|
|
52
61
|
end
|
|
53
62
|
|
|
54
|
-
# Checks if the new action is permitted
|
|
55
|
-
#
|
|
63
|
+
# Checks if the new action is permitted.
|
|
64
|
+
#
|
|
65
|
+
# @return [Boolean] Delegates to create?.
|
|
56
66
|
def new?
|
|
57
67
|
create?
|
|
58
68
|
end
|
|
59
69
|
|
|
60
|
-
# Checks if the show action is permitted
|
|
61
|
-
#
|
|
70
|
+
# Checks if the show action is permitted.
|
|
71
|
+
#
|
|
72
|
+
# @return [Boolean] Delegates to read?.
|
|
62
73
|
def show?
|
|
63
74
|
read?
|
|
64
75
|
end
|
|
65
76
|
|
|
66
|
-
# Checks if the edit action is permitted
|
|
67
|
-
#
|
|
77
|
+
# Checks if the edit action is permitted.
|
|
78
|
+
#
|
|
79
|
+
# @return [Boolean] Delegates to update?.
|
|
68
80
|
def edit?
|
|
69
81
|
update?
|
|
70
82
|
end
|
|
71
83
|
|
|
72
|
-
# Checks if the search action is permitted
|
|
73
|
-
#
|
|
84
|
+
# Checks if the search action is permitted.
|
|
85
|
+
#
|
|
86
|
+
# @return [Boolean] Delegates to index?.
|
|
74
87
|
def search?
|
|
75
88
|
index?
|
|
76
89
|
end
|
|
77
90
|
|
|
78
91
|
# Core attributes
|
|
79
92
|
|
|
80
|
-
# Returns the permitted attributes for the create action
|
|
81
|
-
#
|
|
93
|
+
# Returns the permitted attributes for the create action.
|
|
94
|
+
#
|
|
95
|
+
# @return [Array<Symbol>] The permitted attributes.
|
|
82
96
|
def permitted_attributes_for_create
|
|
83
97
|
autodetect_permitted_fields(:permitted_attributes_for_create) - [
|
|
84
98
|
context.resource_context.resource_class.primary_key.to_sym, # primary_key
|
|
@@ -86,64 +100,72 @@ module Plutonium
|
|
|
86
100
|
]
|
|
87
101
|
end
|
|
88
102
|
|
|
89
|
-
# Returns the permitted attributes for the read action
|
|
90
|
-
#
|
|
103
|
+
# Returns the permitted attributes for the read action.
|
|
104
|
+
#
|
|
105
|
+
# @return [Array<Symbol>] The permitted attributes.
|
|
91
106
|
def permitted_attributes_for_read
|
|
92
107
|
autodetect_permitted_fields(:permitted_attributes_for_read)
|
|
93
108
|
end
|
|
94
109
|
|
|
95
|
-
# Returns the permitted attributes for the update action
|
|
96
|
-
#
|
|
110
|
+
# Returns the permitted attributes for the update action.
|
|
111
|
+
#
|
|
112
|
+
# @return [Array<Symbol>] Delegates to permitted_attributes_for_create.
|
|
97
113
|
def permitted_attributes_for_update
|
|
98
114
|
permitted_attributes_for_create
|
|
99
115
|
end
|
|
100
116
|
|
|
101
117
|
# Inferred attributes
|
|
102
118
|
|
|
103
|
-
# Returns the permitted attributes for the index action
|
|
104
|
-
#
|
|
119
|
+
# Returns the permitted attributes for the index action.
|
|
120
|
+
#
|
|
121
|
+
# @return [Array<Symbol>] Delegates to permitted_attributes_for_read.
|
|
105
122
|
def permitted_attributes_for_index
|
|
106
123
|
permitted_attributes_for_read
|
|
107
124
|
end
|
|
108
125
|
|
|
109
|
-
# Returns the permitted attributes for the show action
|
|
110
|
-
#
|
|
126
|
+
# Returns the permitted attributes for the show action.
|
|
127
|
+
#
|
|
128
|
+
# @return [Array<Symbol>] Delegates to permitted_attributes_for_read.
|
|
111
129
|
def permitted_attributes_for_show
|
|
112
130
|
permitted_attributes_for_read
|
|
113
131
|
end
|
|
114
132
|
|
|
115
|
-
# Returns the permitted attributes for the new action
|
|
116
|
-
#
|
|
133
|
+
# Returns the permitted attributes for the new action.
|
|
134
|
+
#
|
|
135
|
+
# @return [Array<Symbol>] Delegates to permitted_attributes_for_create.
|
|
117
136
|
def permitted_attributes_for_new
|
|
118
137
|
permitted_attributes_for_create
|
|
119
138
|
end
|
|
120
139
|
|
|
121
|
-
# Returns the permitted attributes for the edit action
|
|
122
|
-
#
|
|
140
|
+
# Returns the permitted attributes for the edit action.
|
|
141
|
+
#
|
|
142
|
+
# @return [Array<Symbol>] Delegates to permitted_attributes_for_update.
|
|
123
143
|
def permitted_attributes_for_edit
|
|
124
144
|
permitted_attributes_for_update
|
|
125
145
|
end
|
|
126
146
|
|
|
127
|
-
#
|
|
128
|
-
#
|
|
129
|
-
#
|
|
130
|
-
|
|
131
|
-
|
|
147
|
+
# Returns the permitted associations.
|
|
148
|
+
#
|
|
149
|
+
# @return [Array<Symbol>] An empty array by default.
|
|
150
|
+
def permitted_associations
|
|
151
|
+
[]
|
|
152
|
+
end
|
|
132
153
|
|
|
133
154
|
private
|
|
134
155
|
|
|
135
|
-
# Autodetects the permitted fields for a given method
|
|
136
|
-
#
|
|
137
|
-
# @
|
|
156
|
+
# Autodetects the permitted fields for a given method.
|
|
157
|
+
#
|
|
158
|
+
# @param method_name [Symbol] The name of the method.
|
|
159
|
+
# @return [Array<Symbol>] The auto-detected permitted fields.
|
|
138
160
|
def autodetect_permitted_fields(method_name)
|
|
139
161
|
warn_about_autodetect_usage(method_name)
|
|
140
|
-
|
|
141
162
|
context.resource_context.resource_class.resource_field_names
|
|
142
163
|
end
|
|
143
164
|
|
|
144
|
-
# Warns about the usage of auto-detection of fields
|
|
145
|
-
#
|
|
146
|
-
# @
|
|
165
|
+
# Warns about the usage of auto-detection of fields.
|
|
166
|
+
#
|
|
167
|
+
# @param method [Symbol] The method name.
|
|
168
|
+
# @raise [RuntimeError] if not in the development environment.
|
|
147
169
|
def warn_about_autodetect_usage(method)
|
|
148
170
|
unless Rails.env.development?
|
|
149
171
|
raise "Resource field auto-detection: #{self.class}##{method} outside development"
|
|
@@ -5,6 +5,7 @@ module Plutonium
|
|
|
5
5
|
class Presenter
|
|
6
6
|
include Plutonium::Core::Definers::FieldDefiner
|
|
7
7
|
include Plutonium::Core::Definers::ActionDefiner
|
|
8
|
+
include Plutonium::Core::Definers::AssociationRendererDefiner
|
|
8
9
|
|
|
9
10
|
# Initializes the presenter with context and resource record
|
|
10
11
|
# @param [Object] context The context in which the presenter is used
|