active_scaffold 4.2.3 → 4.3.1

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.
Files changed (84) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.rdoc +19 -1
  3. data/README.md +115 -12
  4. data/app/assets/javascripts/{jquery → active_scaffold}/active_scaffold.js +759 -762
  5. data/app/assets/javascripts/{jquery/date_picker_bridge.js.erb → active_scaffold/date_picker_bridge.js} +0 -3
  6. data/app/assets/javascripts/active_scaffold/load.js +102 -0
  7. data/app/assets/javascripts/active_scaffold.js.erb +3 -27
  8. data/app/assets/stylesheets/active_scaffold/_colours.scss +330 -0
  9. data/app/assets/stylesheets/active_scaffold/_images.scss +65 -0
  10. data/app/assets/stylesheets/{active_scaffold_layout.scss → active_scaffold/_layout.scss} +14 -0
  11. data/app/assets/stylesheets/active_scaffold/_variables.scss +194 -0
  12. data/app/assets/stylesheets/active_scaffold/core.scss +15 -0
  13. data/app/assets/stylesheets/active_scaffold.scss.erb +16 -0
  14. data/app/views/active_scaffold_overrides/_field_search_columns.html.erb +8 -0
  15. data/app/views/active_scaffold_overrides/_form.html.erb +8 -0
  16. data/app/views/active_scaffold_overrides/_form_association.html.erb +3 -1
  17. data/app/views/active_scaffold_overrides/_form_association_record.html.erb +4 -2
  18. data/app/views/active_scaffold_overrides/_new_record.js.erb +2 -2
  19. data/app/views/active_scaffold_overrides/_refresh_list.js.erb +1 -1
  20. data/app/views/active_scaffold_overrides/_show_association.html.erb +2 -1
  21. data/app/views/active_scaffold_overrides/_show_association_horizontal.html.erb +2 -2
  22. data/app/views/active_scaffold_overrides/_show_association_vertical.html.erb +1 -1
  23. data/app/views/active_scaffold_overrides/destroy.js.erb +2 -2
  24. data/app/views/active_scaffold_overrides/edit_associated.js.erb +10 -8
  25. data/app/views/active_scaffold_overrides/on_update.js.erb +1 -1
  26. data/config/locales/de.yml +19 -15
  27. data/config/locales/en.yml +5 -4
  28. data/config/locales/es.yml +16 -8
  29. data/config/locales/fr.yml +27 -20
  30. data/config/locales/hu.yml +35 -31
  31. data/config/locales/ja.yml +39 -38
  32. data/config/locales/ru.yml +37 -36
  33. data/config/locales/ta.yml +165 -0
  34. data/config/locales/zh_Hans.yml +163 -0
  35. data/lib/active_scaffold/actions/core.rb +34 -3
  36. data/lib/active_scaffold/assets/css_deps_generator.rb +42 -0
  37. data/lib/active_scaffold/assets/jquery_ui_manifest.rb +77 -0
  38. data/lib/active_scaffold/assets/jquery_ui_theme_generator.rb +102 -0
  39. data/lib/active_scaffold/assets.rb +109 -0
  40. data/lib/active_scaffold/attribute_params.rb +11 -2
  41. data/lib/active_scaffold/bridges/active_storage/form_ui.rb +1 -1
  42. data/lib/active_scaffold/bridges/carrierwave/form_ui.rb +1 -1
  43. data/lib/active_scaffold/bridges/chosen.rb +1 -1
  44. data/lib/active_scaffold/bridges/date_picker/helper.rb +12 -1
  45. data/lib/active_scaffold/bridges/dragonfly/form_ui.rb +1 -1
  46. data/lib/active_scaffold/bridges/file_column/form_ui.rb +1 -1
  47. data/lib/active_scaffold/bridges/paperclip/form_ui.rb +1 -1
  48. data/lib/active_scaffold/bridges/record_select/helpers.rb +1 -1
  49. data/lib/active_scaffold/bridges/tiny_mce/helpers.rb +1 -0
  50. data/lib/active_scaffold/bridges/tiny_mce.rb +6 -1
  51. data/lib/active_scaffold/bridges.rb +7 -0
  52. data/lib/active_scaffold/config/core.rb +7 -3
  53. data/lib/active_scaffold/constraints.rb +1 -1
  54. data/lib/active_scaffold/data_structures/action_columns.rb +66 -0
  55. data/lib/active_scaffold/data_structures/bridge.rb +2 -0
  56. data/lib/active_scaffold/data_structures/column.rb +3 -0
  57. data/lib/active_scaffold/engine.rb +40 -0
  58. data/lib/active_scaffold/finder.rb +1 -1
  59. data/lib/active_scaffold/helpers/assets_helpers.rb +39 -0
  60. data/lib/active_scaffold/helpers/controller_helpers.rb +1 -1
  61. data/lib/active_scaffold/helpers/form_column_helpers.rb +57 -532
  62. data/lib/active_scaffold/helpers/form_ui_helpers.rb +530 -0
  63. data/lib/active_scaffold/helpers/human_condition_helpers.rb +1 -0
  64. data/lib/active_scaffold/helpers/list_column_helpers.rb +31 -11
  65. data/lib/active_scaffold/helpers/search_column_helpers.rb +5 -12
  66. data/lib/active_scaffold/helpers/show_column_helpers.rb +4 -2
  67. data/lib/active_scaffold/helpers/view_helpers.rb +12 -0
  68. data/lib/active_scaffold/railties/tasks.rake +10 -0
  69. data/lib/active_scaffold/tableless.rb +1 -1
  70. data/lib/active_scaffold/testing/assert_embedded_load.rb +33 -0
  71. data/lib/active_scaffold/version.rb +2 -2
  72. data/lib/active_scaffold.rb +7 -2
  73. data/lib/tasks/active_scaffold/assets.rake +42 -0
  74. data/lib/tasks/bundle.rake +25 -0
  75. data/vendor/assets/stylesheets/{jquery-ui-theme.css.erb → jquery-ui-theme.css} +17 -17
  76. metadata +28 -28
  77. data/app/assets/stylesheets/active_scaffold.scss +0 -424
  78. data/app/assets/stylesheets/active_scaffold_extensions.css.erb +0 -2
  79. data/app/assets/stylesheets/active_scaffold_images.scss +0 -65
  80. data/app/assets/stylesheets/active_scaffold_jquery_ui.css.erb +0 -13
  81. /data/app/assets/javascripts/{jquery → active_scaffold}/active_scaffold_chosen.js +0 -0
  82. /data/app/assets/javascripts/{jquery → active_scaffold}/draggable_lists.js +0 -0
  83. /data/app/assets/javascripts/{jquery → active_scaffold}/jquery.editinplace.js +0 -0
  84. /data/app/assets/javascripts/{jquery → active_scaffold}/tiny_mce_bridge.js +0 -0
