active_scaffold 3.0.12 → 3.0.21

Sign up to get free protection for your applications and to get access to all the features.
Files changed (142) hide show
  1. data/README +21 -11
  2. data/frontends/default/images/close_touch.png +0 -0
  3. data/frontends/default/javascripts/jquery/active_scaffold.js +187 -99
  4. data/frontends/default/javascripts/prototype/active_scaffold.js +105 -33
  5. data/frontends/default/javascripts/prototype/dhtml_history.js +80 -77
  6. data/frontends/default/stylesheets/stylesheet.css +121 -2
  7. data/frontends/default/views/_action_group.html.erb +6 -2
  8. data/frontends/default/views/_base_form.html.erb +11 -5
  9. data/frontends/default/views/_base_form.html.erb~ +42 -0
  10. data/frontends/default/views/_field_search.html.erb +1 -1
  11. data/frontends/default/views/_form.html.erb +9 -7
  12. data/frontends/default/views/_form_association.html.erb +8 -3
  13. data/frontends/default/views/_form_association_footer.html.erb +10 -3
  14. data/frontends/default/views/_form_attribute.html.erb +8 -3
  15. data/frontends/default/views/_horizontal_subform.html.erb +12 -2
  16. data/frontends/default/views/_horizontal_subform_header.html.erb +1 -1
  17. data/frontends/default/views/_horizontal_subform_record.html.erb +5 -4
  18. data/frontends/default/views/_list_messages.html.erb +1 -1
  19. data/frontends/default/views/_list_with_header.html.erb +1 -1
  20. data/frontends/default/views/_render_field.js.rjs +4 -6
  21. data/frontends/default/views/_vertical_subform.html.erb +1 -1
  22. data/frontends/default/views/_vertical_subform_record.html.erb +2 -2
  23. data/frontends/default/views/on_action_update.js.rjs +3 -1
  24. data/frontends/default/views/on_mark_all.js.rjs +12 -0
  25. data/frontends/default/views/on_update.js.rjs +1 -1
  26. data/frontends/default/views/render_field.js.rjs +1 -0
  27. data/frontends/default/views/update_column.js.rjs +1 -1
  28. data/lib/active_scaffold.rb +60 -21
  29. data/lib/active_scaffold/actions/common_search.rb +2 -2
  30. data/lib/active_scaffold/actions/core.rb +30 -9
  31. data/lib/active_scaffold/actions/create.rb +14 -10
  32. data/lib/active_scaffold/actions/field_search.rb +6 -6
  33. data/lib/active_scaffold/actions/list.rb +22 -12
  34. data/lib/active_scaffold/actions/mark.rb +34 -9
  35. data/lib/active_scaffold/actions/nested.rb +12 -16
  36. data/lib/active_scaffold/actions/show.rb +2 -2
  37. data/lib/active_scaffold/actions/subform.rb +15 -8
  38. data/lib/active_scaffold/actions/update.rb +14 -4
  39. data/lib/active_scaffold/attribute_params.rb +15 -10
  40. data/lib/active_scaffold/bridges/bridge.rb +21 -12
  41. data/lib/active_scaffold/bridges/calendar_date_select/bridge.rb +3 -3
  42. data/lib/active_scaffold/bridges/cancan/bridge.rb +12 -0
  43. data/lib/active_scaffold/bridges/cancan/lib/cancan_bridge.rb +107 -0
  44. data/lib/active_scaffold/bridges/carrierwave/bridge.rb +1 -1
  45. data/lib/active_scaffold/bridges/carrierwave/lib/carrierwave_bridge.rb +3 -8
  46. data/lib/active_scaffold/bridges/carrierwave/lib/carrierwave_bridge_helpers.rb +1 -15
  47. data/lib/active_scaffold/bridges/carrierwave/lib/form_ui.rb +23 -13
  48. data/lib/active_scaffold/bridges/carrierwave/lib/list_ui.rb +1 -1
  49. data/lib/active_scaffold/bridges/country_helper/bridge.rb +9 -0
  50. data/lib/active_scaffold/bridges/country_helper/lib/country_helper_bridge.rb +358 -0
  51. data/lib/active_scaffold/bridges/date_picker/bridge.rb +5 -3
  52. data/lib/active_scaffold/bridges/date_picker/lib/datepicker_bridge.rb +9 -0
  53. data/lib/active_scaffold/bridges/dragonfly/bridge.rb +9 -0
  54. data/lib/active_scaffold/bridges/dragonfly/bridge.rb~ +12 -0
  55. data/lib/active_scaffold/bridges/dragonfly/lib/dragonfly_bridge.rb +36 -0
  56. data/lib/active_scaffold/bridges/dragonfly/lib/dragonfly_bridge.rb~ +36 -0
  57. data/lib/active_scaffold/bridges/dragonfly/lib/dragonfly_bridge_helpers.rb +12 -0
  58. data/lib/active_scaffold/bridges/dragonfly/lib/dragonfly_bridge_helpers.rb~ +12 -0
  59. data/lib/active_scaffold/bridges/dragonfly/lib/form_ui.rb +27 -0
  60. data/lib/active_scaffold/bridges/dragonfly/lib/form_ui.rb~ +27 -0
  61. data/lib/active_scaffold/bridges/dragonfly/lib/list_ui.rb +16 -0
  62. data/lib/active_scaffold/bridges/dragonfly/lib/list_ui.rb~ +16 -0
  63. data/lib/active_scaffold/bridges/paperclip/bridge.rb +1 -1
  64. data/lib/active_scaffold/bridges/record_select/bridge.rb +5 -0
  65. data/lib/active_scaffold/bridges/record_select/lib/record_select_bridge.rb +87 -0
  66. data/lib/active_scaffold/bridges/record_select/lib/record_select_bridge.rb~ +84 -0
  67. data/lib/active_scaffold/bridges/shared/date_bridge.rb +56 -34
  68. data/lib/active_scaffold/bridges/tiny_mce/lib/tiny_mce_bridge.rb +19 -3
  69. data/lib/active_scaffold/config/base.rb +4 -4
  70. data/lib/active_scaffold/config/core.rb +4 -0
  71. data/lib/active_scaffold/config/create.rb +1 -1
  72. data/lib/active_scaffold/config/field_search.rb +7 -7
  73. data/lib/active_scaffold/config/form.rb +8 -2
  74. data/lib/active_scaffold/config/list.rb +22 -8
  75. data/lib/active_scaffold/config/mark.rb +18 -5
  76. data/lib/active_scaffold/config/nested.rb +3 -3
  77. data/lib/active_scaffold/config/search.rb +1 -1
  78. data/lib/active_scaffold/config/show.rb +1 -1
  79. data/lib/active_scaffold/data_structures/action_columns.rb +10 -6
  80. data/lib/active_scaffold/data_structures/action_link.rb +14 -10
  81. data/lib/active_scaffold/data_structures/action_links.rb +2 -2
  82. data/lib/active_scaffold/data_structures/column.rb +25 -11
  83. data/lib/active_scaffold/data_structures/nested_info.rb +21 -21
  84. data/lib/active_scaffold/data_structures/set.rb +2 -3
  85. data/lib/active_scaffold/data_structures/sorting.rb +8 -8
  86. data/lib/{extensions → active_scaffold/extensions}/action_controller_rendering.rb +3 -1
  87. data/lib/{extensions → active_scaffold/extensions}/action_view_rendering.rb +31 -33
  88. data/lib/{extensions → active_scaffold/extensions}/action_view_resolver.rb +0 -0
  89. data/lib/{extensions → active_scaffold/extensions}/active_association_reflection.rb +0 -0
  90. data/lib/active_scaffold/extensions/active_record_offset.rb +12 -0
  91. data/lib/{extensions → active_scaffold/extensions}/array.rb +0 -0
  92. data/lib/{extensions → active_scaffold/extensions}/localize.rb +1 -1
  93. data/lib/{extensions → active_scaffold/extensions}/name_option_for_datetime.rb +1 -1
  94. data/lib/{extensions → active_scaffold/extensions}/nil_id_in_url_params.rb +0 -0
  95. data/lib/{extensions → active_scaffold/extensions}/paginator_extensions.rb +2 -2
  96. data/lib/{extensions → active_scaffold/extensions}/reverse_associations.rb +1 -1
  97. data/lib/{extensions → active_scaffold/extensions}/routing_mapper.rb +2 -2
  98. data/lib/{extensions → active_scaffold/extensions}/to_label.rb +0 -0
  99. data/lib/{extensions → active_scaffold/extensions}/unsaved_associated.rb +0 -0
  100. data/lib/{extensions → active_scaffold/extensions}/unsaved_record.rb +0 -0
  101. data/lib/active_scaffold/extensions/usa_state.rb +46 -0
  102. data/lib/active_scaffold/finder.rb +30 -19
  103. data/lib/active_scaffold/helpers/controller_helpers.rb +3 -5
  104. data/lib/active_scaffold/helpers/form_column_helpers.rb +19 -45
  105. data/lib/active_scaffold/helpers/human_condition_helpers.rb +1 -1
  106. data/lib/active_scaffold/helpers/id_helpers.rb +2 -2
  107. data/lib/active_scaffold/helpers/list_column_helpers.rb +28 -17
  108. data/lib/active_scaffold/helpers/search_column_helpers.rb +51 -40
  109. data/lib/active_scaffold/helpers/search_column_helpers.rb~ +215 -0
  110. data/lib/active_scaffold/helpers/show_column_helpers.rb +8 -4
  111. data/lib/active_scaffold/helpers/view_helpers.rb +50 -27
  112. data/lib/active_scaffold/locale/de.yml +111 -0
  113. data/lib/active_scaffold/locale/en.yml +115 -0
  114. data/lib/active_scaffold/locale/es.yml +32 -32
  115. data/lib/active_scaffold/locale/fr.yml +118 -0
  116. data/lib/active_scaffold/marked_model.rb +6 -6
  117. data/lib/active_scaffold/version.rb +1 -1
  118. data/lib/active_scaffold_assets.rb +1 -3
  119. data/lib/active_scaffold_env.rb +1 -2
  120. data/lib/generators/active_scaffold/active_scaffold_generator.rb +5 -5
  121. data/lib/generators/active_scaffold_controller/active_scaffold_controller_generator.rb +3 -2
  122. data/lib/generators/active_scaffold_controller/templates/helper.rb +2 -0
  123. data/lib/generators/active_scaffold_setup/active_scaffold_setup_generator.rb +17 -19
  124. data/shoulda_macros/macros.rb +4 -4
  125. data/test/misc/finder_test.rb +2 -2
  126. data/test/mock_app/public/stylesheets/active_scaffold/default/stylesheet.css +4 -1
  127. metadata +144 -126
  128. data/.autotest +0 -27
  129. data/.document +0 -5
  130. data/Gemfile +0 -13
  131. data/Gemfile.lock +0 -20
  132. data/Rakefile +0 -53
  133. data/active_scaffold.gemspec +0 -385
  134. data/init.rb +0 -2
  135. data/lib/active_scaffold/helpers/country_helpers.rb +0 -358
  136. data/lib/active_scaffold/locale/de.rb +0 -120
  137. data/lib/active_scaffold/locale/en.rb +0 -119
  138. data/lib/active_scaffold/locale/fr.rb +0 -116
  139. data/lib/extensions/active_record_offset.rb +0 -12
  140. data/lib/extensions/usa_state.rb +0 -50
  141. data/test/mock_app/.gitignore +0 -2
  142. data/uninstall.rb +0 -13
