plutonium 0.13.1 → 0.13.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/views/components/form/form_builder.rb +4 -0
- data/lib/generators/pu/lib/plutonium_generators/generator.rb +2 -2
- data/lib/generators/pu/res/conn/conn_generator.rb +1 -1
- data/lib/plutonium/core/controllers/base.rb +2 -4
- data/lib/plutonium/core/controllers/crud_actions.rb +10 -0
- data/lib/plutonium/core/fields/inputs/polymorphic_belongs_to_association_input.rb +2 -2
- data/lib/plutonium/resource/record.rb +2 -2
- data/lib/plutonium/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 866175a8ec5a15285d1fe65350957749b173840f32ed54bfd4eeb929d4ecc735
|
4
|
+
data.tar.gz: 759aff94626c9b5eb9851d0dba4f4fb3f9221284d00bafd960fe95eae87181b7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7f51b28186a4f9618657426c4e63a99eac77483f814fdd471cd05193c2d90dececc208ebd73464565b70d923101889f40655a17303b9e248292695af646f8e92
|
7
|
+
data.tar.gz: d72197c60fa506326f3888c1f1afedc4c0bf09302399b5a55ababee52210b7220c732eeaeb167c94444d94d658b38ea30350c6ee609723f625814b3b3f4a3ace
|
@@ -28,6 +28,10 @@ module PlutoniumUi
|
|
28
28
|
super(...)
|
29
29
|
end
|
30
30
|
|
31
|
+
def return_to(url)
|
32
|
+
@template.tag(:input, type: "hidden", name: "return_to", value: url, hidden: true)
|
33
|
+
end
|
34
|
+
|
31
35
|
def error_notification(options = {})
|
32
36
|
# Overriding this because we want an unstyled error notification
|
33
37
|
translate_error_notification = lambda {
|
@@ -34,11 +34,11 @@ module PlutoniumGenerators
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def available_apps
|
37
|
-
@available_apps ||= ["main_app"] + available_packages.select { |pkg| pkg.ends_with? "_app" }
|
37
|
+
@available_apps ||= ["main_app"] + available_packages.select { |pkg| pkg.ends_with? "_app" }.sort
|
38
38
|
end
|
39
39
|
|
40
40
|
def available_features
|
41
|
-
@available_features ||= ["main_app"] + available_packages.select { |pkg| !pkg.ends_with?("_app") }
|
41
|
+
@available_features ||= ["main_app"] + available_packages.select { |pkg| !pkg.ends_with?("_app") }.sort
|
42
42
|
end
|
43
43
|
|
44
44
|
def select_package(selected_package = nil, msg: "Select package", pkgs: nil)
|
@@ -18,7 +18,7 @@ module Pu
|
|
18
18
|
source_module = (source_feature == "main_app") ? "ResourceRecord" : "#{source_feature.classify}::ResourceRecord"
|
19
19
|
|
20
20
|
Plutonium.eager_load_rails!
|
21
|
-
available_resources = source_module.constantize.descendants.map(&:to_s)
|
21
|
+
available_resources = source_module.constantize.descendants.map(&:to_s).sort
|
22
22
|
selected_resources = prompt.multi_select("Select resources", available_resources)
|
23
23
|
|
24
24
|
@app_namespace = select_app.classify
|
@@ -9,8 +9,6 @@ module Plutonium
|
|
9
9
|
included do
|
10
10
|
add_flash_types :success, :warning, :error
|
11
11
|
|
12
|
-
before_action :set_page_title
|
13
|
-
|
14
12
|
before_action do
|
15
13
|
next unless defined?(ActiveStorage)
|
16
14
|
|
@@ -26,8 +24,8 @@ module Plutonium
|
|
26
24
|
|
27
25
|
private
|
28
26
|
|
29
|
-
def set_page_title
|
30
|
-
@page_title =
|
27
|
+
def set_page_title(page_title)
|
28
|
+
@page_title = page_title
|
31
29
|
end
|
32
30
|
|
33
31
|
def make_page_title(title)
|
@@ -11,6 +11,7 @@ module Plutonium
|
|
11
11
|
# GET /resources(.{format})
|
12
12
|
def index
|
13
13
|
authorize resource_class
|
14
|
+
set_page_title resource_class.model_name.human.pluralize.titleize
|
14
15
|
|
15
16
|
@search_object = current_query_object
|
16
17
|
base_query = policy_scope(resource_class)
|
@@ -25,6 +26,7 @@ module Plutonium
|
|
25
26
|
# GET /resources/1(.{format})
|
26
27
|
def show
|
27
28
|
authorize resource_record
|
29
|
+
set_page_title resource_record.to_label.titleize
|
28
30
|
|
29
31
|
@detail = build_detail
|
30
32
|
|
@@ -34,6 +36,7 @@ module Plutonium
|
|
34
36
|
# GET /resources/new
|
35
37
|
def new
|
36
38
|
authorize resource_class
|
39
|
+
set_page_title "Create #{resource_class.model_name.human.titleize}"
|
37
40
|
|
38
41
|
@resource_record = resource_class.new
|
39
42
|
maybe_apply_submitted_resource_params!
|
@@ -45,6 +48,7 @@ module Plutonium
|
|
45
48
|
# POST /resources(.{format})
|
46
49
|
def create
|
47
50
|
authorize resource_class
|
51
|
+
set_page_title "Create #{resource_class.model_name.human.titleize}"
|
48
52
|
|
49
53
|
@resource_record = resource_class.new resource_params
|
50
54
|
|
@@ -71,6 +75,7 @@ module Plutonium
|
|
71
75
|
# GET /resources/1/edit
|
72
76
|
def edit
|
73
77
|
authorize resource_record
|
78
|
+
set_page_title "Update #{resource_record.to_label.titleize}"
|
74
79
|
|
75
80
|
maybe_apply_submitted_resource_params!
|
76
81
|
@form = build_form
|
@@ -81,6 +86,7 @@ module Plutonium
|
|
81
86
|
# PATCH/PUT /resources/1(.{format})
|
82
87
|
def update
|
83
88
|
authorize resource_record
|
89
|
+
set_page_title "Update #{resource_record.to_label.titleize}"
|
84
90
|
|
85
91
|
respond_to do |format|
|
86
92
|
if resource_record.update(resource_params)
|
@@ -131,6 +137,10 @@ module Plutonium
|
|
131
137
|
private
|
132
138
|
|
133
139
|
def redirect_url_after_submit
|
140
|
+
if (return_to = url_from(params[:return_to]))
|
141
|
+
return return_to
|
142
|
+
end
|
143
|
+
|
134
144
|
url = case preferred_action_after_submit
|
135
145
|
when "show"
|
136
146
|
resource_url_for(resource_record) if current_policy.show?
|
@@ -32,13 +32,13 @@ module Plutonium
|
|
32
32
|
next unless model.table_exists?
|
33
33
|
model.reflect_on_all_associations(:has_many).each do |association|
|
34
34
|
if association.options[:as] == reflection.name
|
35
|
-
associated_classes << model
|
35
|
+
associated_classes << model
|
36
36
|
end
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
40
|
associated_classes.map { |klass|
|
41
|
-
[klass.
|
41
|
+
[klass.model_name.human.pluralize, klass.all]
|
42
42
|
}.to_h
|
43
43
|
end
|
44
44
|
end
|
@@ -181,7 +181,7 @@ module Plutonium
|
|
181
181
|
# @return [ActiveRecord::Reflection::AssociationReflection, nil]
|
182
182
|
def find_association_to_record(record)
|
183
183
|
reflect_on_all_associations.find do |assoc|
|
184
|
-
assoc.klass.name == record.class.name
|
184
|
+
assoc.klass.name == record.class.name unless assoc.polymorphic?
|
185
185
|
rescue
|
186
186
|
assoc.check_validity!
|
187
187
|
raise
|
@@ -267,7 +267,7 @@ module Plutonium
|
|
267
267
|
def belongs_to_association_parameters
|
268
268
|
reflect_on_all_associations(:belongs_to).map do |reflection|
|
269
269
|
input_param = reflection.options[:foreign_key] || :"#{reflection.name}_id"
|
270
|
-
[reflection.name, {input_param => nil}]
|
270
|
+
[reflection.name, {input_param => nil, :"#{reflection.name}_sgid" => nil}]
|
271
271
|
end.to_h
|
272
272
|
end
|
273
273
|
|
data/lib/plutonium/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: plutonium
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.13.
|
4
|
+
version: 0.13.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stefan Froelich
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-07-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: zeitwerk
|