inline_forms_installer 8.1.58 → 8.1.60
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/lib/inline_forms_installer/installer_core.rb +59 -3
- data/lib/inline_forms_installer/version.rb +1 -1
- data/lib/installer_templates/dartsass/inline_forms_dartsass_builds.rb +15 -5
- data/lib/installer_templates/example_app_tests/test/integration/example_app_dartsass_build_test.rb +2 -1
- data/lib/installer_templates/example_app_tests/test/integration/example_app_phase_dropdown_test.rb +48 -0
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 216f417bd81b48d798076676ab738b5cccd3cb975dcd111bf7eec4d0c4209611
|
|
4
|
+
data.tar.gz: 6cc34bbd9d1579ff0be367a8b1ded62b35f0c303e02daec2e4079326ec71b617
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b3330d050fb3a4d7fc9995e26a032736c00e28c1df3d1cdd57a7a3adbeae7da4826fb90114807799fc0dd110084840ed18f2139b19e0af9a43c2e53196ac25cb
|
|
7
|
+
data.tar.gz: e662affa087a5c224743d3c76d28d0829cb6261ef2353d5a790a891c85cd60479ed05d8a5897b29c4f0923754949c3457d8e41f7f3447312564726ffe1253327
|
|
@@ -1095,11 +1095,40 @@ if ENV['install_example'] == 'true'
|
|
|
1095
1095
|
end
|
|
1096
1096
|
OWNERS_CTRL
|
|
1097
1097
|
|
|
1098
|
+
# Phase -- a lookup whose dropdown follows its dropdown_order column
|
|
1099
|
+
# (inline_forms 8.1.59, InlineForms::DropdownOrder): '---' first, then the
|
|
1100
|
+
# process phases in process order. Its list (/phases) is alphabetical
|
|
1101
|
+
# (_list_order:name) and the seed creates the rows in yet another order,
|
|
1102
|
+
# so the dropdown order is visibly neither id nor name order.
|
|
1103
|
+
say "- Generating Phase lookup (dropdown ordered by dropdown_order)..."
|
|
1104
|
+
sleep 1
|
|
1105
|
+
run %q{bundle exec rails g inline_forms Phase name:string dropdown_order:integer_field _enabled:yes _list_order:name _presentation:'#{name}'}
|
|
1106
|
+
|
|
1107
|
+
say "- Adding phase_id to apartments + belongs_to :phase..."
|
|
1108
|
+
sleep 1
|
|
1109
|
+
add_phase_ts = Time.now.utc.strftime("%Y%m%d%H%M%S")
|
|
1110
|
+
create_file "db/migrate/#{add_phase_ts}_add_phase_to_apartments.rb", <<-ADD_PHASE.strip_heredoc
|
|
1111
|
+
class AddPhaseToApartments < ActiveRecord::Migration[8.1]
|
|
1112
|
+
def change
|
|
1113
|
+
add_reference :apartments, :phase, null: true, foreign_key: true
|
|
1114
|
+
end
|
|
1115
|
+
end
|
|
1116
|
+
ADD_PHASE
|
|
1117
|
+
|
|
1118
|
+
inject_into_file "app/models/apartment.rb",
|
|
1119
|
+
" belongs_to :phase, optional: true\n",
|
|
1120
|
+
after: "class Apartment < ApplicationRecord\n"
|
|
1121
|
+
|
|
1122
|
+
# The :phase dropdown row goes right below :owner.
|
|
1123
|
+
gsub_file "app/models/apartment.rb",
|
|
1124
|
+
/ \[ :owner, :dropdown \], \n/,
|
|
1125
|
+
" [ :owner, :dropdown ], \n [ :phase, :dropdown ], \n"
|
|
1126
|
+
|
|
1098
1127
|
# Seed the example app with 3 apartments + 3 owners and assign photos
|
|
1099
1128
|
# from db/seed_images. Runs as a regular migration so `bundle exec rake
|
|
1100
1129
|
# db:migrate` (and `rails db:setup` on a fresh checkout) populates the
|
|
1101
1130
|
# demo gallery in one shot. Idempotent via find_or_create_by!.
|
|
1102
|
-
say "- Generating seed migration (3 apartments + 3 owners + photo gallery)..."
|
|
1131
|
+
say "- Generating seed migration (3 apartments + 3 owners + 4 phases + photo gallery)..."
|
|
1103
1132
|
sleep 1
|
|
1104
1133
|
seed_ts = Time.now.utc.strftime("%Y%m%d%H%M%S")
|
|
1105
1134
|
create_file "db/migrate/#{seed_ts}_seed_example_apartments_and_owners.rb", <<-SEED_MIGRATION.strip_heredoc
|
|
@@ -1147,6 +1176,17 @@ if ENV['install_example'] == 'true'
|
|
|
1147
1176
|
apartments: [] },
|
|
1148
1177
|
].freeze
|
|
1149
1178
|
|
|
1179
|
+
# Phases, created in neither name nor dropdown order: the apartment
|
|
1180
|
+
# dropdown shows ---, helprequest, decision, admittance (dropdown_order);
|
|
1181
|
+
# /phases lists them by name.
|
|
1182
|
+
PHASES = [
|
|
1183
|
+
{ name: "decision", dropdown_order: 20 },
|
|
1184
|
+
{ name: "admittance", dropdown_order: 30 },
|
|
1185
|
+
{ name: "---", dropdown_order: 0 },
|
|
1186
|
+
{ name: "helprequest", dropdown_order: 10 },
|
|
1187
|
+
].freeze
|
|
1188
|
+
APARTMENT_PHASES = { "Apt 1" => "helprequest", "Apt 2" => "decision", "Apt 3" => "---" }.freeze
|
|
1189
|
+
|
|
1150
1190
|
# Comments seeded on each apartment's first photo (Apartment ->
|
|
1151
1191
|
# Photo -> Comment: the second nesting level).
|
|
1152
1192
|
COMMENTS = [
|
|
@@ -1160,6 +1200,10 @@ if ENV['install_example'] == 'true'
|
|
|
1160
1200
|
Dir.glob(seed_dir.join("*.{png,jpg,jpeg,gif}"), File::FNM_CASEFOLD).sort :
|
|
1161
1201
|
[]
|
|
1162
1202
|
|
|
1203
|
+
PHASES.each do |spec|
|
|
1204
|
+
Phase.find_or_create_by!(name: spec[:name]) { |ph| ph.dropdown_order = spec[:dropdown_order] }
|
|
1205
|
+
end
|
|
1206
|
+
|
|
1163
1207
|
apt_records = {}
|
|
1164
1208
|
APARTMENTS.each_with_index do |spec, idx|
|
|
1165
1209
|
apt = Apartment.find_or_create_by!(name: spec[:name]) do |a|
|
|
@@ -1193,6 +1237,9 @@ if ENV['install_example'] == 'true'
|
|
|
1193
1237
|
end
|
|
1194
1238
|
end
|
|
1195
1239
|
|
|
1240
|
+
phase = Phase.find_by(name: APARTMENT_PHASES[spec[:name]])
|
|
1241
|
+
apt.update!(phase: phase) if phase && apt.phase_id != phase.id
|
|
1242
|
+
|
|
1196
1243
|
apt_records[spec[:name]] = apt
|
|
1197
1244
|
end
|
|
1198
1245
|
|
|
@@ -1212,9 +1259,13 @@ if ENV['install_example'] == 'true'
|
|
|
1212
1259
|
end
|
|
1213
1260
|
|
|
1214
1261
|
def down
|
|
1262
|
+
# apartments.owner_id and apartments.phase_id have foreign keys:
|
|
1263
|
+
# release the apartments (seeded or not) that point at a seeded owner
|
|
1264
|
+
# or phase before destroying it, or destroy raises.
|
|
1215
1265
|
OWNERS.each do |spec|
|
|
1216
|
-
owner = Owner.find_by(name: spec[:name])
|
|
1217
|
-
owner
|
|
1266
|
+
owner = Owner.find_by(name: spec[:name]) or next
|
|
1267
|
+
Apartment.where(owner_id: owner.id).update_all(owner_id: nil)
|
|
1268
|
+
owner.destroy
|
|
1218
1269
|
end
|
|
1219
1270
|
APARTMENTS.each do |spec|
|
|
1220
1271
|
apt = Apartment.find_by(name: spec[:name])
|
|
@@ -1223,6 +1274,11 @@ if ENV['install_example'] == 'true'
|
|
|
1223
1274
|
apt.photos.destroy_all
|
|
1224
1275
|
apt.destroy
|
|
1225
1276
|
end
|
|
1277
|
+
PHASES.each do |spec|
|
|
1278
|
+
phase = Phase.find_by(name: spec[:name]) or next
|
|
1279
|
+
Apartment.where(phase_id: phase.id).update_all(phase_id: nil)
|
|
1280
|
+
phase.destroy
|
|
1281
|
+
end
|
|
1226
1282
|
end
|
|
1227
1283
|
end
|
|
1228
1284
|
SEED_MIGRATION
|
|
@@ -23,8 +23,18 @@ Rails.application.config.dartsass.builds = {
|
|
|
23
23
|
# inline_forms_install/*_main.scss entries would resolve to the PREVIOUS OUTPUT
|
|
24
24
|
# app/assets/builds/inline_forms/{inline_forms,devise}.css instead of the gem's
|
|
25
25
|
# .scss: from the second build on, each build re-imports its own stale result
|
|
26
|
-
# and gem stylesheet changes never reach the app.
|
|
27
|
-
#
|
|
28
|
-
#
|
|
29
|
-
|
|
30
|
-
|
|
26
|
+
# and gem stylesheet changes never reach the app.
|
|
27
|
+
#
|
|
28
|
+
# The gem dir goes in front of the runner's own --load-path list, as a
|
|
29
|
+
# separate argument: not in build_options (the runner splits every entry there
|
|
30
|
+
# on whitespace, which breaks a gem path with a space in it) and not first on
|
|
31
|
+
# config.assets.paths (Sprockets would then resolve inline_forms/*.css to the
|
|
32
|
+
# gem's .scss instead of the compiled build).
|
|
33
|
+
require "dartsass/runner"
|
|
34
|
+
|
|
35
|
+
module InlineFormsDartsassLoadPath
|
|
36
|
+
def dartsass_load_paths
|
|
37
|
+
[ "--load-path", InlineForms::Engine.root.join("app/assets/stylesheets").to_s ] + super
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
Dartsass::Runner.singleton_class.prepend(InlineFormsDartsassLoadPath)
|
data/lib/installer_templates/example_app_tests/test/integration/example_app_dartsass_build_test.rb
CHANGED
|
@@ -17,7 +17,8 @@ class ExampleAppDartsassBuildTest < ActiveSupport::TestCase
|
|
|
17
17
|
command = Dartsass::Runner.dartsass_compile_command
|
|
18
18
|
first_load_path = command.index { |arg| arg == "--load-path" || arg.start_with?("--load-path=") }
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
# Two arguments, so a gem path with a space stays one argument.
|
|
21
|
+
assert_equal [ "--load-path", gem_stylesheets ], command[first_load_path, 2]
|
|
21
22
|
end
|
|
22
23
|
|
|
23
24
|
%w[inline_forms devise].each do |entry|
|
data/lib/installer_templates/example_app_tests/test/integration/example_app_phase_dropdown_test.rb
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "../example_app/example_integration_test_case"
|
|
4
|
+
|
|
5
|
+
# Phase (inline_forms 8.1.59): a lookup with a dropdown_order column. The
|
|
6
|
+
# apartment's phase dropdown follows dropdown_order ('---' first, then the
|
|
7
|
+
# phases in process order), not id order and not the alphabetical list order
|
|
8
|
+
# of /phases. See InlineForms::DropdownOrder.
|
|
9
|
+
class ExampleAppPhaseDropdownTest < ExampleAppIntegrationTestCase
|
|
10
|
+
PHASES = { "decision" => 20, "admittance" => 30, "---" => 0, "helprequest" => 10 }.freeze
|
|
11
|
+
|
|
12
|
+
setup do
|
|
13
|
+
PHASES.each do |name, position|
|
|
14
|
+
Phase.find_or_create_by!(name: name) { |phase| phase.dropdown_order = position }
|
|
15
|
+
end
|
|
16
|
+
@apartment = Apartment.find_or_create_by!(name: "Phase Apt") { |a| a.title = "Phase Title" }
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
test "the apartment phase dropdown follows dropdown_order" do
|
|
20
|
+
frame = "apartment_#{@apartment.id}_phase"
|
|
21
|
+
get edit_apartment_path(@apartment, attribute: "phase", form_element: "dropdown", update: frame),
|
|
22
|
+
headers: { "Turbo-Frame" => frame }
|
|
23
|
+
|
|
24
|
+
assert_response :success
|
|
25
|
+
options = @response.body.scan(%r{<option(?: [^>]*)?>([^<]*)</option>}).flatten
|
|
26
|
+
assert_equal [ "---", "helprequest", "decision", "admittance" ], options
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
test "choosing a phase in the dropdown saves it" do
|
|
30
|
+
frame = "apartment_#{@apartment.id}_phase"
|
|
31
|
+
decision = Phase.find_by!(name: "decision")
|
|
32
|
+
|
|
33
|
+
put apartment_path(@apartment, attribute: "phase", form_element: "dropdown", update: frame),
|
|
34
|
+
params: { _apartment: { phase_id: decision.id } }, headers: { "Turbo-Frame" => frame }
|
|
35
|
+
|
|
36
|
+
assert_response :success
|
|
37
|
+
assert_equal decision, @apartment.reload.phase
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
test "the phases list stays in its own (alphabetical) list order" do
|
|
41
|
+
get phases_path
|
|
42
|
+
|
|
43
|
+
assert_response :success
|
|
44
|
+
positions = %w[admittance decision helprequest].map { |name| @response.body.index(">#{name}<") }
|
|
45
|
+
assert positions.all?, "every phase is listed"
|
|
46
|
+
assert_equal positions.sort, positions
|
|
47
|
+
end
|
|
48
|
+
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: inline_forms_installer
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 8.1.
|
|
4
|
+
version: 8.1.60
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ace Suares
|
|
@@ -103,6 +103,7 @@ files:
|
|
|
103
103
|
- lib/installer_templates/example_app_tests/test/integration/example_app_guest_access_test.rb
|
|
104
104
|
- lib/installer_templates/example_app_tests/test/integration/example_app_layout_title_test.rb
|
|
105
105
|
- lib/installer_templates/example_app_tests/test/integration/example_app_owner_tabs_test.rb
|
|
106
|
+
- lib/installer_templates/example_app_tests/test/integration/example_app_phase_dropdown_test.rb
|
|
106
107
|
- lib/installer_templates/example_app_tests/test/integration/example_app_photo_comments_test.rb
|
|
107
108
|
- lib/installer_templates/example_app_tests/test/integration/example_app_photo_revert_test.rb
|
|
108
109
|
- lib/installer_templates/example_app_tests/test/integration/example_app_photos_test.rb
|