super 0.19.0 → 0.20.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: 9f0389f2e0c768f0d9518a4bee3a7a1ec28431186ab2f2c1eae04c67cb7a0d1c
4
- data.tar.gz: df8188eb7e770f833f000e2e53968cd161f72f5fd3f533aa917074ad926b53dc
3
+ metadata.gz: e47e4344e0e7e7cf55cc943672017a92e7e30d566aa84b28b2351b4f190b22ed
4
+ data.tar.gz: 62b74ffa083bbabe27890359f987e78363e6fc86a8b164d8529155f9eeaff655
5
5
  SHA512:
6
- metadata.gz: e60c90edd1c31515070ef038a5fe019aacc19553943b70e64c40231298440a8e162b5aa883f59f3b842536ca942cc4e0b09a466f622afc7d683bf33af2e6c17c
7
- data.tar.gz: a2ff8276d1b086c8e49fc59d86586af3c834df81e8a206d94b5d1902bf68602f9a9f74cd0a2780af2119ad3b024da369dbfb1ff675406de4d6e5bca76ff4fb0d
6
+ metadata.gz: ec637b18bb09e636e988507036d41dde995a8f33aeacd69a5b94924eadfcbae4acba73a58c32a0d4188f4f3a8ae852c5b9a9566af647bf4e0583484369d4566c
7
+ data.tar.gz: 7a9e37ed3dc2232e902e2d8b770c02e737413eec66cc4df80c1cefdb974e38d523568a1f66962a2943b667c6cb28439c0fb501c98b102747ad511d9d5204cc3c
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Super
2
2
 