@@ -8,8 +8,8 @@ es:
8
8
  click_to_edit: 'Pulsa para editar'
9
9
  click_to_reset: 'Pulsa para restaurar'
10
10
  close: 'Cerrar'
11
- config_list: 'Configure'
12
- config_list_model: 'Configure Columns for %{model}'
11
+ config_list: 'Configurar'
12
+ config_list_model: 'Configurar columnas de %{model}'
13
13
  create: 'Crear'
14
14
  create_model: 'Crear %{model}'
15
15
  create_another: 'Crear Otro %{model}'
@@ -31,7 +31,7 @@ es:
31
31
  live_search: 'Buscar en Vivo'
32
32
  loading: 'Cargando…'
33
33
  nested_for_model: '%{nested_model} de %{parent_model}'
34
- nested_of_model: '%{nested_model} of %{parent_model}'
34
+ nested_of_model: '%{nested_model} de %{parent_model}'
35
35
  next: 'Siguiente'
36
36
  no_entries: 'Sin entradas'
37
37
  no_options: 'sin opciones'
@@ -67,31 +67,31 @@ es:
67
67
  contains: 'Contiene'
68
68
  begins_with: 'Empieza con'
69
69
  ends_with: 'Termina con'
70
- today: 'Today'
71
- yesterday: 'Yesterday'
72
- tomorrow: 'Tommorrow'
73
- this_week: 'This Week'
74
- prev_week: 'Last Week'
75
- next_week: 'Next Week'
76
- this_month: 'This Month'
77
- prev_month: 'Last Month'
78
- next_month: 'Next Month'
79
- this_year: 'This Year'
80
- prev_year: 'Last Year'
81
- next_year: 'Next Year'
82
- past: 'Past'
83
- future: 'Future'
84
- range: 'Range'
85
- seconds: 'Seconds'
86
- minutes: 'Minutes'
87
- hours: 'Hours'
88
- days: 'Days'
89
- weeks: 'Weeks'
90
- months: 'Months'
91
- years: 'Years'
92
- optional_attributes: 'Further Options'
93
- null: 'Null'
94
- not_null: 'Not Null'
70
+ today: 'Hoy'
71
+ yesterday: 'Ayer'
72
+ tomorrow: 'Mañana'
73
+ this_week: 'Esta semana'
74
+ prev_week: 'Semana pasada'
75
+ next_week: 'Próxima semana'
76
+ this_month: 'Este mes'
77
+ prev_month: 'Mes pasado'
78
+ next_month: 'Próximo mes'
79
+ this_year: 'Este año'
80
+ prev_year: 'Año pasado'
81
+ next_year: 'Próximo año'
82
+ past: 'Pasado'
83
+ future: 'Futuro'
84
+ range: 'Rango'
85
+ seconds: 'Segundos'
86
+ minutes: 'Minutos'
87
+ hours: 'Horas'
88
+ days: 'Días'
89
+ weeks: 'Semanas'
90
+ months: 'Meses'
91
+ years: 'Años'
92
+ optional_attributes: 'Más opciones'
93
+ null: 'Nulo'
94
+ not_null: 'No Nulo'
95
95
  date_picker_options:
96
96
  weekHeader: 'Sm'
97
97
  firstDay: 1
@@ -104,12 +104,12 @@ es:
104
104
  errors:
105
105
  template:
106
106
  header:
107
- one: "1 error prohibited this %{model} from being saved."
108
- other: "%{count} errors prohibited this %{model} from being saved"
109
- body: "There were problems with the following fields:"
107
+ one: "No se pudo guardar debido a un error."
108
+ other: "No se pudo guardar debido a %{count} errores."
109
+ body: "Hubo problemas con los siguientes campos:"
110
110
 
111
111
  # error_messages
112
112
  cant_destroy_record: "No se pudo borrar %{record}"
113
113
  internal_error: 'Petición fallida (código 500, error interno)'
114
114
  version_inconsistency: 'Inconsistencia de versiones - este registro se ha modificado después de que empezó a editarlo.'
115
- no_authorization_for_action: "No Authorization for action %{action}"
115
+ no_authorization_for_action: "No dispone de autorización para la acción %{action}"
@@ -0,0 +1,118 @@
1
+ fr:
2
+ active_scaffold:
3
+ add: 'Ajouter'
4
+ add_existing: 'Ajouter un(e) existant(e)'
5
+ add_existing_model: 'Ajouter un(e) %{model} existant(e)'
6
+ are_you_sure_to_delete: 'Êtes vous sûr?'
7
+ cancel: 'Annuler'
8
+ click_to_edit: 'Cliquer pour éditer'
9
+ click_to_reset: 'Cliquer pour ré-initialiser'
10
+ close: 'Fermer'
11
+ config_list: 'Configure'
12
+ config_list_model: 'Configure Columns for %{model}'
13
+ create: 'Créer'
14
+ create_model: 'Créer %{model}'
15
+ create_another: 'Créer un autre'
16
+ created_model: '%{model} créé'
17
+ create_new: 'Créer un nouveau'
18
+ customize: 'Personnaliser'
19
+ delete: 'Supprimer'
20
+ deleted_model: 'Suppression de %{model}'
21
+ delimiter: 'Délimiteur'
22
+ download: 'Télécharger'
23
+ edit: 'Éditer'
24
+ export: 'Exporter'
25
+ nested_for_model: '%{nested_model} pour %{parent_model}'
26
+ nested_of_model: '%{nested_model} de %{parent_model}'
27
+ 'false': 'Faux'
28
+ filtered: '(Filtré)'
29
+ found: 'Trouvé'
30
+ hide: 'Cacher'
31
+ live_search: 'Recherche en temps réel'
32
+ loading: 'Chargement…'
33
+ next: 'Suivant'
34
+ no_entries: "Pas d'entrée"
35
+ no_options: "pas d'option"
36
+ omit_header: 'Omettre les en-têtes'
37
+ options: 'Options'
38
+ pdf: 'PDF'
39
+ previous: 'Précédent'
40
+ print: 'Imprimer'
41
+ refresh: 'Rafraîchir'
42
+ remove: 'Supprimer'
43
+ remove_file: 'Supprimer et remplacer le fichier'
44
+ replace_with_new: 'Remplacer avec le nouveau'
45
+ revisions_for_model: 'Révision pour %{model}'
46
+ reset: 'Annuler'
47
+ saving: 'Sauvegarder…'
48
+ search: 'Rechercher'
49
+ search_terms: 'Recherche de termes'
50
+ _select_: '- sélectionner -'
51
+ show: 'Montrer'
52
+ show_model: 'Montrer %{model}'
53
+ _to_ : ' à '
54
+ 'true': 'Vrai'
55
+ update: 'Mettre à jour'
56
+ update_model: 'Mettre à jour le(/la) %{model}'
57
+ updated_model: 'Mis à jour de %{model}'
58
+ '=': '='
59
+ '>=': '>='
60
+ '<=': '<='
61
+ '>': '>'
62
+ '<': '<'
63
+ '!=': '!='
64
+ between: 'Entre'
65
+ contains: 'Contient'
66
+ begins_with: 'Commençant par'
67
+ ends_with: 'Se terminant par'
68
+ today: "Aujourd'hui"
69
+ yesterday: 'Hier'
70
+ tomorrow: 'Demain'
71
+ this_week: 'Cette Semaine'
72
+ prev_week: 'Semaine dernière'
73
+ next_week: 'Semaine prochaine'
74
+ this_month: 'Ce Mois'
75
+ prev_month: 'Mois dernier'
76
+ next_month: 'Mois prochain'
77
+ this_year: 'Cette Année'
78
+ prev_year: 'Année dernière'
79
+ next_year: 'Année prochaine'
80
+ past: 'Passé'
81
+ future: 'Futur'
82
+ range: 'Intervale'
83
+ seconds: 'Secondes'
84
+ minutes: 'Minutes'
85
+ hours: 'Heures'
86
+ days: 'Jours'
87
+ weeks: 'Semaines'
88
+ months: 'Mois'
89
+ years: 'Années'
90
+ optional_attributes: 'Options additionnelles'
91
+ null: 'Nulle'
92
+ not_null: 'Non Nulle'
93
+ date_picker_options:
94
+ weekHeader: 'Sm'
95
+ firstDay: 1
96
+ isRTL: false
97
+ showMonthAfterYear: false
98
+
99
+ datetime_picker_options:
100
+ timeText: 'Heure'
101
+ currentText: 'Maintenant'
102
+ closeText: 'Fermer'
103
+
104
+ errors:
105
+ template:
106
+ header:
107
+ one: "1 erreur interdit ce(tte) %{model} d'être sauvegardé."
108
+ other: "%{count} erreurs interdit ce(tte) %{model} d'être sauvegardé"
109
+
110
+ body: "Il y avait des problèmes avec les champs suivants :"
111
+
112
+
113
+ # error_messages
114
+ cant_destroy_record: "%{record} ne peut être supprimé"
115
+ internal_error: 'Erreur de la requête (code 500, Erreur interne)'
116
+ version_inconsistency: "Version incomplète - Cet enregistrement a été modifié depuis que vous avez commencé à l'éditer."
117
+ record_not_saved: "Impossible d'enregistrer l'enregistrement à cause d'une erreur inconnue"
118
+ no_authorization_for_action: "Aucune autorisation pour l'action %{action}"
@@ -1,16 +1,16 @@
1
1
  module ActiveScaffold
