active_fields 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +1 -1
  3. data/CHANGELOG.md +6 -0
  4. data/README.md +92 -77
  5. data/app/models/concerns/active_fields/customizable_concern.rb +4 -1
  6. data/lib/active_fields/engine.rb +6 -0
  7. data/lib/active_fields/version.rb +1 -1
  8. data/lib/active_fields.rb +51 -31
  9. data/lib/generators/active_fields/install/install_generator.rb +1 -1
  10. data/lib/generators/active_fields/scaffold/USAGE +9 -0
  11. data/lib/generators/active_fields/scaffold/scaffold_generator.rb +25 -0
  12. data/lib/generators/active_fields/scaffold/templates/controllers/active_fields_controller.rb +143 -0
  13. data/lib/generators/active_fields/scaffold/templates/helpers/active_fields_helper.rb +33 -0
  14. data/lib/generators/active_fields/scaffold/templates/javascript/controllers/array_field_controller.js +25 -0
  15. data/lib/generators/active_fields/scaffold/templates/views/active_fields/edit.html.erb +5 -0
  16. data/lib/generators/active_fields/scaffold/templates/views/active_fields/forms/_boolean.html.erb +53 -0
  17. data/lib/generators/active_fields/scaffold/templates/views/active_fields/forms/_date.html.erb +58 -0
  18. data/lib/generators/active_fields/scaffold/templates/views/active_fields/forms/_date_array.html.erb +70 -0
  19. data/lib/generators/active_fields/scaffold/templates/views/active_fields/forms/_datetime.html.erb +63 -0
  20. data/lib/generators/active_fields/scaffold/templates/views/active_fields/forms/_datetime_array.html.erb +75 -0
  21. data/lib/generators/active_fields/scaffold/templates/views/active_fields/forms/_decimal.html.erb +63 -0
  22. data/lib/generators/active_fields/scaffold/templates/views/active_fields/forms/_decimal_array.html.erb +76 -0
  23. data/lib/generators/active_fields/scaffold/templates/views/active_fields/forms/_enum.html.erb +61 -0
  24. data/lib/generators/active_fields/scaffold/templates/views/active_fields/forms/_enum_array.html.erb +73 -0
  25. data/lib/generators/active_fields/scaffold/templates/views/active_fields/forms/_integer.html.erb +58 -0
  26. data/lib/generators/active_fields/scaffold/templates/views/active_fields/forms/_integer_array.html.erb +70 -0
  27. data/lib/generators/active_fields/scaffold/templates/views/active_fields/forms/_text.html.erb +53 -0
  28. data/lib/generators/active_fields/scaffold/templates/views/active_fields/forms/_text_array.html.erb +70 -0
  29. data/lib/generators/active_fields/scaffold/templates/views/active_fields/index.html.erb +41 -0
  30. data/lib/generators/active_fields/scaffold/templates/views/active_fields/new.html.erb +5 -0
  31. data/lib/generators/active_fields/scaffold/templates/views/active_fields/show.html.erb +29 -0
  32. data/lib/generators/active_fields/scaffold/templates/views/active_fields/values/inputs/_boolean.html.erb +8 -0
  33. data/lib/generators/active_fields/scaffold/templates/views/active_fields/values/inputs/_date.html.erb +4 -0
  34. data/lib/generators/active_fields/scaffold/templates/views/active_fields/values/inputs/_date_array.html.erb +12 -0
  35. data/lib/generators/active_fields/scaffold/templates/views/active_fields/values/inputs/_datetime.html.erb +4 -0
  36. data/lib/generators/active_fields/scaffold/templates/views/active_fields/values/inputs/_datetime_array.html.erb +12 -0
  37. data/lib/generators/active_fields/scaffold/templates/views/active_fields/values/inputs/_decimal.html.erb +4 -0
  38. data/lib/generators/active_fields/scaffold/templates/views/active_fields/values/inputs/_decimal_array.html.erb +12 -0
  39. data/lib/generators/active_fields/scaffold/templates/views/active_fields/values/inputs/_enum.html.erb +4 -0
  40. data/lib/generators/active_fields/scaffold/templates/views/active_fields/values/inputs/_enum_array.html.erb +4 -0
  41. data/lib/generators/active_fields/scaffold/templates/views/active_fields/values/inputs/_integer.html.erb +4 -0
  42. data/lib/generators/active_fields/scaffold/templates/views/active_fields/values/inputs/_integer_array.html.erb +12 -0
  43. data/lib/generators/active_fields/scaffold/templates/views/active_fields/values/inputs/_text.html.erb +4 -0
  44. data/lib/generators/active_fields/scaffold/templates/views/active_fields/values/inputs/_text_array.html.erb +12 -0
  45. data/lib/generators/active_fields/scaffold/templates/views/shared/_array_field.html.erb +19 -0
  46. metadata +39 -3
