active_scaffold 3.6.0.pre → 3.6.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/{CHANGELOG → CHANGELOG.rdoc} +39 -0
- data/app/assets/javascripts/active_scaffold.js.erb +0 -1
- data/app/assets/javascripts/jquery/active_scaffold.js +35 -4
- data/app/assets/stylesheets/active_scaffold_colors.scss +1 -1
- data/app/assets/stylesheets/active_scaffold_layout.css +52 -29
- data/app/views/active_scaffold_overrides/_list_header.html.erb +5 -7
- data/app/views/active_scaffold_overrides/_list_record.html.erb +4 -5
- data/app/views/active_scaffold_overrides/_list_with_header.html.erb +1 -1
- data/app/views/active_scaffold_overrides/_refresh_list.js.erb +4 -0
- data/config/locales/de.yml +2 -1
- data/config/locales/en.yml +1 -0
- data/config/locales/es.yml +1 -0
- data/config/locales/fr.yml +2 -1
- data/config/locales/hu.yml +1 -0
- data/config/locales/ja.yml +1 -0
- data/config/locales/ru.yml +1 -0
- data/lib/active_scaffold.rb +8 -3
- data/lib/active_scaffold/actions/common_search.rb +11 -8
- data/lib/active_scaffold/actions/core.rb +79 -51
- data/lib/active_scaffold/actions/create.rb +27 -27
- data/lib/active_scaffold/actions/delete.rb +1 -1
- data/lib/active_scaffold/actions/field_search.rb +52 -42
- data/lib/active_scaffold/actions/list.rb +106 -23
- data/lib/active_scaffold/actions/nested.rb +59 -42
- data/lib/active_scaffold/actions/show.rb +3 -3
- data/lib/active_scaffold/actions/subform.rb +9 -16
- data/lib/active_scaffold/actions/update.rb +95 -77
- data/lib/active_scaffold/attribute_params.rb +93 -68
- data/lib/active_scaffold/bridges/active_storage.rb +6 -0
- data/lib/active_scaffold/bridges/active_storage/active_storage_bridge.rb +33 -0
- data/lib/active_scaffold/bridges/active_storage/active_storage_helpers.rb +54 -0
- data/lib/active_scaffold/bridges/active_storage/form_ui.rb +22 -0
- data/lib/active_scaffold/bridges/active_storage/list_ui.rb +36 -0
- data/lib/active_scaffold/bridges/bitfields.rb +1 -0
- data/lib/active_scaffold/bridges/bitfields/bitfields_bridge.rb +12 -15
- data/lib/active_scaffold/bridges/cancan/cancan_bridge.rb +6 -0
- data/lib/active_scaffold/bridges/carrierwave/list_ui.rb +2 -2
- data/lib/active_scaffold/bridges/date_picker/helper.rb +46 -41
- data/lib/active_scaffold/bridges/dragonfly/list_ui.rb +1 -1
- data/lib/active_scaffold/bridges/file_column/file_column_helpers.rb +2 -2
- data/lib/active_scaffold/bridges/file_column/form_ui.rb +3 -3
- data/lib/active_scaffold/bridges/file_column/test/functional/file_column_keep_test.rb +3 -1
- data/lib/active_scaffold/bridges/paperclip/paperclip_bridge_helpers.rb +2 -2
- data/lib/active_scaffold/bridges/record_select/helpers.rb +3 -7
- data/lib/active_scaffold/bridges/shared/date_bridge.rb +19 -18
- data/lib/active_scaffold/bridges/tiny_mce/helpers.rb +3 -1
- data/lib/active_scaffold/bridges/usa_state_select/usa_state_select_helper.rb +20 -3
- data/lib/active_scaffold/config/base.rb +58 -34
- data/lib/active_scaffold/config/core.rb +31 -12
- data/lib/active_scaffold/config/delete.rb +12 -1
- data/lib/active_scaffold/config/list.rb +17 -7
- data/lib/active_scaffold/config/mark.rb +1 -1
- data/lib/active_scaffold/configurable.rb +5 -3
- data/lib/active_scaffold/constraints.rb +21 -19
- data/lib/active_scaffold/core.rb +35 -26
- data/lib/active_scaffold/data_structures/action_columns.rb +1 -1
- data/lib/active_scaffold/data_structures/action_link.rb +34 -16
- data/lib/active_scaffold/data_structures/action_links.rb +9 -11
- data/lib/active_scaffold/data_structures/association/abstract.rb +35 -13
- data/lib/active_scaffold/data_structures/association/active_mongoid.rb +2 -6
- data/lib/active_scaffold/data_structures/association/active_record.rb +5 -1
- data/lib/active_scaffold/data_structures/association/mongoid.rb +0 -3
- data/lib/active_scaffold/data_structures/column.rb +49 -58
- data/lib/active_scaffold/data_structures/columns.rb +3 -2
- data/lib/active_scaffold/data_structures/nested_info.rb +20 -18
- data/lib/active_scaffold/data_structures/sorting.rb +5 -0
- data/lib/active_scaffold/delayed_setup.rb +16 -6
- data/lib/active_scaffold/extensions/action_controller_rendering.rb +1 -1
- data/lib/active_scaffold/extensions/action_view_rendering.rb +34 -14
- data/lib/active_scaffold/extensions/cow_proxy.rb +50 -2
- data/lib/active_scaffold/extensions/localize.rb +3 -1
- data/lib/active_scaffold/extensions/routing_mapper.rb +2 -2
- data/lib/active_scaffold/extensions/to_label.rb +3 -2
- data/lib/active_scaffold/finder.rb +81 -46
- data/lib/active_scaffold/helpers/action_link_helpers.rb +47 -21
- data/lib/active_scaffold/helpers/association_helpers.rb +13 -11
- data/lib/active_scaffold/helpers/controller_helpers.rb +14 -11
- data/lib/active_scaffold/helpers/form_column_helpers.rb +133 -99
- data/lib/active_scaffold/helpers/human_condition_helpers.rb +1 -1
- data/lib/active_scaffold/helpers/id_helpers.rb +4 -0
- data/lib/active_scaffold/helpers/list_column_helpers.rb +76 -49
- data/lib/active_scaffold/helpers/pagination_helpers.rb +2 -2
- data/lib/active_scaffold/helpers/search_column_helpers.rb +25 -30
- data/lib/active_scaffold/helpers/show_column_helpers.rb +3 -5
- data/lib/active_scaffold/helpers/view_helpers.rb +31 -22
- data/lib/active_scaffold/orm_checks.rb +2 -2
- data/lib/active_scaffold/paginator.rb +1 -3
- data/lib/active_scaffold/registry.rb +11 -0
- data/lib/active_scaffold/responds_to_parent.rb +6 -5
- data/lib/active_scaffold/tableless.rb +6 -8
- data/lib/active_scaffold/version.rb +1 -1
- data/shoulda_macros/macros.rb +3 -1
- data/test/bridges/paperclip_test.rb +1 -1
- data/test/company.rb +2 -2
- data/test/data_structures/action_columns_test.rb +2 -2
- data/test/data_structures/column_test.rb +3 -6
- data/test/data_structures/columns_test.rb +2 -2
- data/test/extensions/active_record_test.rb +4 -4
- data/test/extensions/routing_mapper_test.rb +2 -2
- data/test/helpers/list_column_helpers_test.rb +3 -1
- data/test/misc/active_record_permissions_test.rb +2 -2
- data/test/misc/attribute_params_test.rb +4 -0
- data/test/misc/configurable_test.rb +10 -10
- data/test/misc/convert_numbers_format_test.rb +4 -0
- data/test/mock_app/app/assets/config/manifest.js +0 -0
- data/test/mock_app/app/controllers/cars_controller.rb +1 -0
- data/test/mock_app/app/controllers/people_controller.rb +3 -1
- data/test/mock_app/config/application.rb +1 -0
- data/test/mock_app/config/routes.rb +4 -1
- data/test/mock_app/db/schema.rb +2 -0
- data/test/performance/list_cars_performance_test.rb +34 -0
- data/test/performance/list_people_performance_test.rb +31 -0
- data/test/performance_test_help.rb +3 -0
- data/test/test_helper.rb +2 -1
- metadata +22 -12
- data/app/assets/javascripts/prototype/rico_corner.js +0 -370
- data/lib/active_scaffold/bridges/file_column/test/test_helper.rb +0 -5
@@ -0,0 +1,6 @@
|
|
1
|
+
class ActiveScaffold::Bridges::ActiveStorage < ActiveScaffold::DataStructures::Bridge
|
2
|
+
def self.install
|
3
|
+
Dir[File.join(__dir__, 'active_storage', '*.rb')].each { |file| require file }
|
4
|
+
ActiveScaffold::Config::Core.send :prepend, ActiveScaffold::Bridges::ActiveStorage::ActiveStorageBridge
|
5
|
+
end
|
6
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module ActiveScaffold
|
2
|
+
module Bridges
|
3
|
+
class ActiveStorage
|
4
|
+
module ActiveStorageBridge
|
5
|
+
def initialize(model_id)
|
6
|
+
super
|
7
|
+
return unless ActiveScaffold::Bridges::ActiveStorage::ActiveStorageBridgeHelpers.klass_has_active_storage_fields?(model)
|
8
|
+
|
9
|
+
model.send :extend, ActiveScaffold::Bridges::ActiveStorage::ActiveStorageBridgeHelpers
|
10
|
+
|
11
|
+
# include the "delete" helpers for use with active scaffold, unless they are already included
|
12
|
+
model.generate_delete_helpers
|
13
|
+
|
14
|
+
update.multipart = true
|
15
|
+
create.multipart = true
|
16
|
+
|
17
|
+
model.active_storage_has_one_fields.each { |field| configure_active_storage_field(field.to_sym, :has_one) }
|
18
|
+
model.active_storage_has_many_fields.each { |field| configure_active_storage_field(field.to_sym, :has_many) }
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def configure_active_storage_field(field, field_type)
|
24
|
+
columns << field
|
25
|
+
columns.exclude "#{field}_attachment#{'s' if field_type == :has_many}".to_sym
|
26
|
+
columns.exclude "#{field}_blob#{'s' if field_type == :has_many}".to_sym
|
27
|
+
columns[field].form_ui ||= "active_storage_#{field_type}".to_sym
|
28
|
+
columns[field].params.add "delete_#{field}"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
module ActiveScaffold
|
2
|
+
module Bridges
|
3
|
+
class ActiveStorage
|
4
|
+
module ActiveStorageBridgeHelpers
|
5
|
+
mattr_accessor :thumbnail_variant
|
6
|
+
self.thumbnail_variant = {resize_to_limit: [nil, 30]}
|
7
|
+
|
8
|
+
class << self
|
9
|
+
# has_one :"#{name}_attachment", -> { where(name: name) }, class_name: "ActiveStorage::Attachment", as: :record, inverse_of: :record, dependent: false
|
10
|
+
def active_storage_has_one_fields(klass)
|
11
|
+
klass.reflect_on_all_associations(:has_one)&.select { |reflection| reflection.class_name == 'ActiveStorage::Attachment' } &.collect { |association| association.name[0..-12] } || []
|
12
|
+
end
|
13
|
+
|
14
|
+
# has_many :"#{name}_attachments", -> { where(name: name) }, as: :record, class_name: "ActiveStorage::Attachment", inverse_of: :record, dependent: false do
|
15
|
+
def active_storage_has_many_fields(klass)
|
16
|
+
klass.reflect_on_all_associations(:has_many)&.select { |reflection| reflection.class_name == 'ActiveStorage::Attachment' } &.collect { |association| association.name[0..-13] } || []
|
17
|
+
end
|
18
|
+
|
19
|
+
def klass_has_active_storage_fields?(klass)
|
20
|
+
active_storage_has_one_fields(klass).present? || active_storage_has_many_fields(klass).present?
|
21
|
+
end
|
22
|
+
|
23
|
+
def generate_delete_helpers(klass)
|
24
|
+
(active_storage_has_one_fields(klass) | active_storage_has_many_fields(klass)).each do |field|
|
25
|
+
klass.send :class_eval, <<-CODE, __FILE__, __LINE__ + 1 unless klass.method_defined?(:"#{field}_with_delete=")
|
26
|
+
attr_reader :delete_#{field}
|
27
|
+
|
28
|
+
def delete_#{field}=(value)
|
29
|
+
value = (value=="true") if String===value
|
30
|
+
return unless value
|
31
|
+
|
32
|
+
# passing nil to the file column causes the file to be deleted.
|
33
|
+
self.#{field}.purge
|
34
|
+
end
|
35
|
+
CODE
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def active_storage_has_one_fields
|
41
|
+
@active_storage_has_one_fields ||= ActiveStorageBridgeHelpers.active_storage_has_one_fields(self)
|
42
|
+
end
|
43
|
+
|
44
|
+
def active_storage_has_many_fields
|
45
|
+
@active_storage_has_many_fields ||= ActiveStorageBridgeHelpers.active_storage_has_many_fields(self)
|
46
|
+
end
|
47
|
+
|
48
|
+
def generate_delete_helpers
|
49
|
+
ActiveStorageBridgeHelpers.generate_delete_helpers(self)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module ActiveScaffold
|
2
|
+
module Helpers
|
3
|
+
# Helpers that assist with the rendering of a Form Column
|
4
|
+
module FormColumnHelpers
|
5
|
+
def active_scaffold_input_active_storage_has_one(column, options)
|
6
|
+
record = options[:object]
|
7
|
+
active_storage = record.send(column.name.to_s)
|
8
|
+
content = active_scaffold_column_active_storage_has_one(record, column) if active_storage.attached?
|
9
|
+
active_scaffold_file_with_remove_link(column, options, content, 'delete_', 'active_storage_controls')
|
10
|
+
end
|
11
|
+
|
12
|
+
def active_scaffold_input_active_storage_has_many(column, options)
|
13
|
+
record = options[:object]
|
14
|
+
options[:multiple] = 'multiple'
|
15
|
+
options[:name] += '[]'
|
16
|
+
active_storage = record.send(column.name.to_s)
|
17
|
+
content = active_scaffold_column_active_storage_has_many(record, column) if active_storage.attached?
|
18
|
+
active_scaffold_file_with_remove_link(column, options, content, 'delete_', 'active_storage_controls')
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module ActiveScaffold
|
2
|
+
module Helpers
|
3
|
+
module ListColumnHelpers
|
4
|
+
def active_scaffold_column_active_storage_has_one(record, column)
|
5
|
+
attachment = record.send(column.name.to_s)
|
6
|
+
attachment.attached? ? link_for_attachment(attachment) : nil
|
7
|
+
end
|
8
|
+
|
9
|
+
def active_scaffold_column_active_storage_has_many(record, column)
|
10
|
+
active_storage_files = record.send(column.name.to_s)
|
11
|
+
return nil unless active_storage_files.attached?
|
12
|
+
|
13
|
+
attachments = active_storage_files.attachments
|
14
|
+
if attachments.size <= 3 # Lets display up to three links, otherwise just show the count.
|
15
|
+
links = attachments.map { |attachment| link_for_attachment(attachment) }
|
16
|
+
safe_join links, association_join_text(column)
|
17
|
+
else
|
18
|
+
pluralize attachments.size, column.name.to_s
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def link_for_attachment(attachment)
|
25
|
+
variant = column.options[:thumb] || ActiveScaffold::Bridges::ActiveStorage::ActiveStorageBridgeHelpers.thumbnail_variant
|
26
|
+
content =
|
27
|
+
if variant && attachment.variable?
|
28
|
+
image_tag(attachment.variant(variant))
|
29
|
+
else
|
30
|
+
attachment.filename
|
31
|
+
end
|
32
|
+
link_to(content, rails_blob_url(attachment, disposition: 'attachment'), target: '_blank', rel: 'noopener noreferrer')
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -2,5 +2,6 @@ class ActiveScaffold::Bridges::Bitfields < ActiveScaffold::DataStructures::Bridg
|
|
2
2
|
def self.install
|
3
3
|
require File.join(File.dirname(__FILE__), 'bitfields/bitfields_bridge')
|
4
4
|
ActiveScaffold::Config::Core.send :prepend, ActiveScaffold::Bridges::Bitfields::BitfieldsBridge
|
5
|
+
ActiveScaffold::Config::Core.after_config_callbacks << :_setup_bitfields
|
5
6
|
end
|
6
7
|
end
|
@@ -6,7 +6,7 @@ module ActiveScaffold
|
|
6
6
|
super
|
7
7
|
return unless model.respond_to?(:bitfields) && model.bitfields.present?
|
8
8
|
|
9
|
-
model.bitfields.each_value do |
|
9
|
+
model.bitfields.each_value do |options|
|
10
10
|
columns << options.keys
|
11
11
|
options.each do |column, value|
|
12
12
|
columns[column].form_ui = :checkbox
|
@@ -15,23 +15,20 @@ module ActiveScaffold
|
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
|
-
def
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
end
|
18
|
+
def _setup_bitfields
|
19
|
+
return unless model.respond_to?(:bitfields) && model.bitfields.present?
|
20
|
+
model.bitfields.each do |column_name, options|
|
21
|
+
columns = options.keys.sort_by { |column| self.columns[column].weight }
|
22
|
+
%i[create update show subform].each do |action|
|
23
|
+
next unless actions.include? action
|
24
|
+
if send(action).columns.include? column_name
|
25
|
+
send(action).columns.exclude column_name
|
26
|
+
send(action).columns.add_subgroup(column_name) { |group| group.add(*columns) }
|
27
|
+
else
|
28
|
+
send(action).columns.exclude(*columns)
|
30
29
|
end
|
31
30
|
end
|
32
31
|
end
|
33
|
-
|
34
|
-
super
|
35
32
|
end
|
36
33
|
end
|
37
34
|
end
|
@@ -45,6 +45,12 @@ module ActiveScaffold::Bridges
|
|
45
45
|
def beginning_of_chain
|
46
46
|
super.accessible_by(current_ability)
|
47
47
|
end
|
48
|
+
|
49
|
+
# fix when ability allow access base on id
|
50
|
+
# can [:manage], Client, id: Client.of_employee(user).pluck(:id)
|
51
|
+
def new_model
|
52
|
+
super.tap { |record| record.id = nil }
|
53
|
+
end
|
48
54
|
end
|
49
55
|
end
|
50
56
|
|
@@ -7,11 +7,11 @@ module ActiveScaffold
|
|
7
7
|
thumbnail_style = ActiveScaffold::Bridges::Carrierwave::CarrierwaveBridgeHelpers.thumbnail_style
|
8
8
|
content =
|
9
9
|
if carrierwave.versions.keys.include?(thumbnail_style)
|
10
|
-
image_tag(carrierwave.url(thumbnail_style), :border => 0)
|
10
|
+
image_tag(carrierwave.url(thumbnail_style), :border => 0)
|
11
11
|
else
|
12
12
|
record.send(record.send(:_mounter, column.name).send(:serialization_column))
|
13
13
|
end
|
14
|
-
link_to(content, carrierwave.url, :target => '_blank')
|
14
|
+
link_to(content, carrierwave.url, :target => '_blank', rel: 'noopener noreferrer')
|
15
15
|
end
|
16
16
|
end
|
17
17
|
end
|
@@ -24,9 +24,7 @@ module ActiveScaffold::Bridges
|
|
24
24
|
def self.date_options_for_locales
|
25
25
|
I18n.available_locales.collect do |locale|
|
26
26
|
locale_date_options = date_options(locale)
|
27
|
-
if locale_date_options
|
28
|
-
"$.datepicker.regional['#{locale}'] = #{locale_date_options.to_json};"
|
29
|
-
end
|
27
|
+
"$.datepicker.regional['#{locale}'] = #{locale_date_options.to_json};" if locale_date_options
|
30
28
|
end.compact.join('')
|
31
29
|
end
|
32
30
|
|
@@ -59,9 +57,7 @@ module ActiveScaffold::Bridges
|
|
59
57
|
def self.datetime_options_for_locales
|
60
58
|
I18n.available_locales.collect do |locale|
|
61
59
|
locale_datetime_options = datetime_options(locale)
|
62
|
-
if locale_datetime_options
|
63
|
-
"$.timepicker.regional['#{locale}'] = #{locale_datetime_options.to_json};"
|
64
|
-
end
|
60
|
+
"$.timepicker.regional['#{locale}'] = #{locale_datetime_options.to_json};" if locale_datetime_options
|
65
61
|
end.compact.join('')
|
66
62
|
end
|
67
63
|
|
@@ -78,12 +74,7 @@ module ActiveScaffold::Bridges
|
|
78
74
|
datetime_picker_options.merge!(as_datetime_picker_options) if as_datetime_picker_options.is_a? Hash
|
79
75
|
Rails.logger.warn "ActiveScaffold: Missing datetime picker localization for your locale: #{locale}" if as_datetime_picker_options.blank?
|
80
76
|
|
81
|
-
|
82
|
-
datetime_picker_options[:dateFormat] = date_format unless date_format.nil?
|
83
|
-
unless time_format.nil?
|
84
|
-
datetime_picker_options[:timeFormat] = time_format
|
85
|
-
datetime_picker_options[:ampm] = true if rails_time_format.include?('%I')
|
86
|
-
end
|
77
|
+
datetime_picker_options.merge! format_to_datetime_picker(rails_time_format)
|
87
78
|
datetime_picker_options
|
88
79
|
rescue StandardError
|
89
80
|
raise if locale == I18n.locale
|
@@ -92,7 +83,11 @@ module ActiveScaffold::Bridges
|
|
92
83
|
def self.to_datepicker_format(rails_format)
|
93
84
|
return nil if rails_format.nil?
|
94
85
|
if rails_format =~ /%[cUWwxXZz]/
|
95
|
-
Rails.logger.warn(
|
86
|
+
Rails.logger.warn(
|
87
|
+
"AS DatePicker::Helper: rails date format #{rails_format} includes options "\
|
88
|
+
"which can't be converted to jquery datepicker format. "\
|
89
|
+
'Options %c, %U, %W, %w, %x %X, %z, %Z are not supported by datepicker and will be removed'
|
90
|
+
)
|
96
91
|
nil
|
97
92
|
end
|
98
93
|
js_format = rails_format.dup
|
@@ -103,6 +98,17 @@ module ActiveScaffold::Bridges
|
|
103
98
|
js_format
|
104
99
|
end
|
105
100
|
|
101
|
+
def self.format_to_datetime_picker(rails_time_format)
|
102
|
+
date_format, time_format = split_datetime_format(to_datepicker_format(rails_time_format))
|
103
|
+
datetime_picker_options = {}
|
104
|
+
datetime_picker_options[:dateFormat] = date_format unless date_format.nil?
|
105
|
+
unless time_format.nil?
|
106
|
+
datetime_picker_options[:timeFormat] = time_format
|
107
|
+
datetime_picker_options[:ampm] = true if rails_time_format.include?('%I')
|
108
|
+
end
|
109
|
+
datetime_picker_options
|
110
|
+
end
|
111
|
+
|
106
112
|
def self.split_datetime_format(datetime_format)
|
107
113
|
date_format = datetime_format
|
108
114
|
time_format = nil
|
@@ -119,46 +125,44 @@ module ActiveScaffold::Bridges
|
|
119
125
|
end
|
120
126
|
|
121
127
|
module DatepickerColumnHelpers
|
122
|
-
def datepicker_split_datetime_format(datetime_format)
|
123
|
-
ActiveScaffold::Bridges::DatePicker::Helper.split_datetime_format(datetime_format)
|
124
|
-
end
|
125
|
-
|
126
128
|
def to_datepicker_format(rails_format)
|
127
129
|
ActiveScaffold::Bridges::DatePicker::Helper.to_datepicker_format(rails_format)
|
128
130
|
end
|
129
131
|
|
130
|
-
def datepicker_format_options(column, format
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
options['data-dateFormat'] = date_format unless date_format.nil?
|
139
|
-
unless time_format.nil?
|
140
|
-
options['data-timeFormat'] = time_format
|
141
|
-
options['data-ampm'] = true if rails_time_format.include?('%I')
|
142
|
-
end
|
143
|
-
end
|
132
|
+
def datepicker_format_options(column, format)
|
133
|
+
return {} if format == :default
|
134
|
+
if column.form_ui == :date_picker
|
135
|
+
js_format = to_datepicker_format(I18n.translate!("date.formats.#{format}"))
|
136
|
+
js_format.nil? ? {} : {dateFormat: js_format}
|
137
|
+
else
|
138
|
+
rails_time_format = I18n.translate!("time.formats.#{format}")
|
139
|
+
ActiveScaffold::Bridges::DatePicker::Helper.format_to_datetime_picker(rails_time_format)
|
144
140
|
end
|
145
141
|
end
|
142
|
+
|
143
|
+
def datepicker_format(options, ui)
|
144
|
+
options.delete(:format) || (ui == :date_picker ? :default : :picker)
|
145
|
+
end
|
146
146
|
end
|
147
147
|
|
148
148
|
module SearchColumnHelpers
|
149
149
|
def active_scaffold_search_date_bridge_calendar_control(column, options, current_search, name)
|
150
|
-
value =
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
150
|
+
value =
|
151
|
+
if current_search.is_a? Hash
|
152
|
+
controller.class.condition_value_for_datetime(column, current_search[name], column.search_ui == :date_picker ? :to_date : :to_time)
|
153
|
+
else
|
154
|
+
current_search
|
155
|
+
end
|
155
156
|
options = column.options.merge(options).except!(:include_blank, :discard_time, :discard_date, :value)
|
156
157
|
options = active_scaffold_input_text_options(options.merge(column.options))
|
158
|
+
format = datepicker_format(options, column.search_ui)
|
157
159
|
options[:class] << " #{column.search_ui}"
|
158
160
|
options[:style] = 'display: none' if options[:show] == false # hide only if asked to hide
|
159
|
-
|
160
|
-
datepicker_format_options(column, format
|
161
|
-
|
161
|
+
options[:data] ||= {}
|
162
|
+
options[:data].merge! datepicker_format_options(column, format)
|
163
|
+
value = l(value, :format => format) if value
|
164
|
+
options = options.merge(:id => "#{options[:id]}_#{name}", :name => "#{options[:name]}[#{name}]", :object => nil)
|
165
|
+
text_field_tag("#{options[:name]}[#{name}]", value, options)
|
162
166
|
end
|
163
167
|
end
|
164
168
|
|
@@ -168,9 +172,10 @@ module ActiveScaffold::Bridges
|
|
168
172
|
options = active_scaffold_input_text_options(options.merge(column.options))
|
169
173
|
options[:class] << " #{column.form_ui}"
|
170
174
|
|
175
|
+
format = datepicker_format(options, column.form_ui)
|
171
176
|
value = controller.class.condition_value_for_datetime(column, record.send(column.name), column.form_ui == :date_picker ? :to_date : :to_time)
|
172
|
-
|
173
|
-
datepicker_format_options(column, format
|
177
|
+
options[:data] ||= {}
|
178
|
+
options[:data].merge! datepicker_format_options(column, format)
|
174
179
|
options[:value] = (value ? l(value, :format => format) : nil)
|
175
180
|
text_field(:record, column.name, options)
|
176
181
|
end
|
@@ -10,7 +10,7 @@ module ActiveScaffold
|
|
10
10
|
else
|
11
11
|
attachment.name
|
12
12
|
end
|
13
|
-
link_to(content, dragonfly_url_for_attachment(attachment, record, column), :target => '_blank')
|
13
|
+
link_to(content, dragonfly_url_for_attachment(attachment, record, column), :target => '_blank', rel: 'noopener noreferrer')
|
14
14
|
end
|
15
15
|
|
16
16
|
def dragonfly_url_for_attachment(attachment, record, column)
|
@@ -9,7 +9,7 @@ module ActiveScaffold
|
|
9
9
|
|
10
10
|
def generate_delete_helpers(klass)
|
11
11
|
file_column_fields(klass).each do |field|
|
12
|
-
klass.send :class_eval, <<-
|
12
|
+
klass.send :class_eval, <<-CODE, __FILE__, __LINE__ + 1 unless klass.method_defined?(:"#{field}_with_delete=")
|
13
13
|
attr_reader :delete_#{field}
|
14
14
|
|
15
15
|
def delete_#{field}=(value)
|
@@ -19,7 +19,7 @@ module ActiveScaffold
|
|
19
19
|
# passing nil to the file column causes the file to be deleted. Don't delete if we just uploaded a file!
|
20
20
|
self.#{field} = nil unless self.#{field}_just_uploaded?
|
21
21
|
end
|
22
|
-
|
22
|
+
CODE
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
@@ -18,9 +18,9 @@ module ActiveScaffold
|
|
18
18
|
|
19
19
|
content_tag(:div) do
|
20
20
|
content_tag(:div) do
|
21
|
-
get_column_value(record, column)
|
22
|
-
|
23
|
-
|
21
|
+
safe_join [get_column_value(record, column), custom_hidden_field_tag, '|',
|
22
|
+
content_tag(:a, as_(:remove_file), :href => '#', :onclick => remove_file_js),
|
23
|
+
content_tag(:div, 'test', :style => 'display: none')], ' '
|
24
24
|
end
|
25
25
|
end
|
26
26
|
else
|
@@ -6,7 +6,7 @@ module ActiveScaffold
|
|
6
6
|
self.thumbnail_style = :thumbnail
|
7
7
|
|
8
8
|
def self.generate_delete_helper(klass, field)
|
9
|
-
klass.class_eval <<-
|
9
|
+
klass.class_eval <<-CODE, __FILE__, __LINE__ + 1 unless klass.method_defined?(:"delete_#{field}=")
|
10
10
|
attr_reader :delete_#{field}
|
11
11
|
|
12
12
|
def delete_#{field}=(value)
|
@@ -16,7 +16,7 @@ module ActiveScaffold
|
|
16
16
|
# passing nil to the file column causes the file to be deleted. Don't delete if we just uploaded a file!
|
17
17
|
self.#{field} = nil unless self.#{field}.dirty?
|
18
18
|
end
|
19
|
-
|
19
|
+
CODE
|
20
20
|
end
|
21
21
|
end
|
22
22
|
end
|