2
2
  module MarkedModel
3
3
  # This is a module aimed at making the make session_stored marked_records available to ActiveRecord models
4
-
4
+
5
5
  def self.included(base)
6
6
  base.extend ClassMethods
7
7
  base.scope :marked, lambda {{:conditions => {:id => base.marked_records.to_a}}}
8
8
  end
9
-
9
+
10
10
  def marked
11
11
  marked_records.include?(self.id)
12
12
  end
13
-
13
+
14
14
  def marked=(value)
15
15
  value = [true, 'true', 1, '1', 'T', 't'].include?(value.class == String ? value.downcase : value)
16
16
  if value == true
@@ -19,17 +19,17 @@ module ActiveScaffold
19
19
  marked_records.delete(self.id)
20
20
  end
21
21
  end
22
-
22
+
23
23
  module ClassMethods
24
24
  def marked_records
25
25
  Thread.current[:marked_records] ||= Set.new
26
26
  end
27
27
 
28
28
  def marked_records=(marked)
29
- Thread.current[:marked_records] = marked
29
+ Thread.current[:marked_records] = marked
30
30
  end
31
31
  end
32
-
32
+
33
33
  # Instance-level access to the marked_records
34
34
  def marked_records
35
35
  self.class.marked_records
@@ -2,7 +2,7 @@ module ActiveScaffold
2
2
  module Version