3
- ![Unit tests status](https://github.com/zachahn/super/workflows/Unit%20tests/badge.svg?branch=master)
3
+ ![Unit tests status](https://github.com/superadministration/super/workflows/Unit%20tests/badge.svg?branch=master)
4
4
  [![Gem](https://img.shields.io/gem/v/super)][gem]
5
5
  [![Try the demo](https://img.shields.io/badge/demo-try-blue)][demo]
6
6
  [![Read the docs](https://img.shields.io/badge/docs-available-brightgreen)][docs]
@@ -88,7 +88,7 @@ The gem is available under the terms of the [GNU LGPLv3](./LICENSE).
88
88
 
89
89
 
90
90
  [gem]: https://rubygems.org/gems/super
91
- [discussions]: https://github.com/zachahn/super/discussions
91
+ [discussions]: https://github.com/superadministration/super/discussions
92
92
  [docs]: https://superadministration.github.io/
93
- [demo]: https://demo-super.herokuapp.com/admin/members
94
- [demo_source]: https://github.com/zachahn/super_demo
93
+ [demo]: https://demo-super.herokuapp.com/admin
94
+ [demo_source]: https://github.com/superadministration/super_demo
@@ -118,7 +118,7 @@ module Super
118
118
  helper_method def resolved_member_actions(record)
119
119
  member_actions(record).map do |action|
120
120
  if action.respond_to?(:resolve)
121
- action.resolve(record: record, params: params)
121
+ resolve_member_action(action, record)
122
122
  else
123
123
  action
124
124
  end
@@ -128,7 +128,7 @@ module Super
128
128
  helper_method def resolved_collection_actions
129
129
  collection_actions.map do |action|
130
130
  if action.respond_to?(:resolve)
131
- action.resolve(params: params)
131
+ resolve_collection_action(action)
132
132
  else
133
133
  action
134
134
  end
@@ -93,6 +93,14 @@ module Super
93
93
  params.require(strong_params.require(model)).permit(strong_params.permit)
94
94
  end
95
95
 
96
+ helper_method def form_record(record)
97
+ record
98
+ end
99
+
100
+ helper_method def form_action(record)
101
+ Super::Link.polymorphic_parts(record)
102
+ end
103
+
96
104
  # Configures the actions linked to on the index page. This is an optional
97
105
  # method
98
106
  #
@@ -127,6 +135,14 @@ module Super
127
135
  end
128
136
  end
129
137
 
138
+ helper_method def resolve_collection_action(action)
139
+ action.resolve(params: params)
140
+ end
141
+
142
+ helper_method def resolve_member_action(action, record)
143
+ action.resolve(params: params, record: record)
144
+ end
145
+
130
146
  helper_method def filters_enabled?
131
147
  true
132
148
  end
@@ -264,6 +280,13 @@ module Super
264
280
  .offset(@pagination.offset)
265
281
  end
266
282
 
283
+ helper_method def paginated_link(page_query_params)
284
+ polymorphic_path(
285
+ Super::Link.polymorphic_parts(model),
286
+ page_query_params
287
+ )
288
+ end
289
+
267
290
  helper_method def csv_enabled?
268
291
  true
269
292
  end
@@ -286,7 +309,7 @@ module Super
286
309
  Super::Layout.new(
287
310
  main: Super::ViewChain.new(
288
311
  main_panel: Super::Panel.new,
289
- main_header: Super::Partial.new("collection_header"),
312
+ main_header: Super::Partial.new("member_header"),
290
313
  main: :@display
291
314
  )
292
315
  )
@@ -10,9 +10,9 @@ module Super
10
10
  # Super's version of `#form_for`
11
11
  def super_form_for(record, options = {}, &block)
12
12
  original = ActionView::Base.field_error_proc
13
- ActionView::Base.field_error_proc = Form::Builder::FIELD_ERROR_PROC
13
+ ActionView::Base.field_error_proc = FormBuilder::FIELD_ERROR_PROC
14
14
 
15
- options[:builder] ||= Form::Builder
15
+ options[:builder] ||= FormBuilder
16
16
  return form_for(record, options, &block)
17
17
  ensure
18
18
  ActionView::Base.field_error_proc = original
@@ -21,9 +21,9 @@ module Super
21
21
  # Super's version of `#form_with`
22
22
  def super_form_with(**options, &block)
23
23
  original = ActionView::Base.field_error_proc
24
- ActionView::Base.field_error_proc = Form::Builder::FIELD_ERROR_PROC
24
+ ActionView::Base.field_error_proc = FormBuilder::FIELD_ERROR_PROC
25
25
 
26
- options[:builder] ||= Form::Builder
26
+ options[:builder] ||= FormBuilder
27
27
  return form_with(**options, &block)
28
28
  ensure
29
29
  ActionView::Base.field_error_proc = original
@@ -1,5 +1,9 @@
1
+ <% if current_action.collection? %>
1
2
  <div class="whitespace-nowrap gap-1">
2
3
  <% html_id = "batch-checkbox-#{value.to_s.gsub(/[^a-z0-9]+/, "-")}" %>
3
4
  <input type="checkbox" name="batch[]" value="<%= value %>" id="<%= html_id %>">
4
5
  <label for="<%= html_id %>"><%= value %></label>
5
6
  </div>
7
+ <% else %>
8
+ <%= value %>
9
+ <% end %>
@@ -1,4 +1,4 @@
1
- <%= super_form_for(Super::Link.polymorphic_parts(@record), builder: Super::Form::Builder) do |f| %>
1
+ <%= super_form_for(form_record(@record), url: form_action(@record)) do |f| %>
2
2
  <div class="max-w-3xl">
3
3
  <% form.each_attribute do |field, type| %>
4
4
  <%= render(
@@ -5,10 +5,7 @@
5
5
  <% @pagination.each do |page_query_params, is_current_page, display| %>
6
6
  <%= link_to(
7
7
  display,
8
- polymorphic_path(
9
- Super::Link.polymorphic_parts(model),
10
- page_query_params
11
- ),
8
+ paginated_link(page_query_params),
12
9
  class: "inline-block ml-2 text-lg #{is_current_page ? " text-gray-900" : ""}"
13
10
  ) %>
14
11
  <% end %>
@@ -1,3 +1,3 @@
1
1
  <div class="pt-8 text-sm text-gray-800">
2
- <%= t("super.layout.powered_by", env: Rails.env.capitalize, version: Super::VERSION) %>
2
+ <%= t("super.layout.powered_by_html", env: Rails.env.capitalize, version: Super::VERSION) %>
3
3
  </div>
@@ -1,6 +1,12 @@
1
1
  ---
2
2
  en:
3
3
  super:
4
+ actions:
5
+ new: New
6
+ index: Index
7
+ show: View
8
+ edit: Edit
9
+ destroy: Delete
4
10
  batch:
5
11
  none_error: This batch action received no items to act upon
6
12
  csv:
@@ -9,5 +15,5 @@ en:
9
15
  download_current_cta: Download current view
10
16
  download_all_cta: Download all matching query
11
17
  layout:
12
- powered_by: "%{env} environment. Powered by Super %{version}."
18
+ powered_by_html: "%{env} environment. Powered by Super %{version}. <a href='https://superadministration.github.io/v%{version}/'>Developer docs.</a>"
13
19
  mismatching_package_json_gemfile_versions: "The version of Super specified in your package.json file does not match the version specified in your Gemfile.lock."