cm-admin 1.5.43 → 1.5.44
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 063a8dffa41719953d125e6fddb24a3e59f3869ba6a82da090b50aaee5a0d495
|
4
|
+
data.tar.gz: 470c4ffbeff36d4bdbc77af410430b5861eac385b5848536d4796eaa480a4a9f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a3e2798dcfc91f39751010f3956d033ceb852a23ab3bc0b0b992d8f64c2679cb3330385055c519c719083e3c7ee9b5c911abd2cbff8a879205caad2e4eb8b415
|
7
|
+
data.tar.gz: 393ebc8dd097f9b06f837289e86dba708cce6e21721050354fffeb5732b32e6bfd8cc8229df82aec6bca2a8d0ff5285eff1d254f0f5f4dfdbb251fd9fc450e4f
|
data/Gemfile.lock
CHANGED
data/lib/cm_admin/version.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module CmAdmin
|
2
2
|
module ViewHelpers
|
3
3
|
module FormFieldHelper
|
4
|
-
def input_field_for_column(form_obj, cm_field)
|
4
|
+
def input_field_for_column(form_obj, cm_field, is_required: nil)
|
5
5
|
return unless cm_field.display_if.call(form_obj.object)
|
6
6
|
|
7
7
|
value = if cm_field.helper_method
|
@@ -12,7 +12,7 @@ module CmAdmin
|
|
12
12
|
form_obj.object.send(cm_field.field_name)
|
13
13
|
end
|
14
14
|
# value = cm_field.helper_method ? send(cm_field.helper_method, form_obj.object, cm_field.field_name) : form_obj.object.send(cm_field.field_name)
|
15
|
-
is_required = form_obj.object._validators[cm_field.field_name].map(&:kind).include?(:presence)
|
15
|
+
is_required = form_obj.object._validators[cm_field.field_name].map(&:kind).include?(:presence) if is_required.nil?
|
16
16
|
required_class = is_required ? 'required' : ''
|
17
17
|
target_action = @model.available_actions.select { |x| x.name == cm_field.target[:action_name].to_s }.first if cm_field.target.present?
|
18
18
|
send("cm_#{cm_field.input_type}_field", form_obj, cm_field, value, required_class, target_action, cm_field.ajax_url)
|
@@ -106,17 +106,18 @@ module CmAdmin
|
|
106
106
|
|
107
107
|
def set_form_field(resource, form_obj, field)
|
108
108
|
return unless field.display_if.call(form_obj.object)
|
109
|
+
is_required = form_obj.object._validators[field.field_name].map(&:kind).include?(:presence)
|
109
110
|
|
110
111
|
content_tag(:div, class: field.col_size ? "col-#{field.col_size}" : 'col') do
|
111
112
|
if field.input_type.eql?(:hidden)
|
112
|
-
concat input_field_for_column(form_obj, field)
|
113
|
+
concat input_field_for_column(form_obj, field, is_required:)
|
113
114
|
else
|
114
115
|
concat(content_tag(:div, class: "form-field #{field.disabled ? 'disabled' : ''}") do
|
115
116
|
if field.label && %i[check_box switch].exclude?(field.input_type)
|
116
|
-
concat form_obj.label field.label, field.label, class:
|
117
|
+
concat form_obj.label field.label, field.label, class: "field-label #{is_required ? 'required-label' : ''}"
|
117
118
|
concat tag.br
|
118
119
|
end
|
119
|
-
concat input_field_for_column(form_obj, field)
|
120
|
+
concat input_field_for_column(form_obj, field, is_required:)
|
120
121
|
concat tag.small field.helper_text, class: 'form-text text-muted' if field.helper_text.present?
|
121
122
|
concat tag.p resource.errors[field.field_name].first if resource.errors[field.field_name].present?
|
122
123
|
end)
|