para 0.6.3 → 0.6.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/para/admin/job-tracker.coffee +1 -1
  3. data/app/assets/javascripts/para/admin/tabs.coffee +14 -8
  4. data/app/assets/javascripts/para/admin.js +20 -0
  5. data/app/assets/javascripts/para/plugins-includes.js.erb +1 -0
  6. data/app/assets/stylesheets/para/admin.sass +1 -0
  7. data/app/assets/stylesheets/para/plugins-includes.sass.erb +1 -0
  8. data/app/controllers/concerns/para/admin/resource_controller_concerns.rb +8 -2
  9. data/app/controllers/para/admin/crud_resources_controller.rb +1 -1
  10. data/app/controllers/para/admin/exports_controller.rb +1 -1
  11. data/app/controllers/para/admin/resources_controller.rb +7 -2
  12. data/app/decorators/para/component/base_decorator.rb +2 -2
  13. data/app/helpers/para/admin/pagination_helper.rb +31 -0
  14. data/app/helpers/para/model_helper.rb +14 -4
  15. data/app/models/application_record.rb +3 -0
  16. data/app/models/para/cache/item.rb +27 -0
  17. data/app/models/para/page/section.rb +0 -6
  18. data/app/views/para/admin/resources/_exports_menu.html.haml +2 -2
  19. data/app/views/para/admin/resources/_list.html.haml +1 -1
  20. data/app/views/para/admin/resources/_per_page_select.html.haml +10 -0
  21. data/app/views/para/inputs/_nested_many.html.haml +1 -1
  22. data/app/views/para/inputs/nested_many/_add_with_subclasses.html.haml +1 -1
  23. data/config/locales/fr.yml +1 -0
  24. data/db/migrate/20161006105728_create_para_cache_items.rb +12 -0
  25. data/lib/generators/para/admin_user/admin_user_generator.rb +2 -1
  26. data/lib/generators/para/exporter/exporter_generator.rb +1 -5
  27. data/lib/generators/para/exporter/templates/base_exporter.rb +18 -12
  28. data/lib/generators/para/exporter/templates/csv_exporter.rb +35 -11
  29. data/lib/generators/para/exporter/templates/xls_exporter.rb +48 -0
  30. data/lib/generators/para/orderable/orderable_generator.rb +1 -1
  31. data/lib/generators/para/page/section/section_generator.rb +1 -1
  32. data/lib/para/attribute_field/base.rb +4 -0
  33. data/lib/para/attribute_field/datetime.rb +1 -1
  34. data/lib/para/attribute_field/file.rb +4 -0
  35. data/lib/para/attribute_field/image.rb +4 -0
  36. data/lib/para/cache/database_store.rb +71 -0
  37. data/lib/para/cache.rb +11 -0
  38. data/lib/para/config.rb +28 -2
  39. data/lib/para/engine.rb +9 -14
  40. data/lib/para/exporter/base.rb +26 -0
  41. data/lib/para/exporter/csv.rb +6 -26
  42. data/lib/para/exporter/table.rb +23 -0
  43. data/lib/para/exporter/xls.rb +59 -0
  44. data/lib/para/exporter.rb +6 -3
  45. data/lib/para/ext.rb +0 -1
  46. data/lib/para/form_builder/containers.rb +14 -1
  47. data/lib/para/form_builder.rb +1 -0
  48. data/lib/para/importer/base.rb +2 -28
  49. data/lib/para/inputs/nested_many_input.rb +9 -4
  50. data/lib/para/job/base.rb +23 -4
  51. data/lib/para/logging/active_job_log_subscriber.rb +2 -0
  52. data/lib/para/orderable.rb +2 -2
  53. data/lib/para/plugins/set.rb +34 -0
  54. data/lib/para/plugins.rb +3 -2
  55. data/lib/para/routing/component_controller_constraint.rb +1 -1
  56. data/lib/para/routing/component_name_constraint.rb +22 -0
  57. data/lib/para/routing.rb +1 -0
  58. data/lib/para/sti/root_model.rb +4 -54
  59. data/lib/para/version.rb +1 -1
  60. data/lib/para.rb +4 -1
  61. data/lib/rails/routing_mapper.rb +67 -34
  62. data/vendor/assets/javascripts/html5-sortable.js +142 -0
  63. data/vendor/assets/javascripts/jasny.bootstrap.min.js +7 -0
  64. data/vendor/assets/javascripts/jquery.remote-modal-form.coffee +67 -0
  65. data/vendor/assets/javascripts/jquery.scrollto.js +187 -0
  66. data/vendor/assets/stylesheets/animate.min.css +6 -0
  67. data/vendor/assets/stylesheets/jasny.bootstrap.min.css +7 -0
  68. metadata +56 -9
  69. data/app/assets/javascripts/para/admin.coffee +0 -19
  70. data/lib/para/ext/simple_form_extension.rb +0 -27
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f79b2e1b6163469c9247f53880b82b50527729e2
4
- data.tar.gz: 46444b157efef7ace8f76a566dbcca7f90b62e1d
3
+ metadata.gz: d05cde47a5cf42feab91f48cb5df06d758a6d8c8
4
+ data.tar.gz: 82e6001147de85294dff0e7337d23049449aa32a
5
5
  SHA512:
