cm-admin 1.4.6 → 1.4.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +8 -8
- data/app/assets/javascripts/cm_admin/scaffolds.js +19 -1
- data/app/javascript/packs/cm_admin/scaffolds.js +1 -1
- data/lib/cm_admin/models/form_field.rb +1 -1
- data/lib/cm_admin/version.rb +1 -1
- data/lib/cm_admin/view_helpers/form_field_helper.rb +22 -20
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 739e610f8a75252258bd23ad714ba42235f099b2966450609d811a4a87ad8f6b
|
4
|
+
data.tar.gz: cb48e10324ba8876d10299e5f80ac34ed623a7c35ea768415587c81f87e42fb1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4106dee29b565d27cea6ea4f10d3775d8d3cfbb8cb2e22b9dfcfab0f23eae421f74602b516053e7ce1d84e6a742173e1780475a28196ca3dd23948503f0e1ae2
|
7
|
+
data.tar.gz: f0c32a23b1c364d2b5028f71be1e4ab4105f9316ef2585f68eeb11a814ed519548885fcd2292be7f1fb892e17eb151a82df25080b51cbf212678506a668880c1
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
cm-admin (1.4.
|
4
|
+
cm-admin (1.4.8)
|
5
5
|
caxlsx_rails
|
6
6
|
cocoon (~> 1.2.15)
|
7
7
|
csv-importer (~> 0.8.2)
|
@@ -87,7 +87,7 @@ GEM
|
|
87
87
|
ice_nine (~> 0.11.0)
|
88
88
|
thread_safe (~> 0.3, >= 0.3.1)
|
89
89
|
builder (3.2.4)
|
90
|
-
caxlsx (4.
|
90
|
+
caxlsx (4.1.0)
|
91
91
|
htmlentities (~> 4.3, >= 4.3.4)
|
92
92
|
marcel (~> 1.0)
|
93
93
|
nokogiri (~> 1.10, >= 1.10.4)
|
@@ -127,11 +127,11 @@ GEM
|
|
127
127
|
net-imap
|
128
128
|
net-pop
|
129
129
|
net-smtp
|
130
|
-
marcel (1.0.
|
130
|
+
marcel (1.0.4)
|
131
131
|
method_source (1.0.0)
|
132
132
|
mini_mime (1.1.5)
|
133
133
|
minitest (5.18.1)
|
134
|
-
net-imap (0.4.
|
134
|
+
net-imap (0.4.10)
|
135
135
|
date
|
136
136
|
net-protocol
|
137
137
|
net-pop (0.1.2)
|
@@ -140,8 +140,8 @@ GEM
|
|
140
140
|
timeout
|
141
141
|
net-smtp (0.4.0.1)
|
142
142
|
net-protocol
|
143
|
-
nio4r (2.7.
|
144
|
-
nokogiri (1.16.
|
143
|
+
nio4r (2.7.1)
|
144
|
+
nokogiri (1.16.3-arm64-darwin)
|
145
145
|
racc (~> 1.4)
|
146
146
|
pagy (4.11.0)
|
147
147
|
parallel (1.22.1)
|
@@ -226,7 +226,7 @@ GEM
|
|
226
226
|
temple (>= 0.7.6, < 0.9)
|
227
227
|
tilt (>= 2.0.6, < 2.1)
|
228
228
|
temple (0.8.2)
|
229
|
-
thor (1.3.
|
229
|
+
thor (1.3.1)
|
230
230
|
thread_safe (0.3.6)
|
231
231
|
tilt (2.0.10)
|
232
232
|
timeout (0.4.1)
|
@@ -245,7 +245,7 @@ GEM
|
|
245
245
|
websocket-driver (0.7.6)
|
246
246
|
websocket-extensions (>= 0.1.0)
|
247
247
|
websocket-extensions (0.1.5)
|
248
|
-
zeitwerk (2.6.
|
248
|
+
zeitwerk (2.6.13)
|
249
249
|
|
250
250
|
PLATFORMS
|
251
251
|
arm64-darwin-20
|
@@ -39,6 +39,7 @@ document.addEventListener("turbo:load", function () {
|
|
39
39
|
theme: "bootstrap-5",
|
40
40
|
});
|
41
41
|
jqueryJgrowl()
|
42
|
+
setup_select_2_ajax();
|
42
43
|
});
|
43
44
|
|
44
45
|
$(document).on('click', '.menu-item', function(e) {
|
@@ -51,4 +52,21 @@ $(document).on('click', '.destroy-attachment', function(e) {
|
|
51
52
|
$(this).append('<input type="text" name="attachment_destroy_ids[]" value="' + ar_id + '"/>')
|
52
53
|
})
|
53
54
|
|
54
|
-
window.addEventListener('popstate', e => window.location.reload() );
|
55
|
+
window.addEventListener('popstate', e => window.location.reload() );
|
56
|
+
|
57
|
+
function setup_select_2_ajax(){
|
58
|
+
$(".select-2-ajax").each(function(index, element){
|
59
|
+
$(element).select2({
|
60
|
+
ajax: {
|
61
|
+
url: $(element)[0]['dataset'].ajaxUrl,
|
62
|
+
dataType: 'json',
|
63
|
+
processResults: (data, params) => {
|
64
|
+
return {
|
65
|
+
results: data.results,
|
66
|
+
}
|
67
|
+
},
|
68
|
+
},
|
69
|
+
minimumInputLength: 0
|
70
|
+
});
|
71
|
+
});
|
72
|
+
}
|
@@ -6,7 +6,7 @@ module CmAdmin
|
|
6
6
|
include Utils::Helpers
|
7
7
|
|
8
8
|
attr_accessor :field_name, :label, :header, :input_type, :collection, :disabled, :helper_method,
|
9
|
-
:placeholder, :display_if, :html_attr, :target, :col_size
|
9
|
+
:placeholder, :display_if, :html_attr, :target, :col_size, :ajax_url
|
10
10
|
|
11
11
|
VALID_INPUT_TYPES = %i[
|
12
12
|
integer decimal string single_select multi_select date date_time text
|
data/lib/cm_admin/version.rb
CHANGED
@@ -14,10 +14,10 @@ module CmAdmin
|
|
14
14
|
is_required = form_obj.object._validators[cm_field.field_name].map(&:kind).include?(:presence)
|
15
15
|
required_class = is_required ? 'required' : ''
|
16
16
|
target_action = @model.available_actions.select { |x| x.name == cm_field.target[:action_name].to_s }.first if cm_field.target.present?
|
17
|
-
send("cm_#{cm_field.input_type}_field", form_obj, cm_field, value, required_class, target_action)
|
17
|
+
send("cm_#{cm_field.input_type}_field", form_obj, cm_field, value, required_class, target_action, cm_field.ajax_url)
|
18
18
|
end
|
19
19
|
|
20
|
-
def cm_integer_field(form_obj, cm_field, value, required_class, _target_action)
|
20
|
+
def cm_integer_field(form_obj, cm_field, value, required_class, _target_action, _ajax_url)
|
21
21
|
form_obj.text_field cm_field.field_name,
|
22
22
|
class: "field-control #{required_class}",
|
23
23
|
disabled: cm_field.disabled.call(form_obj.object),
|
@@ -26,7 +26,7 @@ module CmAdmin
|
|
26
26
|
data: { behaviour: 'integer-only' }
|
27
27
|
end
|
28
28
|
|
29
|
-
def cm_decimal_field(form_obj, cm_field, value, required_class, _target_action)
|
29
|
+
def cm_decimal_field(form_obj, cm_field, value, required_class, _target_action, _ajax_url)
|
30
30
|
form_obj.text_field cm_field.field_name,
|
31
31
|
class: "field-control #{required_class}",
|
32
32
|
disabled: cm_field.disabled.call(form_obj.object),
|
@@ -35,7 +35,7 @@ module CmAdmin
|
|
35
35
|
data: { behaviour: 'decimal-only' }
|
36
36
|
end
|
37
37
|
|
38
|
-
def cm_string_field(form_obj, cm_field, value, required_class, _target_action)
|
38
|
+
def cm_string_field(form_obj, cm_field, value, required_class, _target_action, _ajax_url)
|
39
39
|
form_obj.text_field cm_field.field_name,
|
40
40
|
class: "field-control #{required_class}",
|
41
41
|
disabled: cm_field.disabled.call(form_obj.object),
|
@@ -50,20 +50,22 @@ module CmAdmin
|
|
50
50
|
placeholder: cm_field.placeholder
|
51
51
|
end
|
52
52
|
|
53
|
-
def cm_single_select_field(form_obj, cm_field, value, required_class, target_action)
|
53
|
+
def cm_single_select_field(form_obj, cm_field, value, required_class, target_action, ajax_url)
|
54
|
+
class_name = ajax_url.present? ? 'select-2-ajax' : 'select-2'
|
54
55
|
form_obj.select cm_field.field_name, options_for_select(select_collection_value(form_obj.object, cm_field), form_obj.object.send(cm_field.field_name)),
|
55
56
|
{ include_blank: cm_field.placeholder },
|
56
|
-
class: "field-control #{required_class}
|
57
|
+
class: "field-control #{required_class} #{class_name}",
|
57
58
|
disabled: cm_field.disabled.call(form_obj.object),
|
58
59
|
data: {
|
59
60
|
field_name: cm_field.field_name,
|
60
61
|
field_type: 'linked-field',
|
61
62
|
target_action: target_action&.name,
|
62
|
-
target_url: target_action&.name ? cm_admin.send("#{@model.name.underscore}_#{target_action&.name}_path") : ''
|
63
|
+
target_url: target_action&.name ? cm_admin.send("#{@model.name.underscore}_#{target_action&.name}_path") : '',
|
64
|
+
ajax_url: ajax_url
|
63
65
|
}
|
64
66
|
end
|
65
67
|
|
66
|
-
def cm_custom_single_select_field(form_obj, cm_field, value, required_class, target_action)
|
68
|
+
def cm_custom_single_select_field(form_obj, cm_field, value, required_class, target_action, _ajax_url)
|
67
69
|
select_tag cm_field.html_attr[:name] || cm_field.field_name,
|
68
70
|
options_for_select(select_collection_value(form_obj.object, cm_field)),
|
69
71
|
{
|
@@ -79,7 +81,7 @@ module CmAdmin
|
|
79
81
|
}
|
80
82
|
end
|
81
83
|
|
82
|
-
def cm_multi_select_field(form_obj, cm_field, value, required_class, target_action)
|
84
|
+
def cm_multi_select_field(form_obj, cm_field, value, required_class, target_action, _ajax_url)
|
83
85
|
form_obj.select cm_field.field_name,
|
84
86
|
options_for_select(select_collection_value(form_obj.object, cm_field), form_obj.object.send(cm_field.field_name)),
|
85
87
|
{ include_blank: cm_field.placeholder },
|
@@ -87,7 +89,7 @@ module CmAdmin
|
|
87
89
|
disabled: cm_field.disabled.call(form_obj.object), multiple: true
|
88
90
|
end
|
89
91
|
|
90
|
-
def cm_date_field(form_obj, cm_field, value, required_class, _target_action)
|
92
|
+
def cm_date_field(form_obj, cm_field, value, required_class, _target_action, _ajax_url)
|
91
93
|
form_obj.text_field cm_field.field_name,
|
92
94
|
class: "field-control #{required_class}",
|
93
95
|
disabled: cm_field.disabled.call(form_obj.object),
|
@@ -96,7 +98,7 @@ module CmAdmin
|
|
96
98
|
data: { behaviour: 'date-only' }
|
97
99
|
end
|
98
100
|
|
99
|
-
def cm_custom_date_field(form_obj, cm_field, value, required_class, _target_action)
|
101
|
+
def cm_custom_date_field(form_obj, cm_field, value, required_class, _target_action, _ajax_url)
|
100
102
|
text_field_tag cm_field.html_attr[:name] || cm_field.field_name, value&.strftime('%d-%m-%Y'),
|
101
103
|
class: "field-control #{required_class}",
|
102
104
|
disabled: cm_field.disabled.call(form_obj.object),
|
@@ -105,7 +107,7 @@ module CmAdmin
|
|
105
107
|
data: { behaviour: 'date-only' }
|
106
108
|
end
|
107
109
|
|
108
|
-
def cm_date_time_field(form_obj, cm_field, value, required_class, _target_action)
|
110
|
+
def cm_date_time_field(form_obj, cm_field, value, required_class, _target_action, _ajax_url)
|
109
111
|
form_obj.text_field cm_field.field_name,
|
110
112
|
class: "field-control #{required_class}",
|
111
113
|
disabled: cm_field.disabled.call(form_obj.object),
|
@@ -114,26 +116,26 @@ module CmAdmin
|
|
114
116
|
data: { behaviour: 'date-time' }
|
115
117
|
end
|
116
118
|
|
117
|
-
def cm_text_field(form_obj, cm_field, value, required_class, _target_action)
|
119
|
+
def cm_text_field(form_obj, cm_field, value, required_class, _target_action, _ajax_url)
|
118
120
|
form_obj.text_area cm_field.field_name,
|
119
121
|
class: "field-control #{required_class}",
|
120
122
|
placeholder: cm_field.placeholder
|
121
123
|
end
|
122
124
|
|
123
|
-
def cm_rich_text_field(form_obj, cm_field, value, required_class, _target_action)
|
125
|
+
def cm_rich_text_field(form_obj, cm_field, value, required_class, _target_action, _ajax_url)
|
124
126
|
form_obj.rich_text_area cm_field.field_name,
|
125
127
|
class: "field-control #{required_class}",
|
126
128
|
placeholder: cm_field.placeholder
|
127
129
|
end
|
128
130
|
|
129
|
-
def cm_single_file_upload_field(form_obj, cm_field, _value, required_class, _target_action)
|
131
|
+
def cm_single_file_upload_field(form_obj, cm_field, _value, required_class, _target_action, _ajax_url)
|
130
132
|
content_tag(:div) do
|
131
133
|
concat form_obj.file_field cm_field.field_name, class: "field-control #{required_class}", disabled: cm_field.disabled.call(form_obj.object)
|
132
134
|
concat attachment_list(form_obj, cm_field, _value, required_class, _target_action)
|
133
135
|
end
|
134
136
|
end
|
135
137
|
|
136
|
-
def cm_multi_file_upload_field(form_obj, cm_field, _value, required_class, _target_action)
|
138
|
+
def cm_multi_file_upload_field(form_obj, cm_field, _value, required_class, _target_action, _ajax_url)
|
137
139
|
content_tag(:div) do
|
138
140
|
concat form_obj.file_field cm_field.field_name, multiple: true, class: "field-control #{required_class}", disabled: cm_field.disabled.call(form_obj.object)
|
139
141
|
concat attachment_list(form_obj, cm_field, _value, required_class, _target_action)
|
@@ -142,7 +144,7 @@ module CmAdmin
|
|
142
144
|
|
143
145
|
def attachment_list(form_obj, cm_field, _value, required_class, _target_action)
|
144
146
|
attached = form_obj.object.send(cm_field.field_name)
|
145
|
-
return if attached.instance_of?(Paperclip::Attachment)
|
147
|
+
return if defined?(::Paperclip) && attached.instance_of?(::Paperclip::Attachment)
|
146
148
|
|
147
149
|
content_tag(:div) do
|
148
150
|
if attached.class == ActiveStorage::Attached::Many
|
@@ -164,15 +166,15 @@ module CmAdmin
|
|
164
166
|
end
|
165
167
|
end
|
166
168
|
|
167
|
-
def cm_check_box_field(form_obj, cm_field, value, required_class, target_action)
|
169
|
+
def cm_check_box_field(form_obj, cm_field, value, required_class, target_action, _ajax_url)
|
168
170
|
format_check_box_options(value, form_obj, cm_field, required_class, target_action)
|
169
171
|
end
|
170
172
|
|
171
|
-
def cm_radio_button_field(form_obj, cm_field, value, required_class, _target_action)
|
173
|
+
def cm_radio_button_field(form_obj, cm_field, value, required_class, _target_action, _ajax_url)
|
172
174
|
format_radio_button_options(value, form_obj)
|
173
175
|
end
|
174
176
|
|
175
|
-
def cm_hidden_field(form_obj, cm_field, value, required_class, _target_action)
|
177
|
+
def cm_hidden_field(form_obj, cm_field, value, required_class, _target_action, _ajax_url)
|
176
178
|
form_obj.hidden_field cm_field.field_name,
|
177
179
|
value: value,
|
178
180
|
name: cm_field.html_attr[:name] || "#{form_obj.object_name}[#{cm_field.field_name}]"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cm-admin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.
|
4
|
+
version: 1.4.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- sajinmp
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date: 2024-03
|
13
|
+
date: 2024-04-03 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: caxlsx_rails
|
@@ -498,7 +498,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
498
498
|
- !ruby/object:Gem::Version
|
499
499
|
version: '0'
|
500
500
|
requirements: []
|
501
|
-
rubygems_version: 3.
|
501
|
+
rubygems_version: 3.2.3
|
502
502
|
signing_key:
|
503
503
|
specification_version: 4
|
504
504
|
summary: CmAdmin is a robust gem designed to assist in creating admin panels for Rails
|