@@ -0,0 +1,165 @@
1
+ ta:
2
+ active_scaffold:
3
+ "!=": "!="
4
+ "<": "<"
5
+ "<=": "<="
6
+ "=": "="
7
+ ">": ">"
8
+ ">=": ">="
9
+ _select_: "- தேர்ந்தெடு -"
10
+ _to_: " செய்ய "
11
+ add: 'கூட்டு'
12
+ add_existing: 'ஏற்கனவே உள்ளதைச் சேர்க்கவும்'
13
+ add_existing_model: 'ஏற்கனவே உள்ள %{model} ஐச் சேர்'
14
+ add_model: '%{model} சேர்'
15
+ all_tokens: 'அனைத்து முக்கிய வார்த்தைகள்'
16
+ any_token: 'எந்த முக்கிய சொல்'
17
+ apply: 'இடு'
18
+ are_you_sure_to_delete: '%{label} ஐ நிச்சயமாக நீக்க விரும்புகிறீர்களா?'
19
+ average: 'சராசரி'
20
+ begins_with: 'உடன் தொடங்குகிறது'
21
+ between: 'இடையில்'
22
+ cancel: 'ரத்துசெய்'
23
+ cant_destroy_record: "%{record} அழிக்க முடியாது"
24
+ changes: 'மாற்றங்கள்'
25
+ check_all: 'அனைத்தையும் சரிபார்க்கவும்'
26
+ click_to_edit: 'திருத்த சொடுக்கு செய்யவும்'
27
+ click_to_reset: 'மீட்டமைக்க சொடுக்கு செய்யவும்'
28
+ close: 'மூடு'
29
+ config_list: 'கட்டமைக்கவும்'
30
+ config_list_model: '%{model} க்கான நெடுவரிசைகளை உள்ளமை'
31
+ contains: 'கொண்டுள்ளது'
32
+ create: 'உருவாக்கு'
33
+ create_another: 'மற்றொரு %{model} ஐ உருவாக்கு'
34
+ create_apply: 'உருவாக்கி தொடரவும்'
35
+ create_model: '%{model} ஐ உருவாக்கு'
36
+ create_new: 'புதிதாக உருவாக்கவும்'
37
+ created_model: '%{model} உருவாக்கப்பட்டது'
38
+ customize: 'தனிப்பயனாக்கு'
39
+ date_picker_options:
40
+ firstDay: '0'
41
+ isRTL: 'பொய்'
42
+ showMonthAfterYear: 'பொய்'
43
+ weekHeader: 'Wk'
44
+ datetime_picker_options:
45
+ closeText: 'மூடு'
46
+ currentText: 'இப்போது'
47
+ timeText: 'மணி'
48
+ timezoneText: 'நேர மண்டலம்'
49
+ days: 'நாட்கள்'
50
+ delete: 'நீக்கு'
51
+ deleted_model: '%{model} நீக்கப்பட்டது'
52
+ deleted_records: 'நீக்கப்பட்ட பதிவுகளை பட்டியலிடுங்கள்'
53
+ delimiter: 'பிரிப்பான்'
54
+ doesnt_begin_with: 'தொடங்கவில்லை'
55
+ doesnt_contain: 'கொண்டிருக்கவில்லை'
56
+ doesnt_end_with: 'இத்துடன் முடிவதில்லை'
57
+ download: 'பதிவிறக்கம்'
58
+ edit: 'தொகு'
59
+ ends_with: 'உடன் முடிகிறது'
60
+ error_500: "(குறியீடு 500, உள் பிழை)"
61
+ errors:
62
+ template:
63
+ body: 'பின்வரும் துறைகளில் சிக்கல்கள் உள்ளன:'
64
+ header:
65
+ one: 1 பிழை இந்த %{model} சேமிக்கப்படுவதைத் தடுக்கிறது.
66
+ other: '%{count} பிழைகள் இந்த %{model} சேமிக்கப்படுவதைத் தடுக்கின்றன'
67
+ export: 'ஏற்றுமதி'
68
+ 'false': 'பொய்'
69
+ filtered: "(வடிகட்டப்பட்டது)"
70
+ found: 'கண்டுபிடிக்கப்பட்டது'
71
+ future: 'எதிர்காலம்'
72
+ group_by: 'குழு மூலம்'
73
+ grouped_by: '%{column} மூலம் குழுவாக்கப்பட்டது'
74
+ hide: "(மறை)"
75
+ hours: 'மணிநேரம்'
76
+ human_conditions:
77
+ association: "%{column} = %{value}"
78
+ boolean: "%{column} = %{value}"
79
+ inplace_edit_handle: "--"
80
+ internal_error: 'கோரிக்கை தோல்வியடைந்தது'
81
+ live_search: 'நேரடி தேடல்'
82
+ loading: 'ஏற்றுகிறது…'
83
+ logical_search: 'தருக்க தேடல்'
84
+ mark_all_records: 'அனைத்தையும் குறிக்கவும்'
85
+ maximum: 'பெருமம்'
86
+ minimum: 'சிறுமம்'
87
+ minutes: 'நிமிடங்கள்'
88
+ months: 'மாதங்கள்'
89
+ nested_for_model: "%{parent_model} க்கான %{nested_model}"
90
+ nested_of_model: "%{parent_model} இல் %{nested_model}"
91
+ next: 'அடுத்தது'
92
+ next_month: 'அடுத்த மாதம்'
93
+ next_week: 'அடுத்த வாரம்'
94
+ next_year: 'அடுத்த வருடம்'
95
+ no_authorization_for_action: 'செயலுக்கு ஏற்பு இல்லை %{action}'
96
+ no_color: 'நிறம் இல்லை'
97
+ no_entries: 'உள்ளீடுகள் இல்லை'
98
+ no_group: 'குழு இல்லை'
99
+ no_options: 'விருப்பங்கள் இல்லை'
100
+ not_null: 'பூச்யமாக இல்லை'
101
+ 'null': 'சுழிய'
102
+ omit_header: 'தலைப்பைத் தவிர்க்கவும்'
103
+ optional_attributes: 'மேலும் விருப்பங்கள்'
104
+ options: 'விருப்பங்கள்'
105
+ past: 'கடந்த'
106
+ pdf: 'PDF'
107
+ prev_month: 'கடந்த மாதம்'
108
+ prev_week: 'போன வாரம்'
109
+ prev_year: 'கடந்த ஆண்டு'
110
+ previous: 'முந்தைய'
111
+ print: 'அச்சிடுக'
112
+ range: 'வீச்சு'
113
+ record_not_saved: 'அறியப்படாத பிழைக்கான பதிவைச் சேமிப்பதில் தோல்வி'
114
+ records_marked:
115
+ one: 1 குறிக்கப்பட்டது %{model}
116
+ other: '%{count} %{model} எனக் குறிக்கப்பட்டது'
117
+ refresh: 'புதுப்பி'
118
+ remove: 'அகற்று'
119
+ remove_file: 'கோப்பை அகற்றவும் அல்லது மாற்றவும்'
120
+ remove_files: 'கோப்புகளை அகற்றவும் அல்லது சேர்க்கவும்'
121
+ replace_existing: 'ஏற்கனவே உள்ளதை மாற்றவும்'
122
+ replace_with_new: 'புதியதாக மாற்றவும்'
123
+ reset: 'மீட்டமை'
124
+ revisions_for_model: '%{model} க்கான திருத்தங்கள்'
125
+ saving: 'சேமிக்கிறது…'
126
+ search: 'தேடல்'
127
+ search_terms: 'தேடல் விதிமுறைகள்'
128
+ seconds: 'நொடிகள்'
129
+ show: 'காட்டு'
130
+ show_block: "(காட்டு)"
131
+ show_model: '%{model} ஐக் காட்டு'
132
+ sum: 'தொகை'
133
+ this_month: 'இந்த மாதம்'
134
+ this_week: 'இந்த வாரம்'
135
+ this_year: 'இந்த ஆண்டு'
136
+ today: 'இன்று'
137
+ tomorrow: 'நாளை'
138
+ 'true': 'உண்மை'
139
+ uncheck_all: 'அனைத்தையும் தேர்வுநீக்கு'
140
+ update: 'புதுப்பிப்பு'
141
+ update_apply: 'இடு'
142
+ update_model: '%{model}ஐப் புதுப்பிக்கவும்'
143
+ updated_model: '%{model} புதுப்பிக்கப்பட்டது'
144
+ version_inconsistency: 'பதிப்பு சீரற்ற தன்மை - இந்தப் பதிவை நீங்கள் திருத்தத்
145
+ தொடங்கியதிலிருந்து மாற்றியமைக்கப்பட்டுள்ளது.'
146
+ weeks: 'வாரங்கள்'
147
+ years: 'ஆண்டுகள்'
148
+ yesterday: 'நேற்று'
149
+ date:
150
+ formats:
151
+ month: "%B"
152
+ quarter: 'காலாண்டு %{num}'
153
+ week: 'வாரம் %W, %Y'
154
+ year_month: "%b %Y"
155
+ year_quarter: 'காலாண்டு %{quarter} %{year}'
156
+ time:
157
+ formats:
158
+ picker: "%a, %d %b %Y %H:%M:%S"
159
+ datetime:
160
+ prompts:
161
+ hour: 'மணி'
162
+ minute: 'மணித்துளி'
163
+ second: 'இரண்டாவது'
164
+ millisec: 'மில்லி நொடி'
165
+ microsec: 'மைக்ரோசெகண்ட்'
@@ -0,0 +1,163 @@
1
+ zh_Hans:
2
+ active_scaffold:
3
+ "!=": '!='
4
+ "<": <
5
+ "<=": <=
6
+ "=": '='
7
+ ">": '>'
8
+ ">=": '>='
9
+ _select_: '- 选择 -'
10
+ _to_: ' to '
11
+ add: 添加
12
+ add_existing: 添加现有项目
13
+ add_existing_model: 添加现有%{model}
14
+ add_model: 添加 %{model}
15
+ all_tokens: 所有关键词
16
+ any_token: 任何关键词
17
+ apply: 应用
18
+ are_you_sure_to_delete: 你确定想要删除 %{label}吗?
19
+ average: 平均值
20
+ begins_with: 以……开始
21
+ between: 介于……之间
22
+ cancel: 取消
23
+ cant_destroy_record: '%{record}不能被删除'
24
+ changes: 变更记录
25
+ check_all: 全选
26
+ click_to_edit: 点击以编辑
27
+ click_to_reset: 点击以重置
28
+ close: 关闭
29
+ config_list: 配置
30
+ config_list_model: 为%{model}配置列
31
+ contains: 包含
32
+ create: 创建
33
+ create_another: 新建 %{model}
34
+ create_apply: 创建并继续
35
+ create_model: 创建 %{model}
36
+ create_new: 新建
37
+ created_model: 已创建 %{model}
38
+ customize: 自定义
39
+ date_picker_options:
40
+ firstDay: '0'
41
+ isRTL: 'false'
42
+ showMonthAfterYear: 'false'
43
+ weekHeader: 周
44
+ datetime_picker_options:
45
+ closeText: 关闭
46
+ currentText: 现在
47
+ timeText: 小时
48
+ timezoneText: 时区
49
+ days: 天
50
+ delete: 删除
51
+ deleted_model: 已删除 %{model}
52
+ deleted_records: 已删除记录列表
53
+ delimiter: 分隔符
54
+ doesnt_begin_with: 不能以……开头
55
+ doesnt_contain: 不能包含
56
+ doesnt_end_with: 不能以……结尾
57
+ download: 下载
58
+ edit: 编辑
59
+ ends_with: 以……结尾
60
+ error_500: (代码 500, 互联网错误)
61
+ errors:
62
+ template:
63
+ body: 以下字段存在问题:
64
+ header:
65
+ other: '%{count} 个错误阻止了这个 %{model} 被保存'
66
+ export: Export
67
+ 'false': 'False'
68
+ filtered: (Filtered)
69
+ found: 发现了
70
+ future: Future
71
+ group_by: Group by
72
+ grouped_by: Grouped by %{column}
73
+ hide: (Hide)
74
+ hours: Hours
75
+ human_conditions:
76
+ association: '%{column} = %{value}'
77
+ boolean: '%{column} = %{value}'
78
+ inplace_edit_handle: --
79
+ internal_error: Request Failed
80
+ live_search: Live Search
81
+ loading: Loading…
82
+ logical_search: Logical Search
83
+ mark_all_records: Mark all
84
+ maximum: Maximum
85
+ minimum: Minimum
86
+ minutes: Minutes
87
+ months: 月
88
+ nested_for_model: '%{nested_model} for %{parent_model}'
89
+ nested_of_model: '%{nested_model} of %{parent_model}'
90
+ next: Next
91
+ next_month: Next Month
92
+ next_week: Next Week
93
+ next_year: Next Year
94
+ no_authorization_for_action: No Authorization for action %{action}
95
+ no_color: No color
96
+ no_entries: No Entries
97
+ no_group: No group
98
+ no_options: no options
99
+ 'null': 'Null'
100
+ omit_header: Omit Header
101
+ optional_attributes: Further Options
102
+ options: Options
103
+ past: Past
104
+ pdf: PDF
105
+ prev_month: Last Month
106
+ prev_week: Last Week
107
+ prev_year: Last Year
108
+ previous: Previous
109
+ print: Print
110
+ range: Range
111
+ record_not_saved: Failed to save record cause of an unknown error
112
+ records_marked:
113
+ other: 1 marked %{model}
114
+ refresh: Refresh
115
+ remove: Remove
116
+ remove_file: Remove or Replace file
117
+ remove_files: Remove or Add files
118
+ replace_existing: Replace Existing
119
+ replace_with_new: Replace With New
120
+ reset: Reset
121
+ revisions_for_model: Revisions for %{model}
122
+ saving: Saving…
123
+ search: Search
124
+ search_terms: Search Terms
125
+ seconds: Seconds
126
+ show: Show
127
+ show_block: (Show)
128
+ show_model: Show %{model}
129
+ sum: Sum
130
+ this_month: This Month
131
+ this_week: This Week
132
+ this_year: This Year
133
+ today: Today
134
+ tomorrow: Tomorrow
135
+ 'true': 'True'
136
+ uncheck_all: Uncheck all
137
+ update: Update
138
+ update_apply: Apply
139
+ update_model: Update %{model}
140
+ updated_model: Updated %{model}
141
+ version_inconsistency: Version inconsistency - this record has been modified
142
+ since you started editing it.
143
+ weeks: Weeks
144
+ years: Years
145
+ yesterday: Yesterday
146
+ not_null: Not Null
147
+ date:
148
+ formats:
149
+ month: '%B'
150
+ quarter: Quarter %{num}
151
+ week: Week %W, %Y
152
+ year_month: '%b %Y'
153
+ year_quarter: Quarter %{quarter} %{year}
154
+ datetime:
155
+ prompts:
156
+ hour: Hour
157
+ microsec: Microsecond
158
+ millisec: Millisecond
159
+ minute: Minute
160
+ second: Second
161
+ time:
162
+ formats:
163
+ picker: '%a, %d %b %Y %H:%M:%S'
@@ -80,7 +80,10 @@ module ActiveScaffold::Actions
80
80
  @form_action = params.delete(:form_action).to_sym