3
3
  MAJOR = 3
4
4
  MINOR = 0
5
- PATCH = 12
5
+ PATCH = 21
6
6
 
7
7
  STRING = [MAJOR, MINOR, PATCH].compact.join('.')
8
8
  end
@@ -8,8 +8,6 @@ class ActiveScaffoldAssets
8
8
  copy_asset_type(from, available_frontends, asset_type, options)
9
9
  end
10
10
  end
11
- rescue
12
- raise $! unless Rails.env == 'production'
13
11
  end
14
12
 
15
13
  protected
@@ -44,4 +42,4 @@ protected
44
42
  FileUtils.rm Dir.glob("#{destination}/*") if options[:clean_up_destination]
45
43
  FileUtils.cp_r(Dir.glob("#{source}/#{file_mask}"), destination)
46
44
  end
47
- end
45
+ end
@@ -1,5 +1,5 @@
1
1
  # TODO: clean up extensions. some could be organized for autoloading, and others could be removed entirely.
2
- Dir["#{File.dirname __FILE__}/extensions/*.rb"].each { |file| require file }
2
+ Dir["#{File.dirname __FILE__}/active_scaffold/extensions/*.rb"].each { |file| require file }
3
3
 
4
4
  ActionController::Base.send(:include, ActiveScaffold)
