inline_forms 6.2.12 → 6.3.3
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 +4 -4
- data/CHANGELOG.md +67 -0
- data/README.rdoc +5 -1
- data/Rakefile +12 -1
- data/app/helpers/form_elements/audio_field.rb +1 -1
- data/app/helpers/form_elements/check_box.rb +1 -1
- data/app/helpers/form_elements/check_list.rb +2 -2
- data/app/helpers/form_elements/chicas_dropdown_with_family_members.rb +1 -1
- data/app/helpers/form_elements/ckeditor.rb +2 -1
- data/app/helpers/form_elements/date.rb +1 -1
- data/app/helpers/form_elements/decimal_field.rb +1 -1
- data/app/helpers/form_elements/devise_password_field.rb +1 -1
- data/app/helpers/form_elements/dropdown.rb +1 -1
- data/app/helpers/form_elements/dropdown_with_integers.rb +1 -1
- data/app/helpers/form_elements/dropdown_with_other.rb +1 -1
- data/app/helpers/form_elements/dropdown_with_values.rb +1 -1
- data/app/helpers/form_elements/dropdown_with_values_with_stars.rb +1 -1
- data/app/helpers/form_elements/file_field.rb +1 -1
- data/app/helpers/form_elements/geo_code_curacao.rb +1 -1
- data/app/helpers/form_elements/image_field.rb +1 -1
- data/app/helpers/form_elements/integer_field.rb +1 -1
- data/app/helpers/form_elements/kansen_slider.rb +1 -1
- data/app/helpers/form_elements/money_field.rb +1 -1
- data/app/helpers/form_elements/month_select.rb +1 -1
- data/app/helpers/form_elements/month_year_picker.rb +1 -1
- data/app/helpers/form_elements/move.rb +1 -1
- data/app/helpers/form_elements/multi_image_field.rb +1 -1
- data/app/helpers/form_elements/plain_text_area.rb +1 -1
- data/app/helpers/form_elements/question_list.rb +2 -2
- data/app/helpers/form_elements/radio_button.rb +1 -1
- data/app/helpers/form_elements/scale_with_integers.rb +1 -1
- data/app/helpers/form_elements/scale_with_values.rb +1 -1
- data/app/helpers/form_elements/simple_file_field.rb +1 -1
- data/app/helpers/form_elements/slider_with_values.rb +1 -1
- data/app/helpers/form_elements/text_area.rb +4 -3
- data/app/helpers/form_elements/text_area_without_ckeditor.rb +1 -1
- data/app/helpers/form_elements/text_field.rb +1 -1
- data/app/helpers/form_elements/time.rb +1 -1
- data/app/helpers/inline_forms_helper.rb +17 -30
- data/app/views/inline_forms/_close.html.erb +2 -2
- data/app/views/inline_forms/_edit.html.erb +4 -3
- data/app/views/inline_forms/_new.html.erb +2 -2
- data/bin/inline_forms_installer_core.rb +38 -6
- data/inline_forms.gemspec +3 -1
- data/lib/inline_forms/form_element_from_callee.rb +10 -0
- data/lib/inline_forms/version.rb +1 -1
- data/lib/inline_forms.rb +1 -13
- data/lib/installer_templates/example_app_tests/test/example_app/example_integration_test_case.rb +36 -0
- data/lib/installer_templates/example_app_tests/test/integration/example_app_guest_access_test.rb +21 -0
- data/lib/installer_templates/example_app_tests/test/integration/example_app_photos_test.rb +22 -0
- data/lib/installer_templates/example_app_tests/test/integration/example_app_routing_test.rb +15 -0
- data/lib/installer_templates/example_app_tests/test/models/example_app_apartment_photo_test.rb +26 -0
- data/test/form_element_from_callee_test.rb +73 -0
- data/test/inline_edit_polymorphic_path_test.rb +81 -0
- data/test/test_helper.rb +6 -0
- metadata +35 -9
- data/app/helpers/form_elements/absence_list.rb +0 -45
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
</div>
|
|
26
26
|
</div>
|
|
27
27
|
|
|
28
|
-
<%= form_tag
|
|
28
|
+
<%= form_tag polymorphic_path(@Klass, :update => @update_span,
|
|
29
29
|
:parent_class => @parent_class,
|
|
30
30
|
:parent_id => @parent_id ),
|
|
31
31
|
:multipart => true, :remote => true, :class => "edit_form" do -%>
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
|
|
57
57
|
</div>
|
|
58
58
|
<div class='small-11 column' >
|
|
59
|
-
<%= link_to(
|
|
59
|
+
<%= link_to( polymorphic_path(@Klass, :update => @update_span,
|
|
60
60
|
:parent_class => @parent_class,
|
|
61
61
|
:parent_id => @parent_id,
|
|
62
62
|
:ul_needed => true ),
|
|
@@ -20,7 +20,10 @@ gem 'jquery-ui-sass-rails'
|
|
|
20
20
|
gem 'mini_magick'
|
|
21
21
|
gem 'mysql2'
|
|
22
22
|
gem 'paper_trail', git: 'https://github.com/acesuares/paper_trail.git'
|
|
23
|
-
|
|
23
|
+
# RubyGems 7.0.x requires railties >= 6, < 8 (works with Rails 6.1). The default branch of
|
|
24
|
+
# https://github.com/svenfuchs/rails-i18n.git targets Rails 8+ (railties >= 8) and breaks bundle
|
|
25
|
+
# resolution next to rails 6.1.3.1. Same approach as the Papiamentu app.
|
|
26
|
+
gem 'rails-i18n', '~> 7.0'
|
|
24
27
|
gem 'rails-jquery-autocomplete'
|
|
25
28
|
gem 'rails', '6.1.3.1'
|
|
26
29
|
gem 'rake'
|
|
@@ -32,6 +35,11 @@ gem 'unicorn'
|
|
|
32
35
|
gem 'validation_hints'
|
|
33
36
|
gem 'will_paginate' #, git: 'https://github.com/acesuares/will_paginate.git'
|
|
34
37
|
|
|
38
|
+
gem_group :test do
|
|
39
|
+
# Rails 6.1.3 expects Minitest 5; 6.x breaks railties test runner (run arity, parallelization).
|
|
40
|
+
gem 'minitest', '~> 5.25'
|
|
41
|
+
end
|
|
42
|
+
|
|
35
43
|
gem_group :development do
|
|
36
44
|
gem 'capistrano-bundler', require: false
|
|
37
45
|
gem 'capistrano-rails', require: false
|
|
@@ -41,7 +49,8 @@ gem_group :development do
|
|
|
41
49
|
gem 'rvm-capistrano', :require => false
|
|
42
50
|
gem 'rvm1-capistrano3', require: false
|
|
43
51
|
gem 'seed_dump', '~> 0.5.3'
|
|
44
|
-
|
|
52
|
+
# Rails 6.1 ActiveRecord's sqlite3 adapter requires sqlite3 ~> 1.4; 2.x activates first and breaks.
|
|
53
|
+
gem 'sqlite3', '~> 1.4'
|
|
45
54
|
gem 'switch_user'
|
|
46
55
|
gem 'thin'
|
|
47
56
|
gem 'yaml_db'
|
|
@@ -66,6 +75,12 @@ if ENV['using_sqlite'] == 'true'
|
|
|
66
75
|
pool: 5
|
|
67
76
|
timeout: 5000
|
|
68
77
|
|
|
78
|
+
test:
|
|
79
|
+
adapter: sqlite3
|
|
80
|
+
database: db/test.sqlite3
|
|
81
|
+
pool: 5
|
|
82
|
+
timeout: 5000
|
|
83
|
+
|
|
69
84
|
END_DATABASEYML
|
|
70
85
|
else
|
|
71
86
|
create_file "config/database.yml", <<-END_DATABASEYML.strip_heredoc
|
|
@@ -333,12 +348,21 @@ append_to_file 'config/initializers/assets.rb',
|
|
|
333
348
|
'Rails.application.config.assets.precompile += %w[ckeditor/config.js]'
|
|
334
349
|
|
|
335
350
|
say "- Paper_trail install..."
|
|
336
|
-
|
|
351
|
+
# --with-mysql embeds InnoDB options in create_table; that SQL is invalid on SQLite (example app).
|
|
352
|
+
if ENV['using_sqlite'] == 'true'
|
|
353
|
+
generate "paper_trail:install --with-changes"
|
|
354
|
+
else
|
|
355
|
+
generate "paper_trail:install --with-changes --with-mysql"
|
|
356
|
+
end
|
|
357
|
+
# paper_trail emits two migrations in one second; the next generator would reuse that timestamp.
|
|
358
|
+
sleep 1
|
|
337
359
|
|
|
338
360
|
# Create Translations
|
|
339
361
|
say "- Generate models and tables and views for translations..." # TODO Translations need to be done in inline_forms, and then generate a yml file, perhaps
|
|
340
362
|
generate "inline_forms", "InlineFormsLocale name:string inline_forms_translations:belongs_to _enabled:yes _presentation:\#{name}"
|
|
363
|
+
sleep 1 # unique migration timestamps per generator
|
|
341
364
|
generate "inline_forms", "InlineFormsKey name:string inline_forms_translations:has_many inline_forms_translations:associated _enabled:yes _presentation:\#{name}"
|
|
365
|
+
sleep 1
|
|
342
366
|
generate "inline_forms", "InlineFormsTranslation inline_forms_key:belongs_to inline_forms_locale:dropdown value:text interpolations:text is_proc:boolean _presentation:\#{value}"
|
|
343
367
|
# TODO: fix text_area into text_area_without_ckeditor
|
|
344
368
|
sleep 1 # to get unique migration number
|
|
@@ -563,9 +587,17 @@ if ENV['install_example'] == 'true'
|
|
|
563
587
|
|
|
564
588
|
route "root :to => 'apartments#index'"
|
|
565
589
|
|
|
566
|
-
say "
|
|
567
|
-
|
|
568
|
-
|
|
590
|
+
say "- Adding example app regression tests (bundle exec rails test)..."
|
|
591
|
+
example_tests_root = File.join(GENERATOR_PATH, "lib/installer_templates/example_app_tests")
|
|
592
|
+
Dir.glob(File.join(example_tests_root, "**", "*.rb")).sort.each do |abs|
|
|
593
|
+
rel = abs.delete_prefix(example_tests_root + File::SEPARATOR).tr("\\", "/")
|
|
594
|
+
create_file rel, File.read(abs)
|
|
595
|
+
end
|
|
596
|
+
|
|
597
|
+
say "\nDone! Example app (Photo + Apartment) is ready.", :yellow
|
|
598
|
+
say " bundle exec rails test # example regression tests", :yellow
|
|
599
|
+
say " bundle exec rails s # then http://localhost:3000/apartments", :yellow
|
|
600
|
+
say " Log in: #{ENV["email"]} / #{ENV["password"]}", :yellow
|
|
569
601
|
end
|
|
570
602
|
# done!
|
|
571
603
|
say "\nDone! Now make your tables with 'bundle exec rails g inline_forms ...", :yellow
|
data/inline_forms.gemspec
CHANGED
|
@@ -23,7 +23,9 @@ Gem::Specification.new do |s|
|
|
|
23
23
|
s.add_dependency('rvm')
|
|
24
24
|
s.add_dependency('thor')
|
|
25
25
|
s.add_dependency('validation_hints')
|
|
26
|
-
s.add_dependency('rails', '6.1.3.1')
|
|
26
|
+
s.add_dependency('rails', '>= 6.1.3.1', '< 7')
|
|
27
27
|
s.add_dependency('rails-i18n')
|
|
28
28
|
|
|
29
|
+
s.add_development_dependency("minitest", "~> 5.0")
|
|
30
|
+
|
|
29
31
|
end
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
|
2
|
+
module InlineForms
|
|
3
|
+
# Maps +__callee__+ from a +*_show+ helper to the +params[:form_element]+ string
|
|
4
|
+
# (e.g. +:text_field_show+ → +"text_field"+).
|
|
5
|
+
def self.form_element_string_from_callee(from_callee)
|
|
6
|
+
s = from_callee.to_s
|
|
7
|
+
s = s.sub(/\Ablock in /, "")
|
|
8
|
+
s.delete_suffix("_show")
|
|
9
|
+
end
|
|
10
|
+
end
|
data/lib/inline_forms/version.rb
CHANGED
data/lib/inline_forms.rb
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
# -*- encoding : utf-8 -*-
|
|
2
2
|
require ('inline_forms/version.rb')
|
|
3
|
+
require_relative ('inline_forms/form_element_from_callee')
|
|
3
4
|
# InlineForms is a Rails Engine that let you setup an admin interface quick and
|
|
4
5
|
# easy. Please install it as a gem or include it in your Gemfile.
|
|
5
6
|
module InlineForms
|
|
@@ -153,16 +154,3 @@ module InlineForms
|
|
|
153
154
|
end
|
|
154
155
|
|
|
155
156
|
end
|
|
156
|
-
|
|
157
|
-
# make the current method and the calling method available
|
|
158
|
-
# http://www.ruby-forum.com/topic/75258
|
|
159
|
-
# supposedly, this is fixed in 1.9
|
|
160
|
-
module Kernel
|
|
161
|
-
private
|
|
162
|
-
def this_method
|
|
163
|
-
caller[0] =~ /`([^']*)'/ and $1
|
|
164
|
-
end
|
|
165
|
-
def calling_method
|
|
166
|
-
caller[1] =~ /`([^']*)'/ and $1
|
|
167
|
-
end
|
|
168
|
-
end
|
data/lib/installer_templates/example_app_tests/test/example_app/example_integration_test_case.rb
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Base class for integration tests shipped only with `inline_forms create … --example`.
|
|
4
|
+
# See test/integration/example_app_*_test.rb
|
|
5
|
+
require "test_helper"
|
|
6
|
+
require "devise/test/integration_helpers"
|
|
7
|
+
|
|
8
|
+
class ExampleAppIntegrationTestCase < ActionDispatch::IntegrationTest
|
|
9
|
+
include Devise::Test::IntegrationHelpers
|
|
10
|
+
|
|
11
|
+
setup do
|
|
12
|
+
host!("www.example.com")
|
|
13
|
+
sign_in(example_app_admin_user)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
private
|
|
17
|
+
|
|
18
|
+
def example_app_admin_user
|
|
19
|
+
@example_app_admin_user ||= begin
|
|
20
|
+
locale = Locale.find_or_create_by!(name: "en") { |l| l.title = "English" }
|
|
21
|
+
role = Role.find_or_create_by!(name: "superadmin") { |r| r.description = "Super Admin" }
|
|
22
|
+
user = User.find_or_initialize_by(email: "admin@example.com")
|
|
23
|
+
if user.new_record?
|
|
24
|
+
user.assign_attributes(
|
|
25
|
+
name: "Admin",
|
|
26
|
+
password: "admin999",
|
|
27
|
+
password_confirmation: "admin999",
|
|
28
|
+
locale: locale
|
|
29
|
+
)
|
|
30
|
+
user.save!
|
|
31
|
+
end
|
|
32
|
+
user.roles << role unless user.roles.where(id: role.id).exists?
|
|
33
|
+
user
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
data/lib/installer_templates/example_app_tests/test/integration/example_app_guest_access_test.rb
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "test_helper"
|
|
4
|
+
require "devise/test/integration_helpers"
|
|
5
|
+
|
|
6
|
+
class ExampleAppGuestAccessTest < ActionDispatch::IntegrationTest
|
|
7
|
+
include Devise::Test::IntegrationHelpers
|
|
8
|
+
|
|
9
|
+
setup { host!("www.example.com") }
|
|
10
|
+
|
|
11
|
+
test "apartments index redirects when not signed in" do
|
|
12
|
+
get apartments_path
|
|
13
|
+
assert_response :redirect
|
|
14
|
+
assert_match %r{/auth/users/sign_in}, @response.redirect_url
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
test "root redirects when not signed in" do
|
|
18
|
+
get root_path
|
|
19
|
+
assert_response :redirect
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "../example_app/example_integration_test_case"
|
|
4
|
+
|
|
5
|
+
class ExampleAppPhotosTest < ExampleAppIntegrationTestCase
|
|
6
|
+
setup do
|
|
7
|
+
@apartment = Apartment.create!(name: "Beach", title: "Ocean view")
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
test "photos are not served as standalone html resource" do
|
|
11
|
+
assert Photo.not_accessible_through_html?
|
|
12
|
+
assert_raises(ActionController::UnknownFormat) do
|
|
13
|
+
get photos_path
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
test "can create a photo for an apartment" do
|
|
18
|
+
assert_difference("Photo.count", 1) do
|
|
19
|
+
Photo.create!(name: "Sunset", apartment: @apartment)
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "../example_app/example_integration_test_case"
|
|
4
|
+
|
|
5
|
+
class ExampleAppRoutingTest < ExampleAppIntegrationTestCase
|
|
6
|
+
test "root routes to apartments index" do
|
|
7
|
+
get root_path
|
|
8
|
+
assert_response :success
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
test "apartments index is reachable when signed in" do
|
|
12
|
+
get apartments_path
|
|
13
|
+
assert_response :success
|
|
14
|
+
end
|
|
15
|
+
end
|
data/lib/installer_templates/example_app_tests/test/models/example_app_apartment_photo_test.rb
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "test_helper"
|
|
4
|
+
|
|
5
|
+
class ExampleAppApartmentPhotoTest < ActiveSupport::TestCase
|
|
6
|
+
setup do
|
|
7
|
+
@apartment = Apartment.create!(name: "North", title: "Tower")
|
|
8
|
+
@photo = Photo.create!(name: "Lobby", apartment: @apartment)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
test "photo belongs to apartment" do
|
|
12
|
+
assert_equal @apartment, @photo.apartment
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
test "apartment has many photos" do
|
|
16
|
+
assert_includes @apartment.photos.to_a, @photo
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
test "photo model hides resource from standalone html crud" do
|
|
20
|
+
assert Photo.not_accessible_through_html?
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
test "apartment model allows standalone html crud" do
|
|
24
|
+
assert_not Apartment.not_accessible_through_html?
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "test_helper"
|
|
4
|
+
|
|
5
|
+
# Documents the contract between *_show helpers, +__callee__+, and
|
|
6
|
+
# +params[:form_element]+ (used by InlineFormsController#update as +"#{form_element}_update"+).
|
|
7
|
+
class FormElementFromCalleeTest < Minitest::Test
|
|
8
|
+
def test_symbol_callee_typical_show_method_maps_to_controller_suffix
|
|
9
|
+
got = InlineForms.form_element_string_from_callee(:text_field_show)
|
|
10
|
+
assert_equal(
|
|
11
|
+
"text_field",
|
|
12
|
+
got,
|
|
13
|
+
":text_field_show must become the string \"text_field\" so the edit URL's " \
|
|
14
|
+
"form_element matches text_field_update / text_field_edit."
|
|
15
|
+
)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def test_string_callee_same_as_symbol
|
|
19
|
+
got = InlineForms.form_element_string_from_callee("dropdown_with_values_show")
|
|
20
|
+
assert_equal(
|
|
21
|
+
"dropdown_with_values",
|
|
22
|
+
got,
|
|
23
|
+
"String callee from backtrace-style names must match Symbol behavior."
|
|
24
|
+
)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def test_block_in_prefix_from_nested_call_still_maps_correctly
|
|
28
|
+
got = InlineForms.form_element_string_from_callee("block in text_field_show")
|
|
29
|
+
assert_equal(
|
|
30
|
+
"text_field",
|
|
31
|
+
got,
|
|
32
|
+
"When *_show runs inside a block, Ruby may prefix the callee label with " \
|
|
33
|
+
"\"block in \"; that prefix must be stripped before removing _show."
|
|
34
|
+
)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def test_only_one_trailing_show_suffix_removed
|
|
38
|
+
got = InlineForms.form_element_string_from_callee(:foo_show)
|
|
39
|
+
assert_equal(
|
|
40
|
+
"foo",
|
|
41
|
+
got,
|
|
42
|
+
"delete_suffix('_show') must remove only the trailing _show once " \
|
|
43
|
+
"(not leave \"foo\" with a spurious strip)."
|
|
44
|
+
)
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def test_multi_word_element_name_underscores_preserved
|
|
48
|
+
got = InlineForms.form_element_string_from_callee(:chicas_dropdown_with_family_members_show)
|
|
49
|
+
assert_equal(
|
|
50
|
+
"chicas_dropdown_with_family_members",
|
|
51
|
+
got,
|
|
52
|
+
"Form element names with underscores must survive unchanged except for _show."
|
|
53
|
+
)
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def test_callee_without_show_suffix_is_unchanged_modulo_block_prefix
|
|
57
|
+
got = InlineForms.form_element_string_from_callee(:already_plain)
|
|
58
|
+
assert_equal(
|
|
59
|
+
"already_plain",
|
|
60
|
+
got,
|
|
61
|
+
"If someone passes a callee without _show, output is unchanged (minus block prefix)."
|
|
62
|
+
)
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def test_nil_callee_yields_empty_string
|
|
66
|
+
got = InlineForms.form_element_string_from_callee(nil)
|
|
67
|
+
assert_equal(
|
|
68
|
+
"",
|
|
69
|
+
got,
|
|
70
|
+
"nil.to_s is empty; callers must pass __callee__ from a *_show method."
|
|
71
|
+
)
|
|
72
|
+
end
|
|
73
|
+
end
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "test_helper"
|
|
4
|
+
require "logger"
|
|
5
|
+
require "active_model"
|
|
6
|
+
require "action_dispatch"
|
|
7
|
+
|
|
8
|
+
# Record double with the same +model_name+ routing key as +resources :articles+
|
|
9
|
+
# (a class nested under Minitest::Test would get +inline_edit_…_article+, not +article+).
|
|
10
|
+
class InlineFormsArticlesRouteDouble
|
|
11
|
+
include ActiveModel::Model
|
|
12
|
+
include ActiveModel::Conversion
|
|
13
|
+
|
|
14
|
+
attr_accessor :id
|
|
15
|
+
|
|
16
|
+
def self.model_name
|
|
17
|
+
ActiveModel::Name.new(self, nil, "Article")
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def initialize(id = 1)
|
|
21
|
+
@id = id
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def persisted?
|
|
25
|
+
true
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def to_param
|
|
29
|
+
id.to_s
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# Class-only double for +polymorphic_path(Model)+ (collection +articles+).
|
|
34
|
+
class InlineFormsArticleClassRouteDouble
|
|
35
|
+
def self.model_name
|
|
36
|
+
ActiveModel::Name.new(self, nil, "Article")
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# Parity between polymorphic URL helpers and named +edit_article_path+,
|
|
41
|
+
# +article_path+, and +articles_path+ for a standard +resources :articles+
|
|
42
|
+
# route (no full Rails app boot).
|
|
43
|
+
class InlineEditPolymorphicPathTest < Minitest::Test
|
|
44
|
+
def setup
|
|
45
|
+
@routes = ActionDispatch::Routing::RouteSet.new
|
|
46
|
+
@routes.draw { resources :articles }
|
|
47
|
+
routes = @routes
|
|
48
|
+
holder_class = Class.new do
|
|
49
|
+
include routes.url_helpers
|
|
50
|
+
end
|
|
51
|
+
holder_class.default_url_options = { only_path: true }
|
|
52
|
+
@holder = holder_class.new
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def test_edit_polymorphic_path_matches_named_edit_helper
|
|
56
|
+
article = InlineFormsArticlesRouteDouble.new(42)
|
|
57
|
+
options = {
|
|
58
|
+
attribute: "title",
|
|
59
|
+
form_element: "text_field",
|
|
60
|
+
update: "field_article_42_title"
|
|
61
|
+
}
|
|
62
|
+
poly = @holder.edit_polymorphic_path(article, **options)
|
|
63
|
+
named = @holder.edit_article_path(article, **options)
|
|
64
|
+
assert_equal named, poly
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def test_member_polymorphic_path_matches_article_path
|
|
68
|
+
article = InlineFormsArticlesRouteDouble.new(7)
|
|
69
|
+
options = { update: "span", close: true }
|
|
70
|
+
poly = @holder.polymorphic_path(article, **options)
|
|
71
|
+
named = @holder.article_path(article, **options)
|
|
72
|
+
assert_equal named, poly
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def test_collection_polymorphic_path_matches_articles_path
|
|
76
|
+
options = { update: "list", parent_class: "Parent", parent_id: "3" }
|
|
77
|
+
poly = @holder.polymorphic_path(InlineFormsArticleClassRouteDouble, **options)
|
|
78
|
+
named = @holder.articles_path(**options)
|
|
79
|
+
assert_equal named, poly
|
|
80
|
+
end
|
|
81
|
+
end
|
data/test/test_helper.rb
ADDED
metadata
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: inline_forms
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 6.
|
|
4
|
+
version: 6.3.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ace Suares
|
|
8
8
|
- Lemuel Boyce
|
|
9
9
|
- Manuel Ortega
|
|
10
|
-
autorequire:
|
|
11
10
|
bindir: bin
|
|
12
11
|
cert_chain: []
|
|
13
|
-
date:
|
|
12
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
14
13
|
dependencies:
|
|
15
14
|
- !ruby/object:Gem::Dependency
|
|
16
15
|
name: rvm
|
|
@@ -58,16 +57,22 @@ dependencies:
|
|
|
58
57
|
name: rails
|
|
59
58
|
requirement: !ruby/object:Gem::Requirement
|
|
60
59
|
requirements:
|
|
61
|
-
- -
|
|
60
|
+
- - ">="
|
|
62
61
|
- !ruby/object:Gem::Version
|
|
63
62
|
version: 6.1.3.1
|
|
63
|
+
- - "<"
|
|
64
|
+
- !ruby/object:Gem::Version
|
|
65
|
+
version: '7'
|
|
64
66
|
type: :runtime
|
|
65
67
|
prerelease: false
|
|
66
68
|
version_requirements: !ruby/object:Gem::Requirement
|
|
67
69
|
requirements:
|
|
68
|
-
- -
|
|
70
|
+
- - ">="
|
|
69
71
|
- !ruby/object:Gem::Version
|
|
70
72
|
version: 6.1.3.1
|
|
73
|
+
- - "<"
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: '7'
|
|
71
76
|
- !ruby/object:Gem::Dependency
|
|
72
77
|
name: rails-i18n
|
|
73
78
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -82,6 +87,20 @@ dependencies:
|
|
|
82
87
|
- - ">="
|
|
83
88
|
- !ruby/object:Gem::Version
|
|
84
89
|
version: '0'
|
|
90
|
+
- !ruby/object:Gem::Dependency
|
|
91
|
+
name: minitest
|
|
92
|
+
requirement: !ruby/object:Gem::Requirement
|
|
93
|
+
requirements:
|
|
94
|
+
- - "~>"
|
|
95
|
+
- !ruby/object:Gem::Version
|
|
96
|
+
version: '5.0'
|
|
97
|
+
type: :development
|
|
98
|
+
prerelease: false
|
|
99
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
100
|
+
requirements:
|
|
101
|
+
- - "~>"
|
|
102
|
+
- !ruby/object:Gem::Version
|
|
103
|
+
version: '5.0'
|
|
85
104
|
description: Inline Forms aims to ease the setup of forms that provide inline editing.
|
|
86
105
|
The field list can be specified in the model.
|
|
87
106
|
email:
|
|
@@ -96,6 +115,7 @@ files:
|
|
|
96
115
|
- ".document"
|
|
97
116
|
- ".gitignore"
|
|
98
117
|
- ".ruby-version"
|
|
118
|
+
- CHANGELOG.md
|
|
99
119
|
- Gemfile
|
|
100
120
|
- LICENSE.txt
|
|
101
121
|
- README.rdoc
|
|
@@ -110,7 +130,6 @@ files:
|
|
|
110
130
|
- app/controllers/geo_code_curacao_controller.rb
|
|
111
131
|
- app/controllers/inline_forms_application_controller.rb
|
|
112
132
|
- app/controllers/inline_forms_controller.rb
|
|
113
|
-
- app/helpers/form_elements/absence_list.rb
|
|
114
133
|
- app/helpers/form_elements/audio_field.rb
|
|
115
134
|
- app/helpers/form_elements/check_box.rb
|
|
116
135
|
- app/helpers/form_elements/check_list.rb
|
|
@@ -220,7 +239,13 @@ files:
|
|
|
220
239
|
- lib/generators/templates/test.erb
|
|
221
240
|
- lib/generators/templates/unicorn/production.rb
|
|
222
241
|
- lib/inline_forms.rb
|
|
242
|
+
- lib/inline_forms/form_element_from_callee.rb
|
|
223
243
|
- lib/inline_forms/version.rb
|
|
244
|
+
- lib/installer_templates/example_app_tests/test/example_app/example_integration_test_case.rb
|
|
245
|
+
- lib/installer_templates/example_app_tests/test/integration/example_app_guest_access_test.rb
|
|
246
|
+
- lib/installer_templates/example_app_tests/test/integration/example_app_photos_test.rb
|
|
247
|
+
- lib/installer_templates/example_app_tests/test/integration/example_app_routing_test.rb
|
|
248
|
+
- lib/installer_templates/example_app_tests/test/models/example_app_apartment_photo_test.rb
|
|
224
249
|
- lib/locales/inline_forms.en.yml
|
|
225
250
|
- lib/locales/inline_forms.nl.yml
|
|
226
251
|
- lib/otherstuff/20120310065554_inline_forms_create_view_for_translations.rb
|
|
@@ -229,11 +254,13 @@ files:
|
|
|
229
254
|
- lib/otherstuff/mkrole
|
|
230
255
|
- lib/otherstuff/roles_users.sql
|
|
231
256
|
- lib/vagrant/vagrantbox-inline_forms.zip
|
|
257
|
+
- test/form_element_from_callee_test.rb
|
|
258
|
+
- test/inline_edit_polymorphic_path_test.rb
|
|
259
|
+
- test/test_helper.rb
|
|
232
260
|
homepage: http://github.com/acesuares/inline_forms
|
|
233
261
|
licenses:
|
|
234
262
|
- MIT
|
|
235
263
|
metadata: {}
|
|
236
|
-
post_install_message:
|
|
237
264
|
rdoc_options: []
|
|
238
265
|
require_paths:
|
|
239
266
|
- lib
|
|
@@ -248,8 +275,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
248
275
|
- !ruby/object:Gem::Version
|
|
249
276
|
version: '0'
|
|
250
277
|
requirements: []
|
|
251
|
-
rubygems_version: 3.
|
|
252
|
-
signing_key:
|
|
278
|
+
rubygems_version: 3.7.2
|
|
253
279
|
specification_version: 4
|
|
254
280
|
summary: Inline editing of forms.
|
|
255
281
|
test_files: []
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
# -*- encoding : utf-8 -*-
|
|
2
|
-
#InlineForms::SPECIAL_COLUMN_TYPES[:absence_list]=:no_migration
|
|
3
|
-
|
|
4
|
-
# checklist
|
|
5
|
-
def absence_list_show(object, attribute) # the object is the lesson, attribute should be absences???
|
|
6
|
-
absence_status = { 1 => 'aanwezig', 3 => 'laat met reden', 4 => 'laat' , 5 => 'afwezig met reden', 6 => 'afwezig' }
|
|
7
|
-
out = '<ul class="absence_list">'
|
|
8
|
-
out << link_to_inline_edit(object, attribute) if object.send(attribute).empty? # no absences yet
|
|
9
|
-
object.kids.sort.each do | item | # we need the kids from this lesson.
|
|
10
|
-
|
|
11
|
-
out << "<li>"
|
|
12
|
-
out << "#{item.full_name}: "
|
|
13
|
-
out << "<br />"
|
|
14
|
-
out << "<span id='absence_#{Absence.this_lesson_this_kid(object, item).id}_status'>"
|
|
15
|
-
out << link_to_inline_edit( Absence.this_lesson_this_kid(object, item),
|
|
16
|
-
:status,
|
|
17
|
-
absence_status[Absence.this_lesson_this_kid(object, item).status],
|
|
18
|
-
:dropdown_with_values
|
|
19
|
-
)
|
|
20
|
-
out << '</span>'
|
|
21
|
-
out << '</li>'
|
|
22
|
-
end
|
|
23
|
-
out << '</ul>'
|
|
24
|
-
out.html_safe
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
def absence_list_edit(object, attribute)
|
|
28
|
-
# object.send(attribute).build if object.send(attribute).empty?
|
|
29
|
-
# values = object.send(attribute).first.class.name.constantize.find(:all) # TODO bring order
|
|
30
|
-
out = '<div class="edit_form_checklist">'
|
|
31
|
-
out << '<ul>'
|
|
32
|
-
item = object.kid
|
|
33
|
-
out << "<li>"
|
|
34
|
-
out << item._presentation
|
|
35
|
-
out << dropdown_with_values_edit(Absence.this_lesson(item).first, :status)
|
|
36
|
-
out << '</li>'
|
|
37
|
-
out << '</ul>'
|
|
38
|
-
out << '</div>'
|
|
39
|
-
out.html_safe
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
# def absence_list_update(object, attribute)
|
|
43
|
-
# params[attribute] ||= {}
|
|
44
|
-
# object.send(attribute.singularize + '_ids=', params[attribute].keys)
|
|
45
|
-
# end
|