inline_forms 1.3.49 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/inline_forms +180 -26
- data/lib/app/helpers/inline_forms_helper.rb +9 -23
- data/lib/app/validators/is_a_curacao_id_number_validator.rb +1 -4
- data/lib/app/views/inline_forms/_new.html.erb +3 -3
- data/lib/app/views/inline_forms/_show.html.erb +3 -3
- data/lib/generators/inline_forms_generator.rb +48 -42
- data/lib/inline_forms.rb +1 -0
- data/lib/inline_forms/version.rb +1 -1
- metadata +2 -4
- data/lib/app/validators/must_be_present_validator.rb +0 -12
- data/lib/app/validators/must_be_unique_validator.rb +0 -9
data/bin/inline_forms
CHANGED
@@ -33,6 +33,8 @@ module InlineForms
|
|
33
33
|
method_option :database, :aliases => "-d", :default => DATABASE_OPTIONS.first, :banner => DATABASE_OPTIONS.join('|'), :desc => 'specify development database'
|
34
34
|
method_option :dry, :type => :boolean, :desc => 'dry run. Do not do most things. Only useful for development of inline_forms'
|
35
35
|
method_option :example, :type => :boolean, :desc => 'install the example app. incompatible with --dry and uses sqlite as development database'
|
36
|
+
method_option :email, :aliases => "-e", :default => "admin@example.com", :desc => 'specify admin email'
|
37
|
+
method_option :password, :aliases => "-p", :default => "admin999", :desc => 'specify admin password'
|
36
38
|
|
37
39
|
def create(app_name)
|
38
40
|
|
@@ -44,14 +46,28 @@ module InlineForms
|
|
44
46
|
options[:example]
|
45
47
|
end
|
46
48
|
|
47
|
-
|
49
|
+
def self.database
|
50
|
+
DATABASE_OPTIONS.include?(options[:database]) ? options[:database] : 'sqlite'
|
51
|
+
end
|
52
|
+
|
53
|
+
def self.using_sqlite?
|
54
|
+
database == 'sqlite'
|
55
|
+
end
|
56
|
+
|
57
|
+
def self.email
|
58
|
+
options[:email]
|
59
|
+
end
|
60
|
+
|
61
|
+
def self.password
|
62
|
+
options[:password]
|
63
|
+
end
|
48
64
|
|
49
65
|
if install_example? && dry_run?
|
50
66
|
say "--example and --dry-run can not be used together", :red
|
51
67
|
exit 1
|
52
68
|
end
|
53
69
|
|
54
|
-
if install_example? &&
|
70
|
+
if install_example? && !using_sqlite?
|
55
71
|
say "--example can only be used with an sqlite development database", :red
|
56
72
|
exit 1
|
57
73
|
end
|
@@ -110,10 +126,12 @@ module InlineForms
|
|
110
126
|
gem 'devise'
|
111
127
|
gem 'cancan'
|
112
128
|
gem 'inline_forms'
|
129
|
+
gem 'validation_hints'
|
113
130
|
gem 'mini_magick'
|
114
131
|
gem 'jquery_datepicker'
|
115
132
|
gem 'yaml_db'
|
116
133
|
gem 'rails-i18n'
|
134
|
+
gem 'i18n-active_record', :git => 'git://github.com/acesuares/i18n-active_record.git'
|
117
135
|
gem 'unicorn'
|
118
136
|
gem 'rvm'
|
119
137
|
gem 'rvm-capistrano'
|
@@ -141,22 +159,22 @@ module InlineForms
|
|
141
159
|
|
142
160
|
say "- Database setup: creating config/database.yml with development database #{database}"
|
143
161
|
remove_file "#{app_name}/config/database.yml" # the one that 'rails new' created
|
144
|
-
if
|
162
|
+
if using_sqlite?
|
145
163
|
create_file "#{app_name}/config/database.yml", <<-END_DATABASEYML.strip_heredoc_with_indent
|
146
164
|
development:
|
147
|
-
adapter:
|
148
|
-
database:
|
149
|
-
|
150
|
-
|
165
|
+
adapter: sqlite3
|
166
|
+
database: db/development.sqlite3
|
167
|
+
pool: 5
|
168
|
+
timeout: 5000
|
151
169
|
|
152
170
|
END_DATABASEYML
|
153
171
|
else
|
154
172
|
create_file "#{app_name}/config/database.yml", <<-END_DATABASEYML.strip_heredoc_with_indent
|
155
173
|
development:
|
156
|
-
adapter:
|
157
|
-
database:
|
158
|
-
|
159
|
-
|
174
|
+
adapter: mysql2
|
175
|
+
database: #{app_name}_dev
|
176
|
+
username: #{app_name}
|
177
|
+
password: #{app_name}
|
160
178
|
|
161
179
|
END_DATABASEYML
|
162
180
|
end
|
@@ -171,8 +189,88 @@ module InlineForms
|
|
171
189
|
say "- Devise install..."
|
172
190
|
RVM.run "bundle exec rails g devise:install" unless dry_run?
|
173
191
|
|
174
|
-
say "- Devise User model install with added name field..."
|
175
|
-
RVM.run "bundle exec rails g devise User name:string" unless dry_run?
|
192
|
+
say "- Devise User model install with added name and locale field..."
|
193
|
+
RVM.run "bundle exec rails g devise User name:string locale:string" unless dry_run?
|
194
|
+
|
195
|
+
say "- Replace Devise route and add path_prefix..."
|
196
|
+
gsub_file "#{app_name}/config/routes.rb", /devise_for :users/, "devise_for :users, :path_prefix => 'auth'"
|
197
|
+
insert_into_file "#{app_name}/config/routes.rb", <<-ROUTE.strip_heredoc_with_indent(2), :after => "devise_for :users, :path_prefix => 'auth'\n"
|
198
|
+
resources :users do
|
199
|
+
post 'revert', :on => :member
|
200
|
+
end
|
201
|
+
ROUTE
|
202
|
+
|
203
|
+
say "- Create User Controller..."
|
204
|
+
create_file "#{app_name}/app/controllers/users_controller.rb", <<-USERS_CONTROLLER.strip_heredoc_with_indent
|
205
|
+
class UsersController < InlineFormsController
|
206
|
+
set_tab :user
|
207
|
+
end
|
208
|
+
USERS_CONTROLLER
|
209
|
+
|
210
|
+
say "- Recreate User Model..."
|
211
|
+
remove_file "#{app_name}/app/models/user.rb" # the one that 'devise:install' created
|
212
|
+
create_file "#{app_name}/app/models/user.rb", <<-USER_MODEL.strip_heredoc_with_indent
|
213
|
+
class User < ActiveRecord::Base
|
214
|
+
|
215
|
+
# devise options
|
216
|
+
devise :database_authenticatable
|
217
|
+
# devise :registerable # uncomment this if you want people to be able to register
|
218
|
+
devise :recoverable
|
219
|
+
devise :rememberable
|
220
|
+
devise :trackable
|
221
|
+
devise :validatable
|
222
|
+
# devise :token_authenticatable
|
223
|
+
# devise :confirmable,
|
224
|
+
# devise :lockable
|
225
|
+
# devise :timeoutable
|
226
|
+
# devise :omniauthable
|
227
|
+
|
228
|
+
# Setup accessible (or protected) attributes for your model
|
229
|
+
attr_accessible :email, :password, :password_confirmation, :remember_me, :name, :locale
|
230
|
+
attr_writer :inline_forms_attribute_list
|
231
|
+
|
232
|
+
# validations
|
233
|
+
validates :name, :must_be_present => true
|
234
|
+
|
235
|
+
# pagination
|
236
|
+
attr_reader :per_page
|
237
|
+
@per_page = 7
|
238
|
+
|
239
|
+
has_paper_trail
|
240
|
+
|
241
|
+
def _presentation
|
242
|
+
"\#{name}"
|
243
|
+
end
|
244
|
+
|
245
|
+
def inline_forms_attribute_list
|
246
|
+
@inline_forms_attribute_list ||= [
|
247
|
+
[ :name , 'name', :text_field ],
|
248
|
+
[ :email , 'email', :text_field ],
|
249
|
+
[ :password , 'Nieuw wachtwoord', :devise_password_field ],
|
250
|
+
[ :encrypted_password , 'encrypted_password', :info ],
|
251
|
+
[ :reset_password_token , 'reset_password_token', :info ],
|
252
|
+
[ :reset_password_sent_at , 'reset_password_sent_at', :info],
|
253
|
+
[ :remember_created_at , 'remember_created_at', :info ],
|
254
|
+
[ :sign_in_count , 'sign_in_count', :info ],
|
255
|
+
[ :current_sign_in_at , 'current_sign_in_at', :info ],
|
256
|
+
[ :last_sign_in_at , 'last_sign_in_at', :info ],
|
257
|
+
[ :current_sign_in_ip , 'current_sign_in_ip', :info ],
|
258
|
+
[ :last_sign_in_ip , 'last_sign_in_ip', :info ],
|
259
|
+
[ :created_at , 'created_at', :info ],
|
260
|
+
[ :updated_at , 'updated_at', :info ],
|
261
|
+
]
|
262
|
+
end
|
263
|
+
|
264
|
+
def self.not_accessible_through_html?
|
265
|
+
false
|
266
|
+
end
|
267
|
+
|
268
|
+
def self.order_by_clause
|
269
|
+
'name'
|
270
|
+
end
|
271
|
+
|
272
|
+
end
|
273
|
+
USER_MODEL
|
176
274
|
|
177
275
|
say "- Install ckeditor..."
|
178
276
|
RVM.run "bundle exec rails g ckeditor:install" unless dry_run?
|
@@ -187,8 +285,45 @@ module InlineForms
|
|
187
285
|
say "- Paper_trail install..."
|
188
286
|
RVM.run "bundle exec rails g paper_trail:install" unless dry_run?
|
189
287
|
|
190
|
-
say "-
|
191
|
-
RVM.run
|
288
|
+
say "- Generate models and tables and views for translations..."
|
289
|
+
RVM.run 'rails g inline_forms InlineFormsLocale name:string inline_forms_translations:belongs_to _enabled:yes _presentation:\'#{name}\''
|
290
|
+
RVM.run 'rails g inline_forms InlineFormsKey name:string inline_forms_translations:has_many inline_forms_translations:associated _enabled:yes _presentation:\'#{name}\''
|
291
|
+
RVM.run 'rails g inline_forms InlineFormsTranslation inline_forms_key:belongs_to inline_forms_locale:dropdown value:text interpolations:text is_proc:boolean _presentation:\'#{value}\''
|
292
|
+
|
293
|
+
sleep 1 # to get unique migration number
|
294
|
+
create_file "#{app_name}/db/migrate/" +
|
295
|
+
Time.now.utc.strftime("%Y%m%d%H%M%S") +
|
296
|
+
"_" +
|
297
|
+
"inline_forms_create_view_for_translations.rb", <<-VIEW_MIGRATION.strip_heredoc_with_indent
|
298
|
+
class InlineFormsCreateViewForTranslations < ActiveRecord::Migration
|
299
|
+
|
300
|
+
def self.up
|
301
|
+
execute 'CREATE VIEW translations
|
302
|
+
AS
|
303
|
+
SELECT L.name AS locale,
|
304
|
+
K.name AS thekey,
|
305
|
+
T.value AS value,
|
306
|
+
T.interpolations AS interpolations,
|
307
|
+
T.is_proc AS is_proc
|
308
|
+
FROM inline_forms_keys K, inline_forms_locales L, inline_forms_translations T
|
309
|
+
WHERE T.inline_forms_key_id = K.id AND T.inline_forms_locale_id = L.id '
|
310
|
+
end
|
311
|
+
|
312
|
+
def self.down
|
313
|
+
execute 'DROP VIEW translations'
|
314
|
+
end
|
315
|
+
|
316
|
+
end
|
317
|
+
VIEW_MIGRATION
|
318
|
+
|
319
|
+
say "- Migrating Database"
|
320
|
+
RVM.run "bundle exec rake db:migrate" unless (dry_run? || !using_sqlite?)
|
321
|
+
|
322
|
+
say "- Adding admin user with email: #{email}, password: #{password} to seeds.rb"
|
323
|
+
append_to_file "#{app_name}/db/seeds.rb", "User.new({ :email => '#{email}', :name => 'Admin', :password => '#{password}', :password_confirmation => '#{password}'}).save"
|
324
|
+
|
325
|
+
say "- Seeding the database"
|
326
|
+
RVM.run "bundle exec rake db:seed" unless (dry_run? || !using_sqlite?)
|
192
327
|
|
193
328
|
say "- Creating header in app/views/inline_forms/_header.html.erb..."
|
194
329
|
create_file "#{app_name}/app/views/inline_forms/_header.html.erb", <<-END_HEADER.strip_heredoc_with_indent
|
@@ -218,19 +353,43 @@ module InlineForms
|
|
218
353
|
end
|
219
354
|
END_APPHELPER
|
220
355
|
|
221
|
-
say "- Recreating ApplicationController to add devise
|
356
|
+
say "- Recreating ApplicationController to add devise, cancan, I18n stuff..."
|
222
357
|
remove_file "#{app_name}/app/controllers/application_controller.rb" # the one that 'rails new' created
|
223
358
|
create_file "#{app_name}/app/controllers/application_controller.rb", <<-END_APPCONTROLLER.strip_heredoc_with_indent
|
224
|
-
class ApplicationController <
|
359
|
+
class ApplicationController < InlineFormsApplicationController
|
225
360
|
protect_from_forgery
|
226
361
|
|
227
|
-
#
|
228
|
-
|
362
|
+
# Uncomment next two lines if you want Devise authentication
|
363
|
+
before_filter :authenticate_user!
|
364
|
+
layout 'devise' if :devise_controller?
|
229
365
|
|
366
|
+
# Uncomment next 6 lines if you want CanCan authorization
|
367
|
+
# check_authorization :unless => :devise_controller?
|
368
|
+
#
|
230
369
|
# rescue_from CanCan::AccessDenied do |exception|
|
231
370
|
# sign_out :user if user_signed_in?
|
232
371
|
# redirect_to new_user_session_path, :alert => exception.message
|
233
372
|
# end
|
373
|
+
|
374
|
+
# Uncomment next line if you want I18n
|
375
|
+
# before_filter :set_locale
|
376
|
+
|
377
|
+
# Uncomment next line and specify default locale
|
378
|
+
# I18n.default_locale = :en
|
379
|
+
|
380
|
+
# Uncomment next line and specify available locales
|
381
|
+
# I18n.available_locales = [ :en, :nl, :pp ]
|
382
|
+
|
383
|
+
# Uncomment next nine line if you want locale based on subdomain, like 'it.example.com, de.example.com'
|
384
|
+
# def set_locale
|
385
|
+
# I18n.locale = extract_locale_from_subdomain || I18n.default_locale
|
386
|
+
# end
|
387
|
+
#
|
388
|
+
# def extract_locale_from_subdomain
|
389
|
+
# locale = request.subdomains.first
|
390
|
+
# return nil if locale.nil?
|
391
|
+
# I18n.available_locales.include?(locale.to_sym) ? locale.to_s : nil
|
392
|
+
# end
|
234
393
|
end
|
235
394
|
END_APPCONTROLLER
|
236
395
|
|
@@ -257,14 +416,9 @@ module InlineForms
|
|
257
416
|
|
258
417
|
DEVISE_MAILER_STUFF
|
259
418
|
|
260
|
-
say "- Setting config.assets.compile to true in environments/production.rb..."
|
419
|
+
say "- Setting config.assets.compile to true in environments/production.rb (needed for ckeditor)..."
|
261
420
|
insert_into_file "#{app_name}/config/environments/production.rb", " config.assets.compile = false\n", :before => "end\n" if dry_run?
|
262
|
-
|
263
|
-
# Fallback to assets pipeline if a precompiled asset is missed, we need this for ckeditor
|
264
|
-
config.assets.compile = true
|
265
|
-
COMPILE_ASSETS
|
266
|
-
|
267
|
-
comment_lines "#{app_name}/config/environments/production.rb", /config\.assets\.compile = false/
|
421
|
+
gsub_file "#{app_name}/config/environments/production.rb", /config.assets.compile = false/, "config.assets.compile = true"
|
268
422
|
|
269
423
|
say "- Capify..."
|
270
424
|
RVM.run 'capify .'
|
@@ -11,25 +11,11 @@ module InlineFormsHelper
|
|
11
11
|
def inline_forms_version
|
12
12
|
InlineForms::VERSION
|
13
13
|
end
|
14
|
-
private
|
15
|
-
|
16
|
-
# used as class name
|
17
|
-
def has_validations(object, attribute)
|
18
|
-
not object.class.validators_on(attribute).empty?
|
19
|
-
end
|
20
14
|
|
21
|
-
|
22
|
-
"" and return unless has_validations(object, attribute)
|
23
|
-
content_tag(:ul, validation_help_for(object, attribute).map { |help_message| content_tag(:li, help_message ) }.to_s.html_safe )
|
24
|
-
end
|
15
|
+
private
|
25
16
|
|
26
|
-
|
27
|
-
|
28
|
-
def validation_help_for(object, attribute)
|
29
|
-
"" and return unless has_validations(object, attribute)
|
30
|
-
object.class.validators_on(attribute).map do |v|
|
31
|
-
t("inline_forms.validators.help.#{ActiveModel::Name.new(v.class).i18n_key.to_s.gsub(/active_model\/validations\//, '')}")
|
32
|
-
end.compact
|
17
|
+
def validation_hints_as_list_for(object, attribute)
|
18
|
+
object.has_validations? ? content_tag(:ul, object.hints.full_messages_for(attribute).map { |m| content_tag(:li, m ) }.join.html_safe ) : ""
|
33
19
|
end
|
34
20
|
|
35
21
|
# close link
|
@@ -58,10 +44,10 @@ module InlineFormsHelper
|
|
58
44
|
end
|
59
45
|
end
|
60
46
|
|
61
|
-
# # undo link
|
62
|
-
# def link_to_undo_destroy(object, update_span )
|
63
|
-
# link_to(t('inline_forms.view.undo'), revert_version_path(object.versions.scoped.last), :method => :post)
|
64
|
-
# end
|
47
|
+
# # undo link
|
48
|
+
# def link_to_undo_destroy(object, update_span )
|
49
|
+
# link_to(t('inline_forms.view.undo'), revert_version_path(object.versions.scoped.last), :method => :post)
|
50
|
+
# end
|
65
51
|
|
66
52
|
# link_to_inline_edit
|
67
53
|
def link_to_inline_edit(object, attribute, attribute_value='')
|
@@ -121,8 +107,8 @@ module InlineFormsHelper
|
|
121
107
|
|
122
108
|
def translated_attribute(object,attribute)
|
123
109
|
t("activerecord.attributes.#{object.class.name.underscore}.#{attribute}")
|
124
|
-
# "activerecord.attributes.#{attribute}",
|
125
|
-
# "attributes.#{attribute}" ] )
|
110
|
+
# "activerecord.attributes.#{attribute}",
|
111
|
+
# "attributes.#{attribute}" ] )
|
126
112
|
end
|
127
113
|
|
128
114
|
# get the values for an attribute
|
@@ -1,8 +1,5 @@
|
|
1
1
|
# -*- encoding : utf-8 -*-
|
2
|
-
|
3
|
-
# in your model, add:
|
4
|
-
# validates :id_number, must_be_present => true, is_a_curacao_id_number => true;
|
5
|
-
class IsACuracaoIdNumberValidator < ActiveModel::EachValidator
|
2
|
+
class IsACuracaoIdNumberValidator < InlineFormsValidator
|
6
3
|
|
7
4
|
def validate_each(record, attribute, value)
|
8
5
|
if value =~ /^[0-9]{10}$/
|
@@ -30,13 +30,13 @@
|
|
30
30
|
<% css_class_id = "attribute_#{attribute}_#{@object.id}" -%>
|
31
31
|
<tr>
|
32
32
|
<td valign="top">
|
33
|
-
<div class='<%=
|
33
|
+
<div class='<%= 'has_validations ' if @object.has_validations_for?(attribute) -%><%= "attribute_name attribute_#{attribute} form_element_#{form_element}" -%>' >
|
34
34
|
<%= translated_attribute(@object, attribute) -%>
|
35
35
|
</div>
|
36
|
-
<% if
|
36
|
+
<% if @object.has_validations_for?(attribute) %>
|
37
37
|
<div class='validation_help_tooltip'>
|
38
38
|
<div class='validation_help_content'>
|
39
|
-
<%=
|
39
|
+
<%= validation_hints_as_list_for(@object, attribute) -%>
|
40
40
|
</div>
|
41
41
|
</div>
|
42
42
|
<% end -%>
|
@@ -16,13 +16,13 @@
|
|
16
16
|
<% css_class_id = "#{@object.class.name.underscore}_#{@object.id}_#{attribute}" -%>
|
17
17
|
<tr>
|
18
18
|
<td valign="top">
|
19
|
-
<div class='<%=
|
19
|
+
<div class='<%= 'has_validations ' if @object.has_validations_for?(attribute) -%><%= "attribute_name attribute_#{attribute} form_element_#{form_element}" -%>' >
|
20
20
|
<%= translated_attribute(@object, attribute) -%>
|
21
21
|
</div>
|
22
|
-
<% if
|
22
|
+
<% if @object.has_validations_for?(attribute) %>
|
23
23
|
<div class='validation_help_tooltip'>
|
24
24
|
<div class='validation_help_content'>
|
25
|
-
<%=
|
25
|
+
<%= validation_hints_as_list_for(@object, attribute) -%>
|
26
26
|
</div>
|
27
27
|
</div>
|
28
28
|
<% end -%>
|
@@ -54,18 +54,18 @@ module InlineForms
|
|
54
54
|
|
55
55
|
def migration?
|
56
56
|
not ( column_type == :no_migration ||
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
57
|
+
name == "_presentation" ||
|
58
|
+
name == "_order" ||
|
59
|
+
name == "_enabled" ||
|
60
|
+
name == "_id" )
|
61
61
|
end
|
62
62
|
|
63
63
|
def attribute?
|
64
64
|
not ( name == '_presentation' ||
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
65
|
+
name == '_order' ||
|
66
|
+
name == '_enabled' ||
|
67
|
+
name == "_id" ||
|
68
|
+
relation? )
|
69
69
|
end
|
70
70
|
|
71
71
|
|
@@ -100,9 +100,9 @@ module InlineForms
|
|
100
100
|
@presentation = "\n"
|
101
101
|
@order = "\n"
|
102
102
|
@order_by_clause = " def self.order_by_clause\n" +
|
103
|
-
|
104
|
-
|
105
|
-
|
103
|
+
" \"name\"\n" +
|
104
|
+
" end\n" +
|
105
|
+
"\n"
|
106
106
|
@carrierwave_mounters = "\n"
|
107
107
|
@inline_forms_attribute_list = String.new
|
108
108
|
|
@@ -115,7 +115,7 @@ module InlineForms
|
|
115
115
|
@carrierwave_mounters << ' mount_uploader :' + attribute.name + ', ' + "#{attribute.name}_uploader".camelcase + "\n"
|
116
116
|
end
|
117
117
|
if attribute.type == :has_many ||
|
118
|
-
|
118
|
+
attribute.type == :has_many_destroy
|
119
119
|
@has_many << ' has_many :' + attribute.name
|
120
120
|
@has_many << ', :dependent => :destroy' if attribute.type == :has_many_destroy
|
121
121
|
@has_many << "\n"
|
@@ -124,51 +124,57 @@ module InlineForms
|
|
124
124
|
@has_one << ' has_one :' + attribute.name + "\n"
|
125
125
|
end
|
126
126
|
if attribute.type == :habtm ||
|
127
|
-
|
128
|
-
|
127
|
+
attribute.type == :has_and_belongs_to_many ||
|
128
|
+
attribute.type == :check_list
|
129
129
|
@habtm << ' has_and_belongs_to_many :' + attribute.name + "\n"
|
130
130
|
end
|
131
131
|
if attribute.name == '_presentation'
|
132
132
|
@presentation << " def _presentation\n" +
|
133
|
-
|
134
|
-
|
135
|
-
|
133
|
+
" \"#{attribute.type.to_s}\"\n" +
|
134
|
+
" end\n" +
|
135
|
+
"\n"
|
136
136
|
end
|
137
137
|
if attribute.name == '_order'
|
138
138
|
@order << " def <=>(other)\n" +
|
139
|
-
|
140
|
-
|
141
|
-
|
139
|
+
" self.#{attribute.type} <=> other.#{attribute.type}\n" +
|
140
|
+
" end\n" +
|
141
|
+
"\n"
|
142
142
|
@order_by_clause = " def self.order_by_clause\n" +
|
143
|
-
|
144
|
-
|
145
|
-
|
143
|
+
" \"#{attribute.type}\"\n" +
|
144
|
+
" end\n" +
|
145
|
+
"\n"
|
146
146
|
end
|
147
147
|
if attribute.attribute?
|
148
148
|
attribute.attribute_type == :unknown ? commenter = '#' : commenter = ' '
|
149
149
|
@inline_forms_attribute_list << commenter +
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
150
|
+
' [ :' +
|
151
|
+
attribute.name +
|
152
|
+
' , "' + attribute.name +
|
153
|
+
'", :' + attribute.attribute_type.to_s +
|
154
|
+
" ], \n"
|
155
155
|
end
|
156
156
|
end
|
157
157
|
unless @inline_forms_attribute_list.empty?
|
158
158
|
@inline_forms_attribute_list = "\n" +
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
159
|
+
" def inline_forms_attribute_list\n" +
|
160
|
+
" @inline_forms_attribute_list ||= [\n" +
|
161
|
+
@inline_forms_attribute_list +
|
162
|
+
" ]\n" +
|
163
|
+
" end\n" +
|
164
|
+
"\n"
|
165
165
|
end
|
166
166
|
template "model.erb", "app/models/#{model_file_name}.rb"
|
167
167
|
end
|
168
168
|
end
|
169
169
|
|
170
170
|
def generate_resource_route
|
171
|
-
|
171
|
+
if @flag_create_resource_route
|
172
|
+
route <<-ROUTE.strip_heredoc
|
173
|
+
resources :#{resource_name} do
|
174
|
+
post 'revert', :on => :member
|
175
|
+
end
|
176
|
+
ROUTE
|
177
|
+
end
|
172
178
|
end
|
173
179
|
|
174
180
|
def generate_migration
|
@@ -185,11 +191,11 @@ module InlineForms
|
|
185
191
|
if attribute.migration?
|
186
192
|
attribute.attribute_type == :unknown ? commenter = '#' : commenter = ' '
|
187
193
|
@columns << commenter +
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
194
|
+
' t.' +
|
195
|
+
attribute.column_type.to_s +
|
196
|
+
" :" +
|
197
|
+
attribute.name +
|
198
|
+
" \n"
|
193
199
|
end
|
194
200
|
end
|
195
201
|
end
|
@@ -201,8 +207,8 @@ module InlineForms
|
|
201
207
|
unless @flag_not_accessible_through_html
|
202
208
|
copy_file "_inline_forms_tabs.html.erb", "app/views/_inline_forms_tabs.html.erb" unless File.exists?('app/views/_inline_forms_tabs.html.erb')
|
203
209
|
inject_into_file "app/views/_inline_forms_tabs.html.erb",
|
204
|
-
|
205
|
-
|
210
|
+
" <%= tab.#{name.underscore} '#{name}', #{name.pluralize.underscore + '_path'} %>\n",
|
211
|
+
:after => "<%= tabs_tag :open_tabs => { :id => \"tabs\" } do |tab| %>\n"
|
206
212
|
end
|
207
213
|
end
|
208
214
|
|
data/lib/inline_forms.rb
CHANGED
@@ -143,6 +143,7 @@ module InlineForms
|
|
143
143
|
paths["app/models"] << "lib/app/models"
|
144
144
|
paths["app/views"] << "lib/app/views"
|
145
145
|
paths["app/assets"] << "lib/app/assets"
|
146
|
+
|
146
147
|
I18n.load_path << Dir[File.join(File.expand_path(File.dirname(__FILE__) + '/locales'), '*.yml')]
|
147
148
|
I18n.load_path.flatten!
|
148
149
|
end
|
data/lib/inline_forms/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: inline_forms
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-07-
|
12
|
+
date: 2012-07-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rvm
|
@@ -218,8 +218,6 @@ files:
|
|
218
218
|
- lib/app/validators/is_curacao_phone_validator.rb
|
219
219
|
- lib/app/validators/is_email_address_validator.rb
|
220
220
|
- lib/app/validators/must_be_a_value_validator.rb
|
221
|
-
- lib/app/validators/must_be_present_validator.rb
|
222
|
-
- lib/app/validators/must_be_unique_validator.rb
|
223
221
|
- lib/app/views/devise/confirmations/new.html.erb
|
224
222
|
- lib/app/views/devise/mailer/confirmation_instructions.html.erb
|
225
223
|
- lib/app/views/devise/mailer/reset_password_instructions.html.erb
|