super 0.17.0 → 0.18.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: f4c1533c37aaa4f56c80a7111be8f640d33a29e9de966acb5d389556224057c5
4
- data.tar.gz: d57b41a260d921a135289497b247df2951d2d1c0399b3668f9c54f2c5ddc981a
3
+ metadata.gz: 7f2150ed8df48ecbdc8c2e2cdc9a7e4661d5b101f3bd179fe8d6cf539dec2307
4
+ data.tar.gz: a5377bf3a75715dd13e014ba47c5eb1d14e7c24f9dfeb0aae7e29683c6a13e7d
5
5
  SHA512:
6
- metadata.gz: 67d7be279b48cc7ebbb1ae4a7ea1c1bc6fd6f06ec11e218ccddd590d0392a64cdff7a896d49d0b96b796185a21b08fe4fc15d3cba4299d0d19a419105ee0c4a9
7
- data.tar.gz: 9d0811ebf7fcd8e70d18285fa9e86979c96334c620c0688843dc85c4b33d695dacba1e6fb5f026e0f900ff930ade5c77b5321b5a428adc3968f92a579f7b2d77
6
+ metadata.gz: 92d351640382343c76fe914a4fac0838445bf1f7d1d00884f3f20d897131d280dac0f8a6a4d66ad2bde5ee6d801a9362fc8364eb8f99dad46621f9e640bf3ada
7
+ data.tar.gz: 1027b4d5e7ebd58189f1e8aec89b93578d36a71dadfcae7a04bb59a45129ac1967b7a800876a3ef659fb2777b2490cb52e3eb2f2a391510ad06e5da12ade6e23
@@ -10,7 +10,7 @@ module Super
10
10
  # Displays a list of records to the user
11
11
  def index
12
12
  @records = load_records
13
- @display = display_schema.apply(action: current_action)
13
+ @display = display_schema.apply(action: current_action, format: request.format)
14
14
  @view = index_view
15
15
  @query_form = initialize_query_form
16
16
  initialize_filter_form
@@ -21,7 +21,7 @@ module Super
21
21
  # Displays a specific record to the user
22
22
  def show
23
23
  @record = load_record
24
- @display = display_schema.apply(action: current_action)
24
+ @display = display_schema.apply(action: current_action, format: request.format)
25
25
  @view = show_view
26
26
  end
27
27
 
@@ -7,7 +7,7 @@ module Super
7
7
  private
8
8
 
9
9
  helper_method def model
10
- raise NotImplementedError
10
+ raise Error::NotImplementedError
11
11
  end
12
12
 
13
13
  # This is an optional method
@@ -17,6 +17,16 @@ module Super
17
17
  model.name.pluralize
18
18
  end
19
19
 
20
+ # This defines what to set in the <title> tag. It works in conjunction with
21
+ # the `#site_title` method
22
+ #
23
+ # @return [String, void]
24
+ helper_method def page_title
25
+ model.name.pluralize
26
+ rescue Error::NotImplementedError, NameError
27
+ return nil
28
+ end
29
+
20
30
  # Configures what database records are visible on load. This is an optional
21
31
  # method, it defaults to "`all`" methods
22
32
  #
@@ -188,6 +198,14 @@ module Super
188
198
  end
189
199
  end
190
200
 
201
+ def pagination_disabled_param
202
+ :_all_pages
203
+ end
204
+
205
+ def pagination_enabled?
206
+ !params.key?(pagination_disabled_param)
207
+ end
208
+
191
209
  # Sets up pagination
192
210
  #
193
211
  # @return [Pagination]
@@ -204,6 +222,8 @@ module Super
204
222
  #
205
223
  # @return [ActiveRecord::Relation]
206
224
  def paginate_records
225
+ return @records if !pagination_enabled?
226
+
207
227
  @records
208
228
  .limit(@pagination.limit)
209
229
  .offset(@pagination.offset)
@@ -260,6 +280,7 @@ module Super
260
280
  included do
261
281
  helper_method :site_title
262
282
  helper_method :site_navigation
283
+ helper_method :document_title
263
284
  end
264
285
 
265
286
  private
@@ -271,6 +292,22 @@ module Super
271
292
  def site_navigation
272
293
  Super::Navigation.new(&:all)
273
294
  end
295
+
296
+ def document_title
297
+ if instance_variable_defined?(:@document_title)
298
+ return @document_title
299
+ end
300
+
301
+ document_title_segments.map(&:presence).compact.join(document_title_separator)
302
+ end
303
+
304
+ def document_title_segments
305
+ @document_title_segments ||= [page_title, site_title]
306
+ end
307
+
308
+ def document_title_separator
309
+ @document_title_separator ||= " - "
310
+ end
274
311
  end
