habarico 7.3.0.pre.beta.9 → 7.3.0.pre.beta.11
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/VERSION +1 -1
- data/lib/generators/habarico/preferences/install_generator.rb +3 -0
- data/lib/habarico/config.rb +2 -2
- data/lib/habarico/generators/action/view_action_parameters_generator.rb +7 -7
- data/lib/habarico/generators/menu/menu_view_parameters_generator.rb +2 -2
- data/lib/habarico/generators/resource/local_resource_schema_generator.rb +3 -3
- data/lib/habarico/schema/action/view_action_parameters.rb +2 -2
- data/lib/habarico.rb +6 -0
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6c0c12a78eabc5ec2b734b49fe2631728bebfaaf0dccab0af628c195dc333880
|
|
4
|
+
data.tar.gz: 5bd53485346b0d43bef3791d74c69603a5b6ae8f005fed3eebacabeb4479affa
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 554f357c1b5c47e163d4cbbb9fc441a921a116a05d360e3a01351f8cd120df1135603d512b31c92dd745ecb704347f478b4093b1d657568559407c50d8e66d5e
|
|
7
|
+
data.tar.gz: f1276d2569f91a2365dcdbf07d0c66d1eee8d24cdf39e9d34212b685f788baba7c70686aec9eca61ce0f508edc1ff870819ab5ff63ae2b6483dd729a421071d0
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
7.3.0-beta.
|
|
1
|
+
7.3.0-beta.11
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
require "rails/generators"
|
|
2
2
|
require "rails/generators/migration"
|
|
3
|
+
# Defines ActiveRecord::Generators::Base, whose next_migration_number is reused below. Railties
|
|
4
|
+
# does not autoload it, so without this require the generator fails with a NameError.
|
|
5
|
+
require "rails/generators/active_record"
|
|
3
6
|
|
|
4
7
|
module Habarico
|
|
5
8
|
module Preferences
|
data/lib/habarico/config.rb
CHANGED
|
@@ -53,8 +53,8 @@ module Habarico
|
|
|
53
53
|
# Name of the method Habarico calls (via `send`) as its authentication before_action, on both
|
|
54
54
|
# Habarico::Controller and Habarico::ApplicationController. Point this at an existing no-argument
|
|
55
55
|
# auth method on your ApplicationController (e.g. `:authenticate_user!`) to reuse it directly. If
|
|
56
|
-
# your auth method
|
|
57
|
-
#
|
|
56
|
+
# your auth method takes arguments, define a one-line wrapper method instead and point this at
|
|
57
|
+
# that.
|
|
58
58
|
mattr_accessor :authenticate_method
|
|
59
59
|
@@authenticate_method = :authenticate_request
|
|
60
60
|
|
|
@@ -13,19 +13,19 @@ module Habarico
|
|
|
13
13
|
dialog_width: generate_dialog_width(action, context),
|
|
14
14
|
parameters: generate_parameters(action, context),
|
|
15
15
|
choices: generate_choices(action, context),
|
|
16
|
-
|
|
16
|
+
reference: generate_reference(action, context),
|
|
17
17
|
keep_linked_parent: generate_keep_linked_parent(action, context)
|
|
18
18
|
)
|
|
19
19
|
end
|
|
20
20
|
|
|
21
21
|
protected
|
|
22
22
|
|
|
23
|
-
# What the view
|
|
23
|
+
# What the view action addresses, left unaddressed when the action points at nothing of its
|
|
24
24
|
# own. `action_name` and `record_pk` live inside the address, so an action that has either names
|
|
25
25
|
# the resource it belongs to - the same rule the resource action endpoint follows. Only an
|
|
26
26
|
# explicit `endpoint_record_pk` is carried: the record of the request is the one the frontend
|
|
27
27
|
# already renders.
|
|
28
|
-
def
|
|
28
|
+
def view_action_reference(action, _context)
|
|
29
29
|
action_name = target_view_action_name(action)
|
|
30
30
|
record_pk = action.endpoint_record_pk.presence
|
|
31
31
|
reference = action.endpoint_reference
|
|
@@ -68,12 +68,12 @@ module Habarico
|
|
|
68
68
|
Habarico::CallableHelper.resolve(action.view_choices, context)
|
|
69
69
|
end
|
|
70
70
|
|
|
71
|
-
def
|
|
72
|
-
# A standard action of the current resource needs no
|
|
73
|
-
# over the record it already has. One that names its own target does: the
|
|
71
|
+
def generate_reference(action, context)
|
|
72
|
+
# A standard action of the current resource needs no reference - the frontend opens the view
|
|
73
|
+
# over the record it already has. One that names its own target does: the reference is where
|
|
74
74
|
# the target resource and record are written down.
|
|
75
75
|
return nil if Habarico::ActionHelper.is_standard_action?(action) && !Habarico::ActionHelper.has_explicit_target?(action)
|
|
76
|
-
|
|
76
|
+
view_action_reference(action, context)
|
|
77
77
|
end
|
|
78
78
|
|
|
79
79
|
def generate_keep_linked_parent(action, _context)
|
|
@@ -11,7 +11,7 @@ module Habarico
|
|
|
11
11
|
name: generate_name(menu_item),
|
|
12
12
|
mode: generate_mode(menu_item),
|
|
13
13
|
dialog_width: generate_dialog_width(menu_item),
|
|
14
|
-
|
|
14
|
+
reference: generate_reference(menu_item),
|
|
15
15
|
keep_linked_parent: generate_keep_linked_parent(menu_item)
|
|
16
16
|
)
|
|
17
17
|
end
|
|
@@ -38,7 +38,7 @@ module Habarico
|
|
|
38
38
|
menu_item.dialog_width
|
|
39
39
|
end
|
|
40
40
|
|
|
41
|
-
def
|
|
41
|
+
def generate_reference(menu_item)
|
|
42
42
|
menu_view_endpoint_parameters_generator.generate(menu_item)
|
|
43
43
|
end
|
|
44
44
|
|
|
@@ -89,9 +89,9 @@ module Habarico
|
|
|
89
89
|
end
|
|
90
90
|
|
|
91
91
|
def generate_endpoints(_context, endpoint_parameters)
|
|
92
|
-
# Determine endpoint methods to be included
|
|
93
|
-
#
|
|
94
|
-
methods = endpoint_parameters.select { |e| e.
|
|
92
|
+
# Determine endpoint methods to be included from the endpoint parameters of the actions and views that address
|
|
93
|
+
# the resource itself (no reference; an action name always comes with one). Additionally, always include GET.
|
|
94
|
+
methods = endpoint_parameters.select { |e| e.reference.blank? }.map { |e| e.method.to_sym }
|
|
95
95
|
methods << :get # Ensure GET is always present
|
|
96
96
|
methods = methods.uniq
|
|
97
97
|
|
|
@@ -14,9 +14,9 @@ module Habarico
|
|
|
14
14
|
# Width of the dialog, only used when mode is dialog (MUI breakpoint or CSS width value)
|
|
15
15
|
string_attr :dialog_width
|
|
16
16
|
|
|
17
|
-
# What the view
|
|
17
|
+
# What the view action addresses: which resource, which record, which action. `path` and
|
|
18
18
|
# `method` have no place on a view action - how a thing is called is not part of where it is.
|
|
19
|
-
has_one_attr :
|
|
19
|
+
has_one_attr :reference, 'Habarico::ResourceReference'
|
|
20
20
|
|
|
21
21
|
# Additional parameters to be passed to the view
|
|
22
22
|
has_many_attr :parameters, 'String', underlying_type: :hash
|
data/lib/habarico.rb
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
require "eluvia-base"
|
|
2
2
|
|
|
3
|
+
# Runtime dependencies of the gemspec. Bundler.require in a host app only requires what that app
|
|
4
|
+
# lists itself, so without these a host gets `undefined method 'page'` on its first list request
|
|
5
|
+
# (kaminari) or an uninitialised constant from a permission callable (pundit).
|
|
6
|
+
require "kaminari"
|
|
7
|
+
require "pundit"
|
|
8
|
+
|
|
3
9
|
# *****************************************************************************
|
|
4
10
|
# Basic library
|
|
5
11
|
# *****************************************************************************
|