81
81
  end
82
82
  @form_action ||= params[:id] ? :update : :create
83
- @main_columns = active_scaffold_config.send(@form_action).columns
83
+ parent_column = parent_column(main_form_controller, @scope) if @scope && main_form_controller
84
+ subform_columns = (parent_column.form_ui_options || parent_column.options)&.dig(:subform_columns) if parent_column
85
+ action_cfg = active_scaffold_config.send(@form_action)
86
+ @main_columns = subform_columns ? action_cfg.build_action_columns(subform_columns) : action_cfg.columns
84
87
  end
85
88
 
86
89
  def render_field_for_update_columns
@@ -90,7 +93,7 @@ module ActiveScaffold::Actions
90
93
  @columns += [@column.name] if @column.options[:refresh_link] && @columns.exclude?(@column.name)
91
94
  process_render_field_params
92
95
 
93
- @record = find_from_scope(setup_parent, @scope) if main_form_controller && @scope
96
+ @record = find_from_scope(setup_parent, @scope) if @scope && main_form_controller
94
97
  if @column.send_form_on_update_column
95
98
  @record ||= updated_record_with_form(@main_columns, params[:record] || params[:search], @scope)
96
99
  elsif @record
@@ -180,6 +183,34 @@ module ActiveScaffold::Actions
180
183
  copy_attributes(saved_record, record).tap { |new_record| new_record.id = id }