6
- metadata.gz: 008274f36acb1819e3ac4b37d74eb115806c7c86d8a5e5f409e98bc568c788ce31e8e4019a412eeb1b86f11025805e7f2f47b9bb609f3e5a4994bebd733e176c
7
- data.tar.gz: a08c53ae52881b5ce1d80a2bb951f089db476824802adea8b2e006165164063512b0f2bc660eaa309cd692a8b9a7ea2aee05a740dc81355e6628fbe9c04d453e
6
+ metadata.gz: 1f0fdafd15411b30ae0ef8a42ed3afd38d8e9656ebb4f8c25190498518ce895185deb3f285bebdaf6be9c3d9b649373cfd2e3392e1961b52b28b6fb87cfb3029
7
+ data.tar.gz: 5178cecb9fc29faf92e294870888ec665c4da549b720e59856492077e0479e3467c3a703a582cf94e0082ca54b0d0e089a9651c9bc84a650cc156a0c3c625cf5
@@ -28,7 +28,7 @@ class Para.JobTracker extends RemoteModalForm
28
28
 
29
29
  onFinalModalLoaded: (response) =>
30
30
  @formSuccess(null, response)
31
- @refreshOnClose = true
31
+ @refreshOnClose = !(@$link?.data('refresh-on-close') is false)
32
32
 
33
33
  modalHide: ->
34
34
  super()
@@ -1,21 +1,27 @@
1
1
  # Tabs hash management adapted from SO answer :
2
2
  # http://stackoverflow.com/a/21443271/685925
3
3
  #
4
- class Para.Tabs
5
- constructor: (options = {}) ->
6
- @$el = $(options.el)
4
+ class Para.Tabs extends Vertebra.View
5
+ events:
6
+ 'shown.bs.tab a[data-toggle="tab"]': 'onTabShown'
7
+
8
+ initialize: (options = {}) ->
9
+ @$anchorInput = options.$anchorInput
7
10
  @showActiveTab()
8
- @$('a[data-toggle="tab"]').on('shown.bs.tab', @onTabShown)
9
11
 
10
12
  showActiveTab: ->
11
- @$('a[href="' + location.hash + '"]').tab('show') if location.hash isnt ''
13
+ if (hash = location.hash or @$anchorInput?.val())
14
+ @$('a[href="' + hash + '"]').tab('show')
12
15
 
13
16
  onTabShown: (e) =>
14
17
  tabHash = $(e.target).attr('href').substr(1)
15
18
  history.pushState(null, null, "##{ tabHash }")
19
+ @updateAnchorInput(tabHash)
20
+
21
+ updateAnchorInput: ->
22
+ @$anchorInput.val(location.hash) if @$anchorInput.length
16
23
 
17
- $: (args...) ->
18
- $.fn.find.apply(@$el, args)
19
24
 
20
25
  $(document).on 'page:change turbolinks:load', ->