@@ -0,0 +1,25 @@
1
+ import { Controller } from "@hotwired/stimulus"
2
+
3
+ export default class extends Controller {
4
+ static targets = ["templateFieldGroup"]
5
+
6
+ connect() {
7
+ this.templateFieldGroupTarget.style.display = "none"
8
+ }
9
+
10
+ addField(e) {
11
+ e.preventDefault()
12
+
13
+ let newFieldGroup = this.templateFieldGroupTarget.cloneNode(true)
14
+ delete newFieldGroup.dataset.arrayFieldTarget
15
+ newFieldGroup.style.removeProperty("display")
16
+
17
+ e.target.before(newFieldGroup)
18
+ }
19
+
20
+ removeField(e) {
21
+ e.preventDefault()
22
+
23
+ e.target.parentElement.remove()
24
+ }
25
+ }
@@ -0,0 +1,5 @@
1
+ <h1>Editing Active Field #<%= @active_field.id %></h1>
2
+
3
+ <%= render_active_field_form(active_field: @active_field) %>
4
+
5
+ <div><%= link_to "Back", active_fields_path %></div>
@@ -0,0 +1,53 @@
1
+ <%= form_with(model: active_field, scope: :active_field, url: active_field.persisted? ? active_field_path(active_field) : active_fields_path) do |f| %>
2
+ <% if active_field.errors.any? %>
3
+ <div style="color: red">
4
+ <h2><%= pluralize(active_field.errors.count, "error") %> prohibited this record from being saved:</h2>
5
+
6
+ <ul>
7
+ <% active_field.errors.each do |error| %>
8
+ <li><%= error.full_message %></li>
9
+ <% end %>
10
+ </ul>
11
+ </div>
12
+ <% end %>
13
+
14
+ <div>
15
+ <%= f.label :type %>
16
+ <%=
17
+ f.text_field :type,
18
+ name: "type",
19
+ value: active_field.type_name,
20
+ disabled: active_field.persisted?,
21
+ readonly: active_field.new_record?
22
+ %>
23
+ </div>
24
+
25
+ <div>
26
+ <%= f.label :customizable_type %>
27
+ <%= f.select :customizable_type, ["TODO: add allowed customizable model names"], {}, { disabled: active_field.persisted? } %>
28
+ </div>
29
+
30
+ <div>
31
+ <%= f.label :name %>
32
+ <%= f.text_field :name %>
33
+ </div>
34
+
35
+ <div>
36
+ <%= f.label :required %>
37
+ <%= f.check_box :required, disabled: active_field.persisted? %>
38
+ </div>
39
+
40
+ <div>
41
+ <%= f.label :nullable %>
42
+ <%= f.check_box :nullable, disabled: active_field.persisted? %>
43
+ </div>
44
+
45
+ <div>
46
+ <%= f.label :default_value %>
47
+ <%= f.collection_radio_buttons :default_value, { "Null" => "", "True" => "true", "False" => "false" }, :last, :first %>
48
+ </div>
49
+
50
+ <div>
51
+ <%= f.submit %>
52
+ </div>
53
+ <% end %>
@@ -0,0 +1,58 @@
1
+ <%= form_with(model: active_field, scope: :active_field, url: active_field.persisted? ? active_field_path(active_field) : active_fields_path) do |f| %>
2
+ <% if active_field.errors.any? %>
3
+ <div style="color: red">
4
+ <h2><%= pluralize(active_field.errors.count, "error") %> prohibited this record from being saved:</h2>
5
+
6
+ <ul>
7
+ <% active_field.errors.each do |error| %>
8
+ <li><%= error.full_message %></li>
9
+ <% end %>
10
+ </ul>
11
+ </div>
12
+ <% end %>
13
+
14
+ <div>
15
+ <%= f.label :type %>
16
+ <%=
17
+ f.text_field :type,
18
+ name: "type",
19
+ value: active_field.type_name,
20
+ disabled: active_field.persisted?,
21
+ readonly: active_field.new_record?
22
+ %>
23
+ </div>
24
+
25
+ <div>
26
+ <%= f.label :customizable_type %>
27
+ <%= f.select :customizable_type, ["TODO: add allowed customizable model names"], {}, { disabled: active_field.persisted? } %>
28
+ </div>
29
+
30
+ <div>
31
+ <%= f.label :name %>
32
+ <%= f.text_field :name %>
33
+ </div>
34
+
35
+ <div>
36
+ <%= f.label :required %>
37
+ <%= f.check_box :required, disabled: active_field.persisted? %>
38
+ </div>
39
+
40
+ <div>
41
+ <%= f.label :min %>
42
+ <%= f.date_field :min, disabled: active_field.persisted? %>
43
+ </div>
44
+
45
+ <div>
46
+ <%= f.label :max %>
47
+ <%= f.date_field :max, disabled: active_field.persisted? %>
48
+ </div>
49
+
50
+ <div>
51
+ <%= f.label :default_value %>
52
+ <%= f.date_field :default_value %>
53
+ </div>
54
+
55
+ <div>
56
+ <%= f.submit %>
57
+ </div>
58
+ <% end %>
@@ -0,0 +1,70 @@
1
+ <%= form_with(model: active_field, scope: :active_field, url: active_field.persisted? ? active_field_path(active_field) : active_fields_path) do |f| %>
2
+ <% if active_field.errors.any? %>
3
+ <div style="color: red">
4
+ <h2><%= pluralize(active_field.errors.count, "error") %> prohibited this record from being saved:</h2>
5
+
6
+ <ul>
7
+ <% active_field.errors.each do |error| %>
8
+ <li><%= error.full_message %></li>
9
+ <% end %>
10
+ </ul>
11
+ </div>
12
+ <% end %>
13
+
14
+ <div>
15
+ <%= f.label :type %>
16
+ <%=
17
+ f.text_field :type,
18
+ name: "type",
19
+ value: active_field.type_name,
20
+ disabled: active_field.persisted?,
21
+ readonly: active_field.new_record?
22
+ %>
23
+ </div>
24
+
25
+ <div>
26
+ <%= f.label :customizable_type %>
27
+ <%= f.select :customizable_type, ["TODO: add allowed customizable model names"], {}, { disabled: active_field.persisted? } %>
28
+ </div>
29
+
30
+ <div>
31
+ <%= f.label :name %>
32
+ <%= f.text_field :name %>
33
+ </div>
34
+
35
+ <div>
36
+ <%= f.label :min_size %>
37
+ <%= f.number_field :min_size, disabled: active_field.persisted? %>
38
+ </div>
39
+
40
+ <div>
41
+ <%= f.label :max_size %>
42
+ <%= f.number_field :max_size, disabled: active_field.persisted? %>
43
+ </div>
44
+
45
+ <div>
46
+ <%= f.label :min %>
47
+ <%= f.date_field :min, disabled: active_field.persisted? %>
48
+ </div>
49
+
50
+ <div>
51
+ <%= f.label :max %>
52
+ <%= f.date_field :max, disabled: active_field.persisted? %>
53
+ </div>
54
+
55
+ <div>
56
+ <%= f.label :default_value %>
57
+ <%=
58
+ render_array_field(
59
+ form: f,
60
+ name: :default_value,
61
+ value: active_field.default_value,
62
+ field_method: :date_field,
63
+ )
64
+ %>
65
+ </div>
66
+
67
+ <div>
68
+ <%= f.submit %>
69
+ </div>
70
+ <% end %>
@@ -0,0 +1,63 @@
1
+ <%= form_with(model: active_field, scope: :active_field, url: active_field.persisted? ? active_field_path(active_field) : active_fields_path) do |f| %>
2
+ <% if active_field.errors.any? %>
3
+ <div style="color: red">
4
+ <h2><%= pluralize(active_field.errors.count, "error") %> prohibited this record from being saved:</h2>
5
+
6
+ <ul>
7
+ <% active_field.errors.each do |error| %>
8
+ <li><%= error.full_message %></li>
9
+ <% end %>
10
+ </ul>
11
+ </div>
12
+ <% end %>
13
+
14
+ <div>
15
+ <%= f.label :type %>
16
+ <%=
17
+ f.text_field :type,
18
+ name: "type",
19
+ value: active_field.type_name,
20
+ disabled: active_field.persisted?,
21
+ readonly: active_field.new_record?
22
+ %>
23
+ </div>
24
+
25
+ <div>
26
+ <%= f.label :customizable_type %>
27
+ <%= f.select :customizable_type, ["TODO: add allowed customizable model names"], {}, { disabled: active_field.persisted? } %>
28
+ </div>
29
+
30
+ <div>
31
+ <%= f.label :name %>
32
+ <%= f.text_field :name %>
33
+ </div>
34
+
35
+ <div>
36
+ <%= f.label :required %>
37
+ <%= f.check_box :required, disabled: active_field.persisted? %>
38
+ </div>
39
+
40
+ <div>
41
+ <%= f.label :min %>
42
+ <%= f.datetime_field :min, disabled: active_field.persisted? %>
43
+ </div>
44
+
45
+ <div>
46
+ <%= f.label :max %>
47
+ <%= f.datetime_field :max, disabled: active_field.persisted? %>
48
+ </div>
49
+
50
+ <div>
51
+ <%= f.label :precision %>
52
+ <%= f.number_field :precision, min: 0, max: ActiveFields::Casters::DateTimeCaster::MAX_PRECISION, disabled: active_field.persisted? %>
53
+ </div>
54
+
55
+ <div>
56
+ <%= f.label :default_value %>
57
+ <%= f.datetime_field :default_value %>
58
+ </div>
59
+
60
+ <div>
61
+ <%= f.submit %>
62
+ </div>
63
+ <% end %>
@@ -0,0 +1,75 @@
1
+ <%= form_with(model: active_field, scope: :active_field, url: active_field.persisted? ? active_field_path(active_field) : active_fields_path) do |f| %>
2
+ <% if active_field.errors.any? %>
3
+ <div style="color: red">
4
+ <h2><%= pluralize(active_field.errors.count, "error") %> prohibited this record from being saved:</h2>
5
+
6
+ <ul>
7
+ <% active_field.errors.each do |error| %>
8
+ <li><%= error.full_message %></li>
9
+ <% end %>
10
+ </ul>
11
+ </div>
12
+ <% end %>
13
+
14
+ <div>
15
+ <%= f.label :type %>
16
+ <%=
17
+ f.text_field :type,
18
+ name: "type",
19
+ value: active_field.type_name,
20
+ disabled: active_field.persisted?,
21
+ readonly: active_field.new_record?
22
+ %>
23
+ </div>
24
+
25
+ <div>
26
+ <%= f.label :customizable_type %>
27
+ <%= f.select :customizable_type, ["TODO: add allowed customizable model names"], {}, { disabled: active_field.persisted? } %>
28
+ </div>
29
+
30
+ <div>
31
+ <%= f.label :name %>
32
+ <%= f.text_field :name %>
33
+ </div>
34
+
35
+ <div>
36
+ <%= f.label :min_size %>
37
+ <%= f.number_field :min_size, disabled: active_field.persisted? %>
38
+ </div>
39
+
40
+ <div>
41
+ <%= f.label :max_size %>
42
+ <%= f.number_field :max_size, disabled: active_field.persisted? %>
43
+ </div>
44
+
45
+ <div>
46
+ <%= f.label :min %>
47
+ <%= f.datetime_field :min, disabled: active_field.persisted? %>
48
+ </div>
49
+
50
+ <div>
51
+ <%= f.label :max %>
52
+ <%= f.datetime_field :max, disabled: active_field.persisted? %>
53
+ </div>
54
+
55
+ <div>
56
+ <%= f.label :precision %>
57
+ <%= f.number_field :precision, min: 0, max: ActiveFields::Casters::DateTimeCaster::MAX_PRECISION, disabled: active_field.persisted? %>
58
+ </div>
59
+
60
+ <div>
61
+ <%= f.label :default_value %>
62
+ <%=
63
+ render_array_field(
64
+ form: f,
65
+ name: :default_value,
66
+ value: active_field.default_value,
67
+ field_method: :datetime_field,
68
+ )
69
+ %>
70
+ </div>
71
+
72
+ <div>
73
+ <%= f.submit %>
74
+ </div>
75
+ <% end %>
@@ -0,0 +1,63 @@
1
+ <%= form_with(model: active_field, scope: :active_field, url: active_field.persisted? ? active_field_path(active_field) : active_fields_path) do |f| %>
2
+ <% if active_field.errors.any? %>
3
+ <div style="color: red">
4
+ <h2><%= pluralize(active_field.errors.count, "error") %> prohibited this record from being saved:</h2>
5
+
6
+ <ul>
7
+ <% active_field.errors.each do |error| %>
8
+ <li><%= error.full_message %></li>
9
+ <% end %>
10
+ </ul>
11
+ </div>
12
+ <% end %>
13
+
14
+ <div>
15
+ <%= f.label :type %>
16
+ <%=
17
+ f.text_field :type,
18
+ name: "type",
19
+ value: active_field.type_name,
20
+ disabled: active_field.persisted?,
21
+ readonly: active_field.new_record?
22
+ %>
23
+ </div>
24
+
25
+ <div>
26
+ <%= f.label :customizable_type %>
27
+ <%= f.select :customizable_type, ["TODO: add allowed customizable model names"], {}, { disabled: active_field.persisted? } %>
28
+ </div>
29
+
30
+ <div>
31
+ <%= f.label :name %>
32
+ <%= f.text_field :name %>
33
+ </div>
34
+
35
+ <div>
36
+ <%= f.label :required %>
37
+ <%= f.check_box :required, disabled: active_field.persisted? %>
38
+ </div>
39
+
40
+ <div>
41
+ <%= f.label :min %>
42
+ <%= f.number_field :min, step: "any", disabled: active_field.persisted? %>
43
+ </div>
44
+
45
+ <div>
46
+ <%= f.label :max %>
47
+ <%= f.number_field :max, step: "any", disabled: active_field.persisted? %>
48
+ </div>
49
+
50
+ <div>
51
+ <%= f.label :precision %>
52
+ <%= f.number_field :precision, min: 0, disabled: active_field.persisted? %>
53
+ </div>
54
+
55
+ <div>
56
+ <%= f.label :default_value %>
57
+ <%= f.number_field :default_value, step: "any" %>
58
+ </div>
59
+
60
+ <div>
61
+ <%= f.submit %>
62
+ </div>
63
+ <% end %>
@@ -0,0 +1,76 @@
1
+ <%= form_with(model: active_field, scope: :active_field, url: active_field.persisted? ? active_field_path(active_field) : active_fields_path) do |f| %>
2
+ <% if active_field.errors.any? %>
3
+ <div style="color: red">
4
+ <h2><%= pluralize(active_field.errors.count, "error") %> prohibited this record from being saved:</h2>
5
+
6
+ <ul>
7
+ <% active_field.errors.each do |error| %>
8
+ <li><%= error.full_message %></li>
9
+ <% end %>
10
+ </ul>
11
+ </div>
12
+ <% end %>
13
+
14
+ <div>
15
+ <%= f.label :type %>
16
+ <%=
17
+ f.text_field :type,
18
+ name: "type",
19
+ value: active_field.type_name,
20
+ disabled: active_field.persisted?,
21
+ readonly: active_field.new_record?
22
+ %>
23
+ </div>
24
+
25
+ <div>
26
+ <%= f.label :customizable_type %>
27
+ <%= f.select :customizable_type, ["TODO: add allowed customizable model names"], {}, { disabled: active_field.persisted? } %>
28
+ </div>
29
+
30
+ <div>
31
+ <%= f.label :name %>
32
+ <%= f.text_field :name %>
33
+ </div>
34
+
35
+ <div>
36
+ <%= f.label :min_size %>
37
+ <%= f.number_field :min_size, disabled: active_field.persisted? %>
38
+ </div>
39
+
40
+ <div>
41
+ <%= f.label :max_size %>
42
+ <%= f.number_field :max_size, disabled: active_field.persisted? %>
43
+ </div>
44
+
45
+ <div>
46
+ <%= f.label :min %>
47
+ <%= f.number_field :min, step: "any", disabled: active_field.persisted? %>
48
+ </div>
49
+
50
+ <div>
51
+ <%= f.label :max %>
52
+ <%= f.number_field :max, step: "any", disabled: active_field.persisted? %>
53
+ </div>
54
+
55
+ <div>
56
+ <%= f.label :precision %>
57
+ <%= f.number_field :precision, min: 0, disabled: active_field.persisted? %>
58
+ </div>
59
+
60
+ <div>
61
+ <%= f.label :default_value %>
62
+ <%=
63
+ render_array_field(
64
+ form: f,
65
+ name: :default_value,
66
+ value: active_field.default_value,
67
+ field_method: :number_field,
68
+ field_opts: { step: "any" },
69
+ )
70
+ %>
71
+ </div>
72
+
73
+ <div>
74
+ <%= f.submit %>
75
+ </div>
76
+ <% end %>
@@ -0,0 +1,61 @@
1
+ <%= form_with(model: active_field, scope: :active_field, url: active_field.persisted? ? active_field_path(active_field) : active_fields_path) do |f| %>
2
+ <% if active_field.errors.any? %>
3
+ <div style="color: red">
4
+ <h2><%= pluralize(active_field.errors.count, "error") %> prohibited this record from being saved:</h2>
5
+
6
+ <ul>
7
+ <% active_field.errors.each do |error| %>
8
+ <li><%= error.full_message %></li>
9
+ <% end %>
10
+ </ul>
11
+ </div>
12
+ <% end %>
13
+
14
+ <div>
15
+ <%= f.label :type %>
16
+ <%=
17
+ f.text_field :type,
18
+ name: "type",
19
+ value: active_field.type_name,
20
+ disabled: active_field.persisted?,
21
+ readonly: active_field.new_record?
22
+ %>
23
+ </div>
24
+
25
+ <div>
26
+ <%= f.label :customizable_type %>
27
+ <%= f.select :customizable_type, ["TODO: add allowed customizable model names"], {}, { disabled: active_field.persisted? } %>
28
+ </div>
29
+
30
+ <div>
31
+ <%= f.label :name %>
32
+ <%= f.text_field :name %>
33
+ </div>
34
+
35
+ <div>
36
+ <%= f.label :required %>
37
+ <%= f.check_box :required, disabled: active_field.persisted? %>
38
+ </div>
39
+
40
+ <div>
41
+ <%= f.label :allowed_values %>
42
+ <%=
43
+ render_array_field(
44
+ form: f,
45
+ name: :allowed_values,
46
+ value: active_field.allowed_values,
47
+ field_method: :text_field,
48
+ field_opts: { disabled: active_field.persisted? }
49
+ )
50
+ %>
51
+ </div>
52
+
53
+ <div>
54
+ <%= f.label :default_value %>
55
+ <%= f.text_field :default_value %>
56
+ </div>
57
+
58
+ <div>
59
+ <%= f.submit %>
60
+ </div>
61
+ <% end %>
@@ -0,0 +1,73 @@
1
+ <%= form_with(model: active_field, scope: :active_field, url: active_field.persisted? ? active_field_path(active_field) : active_fields_path) do |f| %>
2
+ <% if active_field.errors.any? %>
3
+ <div style="color: red">
4
+ <h2><%= pluralize(active_field.errors.count, "error") %> prohibited this record from being saved:</h2>
5
+
6
+ <ul>
7
+ <% active_field.errors.each do |error| %>
8
+ <li><%= error.full_message %></li>
9
+ <% end %>
10
+ </ul>
11
+ </div>
12
+ <% end %>
13
+
14
+ <div>
15
+ <%= f.label :type %>
16
+ <%=
17
+ f.text_field :type,
18
+ name: "type",
19
+ value: active_field.type_name,
20
+ disabled: active_field.persisted?,
21
+ readonly: active_field.new_record?
22
+ %>
23
+ </div>
24
+
25
+ <div>
26
+ <%= f.label :customizable_type %>
27
+ <%= f.select :customizable_type, ["TODO: add allowed customizable model names"], {}, { disabled: active_field.persisted? } %>
28
+ </div>
29
+
30
+ <div>
31
+ <%= f.label :name %>
32
+ <%= f.text_field :name %>
33
+ </div>
34
+
35
+ <div>
36
+ <%= f.label :min_size %>
37
+ <%= f.number_field :min_size, disabled: active_field.persisted? %>
38
+ </div>
39
+
40
+ <div>
41
+ <%= f.label :max_size %>
42
+ <%= f.number_field :max_size, disabled: active_field.persisted? %>
43
+ </div>
44
+
45
+ <div>
46
+ <%= f.label :allowed_values %>
47
+ <%=
48
+ render_array_field(
49
+ form: f,
50
+ name: :allowed_values,
51
+ value: active_field.allowed_values,
52
+ field_method: :text_field,
53
+ field_opts: { disabled: active_field.persisted? }
54
+ )
55
+ %>
56
+ </div>
57
+
58
+ <div>
59
+ <%= f.label :default_value %>
60
+ <%=
61
+ render_array_field(
62
+ form: f,
63
+ name: :default_value,
64
+ value: active_field.default_value,
65
+ field_method: :text_field,
66
+ )
67
+ %>
68
+ </div>
69
+
70
+ <div>
71
+ <%= f.submit %>
72
+ </div>
73
+ <% end %>
@@ -0,0 +1,58 @@
1
+ <%= form_with(model: active_field, scope: :active_field, url: active_field.persisted? ? active_field_path(active_field) : active_fields_path) do |f| %>
2
+ <% if active_field.errors.any? %>
3
+ <div style="color: red">
4
+ <h2><%= pluralize(active_field.errors.count, "error") %> prohibited this record from being saved:</h2>
5
+
6
+ <ul>
7
+ <% active_field.errors.each do |error| %>
8
+ <li><%= error.full_message %></li>
9
+ <% end %>
10
+ </ul>
11
+ </div>
12
+ <% end %>
13
+
14
+ <div>
15
+ <%= f.label :type %>
16
+ <%=
17
+ f.text_field :type,
18
+ name: "type",
19
+ value: active_field.type_name,
20
+ disabled: active_field.persisted?,
21
+ readonly: active_field.new_record?
22
+ %>
23
+ </div>
24
+
25
+ <div>
26
+ <%= f.label :customizable_type %>
27
+ <%= f.select :customizable_type, ["TODO: add allowed customizable model names"], {}, { disabled: active_field.persisted? } %>
28
+ </div>
29
+
30
+ <div>
31
+ <%= f.label :name %>
32
+ <%= f.text_field :name %>
33
+ </div>
34
+
35
+ <div>
36
+ <%= f.label :required %>
37
+ <%= f.check_box :required, disabled: active_field.persisted? %>
38
+ </div>
39
+
40
+ <div>
41
+ <%= f.label :min %>
42
+ <%= f.number_field :min, disabled: active_field.persisted? %>
43
+ </div>
44
+
45
+ <div>
46
+ <%= f.label :max %>
47
+ <%= f.number_field :max, disabled: active_field.persisted? %>
48
+ </div>
49
+
50
+ <div>
51
+ <%= f.label :default_value %>
52
+ <%= f.number_field :default_value %>
53
+ </div>
54
+
55
+ <div>
56
+ <%= f.submit %>
57
+ </div>
58
+ <% end %>