181
184
  end
182
185
 
186
+ def parent_column(parent_controller, scope)
187
+ attrs = params[:record]
188
+ parts = scope[1..-2].split('][')
189
+ columns = parent_controller.active_scaffold_config.columns
190
+ column = nil
191
+
192
+ while parts.present?
193
+ column = columns[parts.shift]
194
+ return unless column&.association
195
+ break if parts.blank?
196
+
197
+ klass =
198
+ if column.association.polymorphic? && attrs
199
+ record = column.active_record_class.new(column.association.foreign_type => attrs[column.association.foreign_type])
200
+ column.association.klass(record)
201
+ else
202
+ column.association.klass
203
+ end
204
+ return unless klass
205
+
206
+ columns = active_scaffold_config_for(klass).columns
207
+ attrs = attrs&.dig(column.name)
208
+ attrs = attrs&.dig(parts.shift) if column.association.collection?
209
+ end
210
+
211
+ column
212
+ end
213
+
183
214
  def find_from_scope(parent, scope)
184
215
  parts = scope[1..-2].split('][')
185
216
  record = parent
@@ -189,7 +220,7 @@ module ActiveScaffold::Actions
189
220
  return unless record.respond_to?(part)
190
221
 
191
222
  association = record.class.reflect_on_association(part)
192
- id = parts.shift.to_i if association&.collection?
223
+ id = association&.collection? ? parts.shift.to_i : nil
193
224
  record = record.send(part)
