cm-admin 1.4.6 → 1.4.7
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/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 +17 -15
- 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: 0616f7649aac8382d9b74d034ff4bb55287f911cdfc5316be4fa9f33ccfc26a5
|
4
|
+
data.tar.gz: 02ea79e4c6e59777013276da852a30e476a5e847ff7eac90702908dc4c759656
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c5f68ebbb03c82e19b7f262c70006f4edf096073013e6c422eb20b43096fbdda004d37e537fd0ffe46c0f8f376442b0c3314b32d0227c21bc0bd5377b4a6e848
|
7
|
+
data.tar.gz: f836df493c54f15c8267b8a9458c67a7844489539274655648aef4cde0caf1250e12f1a9bb6b889a7244d21e21579908f0de7e75f5091f0643f6a294281a7e4f
|
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.7)
|
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,16 +50,18 @@ 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
|
|
@@ -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),
|
@@ -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,13 +116,13 @@ 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
|
@@ -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.7
|
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-
|
13
|
+
date: 2024-04-02 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
|