5
5
  ActionController::Base.send(:include, RespondsToParent)
@@ -11,4 +11,3 @@ ActiveRecord::Base.class_eval {include ActiveRecordPermissions::ModelUserAcc
11
11
  ActiveRecord::Base.class_eval {include ActiveRecordPermissions::Permissions}
12
12
 
13
13
  I18n.load_path += Dir[File.join(File.dirname(__FILE__), 'active_scaffold', 'locale', '*.{rb,yml}')]
14
- #ActiveScaffold.js_framework = :jquery
@@ -6,14 +6,14 @@ module Rails
6
6
  class ActiveScaffoldGenerator < ResourceGenerator #metagenerator
7
7
  remove_hook_for :resource_controller
8
8
  remove_class_option :actions
9
-
9
+
10
10
  def add_resource_route
11
- route_config = class_path.collect{|namespace| "namespace :#{namespace} do " }.join(" ")
11
+ route_config = class_path.collect{|namespace| "namespace :#{namespace} do " }.join(" ")
12
12
  route_config << "resources :#{file_name.pluralize} do as_routes end"
13
- route_config << " end" * class_path.size
13
+ route_config << " end" * class_path.size
14
14
  route route_config
15
- end
16
-
15
+ end
16
+
17
17
  invoke "active_scaffold_controller"
18
18
  end
19
19
  end
@@ -16,13 +16,14 @@ module Rails
16
16
 
17
17
  def create_controller_files
18
18
  template 'controller.rb', File.join('app/controllers', class_path, "#{controller_file_name}_controller.rb")
19
+ template 'helper.rb', File.join('app/helpers', class_path, "#{controller_file_name}_helper.rb")
19
20
  end
20
21
 
21
22
  hook_for :test_framework, :as => :scaffold
22
23
 
23
24
  def create_view_root_folder
24
25
  empty_directory File.join("app/views", controller_file_path)
25
- end
26
+ end
26
27
  end
27
28
  end
28
- end
29
+ end
@@ -0,0 +1,2 @@
1
+ module <%= controller_class_name %>Helper
2
+ end
@@ -1,8 +1,8 @@
1
1
  module Rails
2
2
  module Generators
3
3
  class ActiveScaffoldSetupGenerator < Rails::Generators::Base #metagenerator
4
- argument :js_lib, :type => :string, :default => 'prototype', :desc => 'js_lib for activescaffold (prototype|jquery)'
5
-
4
+ argument :js_lib, :type => :string, :default => 'prototype', :desc => 'js_lib for activescaffold (prototype|jquery)'
5
+
6
6
  def self.source_root
7
7
  @source_root ||= File.join(File.dirname(__FILE__), 'templates')
8
8
  end
@@ -19,43 +19,41 @@ module Rails
19
19
  get "https://github.com/vhochstein/jQuery-Timepicker-Addon/raw/master/jquery-ui-timepicker-addon.js", "public/javascripts/jquery-ui-timepicker-addon.js"
20
20
  end
21
21
  end
22
-
22
+
23
23
  def configure_active_scaffold
24
+ return unless js_lib == 'jquery'
24
25
  if defined?(ACTIVE_SCAFFOLD_PLUGIN)
25
- if js_lib == 'jquery'
26
- gsub_file 'vendor/plugins/active_scaffold/lib/active_scaffold_env.rb', /#ActiveScaffold.js_framework = :jquery/, 'ActiveScaffold.js_framework = :jquery'
27
- end
26
+ content = "ActiveSupport.on_load(:active_scaffold) { self.js_framework = :jquery }"
28
27
  else
29
- if js_lib == 'jquery'
30
- create_file "config/initializers/active_scaffold.rb", "ActiveScaffold.js_framework = :jquery"
31
- end
28
+ content = "ActiveScaffold.js_framework = :jquery"
32
29
  end
30
+ create_file "config/initializers/active_scaffold.rb", content
33
31
  end
34
-
32
+
35
33
  def configure_application_layout
36
34
  if js_lib == 'prototype'
37
- inject_into_file "app/views/layouts/application.html.erb",
35
+ inject_into_file "app/views/layouts/application.html.erb",
38
36
  " <%= active_scaffold_includes %>\n",
39
37
  :after => "<%= javascript_include_tag :defaults %>\n"
40
38
  elsif js_lib == 'jquery'
41
- inject_into_file "app/views/layouts/application.html.erb",
42
- " <%= stylesheet_link_tag 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.4/themes/ui-lightness/jquery-ui.css' %>
43
- <%= javascript_include_tag 'http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.js' %>
39
+ inject_into_file "app/views/layouts/application.html.erb",
40
+ " <%= stylesheet_link_tag 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.9/themes/ui-lightness/jquery-ui.css' %>
41
+ <%= javascript_include_tag 'http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.js' %>
44
42
  <%= javascript_include_tag 'rails_jquery.js' %>
45
- <%= javascript_include_tag 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.4/jquery-ui.js' %>
43
+ <%= javascript_include_tag 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.9/jquery-ui.js' %>
46
44
  <%= javascript_include_tag 'jquery-ui-timepicker-addon.js' %>
47
45
  <%= javascript_include_tag 'application.js' %>
48
46
  <%= active_scaffold_includes %>\n",
49
47
  :after => "<%= javascript_include_tag :defaults %>\n"
50
-
48
+
51
49
  inject_into_file "config/locales/en.yml",
52
50
  " time:
53
51
  formats:
54
- default: \"%a, %d %b %Y %H:%M:%S\"",
52
+ default: \"%a, %d %b %Y %H:%M:%S\"",
55
53
  :after => "hello: \"Hello world\"\n"
56
54
  gsub_file 'app/views/layouts/application.html.erb', /<%= javascript_include_tag :defaults/, '<%# javascript_include_tag :defaults'
57
55
  end
58
- end
56
+ end
59
57
  end
60
58
  end
61
- end
59
+ end
@@ -26,7 +26,7 @@ class ActiveSupport::TestCase
26
26
  def self.should_render_as_form_ui(column_name, form_ui)
27
27
  should "render column #{column_name} as #{form_ui} form_ui", :before => lambda{
28
28
  @rendered_columns = []
29
- ActionView::Base.any_instance.expects(:"active_scaffold_input_#{form_ui}").at_least_once.with {|column, options|
29
+ @controller.view_context_class.any_instance.expects(:"active_scaffold_input_#{form_ui}").at_least_once.with {|column, options|
30
30
  @rendered_columns << column.name
31
31
  true
32
32
  }
@@ -60,7 +60,7 @@ class ActiveSupport::TestCase
60
60
  def self.should_render_as_form_hidden(column_name)
61
61
  should "render column #{column_name} as form hidden", :before => lambda{
62
62
  @rendered_columns = []
63
- ActionView::Base.any_instance.expects(:"hidden_field").at_least_once.with {|object, method, options|
63
+ @controller.view_context_class.any_instance.expects(:"hidden_field").at_least_once.with {|object, method, options|
64
64
  @rendered_columns << method
65
65
  true
66
66
  }
@@ -73,7 +73,7 @@ class ActiveSupport::TestCase
73
73
  def self.should_render_as_list_ui(column_name, list_ui)
74
74
  should "render column #{column_name} as #{list_ui} list_ui", :before => lambda{
75
75
  @rendered_columns = []
76
- ActionView::Base.any_instance.expects(:"active_scaffold_column_#{list_ui}").at_least_once.with {|column, options|
76
+ @controller.view_context_class.any_instance.expects(:"active_scaffold_column_#{list_ui}").at_least_once.with {|column, options|
77
77
  @rendered_columns << column.name
78
78
  true
79
79
  }
@@ -102,7 +102,7 @@ class ActiveSupport::TestCase
102
102
  @column = @controller.active_scaffold_config.columns[column_name]
103
103
  @rendered_columns = []
104
104
  method = @column.list_ui == :checkbox ? :format_column_checkbox : :active_scaffold_inplace_edit
105
- ActionView::Base.any_instance.expects(method).at_least_once.with {|model, column, options|
105
+ @controller.view_context_class.any_instance.expects(method).at_least_once.with {|model, column, options|
106
106
  @rendered_columns << column.name
107
107
  true
108
108
  }
@@ -33,13 +33,13 @@ class FinderTest < Test::Unit::TestCase
33
33
  ]
34
34
 
35
35
  expected_conditions = [
36
- '(LOWER("model_stubs"."a") LIKE ? OR LOWER("model_stubs"."b") LIKE ?) AND (LOWER("model_stubs"."a") LIKE ? OR LOWER("model_stubs"."b") LIKE ?)',
36
+ '("model_stubs"."a" LIKE ? OR "model_stubs"."b" LIKE ?) AND ("model_stubs"."a" LIKE ? OR "model_stubs"."b" LIKE ?)',
37
37
  '%foo%', '%foo%', '%bar%', '%bar%'
38
38
  ]
39
39
  assert_equal expected_conditions, ClassWithFinder.create_conditions_for_columns(tokens, columns)
40
40
 
41
41
  expected_conditions = [
42
- '(LOWER("model_stubs"."a") LIKE ? OR LOWER("model_stubs"."b") LIKE ?)',
42
+ '("model_stubs"."a" LIKE ? OR "model_stubs"."b" LIKE ?)',
43
43
  '%foo%', '%foo%'
44
44
  ]
45
45
  assert_equal expected_conditions, ClassWithFinder.create_conditions_for_columns('foo', columns)