active_scaffold 3.0.26 → 3.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +1 -1
- data/{frontends/default → app/assets}/images/add.gif +0 -0
- data/{frontends/default → app/assets}/images/arrow_down.gif +0 -0
- data/{frontends/default → app/assets}/images/arrow_up.gif +0 -0
- data/{frontends/default → app/assets}/images/close.gif +0 -0
- data/{frontends/default → app/assets}/images/close_touch.png +0 -0
- data/{frontends/default → app/assets}/images/config.png +0 -0
- data/{frontends/default → app/assets}/images/cross.png +0 -0
- data/{frontends/default → app/assets}/images/gears.png +0 -0
- data/{frontends/default → app/assets}/images/indicator-small.gif +0 -0
- data/{frontends/default → app/assets}/images/indicator.gif +0 -0
- data/{frontends/default → app/assets}/images/magnifier.png +0 -0
- data/app/assets/javascripts/active_scaffold.js.erb +16 -0
- data/{frontends/default → app/assets}/javascripts/jquery/active_scaffold.js +16 -28
- data/app/assets/javascripts/jquery/active_scaffold.js~ +1036 -0
- data/{lib/active_scaffold/bridges/date_picker/public/javascripts/date_picker_bridge.js → app/assets/javascripts/jquery/date_picker_bridge.js.erb} +3 -1
- data/{frontends/default → app/assets}/javascripts/jquery/jquery.editinplace.js +0 -0
- data/app/assets/javascripts/prototype/active_scaffold.js +1033 -0
- data/{frontends/default/javascripts/prototype/active_scaffold.js → app/assets/javascripts/prototype/active_scaffold.js~} +1 -0
- data/{frontends/default → app/assets}/javascripts/prototype/dhtml_history.js +0 -0
- data/{frontends/default → app/assets}/javascripts/prototype/form_enhancements.js +0 -0
- data/{frontends/default → app/assets}/javascripts/prototype/rico_corner.js +0 -0
- data/{frontends/default/stylesheets/stylesheet-ie.css → app/assets/stylesheets/active_scaffold-ie.css} +0 -0
- data/{frontends/default/stylesheets/stylesheet.css → app/assets/stylesheets/active_scaffold.css.erb} +29 -24
- data/{lib/active_scaffold/locale → config/locales}/de.yml +3 -0
- data/{lib/active_scaffold/locale → config/locales}/en.yml +3 -0
- data/{lib/active_scaffold/locale → config/locales}/es.yml +5 -0
- data/{lib/active_scaffold/locale → config/locales}/fr.yml +3 -0
- data/{lib/active_scaffold/locale → config/locales}/hu.yml +13 -2
- data/{lib/active_scaffold/locale → config/locales}/ja.yml +9 -0
- data/{lib/active_scaffold/locale → config/locales}/ru.yml +3 -0
- data/frontends/default/views/_form.html.erb +1 -1
- data/frontends/default/views/_form_association.html.erb +1 -5
- data/frontends/default/views/_horizontal_subform.html.erb +7 -4
- data/frontends/default/views/_horizontal_subform.html.erb~ +2 -5
- data/frontends/default/views/_horizontal_subform_footer.html.erb +0 -0
- data/frontends/default/views/_horizontal_subform_header.html.erb +1 -1
- data/frontends/default/views/_horizontal_subform_header.html.erb~ +1 -1
- data/frontends/default/views/_horizontal_subform_record.html.erb~ +1 -1
- data/frontends/default/views/_list_actions.html.erb +1 -1
- data/frontends/default/views/_list_messages.html.erb +1 -3
- data/frontends/default/views/_render_field.js.erb +20 -0
- data/frontends/default/views/_row.html.erb +3 -9
- data/frontends/default/views/_show.html.erb +2 -2
- data/frontends/default/views/add_existing.js.erb +20 -0
- data/frontends/default/views/destroy.js.erb +24 -0
- data/frontends/default/views/{edit_associated.js.rjs → edit_associated.js.erb} +3 -2
- data/frontends/default/views/form_messages.js.erb +1 -0
- data/frontends/default/views/list.js.erb +1 -0
- data/frontends/default/views/mark.js.rjs +6 -0
- data/frontends/default/views/on_action_update.js.erb +13 -0
- data/frontends/default/views/{on_create.js.erb~ → on_create.js.erb} +0 -0
- data/frontends/default/views/on_mark_all.js.erb +12 -0
- data/frontends/default/views/{on_update.js.erb~ → on_update.js.erb} +0 -0
- data/frontends/default/views/render_field.js.erb +1 -0
- data/frontends/default/views/search.html.erb +1 -1
- data/frontends/default/views/{update_column.js.erb~ → update_column.js.erb} +3 -3
- data/frontends/default/views/update_row.js.erb +1 -0
- data/lib/active_scaffold.rb +22 -46
- data/lib/active_scaffold/actions/core.rb +14 -6
- data/lib/active_scaffold/actions/core.rb~ +3 -3
- data/lib/active_scaffold/actions/create.rb +2 -5
- data/lib/active_scaffold/actions/create.rb~ +3 -2
- data/lib/active_scaffold/actions/delete.rb +1 -0
- data/lib/active_scaffold/actions/field_search.rb +1 -1
- data/lib/active_scaffold/actions/list.rb +10 -6
- data/lib/active_scaffold/actions/list.rb~ +3 -3
- data/lib/active_scaffold/actions/mark.rb +8 -8
- data/lib/active_scaffold/actions/nested.rb +2 -9
- data/lib/active_scaffold/actions/nested.rb~ +5 -7
- data/lib/active_scaffold/actions/search.rb +2 -1
- data/lib/active_scaffold/actions/subform.rb +1 -5
- data/lib/active_scaffold/actions/update.rb +1 -4
- data/lib/active_scaffold/actions/update.rb~ +5 -5
- data/lib/active_scaffold/attribute_params.rb +15 -26
- data/lib/active_scaffold/attribute_params.rb~ +1 -2
- data/lib/active_scaffold/bridges.rb +61 -0
- data/lib/active_scaffold/bridges/ancestry.rb +5 -0
- data/lib/active_scaffold/bridges/ancestry/{lib/ancestry_bridge.rb → ancestry_bridge.rb} +3 -3
- data/lib/active_scaffold/bridges/{calendar_date_select/bridge.rb → calendar_date_select.rb} +13 -5
- data/lib/active_scaffold/bridges/calendar_date_select/{lib/as_cds_bridge.rb → as_cds_bridge.rb} +4 -20
- data/lib/active_scaffold/bridges/cancan.rb +15 -0
- data/lib/active_scaffold/bridges/cancan/{lib/cancan_bridge.rb → cancan_bridge.rb} +2 -2
- data/lib/active_scaffold/bridges/carrierwave.rb +12 -0
- data/lib/active_scaffold/bridges/carrierwave/carrierwave_bridge.rb +31 -0
- data/lib/active_scaffold/bridges/carrierwave/carrierwave_bridge_helpers.rb +10 -0
- data/lib/active_scaffold/bridges/carrierwave/{lib/form_ui.rb → form_ui.rb} +0 -0
- data/lib/active_scaffold/bridges/carrierwave/{lib/list_ui.rb → list_ui.rb} +1 -1
- data/lib/active_scaffold/bridges/country_helper.rb +9 -0
- data/lib/active_scaffold/bridges/country_helper/{lib/country_helper_bridge.rb → country_helper_bridge.rb} +5 -5
- data/lib/active_scaffold/bridges/date_picker.rb +23 -0
- data/lib/active_scaffold/bridges/date_picker/ext.rb +54 -0
- data/lib/active_scaffold/bridges/date_picker/helper.rb +188 -0
- data/lib/active_scaffold/bridges/dragonfly.rb +9 -0
- data/lib/active_scaffold/bridges/dragonfly/dragonfly_bridge.rb +34 -0
- data/lib/active_scaffold/bridges/dragonfly/dragonfly_bridge_helpers.rb +10 -0
- data/lib/active_scaffold/bridges/dragonfly/{lib/form_ui.rb → form_ui.rb} +0 -0
- data/lib/active_scaffold/bridges/dragonfly/{lib/list_ui.rb → list_ui.rb} +2 -2
- data/lib/active_scaffold/bridges/file_column.rb +11 -0
- data/lib/active_scaffold/bridges/file_column/{lib/as_file_column_bridge.rb → as_file_column_bridge.rb} +2 -2
- data/lib/active_scaffold/bridges/file_column/file_column_helpers.rb +57 -0
- data/lib/active_scaffold/bridges/file_column/{lib/form_ui.rb → form_ui.rb} +2 -2
- data/lib/active_scaffold/bridges/file_column/{lib/list_ui.rb → list_ui.rb} +0 -0
- data/lib/active_scaffold/bridges/paperclip.rb +12 -0
- data/lib/active_scaffold/bridges/paperclip/{lib/form_ui.rb → form_ui.rb} +0 -0
- data/lib/active_scaffold/bridges/paperclip/{lib/list_ui.rb → list_ui.rb} +3 -3
- data/lib/active_scaffold/bridges/paperclip/paperclip_bridge.rb +36 -0
- data/lib/active_scaffold/bridges/paperclip/paperclip_bridge_helpers.rb +24 -0
- data/lib/active_scaffold/bridges/record_select.rb +11 -0
- data/lib/active_scaffold/bridges/record_select/{lib/record_select_bridge.rb → helpers.rb} +5 -16
- data/lib/active_scaffold/bridges/record_select/helpers.rb~ +9 -14
- data/lib/active_scaffold/bridges/semantic_attributes.rb +5 -0
- data/lib/active_scaffold/bridges/semantic_attributes/{lib/semantic_attributes_bridge.rb → column.rb} +3 -3
- data/lib/active_scaffold/bridges/tiny_mce.rb +5 -0
- data/lib/active_scaffold/bridges/tiny_mce/{lib/tiny_mce_bridge.rb → helpers.rb} +16 -8
- data/lib/active_scaffold/config/base.rb +9 -1
- data/lib/active_scaffold/config/core.rb +1 -1
- data/lib/active_scaffold/config/create.rb +3 -10
- data/lib/active_scaffold/config/delete.rb +1 -2
- data/lib/active_scaffold/config/field_search.rb +1 -2
- data/lib/active_scaffold/config/form.rb +2 -6
- data/lib/active_scaffold/config/list.rb +8 -2
- data/lib/active_scaffold/config/nested.rb +2 -6
- data/lib/active_scaffold/config/search.rb +6 -2
- data/lib/active_scaffold/config/show.rb +1 -4
- data/lib/active_scaffold/config/subform.rb +1 -1
- data/lib/active_scaffold/config/update.rb +1 -6
- data/lib/active_scaffold/data_structures/action_columns.rb +3 -0
- data/lib/active_scaffold/data_structures/action_link.rb +14 -10
- data/lib/active_scaffold/data_structures/bridge.rb +22 -0
- data/lib/active_scaffold/data_structures/column.rb +36 -4
- data/lib/active_scaffold/data_structures/nested_info.rb +4 -4
- data/lib/active_scaffold/data_structures/set.rb +1 -6
- data/lib/active_scaffold/data_structures/sorting.rb +2 -2
- data/lib/active_scaffold/engine.rb +4 -0
- data/lib/active_scaffold/extensions/action_controller_rendering.rb +2 -2
- data/lib/active_scaffold/extensions/action_controller_rendering.rb~ +1 -1
- data/lib/active_scaffold/extensions/action_view_rendering.rb +90 -93
- data/lib/active_scaffold/extensions/action_view_rendering.rb~ +1 -13
- data/lib/active_scaffold/extensions/active_association_reflection.rb +16 -7
- data/lib/active_scaffold/extensions/cache_association.rb +16 -0
- data/lib/active_scaffold/extensions/reverse_associations.rb +15 -13
- data/lib/active_scaffold/extensions/unsaved_associated.rb +1 -1
- data/lib/active_scaffold/finder.rb +40 -23
- data/lib/active_scaffold/finder.rb~ +3 -11
- data/lib/active_scaffold/helpers/association_helpers.rb +1 -1
- data/lib/active_scaffold/helpers/controller_helpers.rb +9 -1
- data/lib/active_scaffold/helpers/controller_helpers.rb~ +12 -5
- data/lib/active_scaffold/helpers/form_column_helpers.rb +20 -21
- data/lib/active_scaffold/helpers/form_column_helpers.rb~ +2 -1
- data/lib/active_scaffold/helpers/id_helpers.rb +5 -5
- data/lib/active_scaffold/helpers/list_column_helpers.rb +14 -24
- data/lib/active_scaffold/helpers/list_column_helpers.rb~ +15 -20
- data/lib/active_scaffold/helpers/search_column_helpers.rb +10 -1
- data/lib/active_scaffold/helpers/search_column_helpers.rb~ +1 -1
- data/lib/active_scaffold/helpers/view_helpers.rb +14 -40
- data/lib/active_scaffold/helpers/view_helpers.rb~ +3 -3
- data/lib/active_scaffold/version.rb +2 -2
- data/lib/active_scaffold_env.rb +0 -2
- data/test/bridges/active_scaffold_dependent_protect_test.rb +34 -0
- data/test/bridges/bridge_test.rb +43 -0
- data/test/bridges/company.rb +81 -0
- data/test/bridges/paperclip_test.rb +68 -0
- data/test/bridges/tiny_mce_test.rb +27 -0
- data/test/bridges/unobtrusive_date_picker_test.rb +49 -0
- data/test/bridges/validation_reflection_test.rb +57 -0
- data/test/config/base_test.rb +1 -1
- data/test/config/core_test.rb +58 -0
- data/test/config/create_test.rb +8 -5
- data/test/config/delete_test.rb +33 -0
- data/test/config/field_search_test.rb +47 -0
- data/test/config/list_test.rb +64 -9
- data/test/config/nested_test.rb +62 -0
- data/test/config/search_test.rb +60 -0
- data/test/config/show_test.rb +5 -5
- data/test/config/subform_test.rb +17 -0
- data/test/config/update_test.rb +27 -4
- data/test/helpers/list_column_helpers_test.rb +16 -5
- data/test/helpers/pagination_helpers_test.rb +4 -0
- data/test/misc/attribute_params_test.rb +37 -1
- data/test/misc/finder_test.rb +0 -1
- data/test/misc/lang_test.rb +2 -3
- data/test/mock_app/public/javascripts/active_scaffold/default/active_scaffold.js +2 -2
- data/test/mock_app/public/stylesheets/active_scaffold/default/stylesheet.css +13 -7
- metadata +137 -154
- data/frontends/default/views/_list_with_header.html.erb~ +0 -32
- data/frontends/default/views/_render_field.js.rjs +0 -14
- data/frontends/default/views/_show.html.erb~ +0 -8
- data/frontends/default/views/_update_form.html.erb~ +0 -6
- data/frontends/default/views/add_existing.js.erb~ +0 -18
- data/frontends/default/views/add_existing.js.rjs +0 -17
- data/frontends/default/views/destroy.js.rjs +0 -23
- data/frontends/default/views/form_messages.js.rjs +0 -1
- data/frontends/default/views/list.js.rjs +0 -1
- data/frontends/default/views/on_action_update.js.rjs +0 -10
- data/frontends/default/views/on_create.js.rjs +0 -41
- data/frontends/default/views/on_mark_all.js.rjs +0 -12
- data/frontends/default/views/on_update.js.rjs +0 -28
- data/frontends/default/views/render_field.js.rjs +0 -1
- data/frontends/default/views/update_column.js.rjs +0 -13
- data/frontends/default/views/update_row.js.rjs +0 -1
- data/lib/active_scaffold.rb~ +0 -362
- data/lib/active_scaffold/bridges/ancestry/bridge.rb +0 -5
- data/lib/active_scaffold/bridges/bridge.rb +0 -59
- data/lib/active_scaffold/bridges/cancan/bridge.rb +0 -12
- data/lib/active_scaffold/bridges/carrierwave/bridge.rb +0 -9
- data/lib/active_scaffold/bridges/carrierwave/lib/carrierwave_bridge.rb +0 -33
- data/lib/active_scaffold/bridges/carrierwave/lib/carrierwave_bridge_helpers.rb +0 -12
- data/lib/active_scaffold/bridges/country_helper/bridge.rb +0 -9
- data/lib/active_scaffold/bridges/date_picker/bridge.rb +0 -24
- data/lib/active_scaffold/bridges/date_picker/lib/datepicker_bridge.rb +0 -234
- data/lib/active_scaffold/bridges/dragonfly/bridge.rb +0 -9
- data/lib/active_scaffold/bridges/dragonfly/lib/dragonfly_bridge.rb +0 -36
- data/lib/active_scaffold/bridges/dragonfly/lib/dragonfly_bridge_helpers.rb +0 -12
- data/lib/active_scaffold/bridges/file_column/bridge.rb +0 -11
- data/lib/active_scaffold/bridges/file_column/lib/file_column_helpers.rb +0 -59
- data/lib/active_scaffold/bridges/paperclip/bridge.rb +0 -12
- data/lib/active_scaffold/bridges/paperclip/lib/paperclip_bridge.rb +0 -38
- data/lib/active_scaffold/bridges/paperclip/lib/paperclip_bridge_helpers.rb +0 -26
- data/lib/active_scaffold/bridges/record_select/bridge.rb +0 -5
- data/lib/active_scaffold/bridges/semantic_attributes/bridge.rb +0 -5
- data/lib/active_scaffold/bridges/shared/date_bridge.rb~ +0 -209
- data/lib/active_scaffold/bridges/tiny_mce/bridge.rb +0 -5
- data/lib/active_scaffold/bridges/validation_reflection/bridge.rb +0 -8
- data/lib/active_scaffold/bridges/validation_reflection/lib/validation_reflection_bridge.rb +0 -21
- data/lib/active_scaffold/config/base.rb~ +0 -70
- data/lib/active_scaffold/config/nested.rb~ +0 -41
- data/lib/active_scaffold/constraints.rb~ +0 -186
- data/lib/active_scaffold/data_structures/action_link.rb~ +0 -179
- data/lib/active_scaffold/data_structures/nested_info.rb~ +0 -123
- data/lib/active_scaffold/extensions/action_view_resolver.rb +0 -7
- data/lib/active_scaffold/extensions/active_association_reflection.rb~ +0 -22
- data/lib/active_scaffold/extensions/unsaved_associated.rb~ +0 -62
- data/lib/active_scaffold_assets.rb +0 -45
- data/lib/generators/active_scaffold_setup/USAGE +0 -10
- data/lib/generators/active_scaffold_setup/active_scaffold_setup_generator.rb +0 -59
@@ -0,0 +1,15 @@
|
|
1
|
+
class ActiveScaffold::Bridges::Cancan < ActiveScaffold::DataStructures::Bridge
|
2
|
+
def self.install
|
3
|
+
require File.join(File.dirname(__FILE__), "cancan", "cancan_bridge.rb")
|
4
|
+
|
5
|
+
ActiveScaffold::ClassMethods.send :include, ActiveScaffold::Bridges::Cancan::ClassMethods
|
6
|
+
ActiveScaffold::Actions::Core.send :include, ActiveScaffold::Bridges::Cancan::Actions::Core
|
7
|
+
ActiveScaffold::Actions::Nested.send :include, ActiveScaffold::Bridges::Cancan::Actions::Core
|
8
|
+
ActionController::Base.send :include, ActiveScaffold::Bridges::Cancan::ModelUserAccess::Controller
|
9
|
+
::ActiveRecord::Base.send :include, ActiveScaffold::Bridges::Cancan::ModelUserAccess::Model
|
10
|
+
::ActiveRecord::Base.send :include, ActiveScaffold::Bridges::Cancan::ActiveRecord
|
11
|
+
end
|
12
|
+
def self.install?
|
13
|
+
Object.const_defined? 'CanCan'
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
class ActiveScaffold::Bridges::Carrierwave < ActiveScaffold::DataStructures::Bridge
|
2
|
+
def self.install
|
3
|
+
require File.join(File.dirname(__FILE__), "carrierwave/form_ui")
|
4
|
+
require File.join(File.dirname(__FILE__), "carrierwave/list_ui")
|
5
|
+
require File.join(File.dirname(__FILE__), "carrierwave/carrierwave_bridge_helpers")
|
6
|
+
require File.join(File.dirname(__FILE__), "carrierwave/carrierwave_bridge")
|
7
|
+
ActiveScaffold::Config::Core.send :include, ActiveScaffold::Bridges::Carrierwave::CarrierwaveBridge
|
8
|
+
end
|
9
|
+
def self.install?
|
10
|
+
Object.const_defined? 'CarrierWave'
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module ActiveScaffold
|
2
|
+
module Bridges
|
3
|
+
class Carrierwave
|
4
|
+
module CarrierwaveBridge
|
5
|
+
def initialize_with_carrierwave(model_id)
|
6
|
+
initialize_without_carrierwave(model_id)
|
7
|
+
return unless self.model.respond_to?(:uploaders) && self.model.uploaders.present?
|
8
|
+
|
9
|
+
self.update.multipart = true
|
10
|
+
self.create.multipart = true
|
11
|
+
|
12
|
+
self.model.uploaders.keys.each do |field|
|
13
|
+
configure_carrierwave_field(field.to_sym)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.included(base)
|
18
|
+
base.alias_method_chain :initialize, :carrierwave
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
def configure_carrierwave_field(field)
|
23
|
+
self.columns << field
|
24
|
+
self.columns[field].form_ui ||= :carrierwave # :TODO thumbnail
|
25
|
+
self.columns[field].params.add "#{field}_cache"
|
26
|
+
self.columns[field].params.add "remove_#{field}"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
File without changes
|
@@ -4,7 +4,7 @@ module ActiveScaffold
|
|
4
4
|
def active_scaffold_column_carrierwave(column, record)
|
5
5
|
carrierwave = record.send("#{column.name}")
|
6
6
|
return nil unless !carrierwave.file.blank?
|
7
|
-
thumbnail_style = ActiveScaffold::Bridges::Carrierwave::
|
7
|
+
thumbnail_style = ActiveScaffold::Bridges::Carrierwave::CarrierwaveBridgeHelpers.thumbnail_style
|
8
8
|
content = if carrierwave.versions.keys.include?(thumbnail_style)
|
9
9
|
image_tag(carrierwave.url(thumbnail_style), :border => 0).html_safe
|
10
10
|
else
|
@@ -1,5 +1,5 @@
|
|
1
|
-
module ActiveScaffold
|
2
|
-
|
1
|
+
module ActiveScaffold::Bridges
|
2
|
+
class CountryHelper
|
3
3
|
module CountryHelpers
|
4
4
|
# Return select and option tags for the given object and method, using country_options_for_select to generate the list of option tags.
|
5
5
|
def country_select(object, method, priority_countries = nil, options = {}, html_options = {})
|
@@ -352,7 +352,7 @@ module ActiveScaffold
|
|
352
352
|
end
|
353
353
|
|
354
354
|
ActionView::Base.class_eval do
|
355
|
-
include ActiveScaffold::
|
356
|
-
include ActiveScaffold::
|
357
|
-
include ActiveScaffold::
|
355
|
+
include ActiveScaffold::Bridges::CountryHelper::CountryHelpers
|
356
|
+
include ActiveScaffold::Bridges::CountryHelper::FormColumnHelpers
|
357
|
+
include ActiveScaffold::Bridges::CountryHelper::SearchColumnHelpers
|
358
358
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module ActiveScaffold::Bridges
|
2
|
+
class DatePicker < ActiveScaffold::DataStructures::Bridge
|
3
|
+
autoload :Helper, 'active_scaffold/bridges/date_picker/helper'
|
4
|
+
def self.install
|
5
|
+
require File.join(File.dirname(__FILE__), "date_picker/ext.rb")
|
6
|
+
end
|
7
|
+
def self.install?
|
8
|
+
ActiveScaffold.js_framework == :jquery
|
9
|
+
end
|
10
|
+
def self.localization
|
11
|
+
"jQuery(function($){
|
12
|
+
if (typeof($.datepicker) === 'object') {
|
13
|
+
#{Helper.date_options_for_locales}
|
14
|
+
$.datepicker.setDefaults($.datepicker.regional['#{::I18n.locale}']);
|
15
|
+
}
|
16
|
+
if (typeof($.timepicker) === 'object') {
|
17
|
+
#{Helper.datetime_options_for_locales}
|
18
|
+
$.timepicker.setDefaults($.timepicker.regional['#{::I18n.locale}']);
|
19
|
+
}
|
20
|
+
});\n"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
class File #:nodoc:
|
2
|
+
|
3
|
+
unless File.respond_to?(:binread)
|
4
|
+
def self.binread(file)
|
5
|
+
File.open(file, 'rb') { |f| f.read }
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
end
|
10
|
+
|
11
|
+
ActiveScaffold::Config::Core.class_eval do
|
12
|
+
def initialize_with_date_picker(model_id)
|
13
|
+
initialize_without_date_picker(model_id)
|
14
|
+
|
15
|
+
date_picker_fields = self.model.columns.collect{|c| {:name => c.name.to_sym, :type => c.type} if [:date, :datetime].include?(c.type) }.compact
|
16
|
+
# check to see if file column was used on the model
|
17
|
+
return if date_picker_fields.empty?
|
18
|
+
|
19
|
+
# automatically set the forum_ui to a file column
|
20
|
+
date_picker_fields.each{|field|
|
21
|
+
col_config = self.columns[field[:name]]
|
22
|
+
col_config.form_ui = (field[:type] == :date ? :date_picker : :datetime_picker)
|
23
|
+
}
|
24
|
+
end
|
25
|
+
|
26
|
+
alias_method_chain :initialize, :date_picker
|
27
|
+
end
|
28
|
+
|
29
|
+
ActiveRecord::ConnectionAdapters::Column.class_eval do
|
30
|
+
class << self
|
31
|
+
def fallback_string_to_date_with_date_picker(string)
|
32
|
+
Date.strptime(string, I18n.t('date.formats.default')) rescue fallback_string_to_date_without_date_picker(string)
|
33
|
+
end
|
34
|
+
alias_method_chain :fallback_string_to_date, :date_picker
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
ActionView::Base.class_eval do
|
39
|
+
include ActiveScaffold::Bridges::Shared::DateBridge::SearchColumnHelpers
|
40
|
+
alias_method :active_scaffold_search_date_picker, :active_scaffold_search_date_bridge
|
41
|
+
alias_method :active_scaffold_search_datetime_picker, :active_scaffold_search_date_bridge
|
42
|
+
include ActiveScaffold::Bridges::Shared::DateBridge::HumanConditionHelpers
|
43
|
+
alias_method :active_scaffold_human_condition_date_picker, :active_scaffold_human_condition_date_bridge
|
44
|
+
alias_method :active_scaffold_human_condition_datetime_picker, :active_scaffold_human_condition_date_bridge
|
45
|
+
include ActiveScaffold::Bridges::DatePicker::Helper::SearchColumnHelpers
|
46
|
+
include ActiveScaffold::Bridges::DatePicker::Helper::FormColumnHelpers
|
47
|
+
alias_method :active_scaffold_input_datetime_picker, :active_scaffold_input_date_picker
|
48
|
+
include ActiveScaffold::Bridges::DatePicker::Helper::DatepickerColumnHelpers
|
49
|
+
end
|
50
|
+
ActiveScaffold::Finder::ClassMethods.module_eval do
|
51
|
+
include ActiveScaffold::Bridges::Shared::DateBridge::Finder::ClassMethods
|
52
|
+
alias_method :condition_for_date_picker_type, :condition_for_date_bridge_type
|
53
|
+
alias_method :condition_for_datetime_picker_type, :condition_for_date_picker_type
|
54
|
+
end
|
@@ -0,0 +1,188 @@
|
|
1
|
+
module ActiveScaffold::Bridges
|
2
|
+
class DatePicker
|
3
|
+
module Helper
|
4
|
+
DATE_FORMAT_CONVERSION = {
|
5
|
+
/%a/ => 'D',
|
6
|
+
/%A/ => 'DD',
|
7
|
+
/%b/ => 'M',
|
8
|
+
/%B/ => 'MM',
|
9
|
+
/%d/ => 'dd',
|
10
|
+
/%e/ => 'd',
|
11
|
+
/%j/ => 'oo',
|
12
|
+
/%m/ => 'mm',
|
13
|
+
/%y/ => 'y',
|
14
|
+
/%Y/ => 'yy',
|
15
|
+
/%H/ => 'hh', # options ampm => false
|
16
|
+
/%I/ => 'hh', # options ampm => true
|
17
|
+
/%M/ => 'mm',
|
18
|
+
/%p/ => 'tt',
|
19
|
+
/%S/ => 'ss',
|
20
|
+
/%[cUWwxXZz]/ => ''
|
21
|
+
}
|
22
|
+
|
23
|
+
def self.date_options_for_locales
|
24
|
+
I18n.available_locales.collect do |locale|
|
25
|
+
locale_date_options = date_options(locale)
|
26
|
+
if locale_date_options
|
27
|
+
"$.datepicker.regional['#{locale}'] = #{locale_date_options.to_json};"
|
28
|
+
else
|
29
|
+
nil
|
30
|
+
end
|
31
|
+
end.compact.join('')
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.date_options(locale)
|
35
|
+
begin
|
36
|
+
date_options = I18n.translate! 'date', :locale => locale
|
37
|
+
date_picker_options = { :closeText => as_(:close),
|
38
|
+
:prevText => as_(:previous),
|
39
|
+
:nextText => as_(:next),
|
40
|
+
:currentText => as_(:today),
|
41
|
+
:monthNames => date_options[:month_names][1, (date_options[:month_names].length - 1)],
|
42
|
+
:monthNamesShort => date_options[:abbr_month_names][1, (date_options[:abbr_month_names].length - 1)],
|
43
|
+
:dayNames => date_options[:day_names],
|
44
|
+
:dayNamesShort => date_options[:abbr_day_names],
|
45
|
+
:dayNamesMin => date_options[:abbr_day_names],
|
46
|
+
:changeYear => true,
|
47
|
+
:changeMonth => true,
|
48
|
+
}
|
49
|
+
|
50
|
+
begin
|
51
|
+
as_date_picker_options = I18n.translate! 'active_scaffold.date_picker_options'
|
52
|
+
date_picker_options.merge!(as_date_picker_options) if as_date_picker_options.is_a? Hash
|
53
|
+
rescue
|
54
|
+
Rails.logger.warn "ActiveScaffold: Missing date picker localization for your locale: #{locale}"
|
55
|
+
end
|
56
|
+
|
57
|
+
js_format = self.to_datepicker_format(date_options[:formats][:default])
|
58
|
+
date_picker_options[:dateFormat] = js_format unless js_format.nil?
|
59
|
+
date_picker_options
|
60
|
+
rescue
|
61
|
+
raise if locale == I18n.locale
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def self.datetime_options_for_locales
|
66
|
+
I18n.available_locales.collect do |locale|
|
67
|
+
locale_datetime_options = datetime_options(locale)
|
68
|
+
if locale_datetime_options
|
69
|
+
"$.timepicker.regional['#{locale}'] = #{locale_datetime_options.to_json};"
|
70
|
+
else
|
71
|
+
nil
|
72
|
+
end
|
73
|
+
end.compact.join('')
|
74
|
+
end
|
75
|
+
|
76
|
+
def self.datetime_options(locale)
|
77
|
+
begin
|
78
|
+
rails_time_format = I18n.translate! 'time.formats.picker', :locale => locale
|
79
|
+
datetime_options = I18n.translate! 'datetime.prompts', :locale => locale
|
80
|
+
datetime_picker_options = {:ampm => false,
|
81
|
+
:hourText => datetime_options[:hour],
|
82
|
+
:minuteText => datetime_options[:minute],
|
83
|
+
:secondText => datetime_options[:second],
|
84
|
+
}
|
85
|
+
|
86
|
+
begin
|
87
|
+
as_datetime_picker_options = I18n.translate! 'active_scaffold.datetime_picker_options'
|
88
|
+
datetime_picker_options.merge!(as_datetime_picker_options) if as_datetime_picker_options.is_a? Hash
|
89
|
+
rescue
|
90
|
+
Rails.logger.warn "ActiveScaffold: Missing datetime picker localization for your locale: #{locale}"
|
91
|
+
end
|
92
|
+
|
93
|
+
date_format, time_format = self.split_datetime_format(self.to_datepicker_format(rails_time_format))
|
94
|
+
datetime_picker_options[:dateFormat] = date_format unless date_format.nil?
|
95
|
+
unless time_format.nil?
|
96
|
+
datetime_picker_options[:timeFormat] = time_format
|
97
|
+
datetime_picker_options[:ampm] = true if rails_time_format.include?('%I')
|
98
|
+
end
|
99
|
+
datetime_picker_options
|
100
|
+
rescue
|
101
|
+
raise if locale == I18n.locale
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
def self.to_datepicker_format(rails_format)
|
106
|
+
return nil if rails_format.nil?
|
107
|
+
if rails_format =~ /%[cUWwxXZz]/
|
108
|
+
Rails.logger.warn("AS DatePicker::Helper: rails date format #{rails_format} includes options which can't be converted to jquery datepicker format. Options %c, %U, %W, %w, %x %X, %z, %Z are not supported by datepicker and will be removed")
|
109
|
+
nil
|
110
|
+
end
|
111
|
+
js_format = rails_format.dup
|
112
|
+
DATE_FORMAT_CONVERSION.each do |key, value|
|
113
|
+
js_format.gsub!(key, value)
|
114
|
+
end
|
115
|
+
js_format
|
116
|
+
end
|
117
|
+
|
118
|
+
def self.split_datetime_format(datetime_format)
|
119
|
+
date_format = datetime_format
|
120
|
+
time_format = nil
|
121
|
+
time_start_indicators = %w{hh mm tt ss}
|
122
|
+
unless datetime_format.nil?
|
123
|
+
start_indicator = time_start_indicators.detect {|indicator| datetime_format.include?(indicator)}
|
124
|
+
unless start_indicator.nil?
|
125
|
+
pos_time_format = datetime_format.index(start_indicator)
|
126
|
+
date_format = datetime_format.to(pos_time_format - 1)
|
127
|
+
time_format = datetime_format.from(pos_time_format)
|
128
|
+
end
|
129
|
+
end
|
130
|
+
return date_format, time_format
|
131
|
+
end
|
132
|
+
|
133
|
+
module DatepickerColumnHelpers
|
134
|
+
def datepicker_split_datetime_format(datetime_format)
|
135
|
+
ActiveScaffold::Bridges::DatePicker::Helper.split_datetime_format(datetime_format)
|
136
|
+
end
|
137
|
+
|
138
|
+
def to_datepicker_format(rails_format)
|
139
|
+
ActiveScaffold::Bridges::DatePicker::Helper.to_datepicker_format(rails_format)
|
140
|
+
end
|
141
|
+
|
142
|
+
def datepicker_format_options(column, format, options)
|
143
|
+
if column.form_ui == :date_picker
|
144
|
+
js_format = to_datepicker_format(I18n.translate!("date.formats.#{format}"))
|
145
|
+
options['date:dateFormat'] = js_format unless js_format.nil?
|
146
|
+
else
|
147
|
+
rails_time_format = I18n.translate!("time.formats.#{format}")
|
148
|
+
date_format, time_format = datepicker_split_datetime_format(self.to_datepicker_format(rails_time_format))
|
149
|
+
options['date:dateFormat'] = date_format unless date_format.nil?
|
150
|
+
unless time_format.nil?
|
151
|
+
options['time:timeFormat'] = time_format
|
152
|
+
options['time:ampm'] = true if rails_time_format.include?('%I')
|
153
|
+
end
|
154
|
+
end unless format == :default
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
module SearchColumnHelpers
|
159
|
+
def active_scaffold_search_date_bridge_calendar_control(column, options, current_search, name)
|
160
|
+
if current_search.is_a? Hash
|
161
|
+
value = controller.class.condition_value_for_datetime(current_search[name], column.form_ui == :date_picker ? :to_date : :to_time)
|
162
|
+
else
|
163
|
+
value = current_search
|
164
|
+
end
|
165
|
+
options = column.options.merge(options).except!(:include_blank, :discard_time, :discard_date, :value)
|
166
|
+
options = active_scaffold_input_text_options(options.merge(column.options))
|
167
|
+
options[:class] << " #{column.search_ui.to_s}"
|
168
|
+
options[:style] = "display:#{(options[:show].nil? || options[:show]) ? '' : 'none'}"
|
169
|
+
format = options.delete(:format) || :default
|
170
|
+
datepicker_format_options(column, format, options)
|
171
|
+
text_field_tag("#{options[:name]}[#{name}]", value ? l(value, :format => format) : nil, options.merge(:id => "#{options[:id]}_#{name}", :name => "#{options[:name]}[#{name}]"))
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
175
|
+
module FormColumnHelpers
|
176
|
+
def active_scaffold_input_date_picker(column, options)
|
177
|
+
options = active_scaffold_input_text_options(options.merge(column.options))
|
178
|
+
options[:class] << " #{column.form_ui.to_s}"
|
179
|
+
value = controller.class.condition_value_for_datetime(@record.send(column.name), column.form_ui == :date_picker ? :to_date : :to_time)
|
180
|
+
format = options.delete(:format) || :default
|
181
|
+
datepicker_format_options(column, format, options)
|
182
|
+
options[:value] = (value ? l(value, :format => format) : nil)
|
183
|
+
text_field(:record, column.name, options)
|
184
|
+
end
|
185
|
+
end
|
186
|
+
end
|
187
|
+
end
|
188
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
class ActiveScaffold::Bridges::Dragonfly < ActiveScaffold::DataStructures::Bridge
|
2
|
+
def self.install
|
3
|
+
require File.join(File.dirname(__FILE__), "dragonfly/form_ui")
|
4
|
+
require File.join(File.dirname(__FILE__), "dragonfly/list_ui")
|
5
|
+
require File.join(File.dirname(__FILE__), "dragonfly/dragonfly_bridge_helpers")
|
6
|
+
require File.join(File.dirname(__FILE__), "dragonfly/dragonfly_bridge")
|
7
|
+
ActiveScaffold::Config::Core.send :include, ActiveScaffold::Bridges::Dragonfly::DragonflyBridge
|
8
|
+
end
|
9
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module ActiveScaffold
|
2
|
+
module Bridges
|
3
|
+
class Dragonfly
|
4
|
+
module DragonflyBridge
|
5
|
+
def initialize_with_dragonfly(model_id)
|
6
|
+
initialize_without_dragonfly(model_id)
|
7
|
+
return unless self.model.respond_to?(:dragonfly_attachment_classes) && self.model.dragonfly_attachment_classes.present?
|
8
|
+
|
9
|
+
self.update.multipart = true
|
10
|
+
self.create.multipart = true
|
11
|
+
|
12
|
+
self.model.dragonfly_attachment_classes.each do |attachment|
|
13
|
+
configure_dragonfly_field(attachment.attribute)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.included(base)
|
18
|
+
base.alias_method_chain :initialize, :dragonfly
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
def configure_dragonfly_field(field)
|
23
|
+
self.columns << field
|
24
|
+
self.columns[field].form_ui ||= :dragonfly
|
25
|
+
self.columns[field].params.add "remove_#{field}"
|
26
|
+
|
27
|
+
[:name, :uid].each do |f|
|
28
|
+
self.columns.exclude("#{field}_#{f}".to_sym)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|