194
225
  if id
195
226
  record = record.find { |child| child.id == id }
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActiveScaffold
4
+ module Assets
5
+ class CssDepsGenerator
6
+ class << self
7
+ def generate!
8
+ generator = new
9
+ generator.generate!
10
+ end
11
+ end
12
+
13
+ def initialize
14
+ @css_path = Rails.root.join('app/assets/stylesheets/active_scaffold/deps.scss')
15
+ end
16
+
17
+ def generate!
18
+ Rails.logger.info 'ActiveScaffold: Generating deps.css...'
19
+ perform_generation
20
+ end
21
+
22
+ private
23
+
24
+ def perform_generation
25
+ content = ActiveScaffold::Assets.active_scaffold_stylesheets(:deps).map do |sheet|
26
+ "@use '#{sheet}';\n"
27
+ end
28
+ content.unshift("/* File autogenerated by ActiveScaffold, don't modify it */\n\n")
29
+
30
+ # Ensure directory exists
31
+ FileUtils.mkdir_p(File.dirname(@css_path))
32
+
33
+ # Write the processed file
34
+ File.write(@css_path, content.join)
35
+
36
+ Rails.logger.info "✅ ActiveScaffold: deps.css generated at #{@css_path}"
37
+ rescue StandardError => e
38
+ Rails.logger.error "ActiveScaffold: Failed to generate deps.css: #{e.message}"
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,77 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActiveScaffold
4
+ module Assets
5
+ module JqueryUiManifest
6
+ # Full list of jQuery UI dependencies based on jquery-ui-rails structure
7
+ CORE_FILES = [
8
+ ('jquery-ui/core' unless Jquery::Ui::Rails::VERSION >= '8.0.0'),
9
+ 'jquery-ui/version',
10
+ 'jquery-ui/keycode',
11
+ 'jquery-ui/scroll-parent',
12
+ 'jquery-ui/unique-id',
13
+ 'jquery-ui/widget',
14
+ 'jquery-ui/widgets/mouse',
15
+ 'jquery-ui/plugin',
16
+ ('jquery-ui/safe-active-element' unless Jquery::Ui::Rails::VERSION >= '8.0.0'),
17
+ ('jquery-ui/safe-blur' unless Jquery::Ui::Rails::VERSION >= '8.0.0'),
18
+ 'jquery-ui/data',
19
+ 'jquery-ui/disable-selection',
20
+ 'jquery-ui/focusable',
21
+ ('jquery-ui/form' unless Jquery::Ui::Rails::VERSION >= '8.0.0'),
22
+ ('jquery-ui/ie' unless Jquery::Ui::Rails::VERSION >= '8.0.0'),
23
+ 'jquery-ui/labels',
24
+ "jquery-ui/jquery-#{Jquery::Ui::Rails::VERSION >= '7.0.0' ? 'patch' : '1-7'}",
25
+ ('jquery-ui/escape-selector' unless Jquery::Ui::Rails::VERSION >= '7.0.0'),
26
+ 'jquery-ui/tabbable'
27
+ ].compact.freeze
28
+
29
+ WIDGET_FILES = {
30
+ sortable: [
31
+ 'jquery-ui/widgets/sortable'
32
+ ],
33
+ draggable: [
34
+ 'jquery-ui/widgets/draggable'
35
+ ],
36
+ droppable: [
37
+ 'jquery-ui/widgets/droppable'
38
+ ],
39
+ datepicker: [
40
+ 'jquery-ui/widgets/datepicker'
41
+ ]
42
+ # dialog: [
43
+ # 'jquery-ui/position',
44
+ # 'jquery-ui/form-reset-mixin',
45
+ # 'jquery-ui/widgets/controlgroup',
46
+ # 'jquery-ui/widgets/checkboxradio',
47
+ # 'jquery-ui/widgets/button',
48
+ # 'jquery-ui/widgets/resizable',
49
+ # 'jquery-ui/widgets/dialog'
50
+ # ]
51
+ }.freeze
52
+
53
+ EFFECT_FILES = {
54
+ core: [
55
+ ('jquery-ui/jquery-var-for-color' if Jquery::Ui::Rails::VERSION >= '7.0.0'),
56
+ ('jquery-ui/vendor/jquery-color/jquery.color' if Jquery::Ui::Rails::VERSION >= '7.0.0'),
57
+ 'jquery-ui/effect'
58
+ ].compact,
59
+ highlight: ['jquery-ui/effects/effect-highlight']
60
+ }.freeze
61
+
62
+ def self.all_dependencies
63
+ (CORE_FILES +
64
+ WIDGET_FILES.values.flatten +
65
+ EFFECT_FILES.values.flatten).uniq
66
+ end
67
+
68
+ def self.widget_dependencies(widgets)
69
+ deps = CORE_FILES.dup
70
+ Array(widgets).each do |widget|
71
+ deps += WIDGET_FILES[widget.to_sym] if WIDGET_FILES[widget.to_sym]
72
+ end
73
+ deps
74
+ end
75
+ end
76
+ end
77
+ end
@@ -0,0 +1,102 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActiveScaffold
4
+ module Assets
5
+ class JqueryUiThemeGenerator
6
+ class << self
7
+ def generate_if_needed
8
+ return unless jquery_ui_installed?
9
+
10
+ generator = new
11
+ generator.generate_if_needed
12
+ end
13
+
14
+ def generate!(force: false)
15
+ return unless jquery_ui_installed?
16
+
17
+ generator = new
18
+ generator.generate!(force: force)
19
+ end
20
+
21
+ def needs_generation?
22
+ return false unless jquery_ui_installed?
23
+
24
+ generator = new
25
+ generator.needs_generation?
26
+ end
27
+
28
+ private
29
+
30
+ def jquery_ui_installed?
31
+ Gem.loaded_specs['jquery-ui-rails'].present?
32
+ end
33
+ end
34
+
35
+ def initialize
36
+ @jquery_ui_spec = Gem.loaded_specs['jquery-ui-rails']
37
+ @source_path = File.join(@jquery_ui_spec.full_gem_path, 'app/assets/stylesheets/jquery-ui/theme.css.erb')
38
+ @theme_path = Rails.root.join('app/assets/stylesheets/active_scaffold/jquery-ui/theme.css')
39
+ end
40
+
41
+ def generate_if_needed
42
+ return unless source_exists?
43
+
44
+ generate! if needs_generation?
45
+ end
46
+
47
+ def generate!(force: false)
48
+ return unless source_exists?
49
+
50
+ if force || needs_generation?
51
+ Rails.logger.info 'ActiveScaffold: Generating jQuery UI theme...'
52
+ perform_generation
53
+ true
54
+ else
55
+ false
56
+ end
57
+ end
58
+
59
+ def needs_generation?
60
+ return true unless File.exist?(@theme_path)
61
+ return true if source_newer_than_generated?
62
+
63
+ false
64
+ end
65
+
66
+ def source_exists?
67
+ File.exist?(@source_path)
68
+ end
69
+
70
+ private
71
+
72
+ def source_newer_than_generated?
73
+ source_mtime = File.mtime(@source_path)
74
+ theme_mtime = File.mtime(@theme_path)
75
+ source_mtime > theme_mtime
76
+ end
77
+
78
+ def perform_generation
79
+ # Read and process the ERB
80
+ theme_content = File.read(@source_path)
81
+
82
+ # Process asset_path calls
83
+ processed = theme_content.gsub(/<%= image_path\(['"]([^'"]+)['"]\) %>/) do
84
+ "'/assets/#{::Regexp.last_match(1)}'"
85
+ end
86
+
87
+ # Remove any other ERB tags
88
+ processed.gsub!(/<%=.*?%>/, '')
89
+
90
+ # Ensure directory exists
91
+ FileUtils.mkdir_p(File.dirname(@theme_path))
92
+
93
+ # Write the processed file
94
+ File.write(@theme_path, processed)
95
+
96
+ Rails.logger.info "✅ ActiveScaffold: jQuery UI theme generated at #{@theme_path}"
97
+ rescue StandardError => e
98
+ Rails.logger.error "ActiveScaffold: Failed to generate jQuery UI theme: #{e.message}"
99
+ end
100
+ end
101
+ end
102
+ end