inline_forms 2.23 → 3.0
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.
- checksums.yaml +9 -9
- data/.gitignore +5 -0
- data/bin/inline_forms +41 -414
- data/bin/inline_forms_app_template.rb +16 -0
- data/bin/inline_forms_installer_core.rb +423 -0
- data/lib/app/assets/javascripts/inline_forms.js +12 -32
- data/lib/app/assets/javascripts/inline_forms_application.js +7 -1
- data/lib/app/assets/stylesheets/inline_forms.css +5 -399
- data/lib/app/assets/stylesheets/inline_forms_application.css +3 -3
- data/lib/app/controllers/inline_forms_application_controller.rb +1 -2
- data/lib/app/controllers/inline_forms_controller.rb +2 -2
- data/lib/app/helpers/form_elements/check_list.rb +7 -14
- data/lib/app/helpers/form_elements/date.rb +3 -8
- data/lib/app/helpers/form_elements/decimal_field.rb +15 -0
- data/lib/app/helpers/form_elements/dropdown.rb +1 -1
- data/lib/app/helpers/form_elements/dropdown_with_other.rb +153 -0
- data/lib/app/helpers/form_elements/dropdown_with_values.rb +1 -1
- data/lib/app/helpers/form_elements/info_list.rb +22 -0
- data/lib/app/helpers/form_elements/integer_field.rb +15 -0
- data/lib/app/helpers/form_elements/kansen_slider.rb +89 -0
- data/lib/app/helpers/form_elements/month_year_picker.rb +33 -0
- data/lib/app/helpers/form_elements/move.rb +17 -0
- data/lib/app/helpers/form_elements/plain_text_area.rb +1 -1
- data/lib/app/helpers/form_elements/radio_button.rb +5 -6
- data/lib/app/helpers/form_elements/slider_with_values.rb +1 -1
- data/lib/app/helpers/form_elements/text_area.rb +12 -10
- data/lib/app/helpers/form_elements/text_area_without_ckeditor.rb +1 -1
- data/lib/app/helpers/form_elements/text_field.rb +2 -2
- data/lib/app/helpers/inline_forms_helper.rb +32 -37
- data/lib/app/views/inline_forms/_close.html.erb +12 -2
- data/lib/app/views/inline_forms/_edit.html.erb +54 -21
- data/lib/app/views/inline_forms/_flash.html.erb +13 -0
- data/lib/app/views/inline_forms/_list.html.erb +28 -24
- data/lib/app/views/inline_forms/_new.html.erb +52 -60
- data/lib/app/views/inline_forms/_new_nested.html.erb +43 -0
- data/lib/app/views/inline_forms/_show.html.erb +83 -39
- data/lib/app/views/inline_forms/_tree.html.erb +46 -0
- data/lib/app/views/layouts/devise.html.erb +4 -14
- data/lib/app/views/layouts/inline_forms.html.erb +15 -23
- data/lib/inline_forms/version.rb +1 -1
- metadata +17 -13
- data/lib/app/assets/images/add.png +0 -0
- data/lib/app/assets/images/close.png +0 -0
- data/lib/app/assets/images/tooltip-bubble-down-left.png +0 -0
- data/lib/app/assets/images/tooltip-bubble-down-right.png +0 -0
- data/lib/app/assets/images/tooltip-bubble-up-left.png +0 -0
- data/lib/app/assets/images/tooltip-bubble-up-right.png +0 -0
- data/lib/app/assets/images/trash.png +0 -0
- data/lib/app/assets/javascripts/jquery.qtip.js +0 -3395
- data/lib/app/assets/stylesheets/jquery.qtip.css +0 -567
- data/lib/app/views/inline_forms/_header.html.erb +0 -1
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'rvm'
|
2
|
+
|
3
|
+
if RVM.current && ENV['skiprvm'] !='true'
|
4
|
+
rvm_version = "#{ENV['ruby_version']}@#{app_name}"
|
5
|
+
RVM.chdir "../#{app_name}" do
|
6
|
+
say "Working directory is #{`pwd`}"
|
7
|
+
RVM.use_from_path! '.'
|
8
|
+
rvm_gemset = %x[rvm current]
|
9
|
+
say "RVM GEMSET is now #{rvm_gemset}"
|
10
|
+
say "Installing using gemset : #{RVM.current}", :green
|
11
|
+
end
|
12
|
+
else
|
13
|
+
say "Installing without RVM", :green
|
14
|
+
end
|
15
|
+
|
16
|
+
apply(File.join(File.dirname(__FILE__), 'inline_forms_installer_core.rb'))
|
@@ -0,0 +1,423 @@
|
|
1
|
+
create_file 'Gemfile', '# created by inline_forms\n' # TODO include version
|
2
|
+
|
3
|
+
add_source 'https://rubygems.org'
|
4
|
+
|
5
|
+
gem 'rails', '3.2.12'
|
6
|
+
gem 'rake', '10.0.4'
|
7
|
+
gem 'jquery-rails', '~> 2.3.0'
|
8
|
+
gem 'jquery-ui-sass-rails'
|
9
|
+
gem 'capistrano'
|
10
|
+
gem 'will_paginate', :git => 'git://github.com/acesuares/will_paginate.git'
|
11
|
+
gem 'tabs_on_rails', :git => 'git://github.com/acesuares/tabs_on_rails.git', :branch => 'update_remote'
|
12
|
+
gem 'ckeditor'
|
13
|
+
gem 'cancan', :git => 'git://github.com/acesuares/cancan.git', :branch => '2.0'
|
14
|
+
gem 'carrierwave'
|
15
|
+
gem 'remotipart', '~> 1.0'
|
16
|
+
gem 'paper_trail'
|
17
|
+
gem 'devise'
|
18
|
+
gem 'inline_forms', '~> 3.0'
|
19
|
+
gem 'validation_hints'
|
20
|
+
gem 'mini_magick'
|
21
|
+
gem 'rails-i18n'
|
22
|
+
gem 'i18n-active_record', :git => 'git://github.com/acesuares/i18n-active_record.git'
|
23
|
+
gem 'unicorn'
|
24
|
+
gem 'rvm'
|
25
|
+
gem 'rvm-capistrano'
|
26
|
+
gem 'foundation-rails'
|
27
|
+
gem 'foundation-icons-sass-rails'
|
28
|
+
gem 'mysql2'
|
29
|
+
|
30
|
+
gem_group :development do
|
31
|
+
gem 'yaml_db'
|
32
|
+
gem 'seed_dump', git: 'git://github.com/acesuares/seed_dump.git'
|
33
|
+
gem 'switch_user'
|
34
|
+
|
35
|
+
gem "sqlite3"
|
36
|
+
|
37
|
+
gem "rspec-rails"
|
38
|
+
gem "shoulda", ">= 0"
|
39
|
+
gem "bundler"
|
40
|
+
gem "jeweler"
|
41
|
+
gem "capybara"
|
42
|
+
gem "factory_girl"
|
43
|
+
gem "factory_girl_rails"
|
44
|
+
gem "rspec"
|
45
|
+
end
|
46
|
+
|
47
|
+
gem_group :production do
|
48
|
+
gem 'therubyracer'
|
49
|
+
gem 'uglifier', '>= 1.0.3'
|
50
|
+
end
|
51
|
+
|
52
|
+
gem_group :assets do
|
53
|
+
gem 'sass-rails', '~> 3.2.3'
|
54
|
+
gem 'coffee-rails', '~> 3.2.1'
|
55
|
+
gem 'compass-rails' # you need this or you get an err
|
56
|
+
end
|
57
|
+
|
58
|
+
say "- Running bundle..."
|
59
|
+
run "bundle install"
|
60
|
+
|
61
|
+
say "- Database setup: creating config/database.yml with development database #{ENV['database']}"
|
62
|
+
remove_file "config/database.yml" # the one that 'rails _3.2.13_ new' created
|
63
|
+
if ENV['using_sqlite'] == 'true'
|
64
|
+
create_file "config/database.yml", <<-END_DATABASEYML.strip_heredoc
|
65
|
+
development:
|
66
|
+
adapter: sqlite3
|
67
|
+
database: db/development.sqlite3
|
68
|
+
pool: 5
|
69
|
+
timeout: 5000
|
70
|
+
|
71
|
+
END_DATABASEYML
|
72
|
+
else
|
73
|
+
create_file "config/database.yml", <<-END_DATABASEYML.strip_heredoc
|
74
|
+
development:
|
75
|
+
adapter: mysql2
|
76
|
+
database: #{app_name}_dev
|
77
|
+
username: #{app_name}
|
78
|
+
password: #{app_name}
|
79
|
+
|
80
|
+
END_DATABASEYML
|
81
|
+
end
|
82
|
+
append_file "config/database.yml", <<-END_DATABASEYML.strip_heredoc
|
83
|
+
production:
|
84
|
+
adapter: mysql2
|
85
|
+
database: #{app_name}_prod
|
86
|
+
username: #{app_name}
|
87
|
+
password: #{app_name}444
|
88
|
+
END_DATABASEYML
|
89
|
+
|
90
|
+
say "- Devise install..."
|
91
|
+
run "bundle exec rails g devise:install"
|
92
|
+
|
93
|
+
say "- Devise User model install with added name and locale field..."
|
94
|
+
run "bundle exec rails g devise User name:string locale:string"
|
95
|
+
|
96
|
+
say "- Replace Devise route and add path_prefix..."
|
97
|
+
gsub_file "config/routes.rb", /devise_for :users/, "devise_for :users, :path_prefix => 'auth'"
|
98
|
+
insert_into_file "config/routes.rb", <<-ROUTE.strip_heredoc, :after => "devise_for :users, :path_prefix => 'auth'\n"
|
99
|
+
resources :users do
|
100
|
+
post 'revert', :on => :member
|
101
|
+
end
|
102
|
+
ROUTE
|
103
|
+
|
104
|
+
say "- Create User Controller..."
|
105
|
+
create_file "app/controllers/users_controller.rb", <<-USERS_CONTROLLER.strip_heredoc
|
106
|
+
class UsersController < InlineFormsController
|
107
|
+
set_tab :user
|
108
|
+
end
|
109
|
+
USERS_CONTROLLER
|
110
|
+
|
111
|
+
say "- Recreate User Model..."
|
112
|
+
remove_file "app/models/user.rb" # the one that 'devise:install' created
|
113
|
+
create_file "app/models/user.rb", <<-USER_MODEL.strip_heredoc
|
114
|
+
class User < ActiveRecord::Base
|
115
|
+
|
116
|
+
# devise options
|
117
|
+
devise :database_authenticatable
|
118
|
+
# devise :registerable # uncomment this if you want people to be able to register
|
119
|
+
devise :recoverable
|
120
|
+
devise :rememberable
|
121
|
+
devise :trackable
|
122
|
+
devise :validatable
|
123
|
+
# devise :token_authenticatable
|
124
|
+
# devise :confirmable,
|
125
|
+
# devise :lockable
|
126
|
+
# devise :timeoutable
|
127
|
+
# devise :omniauthable
|
128
|
+
|
129
|
+
# Setup accessible (or protected) attributes for your model
|
130
|
+
attr_accessible :email, :password, :password_confirmation, :remember_me, :name, :locale
|
131
|
+
attr_writer :inline_forms_attribute_list
|
132
|
+
|
133
|
+
# validations
|
134
|
+
validates :name, :presence => true
|
135
|
+
|
136
|
+
# pagination
|
137
|
+
attr_reader :per_page
|
138
|
+
@per_page = 7
|
139
|
+
|
140
|
+
has_paper_trail
|
141
|
+
|
142
|
+
def _presentation
|
143
|
+
"\#{name}"
|
144
|
+
end
|
145
|
+
|
146
|
+
def inline_forms_attribute_list
|
147
|
+
@inline_forms_attribute_list ||= [
|
148
|
+
[ :name , 'name', :text_field ],
|
149
|
+
[ :email , 'email', :text_field ],
|
150
|
+
[ :password , 'Nieuw wachtwoord', :devise_password_field ],
|
151
|
+
[ :encrypted_password , 'encrypted_password', :info ],
|
152
|
+
[ :reset_password_token , 'reset_password_token', :info ],
|
153
|
+
[ :reset_password_sent_at , 'reset_password_sent_at', :info],
|
154
|
+
[ :remember_created_at , 'remember_created_at', :info ],
|
155
|
+
[ :sign_in_count , 'sign_in_count', :info ],
|
156
|
+
[ :current_sign_in_at , 'current_sign_in_at', :info ],
|
157
|
+
[ :last_sign_in_at , 'last_sign_in_at', :info ],
|
158
|
+
[ :current_sign_in_ip , 'current_sign_in_ip', :info ],
|
159
|
+
[ :last_sign_in_ip , 'last_sign_in_ip', :info ],
|
160
|
+
[ :created_at , 'created_at', :info ],
|
161
|
+
[ :updated_at , 'updated_at', :info ],
|
162
|
+
]
|
163
|
+
end
|
164
|
+
|
165
|
+
def self.not_accessible_through_html?
|
166
|
+
false
|
167
|
+
end
|
168
|
+
|
169
|
+
def self.order_by_clause
|
170
|
+
'name'
|
171
|
+
end
|
172
|
+
|
173
|
+
end
|
174
|
+
USER_MODEL
|
175
|
+
|
176
|
+
say "- Install ckeditor..."
|
177
|
+
generate "ckeditor:install --backend=carrierwave"
|
178
|
+
|
179
|
+
say "- Mount Ckeditor::Engine to routes..."
|
180
|
+
route "mount Ckeditor::Engine => '/ckeditor'"
|
181
|
+
|
182
|
+
say "- Add ckeditor autoload_paths to application.rb..."
|
183
|
+
application "config.autoload_paths += %W(\#{config.root}/app/models/ckeditor)"
|
184
|
+
|
185
|
+
say "- Add ckeditor/init to application.js..."
|
186
|
+
insert_into_file "app/assets/javascripts/application.js",
|
187
|
+
"//= require ckeditor/init\n",
|
188
|
+
:before => "//= require_tree .\n"
|
189
|
+
|
190
|
+
say "- Create ckeditor config.js"
|
191
|
+
copy_file File.join(File.dirname(File.expand_path(__FILE__)) + '/../lib/app/assets/javascripts/ckeditor/config.js'), "app/assets/javascripts/ckeditor/config.js"
|
192
|
+
|
193
|
+
say "- Add remotipart to application.js..."
|
194
|
+
insert_into_file "app/assets/javascripts/application.js", "//= require jquery.remotipart\n", :before => "//= require_tree .\n"
|
195
|
+
|
196
|
+
say "- Paper_trail install..."
|
197
|
+
generate "paper_trail:install"
|
198
|
+
|
199
|
+
say "- Generate models and tables and views for translations..."
|
200
|
+
# using generate this way http://api.rubyonrails.org/classes/Rails/Generators/Actions.html#method-i-generate
|
201
|
+
# run "bundle install"
|
202
|
+
say "- Installaing ZURB Foundation..."
|
203
|
+
generate "foundation:install"
|
204
|
+
|
205
|
+
say "- Generate models and tables and views for translations..."
|
206
|
+
generate "inline_forms", "InlineFormsLocale name:string inline_forms_translations:belongs_to _enabled:yes _presentation:\#{name}"
|
207
|
+
generate "inline_forms", "InlineFormsKey name:string inline_forms_translations:has_many inline_forms_translations:associated _enabled:yes _presentation:\#{name}"
|
208
|
+
generate "inline_forms", "InlineFormsTranslation inline_forms_key:belongs_to inline_forms_locale:dropdown value:text interpolations:text is_proc:boolean _presentation:\#{value}"
|
209
|
+
sleep 1 # to get unique migration number
|
210
|
+
create_file "db/migrate/" +
|
211
|
+
Time.now.utc.strftime("%Y%m%d%H%M%S") +
|
212
|
+
"_" +
|
213
|
+
"inline_forms_create_view_for_translations.rb", <<-VIEW_MIGRATION.strip_heredoc
|
214
|
+
class InlineFormsCreateViewForTranslations < ActiveRecord::Migration
|
215
|
+
def self.up
|
216
|
+
execute 'CREATE VIEW translations
|
217
|
+
AS
|
218
|
+
SELECT L.name AS locale,
|
219
|
+
K.name AS thekey,
|
220
|
+
T.value AS value,
|
221
|
+
T.interpolations AS interpolations,
|
222
|
+
T.is_proc AS is_proc
|
223
|
+
FROM inline_forms_keys K, inline_forms_locales L, inline_forms_translations T
|
224
|
+
WHERE T.inline_forms_key_id = K.id AND T.inline_forms_locale_id = L.id '
|
225
|
+
end
|
226
|
+
def self.down
|
227
|
+
execute 'DROP VIEW translations'
|
228
|
+
end
|
229
|
+
end
|
230
|
+
VIEW_MIGRATION
|
231
|
+
|
232
|
+
say "- Migrating Database (only when using sqlite)"
|
233
|
+
run "bundle exec rake db:migrate" if ENV['using_sqlite'] == 'true'
|
234
|
+
|
235
|
+
say "- Adding admin user with email: #{ENV['email']}, password: #{ENV['password']} to seeds.rb"
|
236
|
+
append_to_file "db/seeds.rb", "User.create({ :email => '#{ENV['email']}', :name => 'Admin', :password => '#{ENV['password']}', :password_confirmation => '#{ENV['password']}'}, :without_protection => true)"
|
237
|
+
|
238
|
+
say "- Seeding the database (only when using sqlite)"
|
239
|
+
run "bundle exec rake db:seed" if ENV['using_sqlite'] == 'true'
|
240
|
+
|
241
|
+
say "- Creating header in app/views/inline_forms/_header.html.erb..."
|
242
|
+
create_file "app/views/inline_forms/_header.html.erb", <<-END_HEADER.strip_heredoc
|
243
|
+
<div id='Header'>
|
244
|
+
<div id='title'>
|
245
|
+
#{app_name} v<%= inline_forms_version -%>
|
246
|
+
</div>
|
247
|
+
<% if current_user -%>
|
248
|
+
<div id='logout'>
|
249
|
+
<%= link_to \"Afmelden: \#{current_user.name}\", destroy_user_session_path, :method => :delete %>
|
250
|
+
</div>
|
251
|
+
<% end -%>
|
252
|
+
<div style='clear: both;'></div>
|
253
|
+
</div>
|
254
|
+
END_HEADER
|
255
|
+
|
256
|
+
say "- Recreating ApplicationHelper to set application_name and application_title..."
|
257
|
+
remove_file "app/helpers/application_helper.rb" # the one that 'rails new' created
|
258
|
+
create_file "app/helpers/application_helper.rb", <<-END_APPHELPER.strip_heredoc
|
259
|
+
module ApplicationHelper
|
260
|
+
def application_name
|
261
|
+
'#{app_name}'
|
262
|
+
end
|
263
|
+
def application_title
|
264
|
+
'#{app_name}'
|
265
|
+
end
|
266
|
+
end
|
267
|
+
END_APPHELPER
|
268
|
+
|
269
|
+
say "- Recreating ApplicationController to add devise, cancan, I18n stuff..."
|
270
|
+
remove_file "app/controllers/application_controller.rb" # the one that 'rails new' created
|
271
|
+
create_file "app/controllers/application_controller.rb", <<-END_APPCONTROLLER.strip_heredoc
|
272
|
+
class ApplicationController < InlineFormsApplicationController
|
273
|
+
protect_from_forgery
|
274
|
+
|
275
|
+
# Comment next two lines if you don't want Devise authentication
|
276
|
+
before_filter :authenticate_user!
|
277
|
+
layout 'devise' if :devise_controller?
|
278
|
+
|
279
|
+
# Comment next 6 lines if you want CanCan authorization
|
280
|
+
enable_authorization :unless => :devise_controller?
|
281
|
+
|
282
|
+
rescue_from CanCan::Unauthorized do |exception|
|
283
|
+
sign_out :user if user_signed_in?
|
284
|
+
redirect_to new_user_session_path, :alert => exception.message
|
285
|
+
end
|
286
|
+
|
287
|
+
# Uncomment next line if you want I18n (based on subdomain)
|
288
|
+
# before_filter :set_locale
|
289
|
+
|
290
|
+
# Uncomment next line and specify default locale
|
291
|
+
# I18n.default_locale = :en
|
292
|
+
|
293
|
+
# Uncomment next line and specify available locales
|
294
|
+
# I18n.available_locales = [ :en, :nl, :pp ]
|
295
|
+
|
296
|
+
# Uncomment next nine line if you want locale based on subdomain, like 'it.example.com, de.example.com'
|
297
|
+
# def set_locale
|
298
|
+
# I18n.locale = extract_locale_from_subdomain || I18n.default_locale
|
299
|
+
# end
|
300
|
+
#
|
301
|
+
# def extract_locale_from_subdomain
|
302
|
+
# locale = request.subdomains.first
|
303
|
+
# return nil if locale.nil?
|
304
|
+
# I18n.available_locales.include?(locale.to_sym) ? locale.to_s : nil
|
305
|
+
# end
|
306
|
+
end
|
307
|
+
END_APPCONTROLLER
|
308
|
+
|
309
|
+
say "- Creating Ability model so that the user with id = 1 can access all..."
|
310
|
+
create_file "app/models/ability.rb", <<-END_ABILITY.strip_heredoc
|
311
|
+
class Ability
|
312
|
+
include CanCan::Ability
|
313
|
+
|
314
|
+
def initialize(user)
|
315
|
+
# See the wiki for details: https://github.com/ryanb/cancan/wiki/Defining-Abilities
|
316
|
+
|
317
|
+
user ||= user.new # guest user
|
318
|
+
|
319
|
+
if user.id == 1 #quick hack
|
320
|
+
can :access, :all
|
321
|
+
else
|
322
|
+
# put restrictions for other users here
|
323
|
+
end
|
324
|
+
end
|
325
|
+
end
|
326
|
+
END_ABILITY
|
327
|
+
|
328
|
+
say "- Generating test files", :green
|
329
|
+
# run "bundle exec rspec:install" # TODO: I need do this or simply copy the files in the spec folder ?
|
330
|
+
create_file "spec/spec_helper.rb", <<-END_TEST_HELPER.strip_heredoc
|
331
|
+
# This file is copied to spec/ when you run 'rails generate rspec:install'
|
332
|
+
ENV["RAILS_ENV"] ||= 'development' # this need to be changed to test ???
|
333
|
+
require File.expand_path("../../config/environment", __FILE__)
|
334
|
+
require 'capybara/rspec'
|
335
|
+
require 'rspec/rails'
|
336
|
+
require 'rspec/autorun'
|
337
|
+
require 'carrierwave/test/matchers'
|
338
|
+
|
339
|
+
|
340
|
+
# Requires supporting ruby files with custom matchers and macros, etc,
|
341
|
+
# in spec/support/ and its subdirectories.
|
342
|
+
Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }
|
343
|
+
|
344
|
+
RSpec.configure do |config|
|
345
|
+
config.include FactoryGirl::Syntax::Methods
|
346
|
+
# ## Mock Framework
|
347
|
+
#
|
348
|
+
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
|
349
|
+
#
|
350
|
+
# config.mock_with :mocha
|
351
|
+
# config.mock_with :flexmock
|
352
|
+
# config.mock_with :rr
|
353
|
+
|
354
|
+
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
|
355
|
+
config.fixture_path = Rails.root + "/spec/fixtures"
|
356
|
+
|
357
|
+
# If you're not using ActiveRecord, or you'd prefer not to run each of your
|
358
|
+
# examples within a transaction, remove the following line or assign false
|
359
|
+
# instead of true.
|
360
|
+
config.use_transactional_fixtures = true
|
361
|
+
|
362
|
+
# If true, the base class of anonymous controllers will be inferred
|
363
|
+
# automatically. This will be the default behavior in future versions of
|
364
|
+
# rspec-rails.
|
365
|
+
config.infer_base_class_for_anonymous_controllers = false
|
366
|
+
|
367
|
+
# Run specs in random order to surface order dependencies. If you find an
|
368
|
+
# order dependency and want to debug it, you can fix the order by providing
|
369
|
+
# the seed, which is printed after each run.
|
370
|
+
# --seed 1234
|
371
|
+
config.order = "random"
|
372
|
+
end
|
373
|
+
END_TEST_HELPER
|
374
|
+
say 'copy test image into rspec folder'
|
375
|
+
copy_file File.join(File.dirname(File.expand_path(__FILE__)) + '/../lib/otherstuff/fixtures/rails.png'), "spec/fixtures/images/rails.png"
|
376
|
+
say '- Creating factory_girl file'
|
377
|
+
create_file "spec/factories/inline_forms.rb", <<-END_FACTORY_GIRL.strip_heredoc
|
378
|
+
FactoryGirl.define do
|
379
|
+
factory :apartment do
|
380
|
+
name "Luxe House in Bandabou 147A" #string
|
381
|
+
title "A dream house in a dream place" # string
|
382
|
+
description "A beatiful House at the edge of the <strong>sea</strong>" #text
|
383
|
+
end
|
384
|
+
factory :large_text do
|
385
|
+
name "Luxe House in Bandabou 147A" #string
|
386
|
+
title "A dream house in a dream place" # string
|
387
|
+
description "A beatiful House at the edge of the <strong>sea</strong>" #text
|
388
|
+
end
|
389
|
+
end
|
390
|
+
END_FACTORY_GIRL
|
391
|
+
remove_file 'spec/factories/users.rb'
|
392
|
+
remove_file 'spec/models/user_spec.rb'
|
393
|
+
if ENV['install_example'] == 'true'
|
394
|
+
say "\nInstalling example application..."
|
395
|
+
run 'bundle exec rails g inline_forms Photo name:string caption:string image:image_field description:text apartment:belongs_to _presentation:\'#{name}\'' # FIXME temporary changed because ckeditor is playing dirty
|
396
|
+
run 'bundle exec rails generate uploader Image'
|
397
|
+
run 'bundle exec rails g inline_forms Apartment name:string title:string description:text photos:has_many photos:associated _enabled:yes _presentation:\'#{name}\'' # FIXME temporary changed because ckeditor is playing dirty
|
398
|
+
run 'bundle exec rake db:migrate'
|
399
|
+
say '-Adding example test'
|
400
|
+
create_file "spec/models/#{app_name}_example.rb", <<-END_EXAMPLE_TEST.strip_heredoc
|
401
|
+
require "spec_helper"
|
402
|
+
describe Apartment do
|
403
|
+
it "insert an appartment and retrieve it" do
|
404
|
+
appartment_data = create(:apartment)
|
405
|
+
first = Apartment.first.id
|
406
|
+
expect(Apartment.first.id).to eq(first)
|
407
|
+
end
|
408
|
+
end
|
409
|
+
END_EXAMPLE_TEST
|
410
|
+
# run tests
|
411
|
+
if ENV['runtest'] == 'true' # Not Dry
|
412
|
+
run "rspec"
|
413
|
+
end
|
414
|
+
say "\nDone! Now point your browser to http://localhost:3000/apartments !", :yellow
|
415
|
+
say "\nPress ctlr-C to quit...", :yellow
|
416
|
+
run 'bundle exec rails s'
|
417
|
+
else
|
418
|
+
say "\nDone! Now make your tables with 'bundle exec rails g inline_forms ...", :yellow
|
419
|
+
# run tests
|
420
|
+
if ENV['runtest'] == 'true'
|
421
|
+
run "rspec"
|
422
|
+
end
|
423
|
+
end
|
@@ -1,34 +1,14 @@
|
|
1
|
+
$(document).foundation();
|
2
|
+
|
1
3
|
$(document).ready(function() {
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
return $(this).attr('validation-hint');
|
13
|
-
}
|
14
|
-
},
|
15
|
-
show: {
|
16
|
-
ready: true // this took a loooooong time to find out...
|
17
|
-
},
|
18
|
-
position: {
|
19
|
-
my: 'left top',
|
20
|
-
at: 'top right',
|
21
|
-
adjust: {
|
22
|
-
y: +17
|
23
|
-
}
|
24
|
-
},
|
25
|
-
style: {
|
26
|
-
classes: 'ui-tooltip-jtools',
|
27
|
-
tip: {
|
28
|
-
corner: false
|
29
|
-
}
|
30
|
-
}
|
31
|
-
})
|
32
|
-
});
|
4
|
+
// initialize datepickers
|
5
|
+
$.datepicker.setDefaults({
|
6
|
+
changeMonth : true,
|
7
|
+
changeYear : true,
|
8
|
+
yearRange: '-100:+1'
|
9
|
+
});
|
10
|
+
// get rid of translation_missing tooltips
|
11
|
+
$(this).on("mouseover", ".translation_missing", function() {
|
12
|
+
$(this).attr('title', '');
|
13
|
+
});
|
33
14
|
});
|
34
|
-
|