active_scaffold 3.0.5 → 3.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.document +5 -0
- data/Gemfile +11 -2
- data/Gemfile.lock +20 -0
- data/Rakefile +33 -4
- data/active_scaffold.gemspec +378 -17
- data/frontends/default/images/config.png +0 -0
- data/frontends/default/images/gears.png +0 -0
- data/frontends/default/javascripts/jquery/active_scaffold.js +34 -33
- data/frontends/default/javascripts/jquery/jquery.editinplace.js +21 -4
- data/frontends/default/javascripts/prototype/active_scaffold.js +43 -38
- data/frontends/default/stylesheets/stylesheet.css +110 -35
- data/frontends/default/views/_action_group.html.erb +20 -0
- data/frontends/default/views/_base_form.html.erb +7 -3
- data/frontends/default/views/_create_form.html.erb +5 -3
- data/frontends/default/views/_create_form_on_list.html.erb +2 -1
- data/frontends/default/views/_field_search.html.erb +2 -2
- data/frontends/default/views/_form.html.erb +2 -2
- data/frontends/default/views/_form_messages.html.erb +1 -1
- data/frontends/default/views/_horizontal_subform.html.erb +1 -1
- data/frontends/default/views/_list_actions.html.erb +6 -14
- data/frontends/default/views/_list_header.html.erb +4 -6
- data/frontends/default/views/_list_with_header.html.erb +2 -2
- data/frontends/default/views/_messages.html.erb +2 -2
- data/frontends/default/views/_search.html.erb +2 -2
- data/frontends/default/views/_show.html.erb +1 -1
- data/frontends/default/views/_update_form.html.erb +2 -1
- data/frontends/default/views/_vertical_subform.html.erb +1 -1
- data/frontends/default/views/action_confirmation.html.erb +13 -0
- data/frontends/default/views/add_existing.js.rjs +1 -1
- data/frontends/default/views/destroy.js.rjs +21 -3
- data/frontends/default/views/on_action_update.js.rjs +1 -1
- data/frontends/default/views/on_create.js.rjs +30 -13
- data/frontends/default/views/on_update.js.rjs +19 -6
- data/init.rb +6 -0
- data/lib/active_scaffold/actions/core.rb +32 -12
- data/lib/active_scaffold/actions/create.rb +4 -11
- data/lib/active_scaffold/actions/delete.rb +16 -13
- data/lib/active_scaffold/actions/list.rb +58 -2
- data/lib/active_scaffold/actions/mark.rb +1 -1
- data/lib/active_scaffold/actions/nested.rb +24 -15
- data/lib/active_scaffold/actions/show.rb +10 -3
- data/lib/active_scaffold/actions/update.rb +10 -3
- data/lib/{active_record_permissions.rb → active_scaffold/active_record_permissions.rb} +0 -0
- data/lib/active_scaffold/bridges/ancestry/lib/ancestry_bridge.rb +9 -8
- data/lib/active_scaffold/bridges/bridge.rb +1 -1
- data/lib/active_scaffold/bridges/calendar_date_select/lib/as_cds_bridge.rb +8 -4
- data/lib/active_scaffold/bridges/carrierwave/bridge.rb +1 -1
- data/lib/active_scaffold/bridges/paperclip/bridge.rb +1 -1
- data/lib/active_scaffold/bridges/paperclip/lib/list_ui.rb +1 -1
- data/lib/active_scaffold/config/base.rb +8 -0
- data/lib/active_scaffold/config/core.rb +2 -15
- data/lib/active_scaffold/config/create.rb +8 -0
- data/lib/active_scaffold/config/delete.rb +10 -1
- data/lib/active_scaffold/config/field_search.rb +1 -0
- data/lib/active_scaffold/config/form.rb +2 -1
- data/lib/active_scaffold/config/nested.rb +3 -2
- data/lib/active_scaffold/config/search.rb +1 -0
- data/lib/active_scaffold/config/show.rb +1 -0
- data/lib/active_scaffold/config/update.rb +8 -0
- data/lib/active_scaffold/constraints.rb +9 -4
- data/lib/active_scaffold/data_structures/action_columns.rb +1 -1
- data/lib/active_scaffold/data_structures/action_link.rb +10 -1
- data/lib/active_scaffold/data_structures/action_links.rb +62 -22
- data/lib/active_scaffold/data_structures/column.rb +17 -13
- data/lib/active_scaffold/data_structures/nested_info.rb +21 -6
- data/lib/active_scaffold/finder.rb +2 -1
- data/lib/active_scaffold/helpers/association_helpers.rb +2 -2
- data/lib/active_scaffold/helpers/controller_helpers.rb +57 -10
- data/lib/active_scaffold/helpers/form_column_helpers.rb +12 -8
- data/lib/active_scaffold/helpers/id_helpers.rb +5 -9
- data/lib/active_scaffold/helpers/list_column_helpers.rb +26 -28
- data/lib/active_scaffold/helpers/search_column_helpers.rb +8 -3
- data/lib/active_scaffold/helpers/view_helpers.rb +60 -19
- data/lib/active_scaffold/locale/de.rb +13 -6
- data/lib/active_scaffold/locale/en.rb +2 -1
- data/lib/active_scaffold/locale/es.yml +3 -0
- data/lib/active_scaffold/locale/fr.rb +5 -2
- data/lib/active_scaffold/locale/ru.yml +77 -20
- data/lib/active_scaffold/marked_model.rb +5 -5
- data/lib/{paginator.rb → active_scaffold/paginator.rb} +0 -0
- data/lib/{responds_to_parent.rb → active_scaffold/responds_to_parent.rb} +0 -0
- data/lib/active_scaffold/version.rb +9 -0
- data/lib/active_scaffold.rb +60 -84
- data/lib/active_scaffold_assets.rb +45 -0
- data/lib/active_scaffold_env.rb +14 -0
- data/lib/active_scaffold_vho.rb +2 -0
- data/lib/extensions/active_association_reflection.rb +13 -0
- data/lib/extensions/paginator_extensions.rb +1 -1
- data/lib/extensions/routing_mapper.rb +1 -1
- data/lib/generators/active_scaffold_setup/active_scaffold_setup_generator.rb +12 -4
- metadata +85 -68
- data/lib/dhtml_confirm.rb +0 -54
|
@@ -2,61 +2,118 @@ ru:
|
|
|
2
2
|
active_scaffold:
|
|
3
3
|
add: 'Добавить запись'
|
|
4
4
|
add_existing: 'Добавить существующую запись'
|
|
5
|
-
add_existing_model: '
|
|
6
|
-
are_you_sure_to_delete: '
|
|
5
|
+
add_existing_model: '%{model}: добавить существующую запись'
|
|
6
|
+
are_you_sure_to_delete: 'Удалить %{label}?'
|
|
7
7
|
cancel: 'Отмена'
|
|
8
8
|
click_to_edit: 'Нажмите для редактирования'
|
|
9
|
+
click_to_reset: 'Нажмите для сброса'
|
|
9
10
|
close: 'Закрыть'
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
config_list: 'Настройки списка'
|
|
12
|
+
config_list_model: '%{model}: настройки списка'
|
|
13
|
+
create: 'Создать'
|
|
14
|
+
create_model: '%{model}: создать запись'
|
|
12
15
|
create_another: 'Создать другую запись'
|
|
13
|
-
created_model: '
|
|
16
|
+
created_model: '%{model}: запись создана'
|
|
14
17
|
create_new: 'Создать новую запись'
|
|
15
18
|
customize: 'Настроить'
|
|
16
19
|
delete: 'Удалить'
|
|
17
|
-
deleted_model: '
|
|
20
|
+
deleted_model: '%{model}: запись удалена'
|
|
18
21
|
delimiter: 'Разделитель'
|
|
19
22
|
download: 'Загрузить'
|
|
20
23
|
edit: 'Изменить'
|
|
21
24
|
export: 'Экспорт'
|
|
22
25
|
nested_for_model: '%{parent_model} / %{nested_model}'
|
|
23
|
-
nested_of_model: '%{nested_model}
|
|
26
|
+
nested_of_model: '%{nested_model} @ %{parent_model}'
|
|
27
|
+
false: 'Нет'
|
|
24
28
|
filtered: '(Найденное)'
|
|
25
|
-
found:
|
|
29
|
+
found:
|
|
30
|
+
one: 'запись'
|
|
31
|
+
few: 'записи'
|
|
32
|
+
many: 'записей'
|
|
33
|
+
other: 'записи'
|
|
26
34
|
hide: 'Скрыть'
|
|
27
35
|
live_search: 'Поиск'
|
|
28
|
-
loading: '
|
|
36
|
+
loading: 'Загрузка…'
|
|
29
37
|
next: 'Следующее'
|
|
30
38
|
no_entries: 'Нет записей'
|
|
31
|
-
|
|
39
|
+
no_options: 'Нет вариантов'
|
|
40
|
+
omit_header: 'Пропустить заголовок'
|
|
32
41
|
options: 'Настройки'
|
|
33
42
|
pdf: 'PDF'
|
|
34
43
|
previous: 'Предыдущее'
|
|
35
|
-
print: '
|
|
44
|
+
print: 'Печать'
|
|
36
45
|
refresh: 'Обновить'
|
|
37
46
|
remove: 'Удалить'
|
|
38
47
|
remove_file: 'Удалить или заменить файл'
|
|
39
48
|
replace_with_new: 'Заменить новым'
|
|
40
|
-
revisions_for_model: '
|
|
41
|
-
reset: '
|
|
42
|
-
saving: '
|
|
49
|
+
revisions_for_model: '%{model}: редакции'
|
|
50
|
+
reset: 'Сброс'
|
|
51
|
+
saving: 'Сохранение…'
|
|
43
52
|
search: 'Поиск'
|
|
44
53
|
search_terms: 'Ключевые слова'
|
|
45
54
|
_select_: '- выбрать -'
|
|
46
55
|
show: 'Показать'
|
|
47
|
-
show_model: '
|
|
56
|
+
show_model: '%{model}: показать запись'
|
|
48
57
|
_to_ : ' to '
|
|
58
|
+
true: 'Да'
|
|
49
59
|
update: 'Обновить запись'
|
|
50
|
-
update_model: '
|
|
51
|
-
updated_model: '
|
|
60
|
+
update_model: '%{model}: обновить запись'
|
|
61
|
+
updated_model: '%{model}: запись обновлена'
|
|
52
62
|
'=': '='
|
|
53
63
|
'>=': '>='
|
|
54
64
|
'<=': '<='
|
|
55
65
|
'>': '>'
|
|
56
66
|
'<': '<'
|
|
57
67
|
'!=': '!='
|
|
58
|
-
between: '
|
|
68
|
+
between: 'В интервале'
|
|
69
|
+
contains: 'Содержит'
|
|
70
|
+
begins_with: 'Начинается с'
|
|
71
|
+
ends_with: 'Оканчивается на'
|
|
72
|
+
today: 'Сегодня'
|
|
73
|
+
yesterday: 'Вчера'
|
|
74
|
+
tomorrow: 'Завтра'
|
|
75
|
+
this_week: 'На этой неделе'
|
|
76
|
+
prev_week: 'На прошлой неделе'
|
|
77
|
+
next_week: 'На следующей неделе'
|
|
78
|
+
this_month: 'В этом месяце'
|
|
79
|
+
prev_month: 'В прошлом месяце'
|
|
80
|
+
next_month: 'В следующем месяце'
|
|
81
|
+
this_year: 'В этом году'
|
|
82
|
+
prev_year: 'В прошлом году'
|
|
83
|
+
next_year: 'В следующем году'
|
|
84
|
+
past: 'Прошлое'
|
|
85
|
+
future: 'Будущее'
|
|
86
|
+
range: 'Интервал'
|
|
87
|
+
seconds: 'секунд'
|
|
88
|
+
minutes: 'минут'
|
|
89
|
+
hours: 'часов'
|
|
90
|
+
days: 'дней'
|
|
91
|
+
weeks: 'недель'
|
|
92
|
+
months: 'месяцев'
|
|
93
|
+
years: 'лет'
|
|
94
|
+
optional_attributes: 'Дополнительные настройки'
|
|
95
|
+
null: 'Пусто'
|
|
96
|
+
not_null: 'Не пусто'
|
|
97
|
+
date_picker_options:
|
|
98
|
+
weekHeader: 'Нед.'
|
|
99
|
+
firstDay: 1
|
|
100
|
+
isRTL: false
|
|
101
|
+
showMonthAfterYear: false
|
|
102
|
+
datetime_picker_options:
|
|
103
|
+
timeText: 'Время'
|
|
104
|
+
currentText: 'Сегодня'
|
|
105
|
+
closeText: 'Закрыть'
|
|
106
|
+
errors:
|
|
107
|
+
template:
|
|
108
|
+
header:
|
|
109
|
+
one: '%{model}: сохранение не удалось из-за %{count} ошибки'
|
|
110
|
+
few: '%{model}: сохранение не удалось из-за %{count} ошибок'
|
|
111
|
+
many: '%{model}: сохранение не удалось из-за %{count} ошибок'
|
|
112
|
+
other: '%{model}: сохранение не удалось из-за %{count} ошибки'
|
|
113
|
+
body: 'Проблемы возникли со следующими полями:'
|
|
59
114
|
|
|
60
115
|
# error_messages
|
|
61
|
-
|
|
62
|
-
|
|
116
|
+
cant_destroy_record: 'Запись %{record} не может быть удалена'
|
|
117
|
+
failed_to_save_record: 'Запись не может быть сохранена из-за неизвестной ошибки'
|
|
118
|
+
internal_error: '500 Внутренняя ошибка сервера'
|
|
119
|
+
version_inconsistency: 'Эта запись была обновлена с того момента, как вы начали ее редактировать'
|
|
@@ -21,12 +21,12 @@ module ActiveScaffold
|
|
|
21
21
|
end
|
|
22
22
|
|
|
23
23
|
module ClassMethods
|
|
24
|
-
# The proc to call that retrieves the marked_records from the ApplicationController.
|
|
25
|
-
attr_accessor :marked_records_proc
|
|
26
|
-
|
|
27
|
-
# Class-level access to the marked_records
|
|
28
24
|
def marked_records
|
|
29
|
-
|
|
25
|
+
Thread.current[:marked_records] ||= Set.new
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def marked_records=(marked)
|
|
29
|
+
Thread.current[:marked_records] = marked
|
|
30
30
|
end
|
|
31
31
|
end
|
|
32
32
|
|
|
File without changes
|
|
File without changes
|
data/lib/active_scaffold.rb
CHANGED
|
@@ -2,13 +2,21 @@ unless Rails::VERSION::MAJOR == 3 && Rails::VERSION::MINOR >= 0
|
|
|
2
2
|
raise "This version of ActiveScaffold requires Rails 3.0 or higher. Please use an earlier version."
|
|
3
3
|
end
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
require '
|
|
5
|
+
begin
|
|
6
|
+
require 'render_component'
|
|
7
|
+
rescue LoadError
|
|
8
|
+
end
|
|
9
|
+
begin
|
|
10
|
+
require 'verification'
|
|
11
|
+
rescue LoadError
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
require 'active_scaffold_assets'
|
|
15
|
+
require 'active_scaffold/active_record_permissions'
|
|
16
|
+
require 'active_scaffold/paginator'
|
|
17
|
+
require 'active_scaffold/responds_to_parent'
|
|
7
18
|
|
|
8
|
-
require '
|
|
9
|
-
require 'dhtml_confirm'
|
|
10
|
-
require 'paginator'
|
|
11
|
-
require 'responds_to_parent'
|
|
19
|
+
require 'active_scaffold/version'
|
|
12
20
|
|
|
13
21
|
module ActiveScaffold
|
|
14
22
|
autoload :AttributeParams, 'active_scaffold/attribute_params'
|
|
@@ -17,8 +25,8 @@ module ActiveScaffold
|
|
|
17
25
|
autoload :Finder, 'active_scaffold/finder'
|
|
18
26
|
autoload :MarkedModel, 'active_scaffold/marked_model'
|
|
19
27
|
|
|
20
|
-
def self.
|
|
21
|
-
Dir["#{
|
|
28
|
+
def self.autoload_subdir(dir, mod=self, root = File.dirname(__FILE__))
|
|
29
|
+
Dir["#{root}/active_scaffold/#{dir}/*.rb"].each { |file|
|
|
22
30
|
basename = File.basename(file, ".rb")
|
|
23
31
|
mod.module_eval {
|
|
24
32
|
autoload basename.camelcase.to_sym, "active_scaffold/#{dir}/#{basename}"
|
|
@@ -27,7 +35,7 @@ module ActiveScaffold
|
|
|
27
35
|
end
|
|
28
36
|
|
|
29
37
|
module Actions
|
|
30
|
-
ActiveScaffold.
|
|
38
|
+
ActiveScaffold.autoload_subdir('actions', self)
|
|
31
39
|
end
|
|
32
40
|
|
|
33
41
|
module Bridges
|
|
@@ -35,15 +43,15 @@ module ActiveScaffold
|
|
|
35
43
|
end
|
|
36
44
|
|
|
37
45
|
module Config
|
|
38
|
-
ActiveScaffold.
|
|
46
|
+
ActiveScaffold.autoload_subdir('config', self)
|
|
39
47
|
end
|
|
40
48
|
|
|
41
49
|
module DataStructures
|
|
42
|
-
ActiveScaffold.
|
|
50
|
+
ActiveScaffold.autoload_subdir('data_structures', self)
|
|
43
51
|
end
|
|
44
52
|
|
|
45
53
|
module Helpers
|
|
46
|
-
ActiveScaffold.
|
|
54
|
+
ActiveScaffold.autoload_subdir('helpers', self)
|
|
47
55
|
end
|
|
48
56
|
|
|
49
57
|
class ControllerNotFound < RuntimeError; end
|
|
@@ -100,58 +108,10 @@ module ActiveScaffold
|
|
|
100
108
|
@@js_framework ||= :prototype
|
|
101
109
|
end
|
|
102
110
|
|
|
103
|
-
##
|
|
104
|
-
## Copy over asset files (javascript/css/images) from directory to public/
|
|
105
|
-
##
|
|
106
|
-
def self.install_assets_from(directory)
|
|
107
|
-
copy_files("/public", "/public", directory)
|
|
108
|
-
|
|
109
|
-
available_frontends = Dir[File.join(directory, 'frontends', '*')].map { |d| File.basename d }
|
|
110
|
-
[:stylesheets, :javascripts, :images].each do |asset_type|
|
|
111
|
-
path = "/public/#{asset_type}/active_scaffold"
|
|
112
|
-
copy_files(path, path, directory)
|
|
113
|
-
|
|
114
|
-
File.open(File.join(Rails.root, path, 'DO_NOT_EDIT'), 'w') do |f|
|
|
115
|
-
f.puts "Any changes made to files in sub-folders will be lost."
|
|
116
|
-
f.puts "See http://activescaffold.com/tutorials/faq#custom-css."
|
|
117
|
-
end
|
|
118
|
-
|
|
119
|
-
available_frontends.each do |frontend|
|
|
120
|
-
if asset_type == :javascripts
|
|
121
|
-
file_mask = '*.js'
|
|
122
|
-
source = "/frontends/#{frontend}/#{asset_type}/#{ActiveScaffold.js_framework}"
|
|
123
|
-
else
|
|
124
|
-
file_mask = '*.*'
|
|
125
|
-
source = "/frontends/#{frontend}/#{asset_type}"
|
|
126
|
-
end
|
|
127
|
-
destination = "/public/#{asset_type}/active_scaffold/#{frontend}"
|
|
128
|
-
copy_files(source, destination, directory, file_mask)
|
|
129
|
-
end
|
|
130
|
-
end
|
|
131
|
-
end
|
|
132
|
-
|
|
133
111
|
def self.root
|
|
134
112
|
File.dirname(__FILE__) + "/.."
|
|
135
113
|
end
|
|
136
114
|
|
|
137
|
-
def self.delete_stale_assets
|
|
138
|
-
available_frontends = Dir[File.join(root, 'frontends', '*')].map { |d| File.basename d }
|
|
139
|
-
[:stylesheets, :javascripts, :images].each do |asset_type|
|
|
140
|
-
available_frontends.each do |frontend|
|
|
141
|
-
destination = File.join(Rails.root, "/public/#{asset_type}/active_scaffold/#{frontend}")
|
|
142
|
-
FileUtils.rm Dir.glob("#{destination}/*")
|
|
143
|
-
end
|
|
144
|
-
end
|
|
145
|
-
end
|
|
146
|
-
|
|
147
|
-
private
|
|
148
|
-
def self.copy_files(source_path, destination_path, directory, file_mask = '*.*')
|
|
149
|
-
source, destination = File.join(directory, source_path), File.join(Rails.root, destination_path)
|
|
150
|
-
FileUtils.mkdir_p(destination) unless File.exist?(destination)
|
|
151
|
-
|
|
152
|
-
FileUtils.cp_r(Dir.glob("#{source}/#{file_mask}"), destination)
|
|
153
|
-
end
|
|
154
|
-
|
|
155
115
|
module ClassMethods
|
|
156
116
|
def active_scaffold(model_id = nil, &block)
|
|
157
117
|
# initialize bridges here
|
|
@@ -181,6 +141,7 @@ module ActiveScaffold
|
|
|
181
141
|
@active_scaffold_custom_paths = []
|
|
182
142
|
|
|
183
143
|
self.active_scaffold_superclasses_blocks.each {|superblock| self.active_scaffold_config.configure &superblock}
|
|
144
|
+
self.active_scaffold_config.sti_children = nil # reset sti_children if set in parent block
|
|
184
145
|
self.active_scaffold_config.configure &block if block_given?
|
|
185
146
|
self.active_scaffold_config._configure_sti unless self.active_scaffold_config.sti_children.nil?
|
|
186
147
|
self.active_scaffold_config._load_action_columns
|
|
@@ -200,14 +161,33 @@ module ActiveScaffold
|
|
|
200
161
|
|
|
201
162
|
# sneak the action links from the actions into the main set
|
|
202
163
|
if link = active_scaffold_config.send(mod).link rescue nil
|
|
203
|
-
|
|
164
|
+
if link.is_a? Array
|
|
165
|
+
link.each {|current| active_scaffold_config.action_links.add_to_group(current, active_scaffold_config.send(mod).action_group)}
|
|
166
|
+
elsif link.is_a? ActiveScaffold::DataStructures::ActionLink
|
|
167
|
+
active_scaffold_config.action_links.add_to_group(link, active_scaffold_config.send(mod).action_group)
|
|
168
|
+
end
|
|
204
169
|
end
|
|
205
170
|
end
|
|
206
171
|
end
|
|
207
172
|
active_scaffold_paths.each do |path|
|
|
208
173
|
self.append_view_path(ActionView::ActiveScaffoldResolver.new(path))
|
|
209
174
|
end
|
|
210
|
-
self.
|
|
175
|
+
self._add_sti_create_links if self.active_scaffold_config.add_sti_create_links?
|
|
176
|
+
end
|
|
177
|
+
|
|
178
|
+
# To be called after include action modules
|
|
179
|
+
def _add_sti_create_links
|
|
180
|
+
new_action_link = active_scaffold_config.action_links.collection['new']
|
|
181
|
+
unless new_action_link.nil? || active_scaffold_config.sti_children.empty?
|
|
182
|
+
active_scaffold_config.action_links.collection.delete('new')
|
|
183
|
+
active_scaffold_config.sti_children.each do |child|
|
|
184
|
+
new_sti_link = Marshal.load(Marshal.dump(new_action_link)) # deep clone
|
|
185
|
+
new_sti_link.label = child.to_s.camelize.constantize.model_name.human
|
|
186
|
+
new_sti_link.parameters = {:parent_sti => controller_path}
|
|
187
|
+
new_sti_link.controller = Proc.new { active_scaffold_controller_for(child.to_s.camelize.constantize).controller_path }
|
|
188
|
+
active_scaffold_config.action_links.collection.create.add(new_sti_link)
|
|
189
|
+
end
|
|
190
|
+
end
|
|
211
191
|
end
|
|
212
192
|
|
|
213
193
|
# Create the automatic column links. Note that this has to happen when configuration is *done*, because otherwise the Nested module could be disabled. Actually, it could still be disabled later, couldn't it?
|
|
@@ -215,14 +195,22 @@ module ActiveScaffold
|
|
|
215
195
|
return unless active_scaffold_config.actions.include? :list and active_scaffold_config.actions.include? :nested
|
|
216
196
|
active_scaffold_config.columns.each do |column|
|
|
217
197
|
next unless column.link.nil? and column.autolink?
|
|
218
|
-
action_link
|
|
219
|
-
|
|
198
|
+
#lazy load of action_link, cause it was really slowing down app in dev mode
|
|
199
|
+
#and might lead to trouble cause of cyclic constantization of controllers
|
|
200
|
+
#and might be unnecessary cause it is done before columns are configured
|
|
201
|
+
column.set_link(Proc.new {|col| link_for_association(col)})
|
|
220
202
|
end
|
|
221
203
|
end
|
|
222
204
|
|
|
223
205
|
def link_for_association(column, options = {})
|
|
224
206
|
begin
|
|
225
|
-
controller = column.polymorphic_association?
|
|
207
|
+
controller = if column.polymorphic_association?
|
|
208
|
+
:polymorph
|
|
209
|
+
elsif options.include?(:controller)
|
|
210
|
+
"#{options[:controller].to_s.camelize}Controller".constantize
|
|
211
|
+
else
|
|
212
|
+
active_scaffold_controller_for(column.association.klass)
|
|
213
|
+
end
|
|
226
214
|
rescue ActiveScaffold::ControllerNotFound
|
|
227
215
|
controller = nil
|
|
228
216
|
end
|
|
@@ -230,7 +218,7 @@ module ActiveScaffold
|
|
|
230
218
|
unless controller.nil?
|
|
231
219
|
options.reverse_merge! :label => column.label, :position => :after, :type => :member, :controller => (controller == :polymorph ? controller : controller.controller_path), :column => column
|
|
232
220
|
options[:parameters] ||= {}
|
|
233
|
-
options[:parameters].reverse_merge! :
|
|
221
|
+
options[:parameters].reverse_merge! :parent_scaffold => controller_path, :association => column.association.name
|
|
234
222
|
if column.plural_association?
|
|
235
223
|
# note: we can't create nested scaffolds on :through associations because there's no reverse association.
|
|
236
224
|
|
|
@@ -249,7 +237,7 @@ module ActiveScaffold
|
|
|
249
237
|
def link_for_association_as_scope(scope, options = {})
|
|
250
238
|
options.reverse_merge! :label => scope, :position => :after, :type => :member, :controller => controller_path
|
|
251
239
|
options[:parameters] ||= {}
|
|
252
|
-
options[:parameters].reverse_merge! :
|
|
240
|
+
options[:parameters].reverse_merge! :parent_scaffold => controller_path, :named_scope => scope
|
|
253
241
|
ActiveScaffold::DataStructures::ActionLink.new('index', options)
|
|
254
242
|
end
|
|
255
243
|
|
|
@@ -343,30 +331,18 @@ module ActiveScaffold
|
|
|
343
331
|
end
|
|
344
332
|
end
|
|
345
333
|
|
|
346
|
-
|
|
347
|
-
Dir["#{File.dirname __FILE__}/extensions/*.rb"].each { |file| require file }
|
|
348
|
-
|
|
349
|
-
ActionController::Base.send(:include, ActiveScaffold)
|
|
350
|
-
ActionController::Base.send(:include, RespondsToParent)
|
|
351
|
-
ActionController::Base.send(:include, ActiveScaffold::Helpers::ControllerHelpers)
|
|
352
|
-
ActionView::Base.send(:include, ActiveScaffold::Helpers::ViewHelpers)
|
|
353
|
-
|
|
354
|
-
ActionController::Base.class_eval {include ActiveRecordPermissions::ModelUserAccess::Controller}
|
|
355
|
-
ActiveRecord::Base.class_eval {include ActiveRecordPermissions::ModelUserAccess::Model}
|
|
356
|
-
ActiveRecord::Base.class_eval {include ActiveRecordPermissions::Permissions}
|
|
357
|
-
|
|
358
|
-
I18n.load_path += Dir[File.join(File.dirname(__FILE__), 'active_scaffold', 'locale', '*.{rb,yml}')]
|
|
359
|
-
#ActiveScaffold.js_framework = :jquery
|
|
334
|
+
require 'active_scaffold_env'
|
|
360
335
|
|
|
361
336
|
##
|
|
362
337
|
## Run the install assets script, too, just to make sure
|
|
363
338
|
## But at least rescue the action in production
|
|
364
339
|
##
|
|
340
|
+
|
|
365
341
|
Rails::Application.initializer("active_scaffold.install_assets") do
|
|
366
342
|
begin
|
|
367
|
-
ActiveScaffold.
|
|
368
|
-
ActiveScaffold.install_assets_from(ActiveScaffold.root)
|
|
343
|
+
ActiveScaffoldAssets.copy_to_public(ActiveScaffold.root, {:clean_up_destination => true})
|
|
369
344
|
rescue
|
|
370
345
|
raise $! unless Rails.env == 'production'
|
|
371
346
|
end
|
|
372
|
-
end
|
|
347
|
+
end if defined?(ACTIVE_SCAFFOLD_GEM)
|
|
348
|
+
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
class ActiveScaffoldAssets
|
|
2
|
+
|
|
3
|
+
def self.copy_to_public(from, options = {})
|
|
4
|
+
unless defined?(ACTIVE_SCAFFOLD_INSTALL_ASSETS) && ACTIVE_SCAFFOLD_INSTALL_ASSETS == false
|
|
5
|
+
copy_files("/public", "/public", from)
|
|
6
|
+
available_frontends = Dir[File.join(from, 'frontends', '*')].collect { |d| File.basename d }
|
|
7
|
+
[:stylesheets, :javascripts, :images].each do |asset_type|
|
|
8
|
+
copy_asset_type(from, available_frontends, asset_type, options)
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
protected
|
|
14
|
+
|
|
15
|
+
def self.copy_asset_type(from, available_frontends, asset_type, options = {})
|
|
16
|
+
path = "/public/#{asset_type}/active_scaffold"
|
|
17
|
+
copy_files(path, path, from)
|
|
18
|
+
|
|
19
|
+
File.open(File.join(Rails.root, path, 'DO_NOT_EDIT'), 'w') do |f|
|
|
20
|
+
f.puts "Any changes made to files in sub-folders will be lost."
|
|
21
|
+
f.puts "See http://activescaffold.com/tutorials/faq#custom-css."
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
available_frontends.each do |frontend|
|
|
25
|
+
if asset_type == :javascripts
|
|
26
|
+
file_mask = '*.js'
|
|
27
|
+
source = "/frontends/#{frontend}/#{asset_type}/#{ActiveScaffold.js_framework}"
|
|
28
|
+
else
|
|
29
|
+
file_mask = '*.*'
|
|
30
|
+
source = "/frontends/#{frontend}/#{asset_type}"
|
|
31
|
+
end
|
|
32
|
+
destination = "/public/#{asset_type}/active_scaffold/#{frontend}"
|
|
33
|
+
copy_files(source, destination, from, file_mask, options)
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def self.copy_files(source_path, destination_path, directory, file_mask = '*.*', options = {})
|
|
38
|
+
source, destination = File.join(directory, source_path), File.join(Rails.root, destination_path)
|
|
39
|
+
FileUtils.mkdir_p(destination) unless File.exist?(destination)
|
|
40
|
+
Dir.glob('*.so')
|
|
41
|
+
|
|
42
|
+
FileUtils.rm Dir.glob("#{destination}/*") if options[:clean_up_destination]
|
|
43
|
+
FileUtils.cp_r(Dir.glob("#{source}/#{file_mask}"), destination)
|
|
44
|
+
end
|
|
45
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
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 }
|
|
3
|
+
|
|
4
|
+
ActionController::Base.send(:include, ActiveScaffold)
|
|
5
|
+
ActionController::Base.send(:include, RespondsToParent)
|
|
6
|
+
ActionController::Base.send(:include, ActiveScaffold::Helpers::ControllerHelpers)
|
|
7
|
+
ActionView::Base.send(:include, ActiveScaffold::Helpers::ViewHelpers)
|
|
8
|
+
|
|
9
|
+
ActionController::Base.class_eval {include ActiveRecordPermissions::ModelUserAccess::Controller}
|
|
10
|
+
ActiveRecord::Base.class_eval {include ActiveRecordPermissions::ModelUserAccess::Model}
|
|
11
|
+
ActiveRecord::Base.class_eval {include ActiveRecordPermissions::Permissions}
|
|
12
|
+
|
|
13
|
+
I18n.load_path += Dir[File.join(File.dirname(__FILE__), 'active_scaffold', 'locale', '*.{rb,yml}')]
|
|
14
|
+
#ActiveScaffold.js_framework = :jquery
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Bugfix: building an sti model from an association fails
|
|
2
|
+
# https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/6306-collection-associations-build-method-not-supported-for-sti
|
|
3
|
+
ActiveRecord::Reflection::AssociationReflection.class_eval do
|
|
4
|
+
def build_association(*opts)
|
|
5
|
+
col = klass.inheritance_column.to_sym
|
|
6
|
+
if !col.nil? && opts.first.is_a?(Hash) && (opts.first.symbolize_keys[col])
|
|
7
|
+
sti_model = opts.first.delete(col)
|
|
8
|
+
sti_model.to_s.camelize.constantize.new(*opts)
|
|
9
|
+
else
|
|
10
|
+
klass.new(*opts)
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -2,7 +2,7 @@ module ActionDispatch
|
|
|
2
2
|
module Routing
|
|
3
3
|
ACTIVE_SCAFFOLD_CORE_ROUTING = {
|
|
4
4
|
:collection => {:show_search => :get, :render_field => :get},
|
|
5
|
-
:member => {:row => :get, :update_column => :post, :render_field => :get
|
|
5
|
+
:member => {:row => :get, :update_column => :post, :render_field => :get}
|
|
6
6
|
}
|
|
7
7
|
ACTIVE_SCAFFOLD_ASSOCIATION_ROUTING = {
|
|
8
8
|
:collection => {:edit_associated => :get, :new_existing => :get, :add_existing => :post},
|
|
@@ -8,8 +8,10 @@ module Rails
|
|
|
8
8
|
end
|
|
9
9
|
|
|
10
10
|
def install_plugins
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
unless defined?(ACTIVE_SCAFFOLD_GEM)
|
|
12
|
+
plugin 'verification', :git => 'git://github.com/rails/verification.git'
|
|
13
|
+
plugin 'render_component', :git => 'git://github.com/vhochstein/render_component.git'
|
|
14
|
+
end
|
|
13
15
|
if js_lib == 'prototype'
|
|
14
16
|
get "https://github.com/vhochstein/prototype-ujs/raw/master/src/rails.js", "public/javascripts/rails.js"
|
|
15
17
|
elsif js_lib == 'jquery'
|
|
@@ -19,8 +21,14 @@ module Rails
|
|
|
19
21
|
end
|
|
20
22
|
|
|
21
23
|
def configure_active_scaffold
|
|
22
|
-
|
|
23
|
-
|
|
24
|
+
unless defined?(ACTIVE_SCAFFOLD_GEM)
|
|
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
|
|
28
|
+
else
|
|
29
|
+
if js_lib == 'jquery'
|
|
30
|
+
create_file "config/initializers/active_scaffold.rb", "ActiveScaffold.js_framework = :jquery"
|
|
31
|
+
end
|
|
24
32
|
end
|
|
25
33
|
end
|
|
26
34
|
|