21
- $('[data-form-tabs]').each (i, el) -> new Para.Tabs(el: el)
26
+ $('[data-form-tabs]').each (i, el) ->
27
+ new Para.Tabs(el: el, $anchorInput: $('[data-current-anchor]'))
@@ -0,0 +1,20 @@
1
+ //= require jquery
2
+ //= require jquery_ujs
3
+ //= require turbolinks
4
+ //= require bootstrap
5
+ //= require vertebra
6
+ //= require jasny.bootstrap.min
7
+ //= require simple_form_extension
8
+ //= require jquery.scrollto
9
+ //= require html5-sortable
10
+ //= require cocoon
11
+ //= require jquery.remote-modal-form
12
+ //= require_self
13
+ //= require_tree ./lib
14
+ //= require_tree ./inputs
15
+ //= require_tree ./admin
16
+ //= require ./plugins-includes
17
+ //= require admin/app
18
+
19
+ // Initialize scope
20
+ window.Para = {}
@@ -0,0 +1 @@
1
+ <% Para.config.plugins.javascript_includes.each { |path| require_asset(path) } %>
@@ -8,4 +8,5 @@
8
8
  //= require ./admin/theme
9
9
  //= require_tree ./overrides
10
10
  //= require_tree ./admin/src
11
+ //= require ./plugins-includes
11
12
  //= require admin/app
@@ -0,0 +1 @@
1
+ <% Para.config.plugins.stylesheet_includes.each { |path| require_asset(path) } %>
@@ -2,11 +2,17 @@ module Para
2
2
  module Admin
3
3
  module ResourceControllerConcerns
4
4
  def resource_model
5
- @resource_model ||= @component.model
5
+ @resource_model ||= @component.try(:model)
6
6
  end
7
7
 
8
8
  def resource
9
- @resource ||= instance_variable_get(:"@#{ resource_name }")
9
+ @resource ||= begin
10
+ resource = instance_variable_get(:"@#{ resource_name }")
11
+ # We ensure that the fetched resource is not a relation, which could
12
+ # happen for uncountable resource names (like "news") and would make
13
+ # code depending on the `resource` getter to fail unexpectedly
14
+ resource unless ActiveRecord::Relation === resource
15
+ end
10
16
  end
11
17
 
12
18
  def resource_name
@@ -14,7 +14,7 @@ module Para
14
14
 
15
15
  def index
16
16
  @q = @component.resources.search(params[:q])
17
- @resources = distinct_search_results(@q).page(params[:page])
17
+ @resources = distinct_search_results(@q).page(params[:page]).per(params[:per_page])
18
18
 
19
19
  # Sort collection for orderable and trees
20
20
  @resources = if @resources.respond_to?(:ordered)
@@ -7,7 +7,7 @@ module Para
7
7
 
8
8
  def create
9
9
  job = @exporter.perform_later(
10
- model_name: @component.model.name,
10
+ model_name: @component.try(:model).try(:name),
11
11
  search: params[:q]
12
12
  )
13
13
 
@@ -77,7 +77,7 @@ module Para
77
77
 
78
78
  def after_form_submit_path
79
79
  if params[:_save_and_edit]
80
- { action: 'edit', id: resource.id }
80
+ { action: 'edit', id: resource.id, anchor: current_anchor }
81
81
  elsif params[:_save_and_add_another]
82
82
  { action: 'new' }
83
83
  else
@@ -157,7 +157,6 @@ module Para
157
157
 
158
158
  def resources_hash
159
159
  @resources_hash ||= begin
160
-
161
160
  ids = resources_data.map { |resource| resource[:id] }
162
161
 
163
162
  resources = resource_model.where(id: ids)
@@ -166,6 +165,12 @@ module Para
166
165
  end
167
166
  end
168
167
  end