275
312
  end
276
313
  end
@@ -1,7 +1,7 @@
1
1
  <!DOCTYPE html>
2
2
  <html class="bg-gray-100">
3
3
  <head>
4
- <title><%= Super.configuration.title %></title>
4
+ <title><%= document_title %></title>
5
5
  <%= csrf_meta_tags %>
6
6
  <% if respond_to?(:csp_meta_tag) -%>
7
7
  <%= csp_meta_tag %>
@@ -0,0 +1,14 @@
1
+ <%=
2
+ attribute_names = @display.each_attribute_name.to_a
3
+
4
+ CSV
5
+ .generate(write_headers: true, headers: attribute_names) do |csv|
6
+ @records.each do |record|
7
+ row = attribute_names.map do |attribute_name|
8
+ @display.render_attribute(template: self, record: record, column: attribute_name)
9
+ end
10
+ csv << row
11
+ end
12
+ end
13
+ .html_safe
14
+ -%>
data/lib/super/display.rb CHANGED
@@ -32,10 +32,11 @@ module Super
32
32
  yield(@fields, @schema_types)
33
33
  end
34
34
 
35
- def apply(action:)
35
+ def apply(action:, format:)
36
36
  @action_inquirer = action
37
37
  return self if !@action_inquirer.index?
38
38
  return self if @schema_types.actions_called?
39
+ return self if !format.html?
39
40
  @fields[:actions] = @schema_types.actions
40
41
  self
41
42
  end
data/lib/super/error.rb CHANGED
@@ -30,6 +30,7 @@ module Super
30
30
  class ArgumentError < Error; end
31
31
  class AlreadyRegistered < Error; end
32
32
  class AlreadyTranscribed < Error; end
33
+ class NotImplementedError < Error; end
33
34
 
34
35
  class Enum < Error
35
36
  class ImpossibleValue < Enum; end
data/lib/super/reset.rb CHANGED
@@ -14,7 +14,10 @@ module Super
14
14
  undef_method :destroy
15
15
 
16
16
  Super::SubstructureController.private_instance_methods(false).each do |imethod|
17
+ next if imethod == :_layout
18
+ next if imethod == :_generate_paths_by_default
17
19
  next if imethod == :navigation
20
+ next if imethod == :page_title
18
21
  undef_method imethod
19
22
  end
20
23
  end
data/lib/super/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Super
4
- VERSION = "0.17.0"
4
+ VERSION = "0.18.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: super
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.17.0
4
+ version: 0.18.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zach Ahn
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-06-17 00:00:00.000000000 Z
11
+ date: 2021-08-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -115,7 +115,7 @@ dependencies:
115
115
  - !ruby/object:Gem::Version
116
116
  version: '0'
117
117
  - !ruby/object:Gem::Dependency
118
- name: pry
118
+ name: pry-rails
119
119
  requirement: !ruby/object:Gem::Requirement
120
120
  requirements:
121
121
  - - ">="
@@ -212,6 +212,20 @@ dependencies:
212
212
  - - ">="
213
213
  - !ruby/object:Gem::Version
214
214
  version: '0'
215
+ - !ruby/object:Gem::Dependency
216
+ name: rails_anonymous_controller_testing
217
+ requirement: !ruby/object:Gem::Requirement
218
+ requirements:
219
+ - - ">="
220
+ - !ruby/object:Gem::Version
221
+ version: '0'
222
+ type: :development
223
+ prerelease: false
224
+ version_requirements: !ruby/object:Gem::Requirement
225
+ requirements:
226
+ - - ">="
227
+ - !ruby/object:Gem::Version
228
+ version: '0'
215
229
  description:
216
230
  email:
217
231
  - engineering@zachahn.com
@@ -252,6 +266,7 @@ files:
252
266
  - app/views/super/application/_sort.html.erb
253
267
  - app/views/super/application/_sort_expression.html.erb
254
268
  - app/views/super/application/edit.html.erb
269
+ - app/views/super/application/index.csv.erb
255
270
  - app/views/super/application/index.html.erb
256
271
  - app/views/super/application/new.html.erb
257
272
  - app/views/super/application/nothing.html.erb
@@ -345,7 +360,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
345
360
  - !ruby/object:Gem::Version
346
361
  version: '0'
347
362
  requirements: []
348
- rubygems_version: 3.0.3.1
363
+ rubygems_version: 3.2.4
349
364
  signing_key:
350
365
  specification_version: 4
351
366
  summary: A simple, powerful, zero dependency Rails admin framework