para 0.6.3 → 0.6.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/para/admin/job-tracker.coffee +1 -1
- data/app/assets/javascripts/para/admin/tabs.coffee +14 -8
- data/app/assets/javascripts/para/admin.js +20 -0
- data/app/assets/javascripts/para/plugins-includes.js.erb +1 -0
- data/app/assets/stylesheets/para/admin.sass +1 -0
- data/app/assets/stylesheets/para/plugins-includes.sass.erb +1 -0
- data/app/controllers/concerns/para/admin/resource_controller_concerns.rb +8 -2
- data/app/controllers/para/admin/crud_resources_controller.rb +1 -1
- data/app/controllers/para/admin/exports_controller.rb +1 -1
- data/app/controllers/para/admin/resources_controller.rb +7 -2
- data/app/decorators/para/component/base_decorator.rb +2 -2
- data/app/helpers/para/admin/pagination_helper.rb +31 -0
- data/app/helpers/para/model_helper.rb +14 -4
- data/app/models/application_record.rb +3 -0
- data/app/models/para/cache/item.rb +27 -0
- data/app/models/para/page/section.rb +0 -6
- data/app/views/para/admin/resources/_exports_menu.html.haml +2 -2
- data/app/views/para/admin/resources/_list.html.haml +1 -1
- data/app/views/para/admin/resources/_per_page_select.html.haml +10 -0
- data/app/views/para/inputs/_nested_many.html.haml +1 -1
- data/app/views/para/inputs/nested_many/_add_with_subclasses.html.haml +1 -1
- data/config/locales/fr.yml +1 -0
- data/db/migrate/20161006105728_create_para_cache_items.rb +12 -0
- data/lib/generators/para/admin_user/admin_user_generator.rb +2 -1
- data/lib/generators/para/exporter/exporter_generator.rb +1 -5
- data/lib/generators/para/exporter/templates/base_exporter.rb +18 -12
- data/lib/generators/para/exporter/templates/csv_exporter.rb +35 -11
- data/lib/generators/para/exporter/templates/xls_exporter.rb +48 -0
- data/lib/generators/para/orderable/orderable_generator.rb +1 -1
- data/lib/generators/para/page/section/section_generator.rb +1 -1
- data/lib/para/attribute_field/base.rb +4 -0
- data/lib/para/attribute_field/datetime.rb +1 -1
- data/lib/para/attribute_field/file.rb +4 -0
- data/lib/para/attribute_field/image.rb +4 -0
- data/lib/para/cache/database_store.rb +71 -0
- data/lib/para/cache.rb +11 -0
- data/lib/para/config.rb +28 -2
- data/lib/para/engine.rb +9 -14
- data/lib/para/exporter/base.rb +26 -0
- data/lib/para/exporter/csv.rb +6 -26
- data/lib/para/exporter/table.rb +23 -0
- data/lib/para/exporter/xls.rb +59 -0
- data/lib/para/exporter.rb +6 -3
- data/lib/para/ext.rb +0 -1
- data/lib/para/form_builder/containers.rb +14 -1
- data/lib/para/form_builder.rb +1 -0
- data/lib/para/importer/base.rb +2 -28
- data/lib/para/inputs/nested_many_input.rb +9 -4
- data/lib/para/job/base.rb +23 -4
- data/lib/para/logging/active_job_log_subscriber.rb +2 -0
- data/lib/para/orderable.rb +2 -2
- data/lib/para/plugins/set.rb +34 -0
- data/lib/para/plugins.rb +3 -2
- data/lib/para/routing/component_controller_constraint.rb +1 -1
- data/lib/para/routing/component_name_constraint.rb +22 -0
- data/lib/para/routing.rb +1 -0
- data/lib/para/sti/root_model.rb +4 -54
- data/lib/para/version.rb +1 -1
- data/lib/para.rb +4 -1
- data/lib/rails/routing_mapper.rb +67 -34
- data/vendor/assets/javascripts/html5-sortable.js +142 -0
- data/vendor/assets/javascripts/jasny.bootstrap.min.js +7 -0
- data/vendor/assets/javascripts/jquery.remote-modal-form.coffee +67 -0
- data/vendor/assets/javascripts/jquery.scrollto.js +187 -0
- data/vendor/assets/stylesheets/animate.min.css +6 -0
- data/vendor/assets/stylesheets/jasny.bootstrap.min.css +7 -0
- metadata +56 -9
- data/app/assets/javascripts/para/admin.coffee +0 -19
- 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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d05cde47a5cf42feab91f48cb5df06d758a6d8c8
|
4
|
+
data.tar.gz: 82e6001147de85294dff0e7337d23049449aa32a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1f0fdafd15411b30ae0ef8a42ed3afd38d8e9656ebb4f8c25190498518ce895185deb3f285bebdaf6be9c3d9b649373cfd2e3392e1961b52b28b6fb87cfb3029
|
7
|
+
data.tar.gz: 5178cecb9fc29faf92e294870888ec665c4da549b720e59856492077e0479e3467c3a703a582cf94e0082ca54b0d0e089a9651c9bc84a650cc156a0c3c625cf5
|
@@ -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
|
-
|
6
|
-
|
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
|
-
|
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) ->
|
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) } %>
|
@@ -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 ||=
|
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)
|
@@ -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(
|
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 =
|
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
|
-
|
27
|
-
|
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,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
|
-
=
|
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
|
-
-
|
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
|
data/config/locales/fr.yml
CHANGED
@@ -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/#{
|
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
|
-
|
2
|
-
|
3
|
-
|
1
|
+
class <%= model_exporter_name %> < Para::Exporter::Base
|
2
|
+
def name
|
3
|
+
'<%= file_name %>'
|
4
|
+
end
|
4
5
|
|
5
|
-
|
6
|
-
'<%= @format %>'
|
7
|
-
end
|
6
|
+
protected
|
8
7
|
|
9
|
-
|
10
|
-
|
11
|
-
|
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
|
-
|
14
|
-
|
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
|
-
|
2
|
-
|
3
|
-
|
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
|
-
|
6
|
+
protected
|
10
7
|
|
11
|
-
|
12
|
-
|
13
|
-
|
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 =
|
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"
|