168
+
169
+ def current_anchor
170
+ @current_anchor ||= if (current_anchor = params[:_current_anchor]).presence
171
+ current_anchor.gsub(/^\#/, '')
172
+ end
173
+ end
169
174
  end
170
175
  end
171
176
  end
@@ -4,8 +4,8 @@ module Para
4
4
  include Rails.application.routes.mounted_helpers
5
5
  include ActionDispatch::Routing::PolymorphicRoutes
6
6
 
7
- def path(options = {})
8
- find_path([:admin, self], options)
7
+ def path(namespace: nil, **options)
8
+ find_path([:admin, self, namespace].compact, options)
9
9
  end
10
10
 
11
11
  def relation_path(controller_or_resource, options = {})
@@ -0,0 +1,31 @@
1
+ module Para
2
+ module Admin
3
+ module PaginationHelper
4
+ def page_entries(resources)
5
+ page_entries_info(resources) + per_page_select
6
+ end
7
+
8
+ private
9
+
10
+ def per_page_select
11
+ options = [25, 50, 100, 250, 500, 1000]
12
+
13
+ params = (Rack::Utils.parse_query(request.env['QUERY_STRING']).symbolize_keys rescue {})
14
+ params.delete(:page)
15
+ count_with_url = options.each_with_object({}) do |count, hash|
16
+ query = params.merge(:per_page => count)
17
+ url = request.env['PATH_INFO'] + (query.empty? ? '' : "?#{query.to_query}")
18
+
19
+ hash[count] = url
20
+ end
21
+
22
+ current_per_page = params[:per_page] || Kaminari.config.default_per_page
23
+
24
+ render partial: 'para/admin/resources/per_page_select', locals: {
25
+ count_with_url: count_with_url,
26
+ current_per_page: current_per_page
27
+ }
28
+ end
29
+ end
30
+ end
31
+ end
@@ -17,21 +17,31 @@ module Para
17
17
  component.class.reflect_on_association(relation).klass
18
18
  end
19
19
 
20
+ def field_for(model, field_name, type = nil)
21
+ model_field_mappings(model).field_for(field_name, type)
22
+ end
23
+
20
24
  def value_for(object, field_name, type = nil)
21
- field = model_field_mappings(object.class).field_for(field_name, type)
25
+ field = field_for(object.class, field_name, type)
22
26
  field.value_for(object)
23
27
  end
24
28
 
25
29
  def field_value_for(object, field_name, type = nil)
26
- value = value_for(object, field_name, type)
27
- excerpt_value_for(value)
30
+ field = field_for(object.class, field_name, type)
31
+ value = field.value_for(object)
32
+
33
+ if field.excerptable_value?
34
+ excerpt_value_for(value)
35
+ else
36
+ value
37
+ end
28
38
  end
29
39
 
30
40
  def excerpt_value_for(value)
31
41
  return value unless value.kind_of?(String)
32
42
 
33
43
  value = sanitize(value, tags: [])
34
-
44
+
35
45
  if (truncated = value[0..100]) != value
36
46
  "#{ truncated }..."
37
47
  else
@@ -0,0 +1,3 @@
1
+ class ApplicationRecord < ActiveRecord::Base
2
+ self.abstract_class = true
3
+ end
@@ -0,0 +1,27 @@
1
+ # Borrowed from activesupport-db-cache gem (https://github.com/sergio-fry/activesupport-db-cache),
2
+ # which is out of date now not allowing us to depend on it in para
3
+ #
4
+ module Para
5
+ module Cache
6
+ class Item < ActiveRecord::Base
7
+ def value
8
+ Marshal.load(::Base64.decode64(self[:value])) if self[:value].present?
9
+ end
10
+
11
+ def value=(new_value)
12
+ @raw_value = new_value
13
+ self[:value] = ::Base64.encode64(Marshal.dump(@raw_value))
14
+ end
15
+
16
+ def expired?
17
+ read_attribute(:expires_at).try(:past?) || false
18
+ end
19
+
20
+ # From ActiveSupport::Cache::Store::Entry
21
+ # Seconds since the epoch when the entry will expire.
22
+ def expires_at
23
+ read_attribute(:expires_at).try(:to_f)
24
+ end
25
+ end
26
+ end
27
+ end
@@ -3,16 +3,10 @@ module Para
3
3
  class Section < ActiveRecord::Base
4
4
  self.table_name = 'para_page_sections'
5
5
 
6
- include Para::Sti::RootModel
7
-
8
6
  acts_as_orderable
9
7
 
10
8
  belongs_to :page, polymorphic: true
11
9
 
12
- def self.subclasses_namespace
13
- 'PageSection'
14
- end
15
-
16
10
  def css_class
17
11
  @css_class ||= self.class.name.demodulize.underscore.gsub(/_/, '-')
18
12
  end
@@ -2,7 +2,7 @@
2
2
  - if component.exporters.length == 1
3
3
  - exporter = component.exporters.first
4
4
 
5
- = link_to component.path(namespace: :exports, exporter: exporter.name, q: params[:q]), class: 'btn btn-default', method: :post, remote: true, data: { :'job-tracker-button' => true } do
5
+ = link_to component.path(namespace: :exports, exporter: exporter.name, q: params[:q]), class: 'btn btn-default', method: :post, remote: true, data: { :'job-tracker-button' => true, :'refresh-on-close' => false } do
6
6
  = fa_icon 'download'
7
7
  = exporter.model_name.human
8
8
 
@@ -15,5 +15,5 @@
15
15
  %ul.dropdown-menu
16
16
  - component.exporters.each do |exporter|
17
17
  %li
18
- = link_to component.path(namespace: :exports, exporter: exporter.name, q: params[:q]), method: :post, remote: true, data: { :'job-tracker-button' => true } do
18
+ = link_to component.path(namespace: :exports, exporter: exporter.name, q: params[:q]), method: :post, remote: true, data: { :'job-tracker-button' => true, :'refresh-on-close' => false } do
19
19
  = exporter.model_name.human
@@ -8,7 +8,7 @@
8
8
 
9
9
  - if resources.length > 0
10
10
  = panel.body class: 'page-entries-info' do
11
- = page_entries_info(resources)
11
+ = page_entries(resources)
12
12
 
13
13
  = panel.body class: '' do
14
14
  = table_for(resources: resources, model: model, component: component, attributes: attributes)
@@ -0,0 +1,10 @@
1
+ \.
2
+ = t('helpers.page_entries_info.number_per_page')
3
+ \:
4
+ %span.dropdown
5
+ %button.btn.btn-default.btn-xs{ data: { toggle: 'dropdown' } }
6
+ = current_per_page
7
+ %span.caret
8
+ %ul.dropdown-menu
9
+ - count_with_url.each do |count, url|
10
+ %li= link_to count, url
@@ -5,6 +5,6 @@
5
5
  -# Add button
6
6
  - if add_button
7
7
  - if subclass
8
- = render partial: 'para/inputs/nested_many/add_with_subclasses', locals: { form: form, model: model, dom_identifier: dom_identifier, nested_locals: nested_locals, attribute_name: attribute_name, orderable: orderable }
8
+ = render partial: 'para/inputs/nested_many/add_with_subclasses', locals: { form: form, model: model, dom_identifier: dom_identifier, nested_locals: nested_locals, attribute_name: attribute_name, orderable: orderable, subclasses: subclasses }
9
9
  - else
10
10
  = render partial: 'para/inputs/nested_many/add', locals: { form: form, model: model, dom_identifier: dom_identifier, nested_locals: nested_locals, attribute_name: attribute_name, orderable: orderable }
@@ -4,7 +4,7 @@
4
4
  = t('para.form.nested.add')
5
5
  %span.caret
6
6
  %ul.dropdown-menu
7
- - model.descendants.sort_by { |m| m.model_name.human }.each do |submodel|
7
+ - subclasses.each do |submodel|
8
8
  %li
9
9
  = link_to_add_association form, attribute_name, wrap_object: proc { submodel.new }, partial: find_partial_for(submodel, 'nested_many/container', partial_dir: 'inputs'), form_name: 'form', class: 'dropdown-link', data: { :'association-insertion-node' => "##{ dom_identifier }", :'association-insertion-method' => 'append' }, render_options: { nested_attribute_name: attribute_name, orderable: orderable, locals: { model: submodel, nested_locals: nested_locals } } do
10
10
  = submodel.model_name.human
@@ -144,6 +144,7 @@ fr:
144
144
  truncate: "&hellip;"
145
145
  helpers:
146
146
  page_entries_info:
147
+ number_per_page: Nombre d'entrées par page
147
148
  one_page:
148
149
  display_entries:
149
150
  zero: "Aucune entrée trouvée"
@@ -0,0 +1,12 @@
1
+ class CreateParaCacheItems < ActiveRecord::Migration
2
+ def change
3
+ create_table :para_cache_items do |t|
4
+ t.string :key
5
+ t.text :value
6
+
7
+ t.datetime :expires_at
8
+
9
+ t.timestamps
10
+ end
11
+ end
12
+ end
@@ -6,7 +6,8 @@ module Para
6
6
  say 'Creating default admin...'
7
7
 
8
8
  email = ask('Email [admin@example.com] : ').presence || 'admin@example.com'
9
- password = ask('Password [password] : ').presence || 'password'
9
+ password = ask('Password [password] : ', echo: false).presence || 'password'
10
+ print "\n" # echo: false doesn't print a newline so we manually add it
10
11
 
11
12
  AdminUser.create! email: email, password: password
12
13
 
@@ -14,7 +14,7 @@ module Para
14
14
 
15
15
  template(
16
16
  "#{ base_exporter_template_name_for(format) }_exporter.rb",
17
- "app/exporters/#{ format }/#{ plural_file_name }_exporter.rb"
17
+ "app/exporters/#{ plural_file_name }_exporter.rb"
18
18
  )
19
19
  end
20
20
  end
@@ -25,10 +25,6 @@ module Para
25
25
  Para::Exporter.model_exporter_name(class_name)
26
26
  end
27
27
 
28
- def format_module_name_for(format)
29
- Para::Exporter.format_exporter_name(format)
30
- end
31
-
32
28
  def base_exporter_template_name_for(format)
33
29
  format_specific_template = "../templates/#{ format }_exporter.rb"
34
30
 
@@ -1,17 +1,23 @@
1
- module <%= format_module_name_for(@format) %>
2
- class <%= model_exporter_name %> < Para::Exporter::Base
3
- exports '<%= class_name %>'
1
+ class <%= model_exporter_name %> < Para::Exporter::Base
2
+ def name
3
+ '<%= file_name %>'
4
+ end
4
5
 
5
- def extension
6
- '<%= @format %>'
7
- end
6
+ protected
8
7
 
9
- def name
10
- 'export'
11
- end
8
+ def generate
9
+ # Add your export logic here, returning the exported data that will be
10
+ # stored with Paperclip and then directly served to the user
11
+ end
12
12
 
13
- def render
14
- # Add your export logic here
15
- end
13
+ def extension
14
+ '.<%= @format %>'
16
15
  end
16
+
17
+ # If your #generate method returns binary data, uncomment the following
18
+ # method.
19
+ #
20
+ # def binary?
21
+ # true
22
+ # end
17
23
  end
@@ -1,15 +1,39 @@
1
- module <%= format_module_name_for(@format) %>
2
- class <%= model_exporter_name %> < Para::Exporter::Csv
3
- exports '<%= class_name %>'
4
-
5
- def name
6
- 'export'
7
- end
1
+ class <%= model_exporter_name %> < Para::Exporter::Csv
2
+ def name
3
+ '<%= file_name %>'
4
+ end
8
5
 
9
- private
6
+ protected
10
7
 
11
- def fields
12
- [:id]
13
- end
8
+ # Defining the fields that you want to export will export all those fields
9
+ # directly to the CSV file
10
+ #
11
+ def fields
12
+ [:id]
14
13
  end
14
+
15
+ # If you need special behavior in the row generation (rendering associated
16
+ # models or other specific logic), you can return an array here that will
17
+ # be written to the CSV
18
+ #
19
+ # For safe CSV writing, use the #encode method on every string in the
20
+ # returned array.
21
+ #
22
+ # Example :
23
+ #
24
+ # fields = [...]
25
+ # fields.map!(&:encode)
26
+ #
27
+ # def row_for(resource)
28
+ # end
29
+
30
+ # If you need complete control over you CSV generation, use the following
31
+ # method instead of the #fields or #row_for methods, and return a valid CSV
32
+ # string
33
+ #
34
+ # You can use the `csv` extension from the ruby stdlib, for example with the
35
+ # CSV.generate method (more information )
36
+ #
37
+ # def generate
38
+ # end
15
39
  end
@@ -0,0 +1,48 @@
1
+ class <%= model_exporter_name %> < Para::Exporter::Xls
2
+ def name
3
+ '<%= file_name %>'
4
+ end
5
+
6
+ protected
7
+
8
+ # Defining the fields that you want to export will export all those fields
9
+ # directly to the XLS file
10
+ #
11
+ def fields
12
+ [:id]
13
+ end
14
+
15
+ # If you need special behavior in the row generation (rendering associated
16
+ # models or other specific logic), you can return an array here that will
17
+ # be written to the XLS
18
+ #
19
+ # For safe XLS writing, use the #encode method on every string in the
20
+ # returned array.
21
+ #
22
+ # Example :
23
+ #
24
+ # fields = [...]
25
+ # fields.map!(&:encode)
26
+ #
27
+ # def row_for(resource)
28
+ # end
29
+
30
+ # If you need complete control over you XLS generation, use the following
31
+ # method instead of the #fields or #row_for methods, and return a valid XLS
32
+ # StringIO object.
33
+ #
34
+ # A `#generate_workbook` method is provided, which will yield the workbook to
35
+ # you so you can just fill it, and then returns a StringIO that can be
36
+ # directly written to the Excel file.
37
+ #
38
+ # Please check the [Spreadsheet](https://github.com/zdavatz/spreadsheet) gem
39
+ # documentation for more informations about how to build your Excel document.
40
+ #
41
+ # def generate
42
+ # generate_workbook do |workbook|
43
+ # sheet = workbook.create_worksheet
44
+ # sheet.row(0).concat ['data', 'row']
45
+ # sheet.row(1).concat ['other', 'row']
46
+ # end
47
+ # end
48
+ end
@@ -20,7 +20,7 @@ module Para
20
20
  end
21
21
 
22
22
  def add_orderable_to_model
23
- class_definition = "class #{ class_name } < ActiveRecord::Base\n"
23
+ class_definition = /class #{ class_name } < (ActiveRecord::Base|ApplicationRecord)\n/
24
24
 
25
25
  inject_into_file "app/models/#{ singular_namespaced_path }.rb", after: class_definition do
26
26
  " acts_as_orderable\n"
@@ -10,7 +10,7 @@ module Para
10
10
  def generate_form
11
11
  template(
12
12
  "section.rb.erb",
13
- "app/models/page_section/#{ plural_namespaced_path }.rb"
13
+ "app/models/page_section/#{ singular_namespaced_path }.rb"
14
14
  )
15
15
  end
16
16
 
@@ -71,6 +71,10 @@ module Para
71
71
  instance.send(name)
72
72
  end
73
73
 
74
+ def excerptable_value?
75
+ true
76
+ end
77
+
74
78
  #
75
79
  def searchable?
76
80
  options[:searchable] != false && (
@@ -6,7 +6,7 @@ module Para
6
6
  field_option :wrapper, :wrapper_name
7
7
 
8
8
  def value_for(instance)
9
- (value = instance.send(name)) && ::I18n.l(value)
9
+ (value = instance.send(name)) && ::I18n.l(value, format: :admin)
10
10
  end
11
11
 
12
12
  def wrapper_name
@@ -14,6 +14,10 @@ module Para
14
14
  end
15
15
  end
16
16
 
17
+ def excerptable_value?
18
+ false
19
+ end
20
+
17
21
  def wrapper_name
18
22
  :horizontal_file_input
19
23
  end
@@ -13,6 +13,10 @@ module Para
13
13
  end
14
14
  end
15
15
 
16
+ def excerptable_value?
17
+ false
18
+ end
19
+
16
20
  private
17
21
 
18
22
  def attachment_thumb_style_for(instance)