active_fields 2.0.0 → 3.0.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 +4 -4
- data/.rubocop.yml +15 -2
- data/Appraisals +19 -0
- data/CHANGELOG.md +10 -0
- data/README.md +113 -12
- data/Rakefile +0 -2
- data/app/models/concerns/active_fields/customizable_concern.rb +59 -13
- data/app/models/concerns/active_fields/field_concern.rb +38 -6
- data/app/models/concerns/active_fields/value_concern.rb +8 -3
- data/db/migrate/20250229230000_add_scope_to_active_fields.rb +14 -0
- data/gemfiles/rails_7.1.gemfile +15 -0
- data/gemfiles/rails_7.2.gemfile +15 -0
- data/gemfiles/rails_8.0.gemfile +15 -0
- data/gemfiles/rails_8.1.gemfile +15 -0
- data/lib/active_fields/casters/date_array_caster.rb +2 -2
- data/lib/active_fields/casters/date_time_array_caster.rb +2 -2
- data/lib/active_fields/casters/decimal_array_caster.rb +2 -2
- data/lib/active_fields/casters/enum_array_caster.rb +2 -2
- data/lib/active_fields/casters/integer_array_caster.rb +2 -2
- data/lib/active_fields/casters/text_array_caster.rb +2 -2
- data/lib/active_fields/config.rb +2 -2
- data/lib/active_fields/finders/array_finder.rb +8 -2
- data/lib/active_fields/finders/base_finder.rb +1 -1
- data/lib/active_fields/has_active_fields.rb +3 -1
- data/lib/active_fields/version.rb +1 -1
- data/lib/generators/active_fields/scaffold/templates/controllers/active_fields_controller.rb +18 -18
- data/lib/generators/active_fields/scaffold/templates/javascript/controllers/active_field_form_controller.js +19 -0
- data/lib/generators/active_fields/scaffold/templates/views/active_fields/forms/_boolean.html.erb +22 -1
- data/lib/generators/active_fields/scaffold/templates/views/active_fields/forms/_date.html.erb +22 -1
- data/lib/generators/active_fields/scaffold/templates/views/active_fields/forms/_date_array.html.erb +22 -1
- data/lib/generators/active_fields/scaffold/templates/views/active_fields/forms/_datetime.html.erb +22 -1
- data/lib/generators/active_fields/scaffold/templates/views/active_fields/forms/_datetime_array.html.erb +22 -1
- data/lib/generators/active_fields/scaffold/templates/views/active_fields/forms/_decimal.html.erb +22 -1
- data/lib/generators/active_fields/scaffold/templates/views/active_fields/forms/_decimal_array.html.erb +22 -1
- data/lib/generators/active_fields/scaffold/templates/views/active_fields/forms/_enum.html.erb +22 -1
- data/lib/generators/active_fields/scaffold/templates/views/active_fields/forms/_enum_array.html.erb +22 -1
- data/lib/generators/active_fields/scaffold/templates/views/active_fields/forms/_integer.html.erb +22 -1
- data/lib/generators/active_fields/scaffold/templates/views/active_fields/forms/_integer_array.html.erb +22 -1
- data/lib/generators/active_fields/scaffold/templates/views/active_fields/forms/_text.html.erb +22 -1
- data/lib/generators/active_fields/scaffold/templates/views/active_fields/forms/_text_array.html.erb +22 -1
- data/lib/generators/active_fields/scaffold/templates/views/active_fields/index.html.erb +2 -0
- metadata +24 -4
- data/CODE_OF_CONDUCT.md +0 -84
|
@@ -6,13 +6,13 @@ module ActiveFields
|
|
|
6
6
|
def serialize(value)
|
|
7
7
|
return unless value.is_a?(Array)
|
|
8
8
|
|
|
9
|
-
value.map { super(
|
|
9
|
+
value.map { |element| super(element) }
|
|
10
10
|
end
|
|
11
11
|
|
|
12
12
|
def deserialize(value)
|
|
13
13
|
return unless value.is_a?(Array)
|
|
14
14
|
|
|
15
|
-
value.map { super(
|
|
15
|
+
value.map { |element| super(element) }
|
|
16
16
|
end
|
|
17
17
|
end
|
|
18
18
|
end
|
|
@@ -6,13 +6,13 @@ module ActiveFields
|
|
|
6
6
|
def serialize(value)
|
|
7
7
|
return unless value.is_a?(Array)
|
|
8
8
|
|
|
9
|
-
value.map { super(
|
|
9
|
+
value.map { |element| super(element) }
|
|
10
10
|
end
|
|
11
11
|
|
|
12
12
|
def deserialize(value)
|
|
13
13
|
return unless value.is_a?(Array)
|
|
14
14
|
|
|
15
|
-
value.map { super(
|
|
15
|
+
value.map { |element| super(element) }
|
|
16
16
|
end
|
|
17
17
|
end
|
|
18
18
|
end
|
data/lib/active_fields/config.rb
CHANGED
|
@@ -11,8 +11,6 @@ module ActiveFields
|
|
|
11
11
|
attr_reader :fields
|
|
12
12
|
|
|
13
13
|
def initialize
|
|
14
|
-
@field_base_class_name = DEFAULT_FIELD_BASE_CLASS_NAME
|
|
15
|
-
@value_class_name = DEFAULT_VALUE_CLASS_NAME
|
|
16
14
|
@fields = {
|
|
17
15
|
boolean: "ActiveFields::Field::Boolean",
|
|
18
16
|
date: "ActiveFields::Field::Date",
|
|
@@ -28,6 +26,8 @@ module ActiveFields
|
|
|
28
26
|
text: "ActiveFields::Field::Text",
|
|
29
27
|
text_array: "ActiveFields::Field::TextArray",
|
|
30
28
|
}
|
|
29
|
+
@field_base_class_name = DEFAULT_FIELD_BASE_CLASS_NAME
|
|
30
|
+
@value_class_name = DEFAULT_VALUE_CLASS_NAME
|
|
31
31
|
end
|
|
32
32
|
|
|
33
33
|
def field_base_class
|
|
@@ -91,7 +91,10 @@ module ActiveFields
|
|
|
91
91
|
def jsonb_path_exists(target, jsonpath, vars = nil)
|
|
92
92
|
Arel::Nodes::NamedFunction.new(
|
|
93
93
|
"jsonb_path_exists",
|
|
94
|
-
[
|
|
94
|
+
[
|
|
95
|
+
target,
|
|
96
|
+
*[jsonpath, vars&.to_json].compact.map { |element| Arel::Nodes.build_quoted(element) },
|
|
97
|
+
],
|
|
95
98
|
)
|
|
96
99
|
end
|
|
97
100
|
|
|
@@ -99,7 +102,10 @@ module ActiveFields
|
|
|
99
102
|
def jsonb_path_query_array(target, jsonpath, vars = nil)
|
|
100
103
|
Arel::Nodes::NamedFunction.new(
|
|
101
104
|
"jsonb_path_query_array",
|
|
102
|
-
[
|
|
105
|
+
[
|
|
106
|
+
target,
|
|
107
|
+
*[jsonpath, vars&.to_json].compact.map { |element| Arel::Nodes.build_quoted(element) },
|
|
108
|
+
],
|
|
103
109
|
)
|
|
104
110
|
end
|
|
105
111
|
|
|
@@ -52,7 +52,7 @@ module ActiveFields
|
|
|
52
52
|
# @param op [String, Symbol] Operation name or operator
|
|
53
53
|
# @param value [Any] The value to search for
|
|
54
54
|
def search(op:, value:)
|
|
55
|
-
op = op.to_sym
|
|
55
|
+
op = op.to_sym if op.respond_to?(:to_sym)
|
|
56
56
|
operation = self.class.__operations__.key?(op) ? op : self.class.__operators__[op]
|
|
57
57
|
return if operation.nil?
|
|
58
58
|
|
|
@@ -6,12 +6,14 @@ module ActiveFields
|
|
|
6
6
|
extend ActiveSupport::Concern
|
|
7
7
|
|
|
8
8
|
class_methods do
|
|
9
|
-
def has_active_fields(types: ActiveFields.config.type_names)
|
|
9
|
+
def has_active_fields(types: ActiveFields.config.type_names, scope_method: nil)
|
|
10
10
|
include CustomizableConcern
|
|
11
11
|
|
|
12
12
|
types.each do |field_type|
|
|
13
13
|
ActiveFields.registry.add(field_type, name)
|
|
14
14
|
end
|
|
15
|
+
|
|
16
|
+
define_singleton_method(:active_fields_scope_method) { scope_method }
|
|
15
17
|
end
|
|
16
18
|
end
|
|
17
19
|
end
|
data/lib/generators/active_fields/scaffold/templates/controllers/active_fields_controller.rb
CHANGED
|
@@ -4,7 +4,7 @@ class ActiveFieldsController < ApplicationController
|
|
|
4
4
|
before_action :set_active_field, only: %i[show edit update destroy]
|
|
5
5
|
|
|
6
6
|
def index
|
|
7
|
-
@active_fields = ActiveFields.config.field_base_class.order(:customizable_type, :id)
|
|
7
|
+
@active_fields = ActiveFields.config.field_base_class.order(:customizable_type, :scope, :id)
|
|
8
8
|
end
|
|
9
9
|
|
|
10
10
|
def show; end
|
|
@@ -13,23 +13,23 @@ class ActiveFieldsController < ApplicationController
|
|
|
13
13
|
@active_field = model_class.new
|
|
14
14
|
end
|
|
15
15
|
|
|
16
|
+
def edit; end
|
|
17
|
+
|
|
16
18
|
def create
|
|
17
19
|
@active_field = model_class.new(active_field_create_params(model_class))
|
|
18
20
|
|
|
19
21
|
if @active_field.save
|
|
20
22
|
redirect_to edit_active_field_path(@active_field), status: :see_other
|
|
21
23
|
else
|
|
22
|
-
render :new, status: :
|
|
24
|
+
render :new, status: :unprocessable_content
|
|
23
25
|
end
|
|
24
26
|
end
|
|
25
27
|
|
|
26
|
-
def edit; end
|
|
27
|
-
|
|
28
28
|
def update
|
|
29
29
|
if @active_field.update(active_field_update_params(@active_field.class))
|
|
30
30
|
redirect_to edit_active_field_path(@active_field), status: :see_other
|
|
31
31
|
else
|
|
32
|
-
render :edit, status: :
|
|
32
|
+
render :edit, status: :unprocessable_content
|
|
33
33
|
end
|
|
34
34
|
end
|
|
35
35
|
|
|
@@ -60,31 +60,31 @@ class ActiveFieldsController < ApplicationController
|
|
|
60
60
|
# It is strongly recommended to move it to, for example, policies.
|
|
61
61
|
def permitted_attributes_for_create(model_class)
|
|
62
62
|
if model_class == ActiveFields::Field::Boolean
|
|
63
|
-
%i[customizable_type name required nullable default_value]
|
|
63
|
+
%i[customizable_type name scope required nullable default_value]
|
|
64
64
|
elsif model_class == ActiveFields::Field::Date
|
|
65
|
-
%i[customizable_type name required min max default_value]
|
|
65
|
+
%i[customizable_type name scope required min max default_value]
|
|
66
66
|
elsif model_class == ActiveFields::Field::DateArray
|
|
67
|
-
[:customizable_type, :name, :min_size, :max_size, :min, :max, default_value: []]
|
|
67
|
+
[:customizable_type, :name, :scope, :min_size, :max_size, :min, :max, default_value: []]
|
|
68
68
|
elsif model_class == ActiveFields::Field::DateTime
|
|
69
|
-
%i[customizable_type name required min max precision default_value]
|
|
69
|
+
%i[customizable_type name scope required min max precision default_value]
|
|
70
70
|
elsif model_class == ActiveFields::Field::DateTimeArray
|
|
71
|
-
[:customizable_type, :name, :min_size, :max_size, :min, :max, :precision, default_value: []]
|
|
71
|
+
[:customizable_type, :name, :scope, :min_size, :max_size, :min, :max, :precision, default_value: []]
|
|
72
72
|
elsif model_class == ActiveFields::Field::Decimal
|
|
73
|
-
%i[customizable_type name required min max precision default_value]
|
|
73
|
+
%i[customizable_type name scope required min max precision default_value]
|
|
74
74
|
elsif model_class == ActiveFields::Field::DecimalArray
|
|
75
|
-
[:customizable_type, :name, :min_size, :max_size, :min, :max, :precision, default_value: []]
|
|
75
|
+
[:customizable_type, :name, :scope, :min_size, :max_size, :min, :max, :precision, default_value: []]
|
|
76
76
|
elsif model_class == ActiveFields::Field::Enum
|
|
77
|
-
[:customizable_type, :name, :required, :default_value, allowed_values: []]
|
|
77
|
+
[:customizable_type, :name, :scope, :required, :default_value, allowed_values: []]
|
|
78
78
|
elsif model_class == ActiveFields::Field::EnumArray
|
|
79
|
-
[:customizable_type, :name, :min_size, :max_size, allowed_values: [], default_value: []]
|
|
79
|
+
[:customizable_type, :name, :scope, :min_size, :max_size, allowed_values: [], default_value: []]
|
|
80
80
|
elsif model_class == ActiveFields::Field::Integer
|
|
81
|
-
%i[customizable_type name required min max default_value]
|
|
81
|
+
%i[customizable_type name scope required min max default_value]
|
|
82
82
|
elsif model_class == ActiveFields::Field::IntegerArray
|
|
83
|
-
[:customizable_type, :name, :min_size, :max_size, :min, :max, default_value: []]
|
|
83
|
+
[:customizable_type, :name, :scope, :min_size, :max_size, :min, :max, default_value: []]
|
|
84
84
|
elsif model_class == ActiveFields::Field::Text
|
|
85
|
-
%i[customizable_type name min_length max_length default_value]
|
|
85
|
+
%i[customizable_type name scope min_length max_length default_value]
|
|
86
86
|
elsif model_class == ActiveFields::Field::TextArray
|
|
87
|
-
[:customizable_type, :name, :min_size, :max_size, :min_length, :max_length, default_value: []]
|
|
87
|
+
[:customizable_type, :name, :scope, :min_size, :max_size, :min_length, :max_length, default_value: []]
|
|
88
88
|
else
|
|
89
89
|
raise ArgumentError, "undefined model_class `#{model_class.inspect}`"
|
|
90
90
|
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Controller } from "@hotwired/stimulus"
|
|
2
|
+
|
|
3
|
+
export default class extends Controller {
|
|
4
|
+
static targets = [
|
|
5
|
+
"scopeInput",
|
|
6
|
+
"disableScopeInput",
|
|
7
|
+
]
|
|
8
|
+
|
|
9
|
+
toggleScopeInput(e) {
|
|
10
|
+
e.preventDefault()
|
|
11
|
+
|
|
12
|
+
if (this.disableScopeInputTarget.checked) {
|
|
13
|
+
this.scopeInputTarget.disabled = true
|
|
14
|
+
this.scopeInputTarget.value = ""
|
|
15
|
+
} else {
|
|
16
|
+
this.scopeInputTarget.disabled = false
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
data/lib/generators/active_fields/scaffold/templates/views/active_fields/forms/_boolean.html.erb
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
<%= form_with(
|
|
1
|
+
<%= form_with(
|
|
2
|
+
model: active_field,
|
|
3
|
+
scope: :active_field,
|
|
4
|
+
url: active_field.persisted? ? active_field_path(active_field) : active_fields_path,
|
|
5
|
+
data: { controller: "active-field-form" }
|
|
6
|
+
) do |f| %>
|
|
2
7
|
<% if active_field.errors.any? %>
|
|
3
8
|
<div style="color: red">
|
|
4
9
|
<h2><%= pluralize(active_field.errors.count, "error") %> prohibited this record from being saved:</h2>
|
|
@@ -32,6 +37,22 @@
|
|
|
32
37
|
<%= f.text_field :name %>
|
|
33
38
|
</div>
|
|
34
39
|
|
|
40
|
+
<% if active_field.persisted? %>
|
|
41
|
+
<% if active_field.scope %>
|
|
42
|
+
<div>
|
|
43
|
+
<%= f.label :scope %>
|
|
44
|
+
<%= f.text_field :scope, disabled: true %>
|
|
45
|
+
</div>
|
|
46
|
+
<% end %>
|
|
47
|
+
<% else %>
|
|
48
|
+
<div>
|
|
49
|
+
<%= f.label :scope %>
|
|
50
|
+
<%= f.text_field :scope, data: { "active-field-form-target": "scopeInput" } %>
|
|
51
|
+
<%= f.label :disable_scope %>
|
|
52
|
+
<%= f.check_box :disable_scope, data: { "active-field-form-target": "disableScopeInput", "action": "change->active-field-form#toggleScopeInput" } %>
|
|
53
|
+
</div>
|
|
54
|
+
<% end %>
|
|
55
|
+
|
|
35
56
|
<div>
|
|
36
57
|
<%= f.label :required %>
|
|
37
58
|
<%= f.check_box :required, disabled: active_field.persisted? %>
|
data/lib/generators/active_fields/scaffold/templates/views/active_fields/forms/_date.html.erb
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
<%= form_with(
|
|
1
|
+
<%= form_with(
|
|
2
|
+
model: active_field,
|
|
3
|
+
scope: :active_field,
|
|
4
|
+
url: active_field.persisted? ? active_field_path(active_field) : active_fields_path,
|
|
5
|
+
data: { controller: "active-field-form" }
|
|
6
|
+
) do |f| %>
|
|
2
7
|
<% if active_field.errors.any? %>
|
|
3
8
|
<div style="color: red">
|
|
4
9
|
<h2><%= pluralize(active_field.errors.count, "error") %> prohibited this record from being saved:</h2>
|
|
@@ -32,6 +37,22 @@
|
|
|
32
37
|
<%= f.text_field :name %>
|
|
33
38
|
</div>
|
|
34
39
|
|
|
40
|
+
<% if active_field.persisted? %>
|
|
41
|
+
<% if active_field.scope %>
|
|
42
|
+
<div>
|
|
43
|
+
<%= f.label :scope %>
|
|
44
|
+
<%= f.text_field :scope, disabled: true %>
|
|
45
|
+
</div>
|
|
46
|
+
<% end %>
|
|
47
|
+
<% else %>
|
|
48
|
+
<div>
|
|
49
|
+
<%= f.label :scope %>
|
|
50
|
+
<%= f.text_field :scope, data: { "active-field-form-target": "scopeInput" } %>
|
|
51
|
+
<%= f.label :disable_scope %>
|
|
52
|
+
<%= f.check_box :disable_scope, data: { "active-field-form-target": "disableScopeInput", "action": "change->active-field-form#toggleScopeInput" } %>
|
|
53
|
+
</div>
|
|
54
|
+
<% end %>
|
|
55
|
+
|
|
35
56
|
<div>
|
|
36
57
|
<%= f.label :required %>
|
|
37
58
|
<%= f.check_box :required, disabled: active_field.persisted? %>
|
data/lib/generators/active_fields/scaffold/templates/views/active_fields/forms/_date_array.html.erb
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
<%= form_with(
|
|
1
|
+
<%= form_with(
|
|
2
|
+
model: active_field,
|
|
3
|
+
scope: :active_field,
|
|
4
|
+
url: active_field.persisted? ? active_field_path(active_field) : active_fields_path,
|
|
5
|
+
data: { controller: "active-field-form" }
|
|
6
|
+
) do |f| %>
|
|
2
7
|
<% if active_field.errors.any? %>
|
|
3
8
|
<div style="color: red">
|
|
4
9
|
<h2><%= pluralize(active_field.errors.count, "error") %> prohibited this record from being saved:</h2>
|
|
@@ -32,6 +37,22 @@
|
|
|
32
37
|
<%= f.text_field :name %>
|
|
33
38
|
</div>
|
|
34
39
|
|
|
40
|
+
<% if active_field.persisted? %>
|
|
41
|
+
<% if active_field.scope %>
|
|
42
|
+
<div>
|
|
43
|
+
<%= f.label :scope %>
|
|
44
|
+
<%= f.text_field :scope, disabled: true %>
|
|
45
|
+
</div>
|
|
46
|
+
<% end %>
|
|
47
|
+
<% else %>
|
|
48
|
+
<div>
|
|
49
|
+
<%= f.label :scope %>
|
|
50
|
+
<%= f.text_field :scope, data: { "active-field-form-target": "scopeInput" } %>
|
|
51
|
+
<%= f.label :disable_scope %>
|
|
52
|
+
<%= f.check_box :disable_scope, data: { "active-field-form-target": "disableScopeInput", "action": "change->active-field-form#toggleScopeInput" } %>
|
|
53
|
+
</div>
|
|
54
|
+
<% end %>
|
|
55
|
+
|
|
35
56
|
<div>
|
|
36
57
|
<%= f.label :min_size %>
|
|
37
58
|
<%= f.number_field :min_size, disabled: active_field.persisted? %>
|
data/lib/generators/active_fields/scaffold/templates/views/active_fields/forms/_datetime.html.erb
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
<%= form_with(
|
|
1
|
+
<%= form_with(
|
|
2
|
+
model: active_field,
|
|
3
|
+
scope: :active_field,
|
|
4
|
+
url: active_field.persisted? ? active_field_path(active_field) : active_fields_path,
|
|
5
|
+
data: { controller: "active-field-form" }
|
|
6
|
+
) do |f| %>
|
|
2
7
|
<% if active_field.errors.any? %>
|
|
3
8
|
<div style="color: red">
|
|
4
9
|
<h2><%= pluralize(active_field.errors.count, "error") %> prohibited this record from being saved:</h2>
|
|
@@ -32,6 +37,22 @@
|
|
|
32
37
|
<%= f.text_field :name %>
|
|
33
38
|
</div>
|
|
34
39
|
|
|
40
|
+
<% if active_field.persisted? %>
|
|
41
|
+
<% if active_field.scope %>
|
|
42
|
+
<div>
|
|
43
|
+
<%= f.label :scope %>
|
|
44
|
+
<%= f.text_field :scope, disabled: true %>
|
|
45
|
+
</div>
|
|
46
|
+
<% end %>
|
|
47
|
+
<% else %>
|
|
48
|
+
<div>
|
|
49
|
+
<%= f.label :scope %>
|
|
50
|
+
<%= f.text_field :scope, data: { "active-field-form-target": "scopeInput" } %>
|
|
51
|
+
<%= f.label :disable_scope %>
|
|
52
|
+
<%= f.check_box :disable_scope, data: { "active-field-form-target": "disableScopeInput", "action": "change->active-field-form#toggleScopeInput" } %>
|
|
53
|
+
</div>
|
|
54
|
+
<% end %>
|
|
55
|
+
|
|
35
56
|
<div>
|
|
36
57
|
<%= f.label :required %>
|
|
37
58
|
<%= f.check_box :required, disabled: active_field.persisted? %>
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
<%= form_with(
|
|
1
|
+
<%= form_with(
|
|
2
|
+
model: active_field,
|
|
3
|
+
scope: :active_field,
|
|
4
|
+
url: active_field.persisted? ? active_field_path(active_field) : active_fields_path,
|
|
5
|
+
data: { controller: "active-field-form" }
|
|
6
|
+
) do |f| %>
|
|
2
7
|
<% if active_field.errors.any? %>
|
|
3
8
|
<div style="color: red">
|
|
4
9
|
<h2><%= pluralize(active_field.errors.count, "error") %> prohibited this record from being saved:</h2>
|
|
@@ -32,6 +37,22 @@
|
|
|
32
37
|
<%= f.text_field :name %>
|
|
33
38
|
</div>
|
|
34
39
|
|
|
40
|
+
<% if active_field.persisted? %>
|
|
41
|
+
<% if active_field.scope %>
|
|
42
|
+
<div>
|
|
43
|
+
<%= f.label :scope %>
|
|
44
|
+
<%= f.text_field :scope, disabled: true %>
|
|
45
|
+
</div>
|
|
46
|
+
<% end %>
|
|
47
|
+
<% else %>
|
|
48
|
+
<div>
|
|
49
|
+
<%= f.label :scope %>
|
|
50
|
+
<%= f.text_field :scope, data: { "active-field-form-target": "scopeInput" } %>
|
|
51
|
+
<%= f.label :disable_scope %>
|
|
52
|
+
<%= f.check_box :disable_scope, data: { "active-field-form-target": "disableScopeInput", "action": "change->active-field-form#toggleScopeInput" } %>
|
|
53
|
+
</div>
|
|
54
|
+
<% end %>
|
|
55
|
+
|
|
35
56
|
<div>
|
|
36
57
|
<%= f.label :min_size %>
|
|
37
58
|
<%= f.number_field :min_size, disabled: active_field.persisted? %>
|
data/lib/generators/active_fields/scaffold/templates/views/active_fields/forms/_decimal.html.erb
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
<%= form_with(
|
|
1
|
+
<%= form_with(
|
|
2
|
+
model: active_field,
|
|
3
|
+
scope: :active_field,
|
|
4
|
+
url: active_field.persisted? ? active_field_path(active_field) : active_fields_path,
|
|
5
|
+
data: { controller: "active-field-form" }
|
|
6
|
+
) do |f| %>
|
|
2
7
|
<% if active_field.errors.any? %>
|
|
3
8
|
<div style="color: red">
|
|
4
9
|
<h2><%= pluralize(active_field.errors.count, "error") %> prohibited this record from being saved:</h2>
|
|
@@ -32,6 +37,22 @@
|
|
|
32
37
|
<%= f.text_field :name %>
|
|
33
38
|
</div>
|
|
34
39
|
|
|
40
|
+
<% if active_field.persisted? %>
|
|
41
|
+
<% if active_field.scope %>
|
|
42
|
+
<div>
|
|
43
|
+
<%= f.label :scope %>
|
|
44
|
+
<%= f.text_field :scope, disabled: true %>
|
|
45
|
+
</div>
|
|
46
|
+
<% end %>
|
|
47
|
+
<% else %>
|
|
48
|
+
<div>
|
|
49
|
+
<%= f.label :scope %>
|
|
50
|
+
<%= f.text_field :scope, data: { "active-field-form-target": "scopeInput" } %>
|
|
51
|
+
<%= f.label :disable_scope %>
|
|
52
|
+
<%= f.check_box :disable_scope, data: { "active-field-form-target": "disableScopeInput", "action": "change->active-field-form#toggleScopeInput" } %>
|
|
53
|
+
</div>
|
|
54
|
+
<% end %>
|
|
55
|
+
|
|
35
56
|
<div>
|
|
36
57
|
<%= f.label :required %>
|
|
37
58
|
<%= f.check_box :required, disabled: active_field.persisted? %>
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
<%= form_with(
|
|
1
|
+
<%= form_with(
|
|
2
|
+
model: active_field,
|
|
3
|
+
scope: :active_field,
|
|
4
|
+
url: active_field.persisted? ? active_field_path(active_field) : active_fields_path,
|
|
5
|
+
data: { controller: "active-field-form" }
|
|
6
|
+
) do |f| %>
|
|
2
7
|
<% if active_field.errors.any? %>
|
|
3
8
|
<div style="color: red">
|
|
4
9
|
<h2><%= pluralize(active_field.errors.count, "error") %> prohibited this record from being saved:</h2>
|
|
@@ -32,6 +37,22 @@
|
|
|
32
37
|
<%= f.text_field :name %>
|
|
33
38
|
</div>
|
|
34
39
|
|
|
40
|
+
<% if active_field.persisted? %>
|
|
41
|
+
<% if active_field.scope %>
|
|
42
|
+
<div>
|
|
43
|
+
<%= f.label :scope %>
|
|
44
|
+
<%= f.text_field :scope, disabled: true %>
|
|
45
|
+
</div>
|
|
46
|
+
<% end %>
|
|
47
|
+
<% else %>
|
|
48
|
+
<div>
|
|
49
|
+
<%= f.label :scope %>
|
|
50
|
+
<%= f.text_field :scope, data: { "active-field-form-target": "scopeInput" } %>
|
|
51
|
+
<%= f.label :disable_scope %>
|
|
52
|
+
<%= f.check_box :disable_scope, data: { "active-field-form-target": "disableScopeInput", "action": "change->active-field-form#toggleScopeInput" } %>
|
|
53
|
+
</div>
|
|
54
|
+
<% end %>
|
|
55
|
+
|
|
35
56
|
<div>
|
|
36
57
|
<%= f.label :min_size %>
|
|
37
58
|
<%= f.number_field :min_size, disabled: active_field.persisted? %>
|
data/lib/generators/active_fields/scaffold/templates/views/active_fields/forms/_enum.html.erb
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
<%= form_with(
|
|
1
|
+
<%= form_with(
|
|
2
|
+
model: active_field,
|
|
3
|
+
scope: :active_field,
|
|
4
|
+
url: active_field.persisted? ? active_field_path(active_field) : active_fields_path,
|
|
5
|
+
data: { controller: "active-field-form" }
|
|
6
|
+
) do |f| %>
|
|
2
7
|
<% if active_field.errors.any? %>
|
|
3
8
|
<div style="color: red">
|
|
4
9
|
<h2><%= pluralize(active_field.errors.count, "error") %> prohibited this record from being saved:</h2>
|
|
@@ -32,6 +37,22 @@
|
|
|
32
37
|
<%= f.text_field :name %>
|
|
33
38
|
</div>
|
|
34
39
|
|
|
40
|
+
<% if active_field.persisted? %>
|
|
41
|
+
<% if active_field.scope %>
|
|
42
|
+
<div>
|
|
43
|
+
<%= f.label :scope %>
|
|
44
|
+
<%= f.text_field :scope, disabled: true %>
|
|
45
|
+
</div>
|
|
46
|
+
<% end %>
|
|
47
|
+
<% else %>
|
|
48
|
+
<div>
|
|
49
|
+
<%= f.label :scope %>
|
|
50
|
+
<%= f.text_field :scope, data: { "active-field-form-target": "scopeInput" } %>
|
|
51
|
+
<%= f.label :disable_scope %>
|
|
52
|
+
<%= f.check_box :disable_scope, data: { "active-field-form-target": "disableScopeInput", "action": "change->active-field-form#toggleScopeInput" } %>
|
|
53
|
+
</div>
|
|
54
|
+
<% end %>
|
|
55
|
+
|
|
35
56
|
<div>
|
|
36
57
|
<%= f.label :required %>
|
|
37
58
|
<%= f.check_box :required, disabled: active_field.persisted? %>
|
data/lib/generators/active_fields/scaffold/templates/views/active_fields/forms/_enum_array.html.erb
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
<%= form_with(
|
|
1
|
+
<%= form_with(
|
|
2
|
+
model: active_field,
|
|
3
|
+
scope: :active_field,
|
|
4
|
+
url: active_field.persisted? ? active_field_path(active_field) : active_fields_path,
|
|
5
|
+
data: { controller: "active-field-form" }
|
|
6
|
+
) do |f| %>
|
|
2
7
|
<% if active_field.errors.any? %>
|
|
3
8
|
<div style="color: red">
|
|
4
9
|
<h2><%= pluralize(active_field.errors.count, "error") %> prohibited this record from being saved:</h2>
|
|
@@ -32,6 +37,22 @@
|
|
|
32
37
|
<%= f.text_field :name %>
|
|
33
38
|
</div>
|
|
34
39
|
|
|
40
|
+
<% if active_field.persisted? %>
|
|
41
|
+
<% if active_field.scope %>
|
|
42
|
+
<div>
|
|
43
|
+
<%= f.label :scope %>
|
|
44
|
+
<%= f.text_field :scope, disabled: true %>
|
|
45
|
+
</div>
|
|
46
|
+
<% end %>
|
|
47
|
+
<% else %>
|
|
48
|
+
<div>
|
|
49
|
+
<%= f.label :scope %>
|
|
50
|
+
<%= f.text_field :scope, data: { "active-field-form-target": "scopeInput" } %>
|
|
51
|
+
<%= f.label :disable_scope %>
|
|
52
|
+
<%= f.check_box :disable_scope, data: { "active-field-form-target": "disableScopeInput", "action": "change->active-field-form#toggleScopeInput" } %>
|
|
53
|
+
</div>
|
|
54
|
+
<% end %>
|
|
55
|
+
|
|
35
56
|
<div>
|
|
36
57
|
<%= f.label :min_size %>
|
|
37
58
|
<%= f.number_field :min_size, disabled: active_field.persisted? %>
|
data/lib/generators/active_fields/scaffold/templates/views/active_fields/forms/_integer.html.erb
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
<%= form_with(
|
|
1
|
+
<%= form_with(
|
|
2
|
+
model: active_field,
|
|
3
|
+
scope: :active_field,
|
|
4
|
+
url: active_field.persisted? ? active_field_path(active_field) : active_fields_path,
|
|
5
|
+
data: { controller: "active-field-form" }
|
|
6
|
+
) do |f| %>
|
|
2
7
|
<% if active_field.errors.any? %>
|
|
3
8
|
<div style="color: red">
|
|
4
9
|
<h2><%= pluralize(active_field.errors.count, "error") %> prohibited this record from being saved:</h2>
|
|
@@ -32,6 +37,22 @@
|
|
|
32
37
|
<%= f.text_field :name %>
|
|
33
38
|
</div>
|
|
34
39
|
|
|
40
|
+
<% if active_field.persisted? %>
|
|
41
|
+
<% if active_field.scope %>
|
|
42
|
+
<div>
|
|
43
|
+
<%= f.label :scope %>
|
|
44
|
+
<%= f.text_field :scope, disabled: true %>
|
|
45
|
+
</div>
|
|
46
|
+
<% end %>
|
|
47
|
+
<% else %>
|
|
48
|
+
<div>
|
|
49
|
+
<%= f.label :scope %>
|
|
50
|
+
<%= f.text_field :scope, data: { "active-field-form-target": "scopeInput" } %>
|
|
51
|
+
<%= f.label :disable_scope %>
|
|
52
|
+
<%= f.check_box :disable_scope, data: { "active-field-form-target": "disableScopeInput", "action": "change->active-field-form#toggleScopeInput" } %>
|
|
53
|
+
</div>
|
|
54
|
+
<% end %>
|
|
55
|
+
|
|
35
56
|
<div>
|
|
36
57
|
<%= f.label :required %>
|
|
37
58
|
<%= f.check_box :required, disabled: active_field.persisted? %>
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
<%= form_with(
|
|
1
|
+
<%= form_with(
|
|
2
|
+
model: active_field,
|
|
3
|
+
scope: :active_field,
|
|
4
|
+
url: active_field.persisted? ? active_field_path(active_field) : active_fields_path,
|
|
5
|
+
data: { controller: "active-field-form" }
|
|
6
|
+
) do |f| %>
|
|
2
7
|
<% if active_field.errors.any? %>
|
|
3
8
|
<div style="color: red">
|
|
4
9
|
<h2><%= pluralize(active_field.errors.count, "error") %> prohibited this record from being saved:</h2>
|
|
@@ -32,6 +37,22 @@
|
|
|
32
37
|
<%= f.text_field :name %>
|
|
33
38
|
</div>
|
|
34
39
|
|
|
40
|
+
<% if active_field.persisted? %>
|
|
41
|
+
<% if active_field.scope %>
|
|
42
|
+
<div>
|
|
43
|
+
<%= f.label :scope %>
|
|
44
|
+
<%= f.text_field :scope, disabled: true %>
|
|
45
|
+
</div>
|
|
46
|
+
<% end %>
|
|
47
|
+
<% else %>
|
|
48
|
+
<div>
|
|
49
|
+
<%= f.label :scope %>
|
|
50
|
+
<%= f.text_field :scope, data: { "active-field-form-target": "scopeInput" } %>
|
|
51
|
+
<%= f.label :disable_scope %>
|
|
52
|
+
<%= f.check_box :disable_scope, data: { "active-field-form-target": "disableScopeInput", "action": "change->active-field-form#toggleScopeInput" } %>
|
|
53
|
+
</div>
|
|
54
|
+
<% end %>
|
|
55
|
+
|
|
35
56
|
<div>
|
|
36
57
|
<%= f.label :min_size %>
|
|
37
58
|
<%= f.number_field :min_size, disabled: active_field.persisted? %>
|
data/lib/generators/active_fields/scaffold/templates/views/active_fields/forms/_text.html.erb
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
<%= form_with(
|
|
1
|
+
<%= form_with(
|
|
2
|
+
model: active_field,
|
|
3
|
+
scope: :active_field,
|
|
4
|
+
url: active_field.persisted? ? active_field_path(active_field) : active_fields_path,
|
|
5
|
+
data: { controller: "active-field-form" }
|
|
6
|
+
) do |f| %>
|
|
2
7
|
<% if active_field.errors.any? %>
|
|
3
8
|
<div style="color: red">
|
|
4
9
|
<h2><%= pluralize(active_field.errors.count, "error") %> prohibited this record from being saved:</h2>
|
|
@@ -32,6 +37,22 @@
|
|
|
32
37
|
<%= f.text_field :name %>
|
|
33
38
|
</div>
|
|
34
39
|
|
|
40
|
+
<% if active_field.persisted? %>
|
|
41
|
+
<% if active_field.scope %>
|
|
42
|
+
<div>
|
|
43
|
+
<%= f.label :scope %>
|
|
44
|
+
<%= f.text_field :scope, disabled: true %>
|
|
45
|
+
</div>
|
|
46
|
+
<% end %>
|
|
47
|
+
<% else %>
|
|
48
|
+
<div>
|
|
49
|
+
<%= f.label :scope %>
|
|
50
|
+
<%= f.text_field :scope, data: { "active-field-form-target": "scopeInput" } %>
|
|
51
|
+
<%= f.label :disable_scope %>
|
|
52
|
+
<%= f.check_box :disable_scope, data: { "active-field-form-target": "disableScopeInput", "action": "change->active-field-form#toggleScopeInput" } %>
|
|
53
|
+
</div>
|
|
54
|
+
<% end %>
|
|
55
|
+
|
|
35
56
|
<div>
|
|
36
57
|
<%= f.label :min_length %>
|
|
37
58
|
<%= f.number_field :min_length, disabled: active_field.persisted? %>
|
data/lib/generators/active_fields/scaffold/templates/views/active_fields/forms/_text_array.html.erb
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
<%= form_with(
|
|
1
|
+
<%= form_with(
|
|
2
|
+
model: active_field,
|
|
3
|
+
scope: :active_field,
|
|
4
|
+
url: active_field.persisted? ? active_field_path(active_field) : active_fields_path,
|
|
5
|
+
data: { controller: "active-field-form" }
|
|
6
|
+
) do |f| %>
|
|
2
7
|
<% if active_field.errors.any? %>
|
|
3
8
|
<div style="color: red">
|
|
4
9
|
<h2><%= pluralize(active_field.errors.count, "error") %> prohibited this record from being saved:</h2>
|
|
@@ -32,6 +37,22 @@
|
|
|
32
37
|
<%= f.text_field :name %>
|
|
33
38
|
</div>
|
|
34
39
|
|
|
40
|
+
<% if active_field.persisted? %>
|
|
41
|
+
<% if active_field.scope %>
|
|
42
|
+
<div>
|
|
43
|
+
<%= f.label :scope %>
|
|
44
|
+
<%= f.text_field :scope, disabled: true %>
|
|
45
|
+
</div>
|
|
46
|
+
<% end %>
|
|
47
|
+
<% else %>
|
|
48
|
+
<div>
|
|
49
|
+
<%= f.label :scope %>
|
|
50
|
+
<%= f.text_field :scope, data: { "active-field-form-target": "scopeInput" } %>
|
|
51
|
+
<%= f.label :disable_scope %>
|
|
52
|
+
<%= f.check_box :disable_scope, data: { "active-field-form-target": "disableScopeInput", "action": "change->active-field-form#toggleScopeInput" } %>
|
|
53
|
+
</div>
|
|
54
|
+
<% end %>
|
|
55
|
+
|
|
35
56
|
<div>
|
|
36
57
|
<%= f.label :min_size %>
|
|
37
58
|
<%= f.number_field :min_size, disabled: active_field.persisted? %>
|