activeadmin_addons 2.0.0.beta.0 → 2.0.0.beta.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/inputs/active_admin/inputs/select_input.rb +4 -4
- data/app/inputs/nested_level_input.rb +12 -7
- data/app/inputs/nested_select_input.rb +19 -13
- data/app/inputs/search_select_filter_input.rb +15 -1
- data/app/inputs/search_select_input.rb +6 -5
- data/app/inputs/selected_list_input.rb +1 -1
- data/app/inputs/tags_input.rb +4 -33
- data/app/javascript/activeadmin_addons/inputs/slim-select-nested.js +7 -5
- data/app/javascript/activeadmin_addons/inputs/slim-select-tags.js +1 -40
- data/app/javascript/activeadmin_addons/inputs/slim-select.js +28 -10
- data/app/javascript/activeadmin_addons/stylesheets/all.scss +1 -1
- data/lib/activeadmin_addons/addons/state_builder.rb +1 -0
- data/lib/activeadmin_addons/engine.rb +1 -1
- data/lib/activeadmin_addons/support/custom_builder.rb +1 -1
- data/lib/activeadmin_addons/support/input_base.rb +0 -42
- data/lib/activeadmin_addons/support/input_helpers/filter_input_methods.rb +1 -0
- data/lib/activeadmin_addons/support/input_helpers/input_html_helpers.rb +42 -0
- data/lib/activeadmin_addons/support/input_helpers/select_helpers.rb +9 -11
- data/lib/activeadmin_addons/support/select_filter_input_extension.rb +1 -3
- data/lib/activeadmin_addons/support/select_input_base.rb +11 -0
- data/lib/activeadmin_addons/version.rb +1 -1
- data/lib/activeadmin_addons.rb +3 -0
- data/lib/generators/activeadmin_addons/install/templates/initializer.rb +1 -1
- data/lib/generators/activeadmin_addons/webpacker/webpacker_generator.rb +2 -5
- metadata +73 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 89b4ce7695da72133e698f7a197889ac11799489282ec78b5e86aa8c91b067ba
|
4
|
+
data.tar.gz: 19d91fa45dacd9e69381732b8565ca19126980b2c774082f4ea04874bf2652aa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8325581c4b779c1b55cccb627afd6da7fe360212e051851358124c2f837a1fdfdea0264051d7c545136f611b56311494286de1b1c4ee760c46fe77b81776438a
|
7
|
+
data.tar.gz: 7700a77a2ad797b32259d4060cf0ae637452a6e1403fae4387b231c8322128fbe6b4e59b95d6cedb707fd12768f41837bfda13b48aebc52ab4fef54c61acbf9e
|
@@ -9,10 +9,10 @@ class ActiveAdmin::Inputs::SelectInput < Formtastic::Inputs::SelectInput
|
|
9
9
|
|
10
10
|
def raw_collection
|
11
11
|
field_value = begin
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
12
|
+
object.send(method)
|
13
|
+
rescue NoMethodError
|
14
|
+
nil
|
15
|
+
end
|
16
16
|
|
17
17
|
@options[:tags].present? && field_value.present? ? (super.to_a << field_value).uniq : super
|
18
18
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
class NestedLevelInput < ActiveAdminAddons::
|
1
|
+
class NestedLevelInput < ActiveAdminAddons::SelectInputBase
|
2
2
|
include ActiveAdminAddons::SelectHelpers
|
3
3
|
|
4
4
|
def render_custom_input
|
@@ -13,11 +13,12 @@ class NestedLevelInput < ActiveAdminAddons::InputBase
|
|
13
13
|
|
14
14
|
private
|
15
15
|
|
16
|
+
# rubocop:disable Metrics/MethodLength
|
16
17
|
def load_control_attributes
|
17
18
|
load_class(@options[:class])
|
18
19
|
load_data_attr(:association, value: association_name)
|
19
20
|
load_data_attr(:fields, default: ["name"], formatter: :to_json)
|
20
|
-
load_data_attr(:predicate, default: "
|
21
|
+
load_data_attr(:predicate, default: "cont")
|
21
22
|
load_data_attr(:filters)
|
22
23
|
load_data_attr(:model, value: model_name)
|
23
24
|
load_data_attr(:display_name, default: "name")
|
@@ -26,24 +27,28 @@ class NestedLevelInput < ActiveAdminAddons::InputBase
|
|
26
27
|
load_data_attr(:response_root, default: tableize_method)
|
27
28
|
load_data_attr(:width)
|
28
29
|
load_data_attr(:order,
|
29
|
-
|
30
|
-
|
30
|
+
value: @options[:order_by],
|
31
|
+
default: "#{get_data_attr_value(:fields).first}_desc")
|
31
32
|
load_parent_data_options
|
32
33
|
load_collection_data
|
33
34
|
end
|
35
|
+
# rubocop:enable Metrics/MethodLength
|
34
36
|
|
35
37
|
def load_parent_data_options
|
36
38
|
return unless @options[:parent_attribute]
|
39
|
+
|
37
40
|
load_data_attr(:parent, value: @options[:parent_attribute])
|
38
|
-
load_data_attr(
|
41
|
+
load_data_attr(
|
42
|
+
:parent_id, value: @object.send(@options[:parent_id_attribute]), default: -1
|
43
|
+
)
|
39
44
|
end
|
40
45
|
|
41
46
|
def load_collection_data
|
42
47
|
return unless @options[:collection]
|
43
48
|
|
44
49
|
collection_options = collection_to_select_options do |item, option|
|
45
|
-
if
|
46
|
-
option[@options[:parent_attribute]] = item.send(@options[:
|
50
|
+
if @options[:parent_attribute].present?
|
51
|
+
option[@options[:parent_attribute]] = item.send(@options[:parent_id_attribute])
|
47
52
|
end
|
48
53
|
end
|
49
54
|
|
@@ -59,32 +59,38 @@ class NestedSelectInput < ActiveAdminAddons::InputBase
|
|
59
59
|
parent_level_data = hierarchy[next_idx] if hierarchy.count != next_idx
|
60
60
|
if parent_level_data
|
61
61
|
level_data[:parent_attribute] = parent_level_data[:attribute]
|
62
|
+
level_data[:parent_id_attribute] = "#{level_data[:parent_attribute]}_id"
|
62
63
|
set_parent_value(level_data)
|
63
64
|
end
|
64
65
|
end
|
65
66
|
end
|
66
67
|
|
67
68
|
def set_parent_value(level_data)
|
68
|
-
|
69
|
-
build_virtual_attr(
|
70
|
-
instance =
|
71
|
-
if instance
|
72
|
-
@object.send(
|
69
|
+
build_virtual_attr(level_data[:parent_attribute])
|
70
|
+
build_virtual_attr(level_data[:parent_id_attribute])
|
71
|
+
instance = instance_from_attribute_id("#{level_data[:attribute]}_id")
|
72
|
+
if instance.respond_to?(level_data[:parent_id_attribute])
|
73
|
+
@object.send(
|
74
|
+
"#{level_data[:parent_attribute]}=", instance.send(level_data[:parent_attribute])
|
75
|
+
)
|
76
|
+
@object.send(
|
77
|
+
"#{level_data[:parent_id_attribute]}=", instance.send(level_data[:parent_id_attribute])
|
78
|
+
)
|
73
79
|
end
|
74
80
|
end
|
75
81
|
|
76
|
-
def
|
77
|
-
return unless
|
82
|
+
def instance_from_attribute_id(attribute_id)
|
83
|
+
return unless attribute_id
|
78
84
|
|
79
|
-
|
80
|
-
return unless
|
85
|
+
attribute_id_value = @object.send(attribute_id)
|
86
|
+
return unless attribute_id_value
|
81
87
|
|
82
|
-
klass =
|
83
|
-
klass.find_by(id:
|
88
|
+
klass = class_from_attribute_id(attribute_id)
|
89
|
+
klass.find_by(id: attribute_id_value)
|
84
90
|
end
|
85
91
|
|
86
|
-
def
|
87
|
-
association_name =
|
92
|
+
def class_from_attribute_id(attribute_id)
|
93
|
+
association_name = attribute_id.to_s.chomp("_id")
|
88
94
|
association_name.camelize.constantize
|
89
95
|
rescue NameError
|
90
96
|
object_class.reflect_on_association(association_name).klass
|
@@ -7,6 +7,20 @@ class SearchSelectFilterInput < SearchSelectInput
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def input_method
|
10
|
-
|
10
|
+
"#{input_name}_eq"
|
11
|
+
end
|
12
|
+
|
13
|
+
def input_html_options_name
|
14
|
+
"#{object_name}[#{input_method}]"
|
15
|
+
end
|
16
|
+
|
17
|
+
def input_value
|
18
|
+
result = valid_object.conditions.find do |condition|
|
19
|
+
condition.attributes.map(&:name).include?(input_name.to_s)
|
20
|
+
end
|
21
|
+
|
22
|
+
return unless result
|
23
|
+
|
24
|
+
result.values.first.value
|
11
25
|
end
|
12
26
|
end
|
@@ -1,10 +1,11 @@
|
|
1
|
-
class SearchSelectInput < ActiveAdminAddons::
|
1
|
+
class SearchSelectInput < ActiveAdminAddons::SelectInputBase
|
2
2
|
include ActiveAdminAddons::SelectHelpers
|
3
3
|
|
4
4
|
def render_custom_input
|
5
5
|
concat(label_html)
|
6
|
-
concat(
|
7
|
-
initial_collection_to_select_options, {}, input_html_options)
|
6
|
+
concat(
|
7
|
+
builder.select(input_method, initial_collection_to_select_options, {}, input_html_options)
|
8
|
+
)
|
8
9
|
end
|
9
10
|
|
10
11
|
def input_method
|
@@ -14,7 +15,7 @@ class SearchSelectInput < ActiveAdminAddons::InputBase
|
|
14
15
|
def load_control_attributes
|
15
16
|
load_class(@options[:class])
|
16
17
|
load_data_attr(:fields, default: ["name"], formatter: :to_json)
|
17
|
-
load_data_attr(:predicate, default: "
|
18
|
+
load_data_attr(:predicate, default: "cont")
|
18
19
|
load_data_attr(:url, default: url_from_method)
|
19
20
|
load_data_attr(:response_root, default: tableize_method)
|
20
21
|
load_data_attr(:display_name, default: "name")
|
@@ -23,7 +24,7 @@ class SearchSelectInput < ActiveAdminAddons::InputBase
|
|
23
24
|
load_data_attr(
|
24
25
|
:order,
|
25
26
|
value: @options[:order_by],
|
26
|
-
default: get_data_attr_value(:fields).first
|
27
|
+
default: "#{get_data_attr_value(:fields).first}_desc"
|
27
28
|
)
|
28
29
|
end
|
29
30
|
end
|
@@ -11,7 +11,7 @@ class SelectedListInput < ActiveAdminAddons::InputBase
|
|
11
11
|
load_data_attr(:url, default: url_from_method)
|
12
12
|
load_data_attr(:response_root, default: tableize_method)
|
13
13
|
load_data_attr(:fields, default: ["name"], formatter: :to_json)
|
14
|
-
load_data_attr(:predicate, default: "
|
14
|
+
load_data_attr(:predicate, default: "cont")
|
15
15
|
load_data_attr(:display_name, default: "name")
|
16
16
|
load_data_attr(:minimum_input_length, default: 1)
|
17
17
|
load_data_attr(:width, default: "100%")
|
data/app/inputs/tags_input.rb
CHANGED
@@ -1,17 +1,12 @@
|
|
1
|
-
class TagsInput < ActiveAdminAddons::
|
1
|
+
class TagsInput < ActiveAdminAddons::SelectInputBase
|
2
2
|
include ActiveAdminAddons::SelectHelpers
|
3
3
|
|
4
4
|
def render_custom_input
|
5
|
-
|
6
|
-
return render_collection_tags
|
7
|
-
end
|
8
|
-
|
9
|
-
render_array_tags
|
5
|
+
render_collection_tags
|
10
6
|
end
|
11
7
|
|
12
8
|
def load_control_attributes
|
13
|
-
|
14
|
-
load_data_attr(:method, value: method)
|
9
|
+
@options[:multiple] = true
|
15
10
|
load_data_attr(:width)
|
16
11
|
|
17
12
|
if active_record_select?
|
@@ -24,32 +19,8 @@ class TagsInput < ActiveAdminAddons::InputBase
|
|
24
19
|
|
25
20
|
private
|
26
21
|
|
27
|
-
def render_array_tags
|
28
|
-
render_tags_control { build_hidden_control(prefixed_method, method_to_input_name, input_value) }
|
29
|
-
end
|
30
|
-
|
31
22
|
def render_collection_tags
|
32
|
-
render_tags_control { render_selected_hidden_items }
|
33
|
-
end
|
34
|
-
|
35
|
-
def render_tags_control(&block)
|
36
23
|
concat(label_html)
|
37
|
-
concat(
|
38
|
-
concat(builder.select(build_virtual_attr, [], {}, input_html_options))
|
39
|
-
end
|
40
|
-
|
41
|
-
def render_selected_hidden_items
|
42
|
-
template.content_tag(:div, id: selected_values_id) do
|
43
|
-
template.concat(build_hidden_control(empty_input_id, method_to_input_array_name, ""))
|
44
|
-
input_value.each do |item_id|
|
45
|
-
template.concat(
|
46
|
-
build_hidden_control(
|
47
|
-
method_to_input_id(item_id),
|
48
|
-
method_to_input_array_name,
|
49
|
-
item_id.to_s
|
50
|
-
)
|
51
|
-
)
|
52
|
-
end
|
53
|
-
end
|
24
|
+
concat(builder.select(method, [], input_options, input_html_options))
|
54
25
|
end
|
55
26
|
end
|
@@ -12,7 +12,7 @@ function ajaxSearch(search, currentData, args) {
|
|
12
12
|
});
|
13
13
|
|
14
14
|
if (!!args.parent) {
|
15
|
-
args.query.q[`${args.parent}
|
15
|
+
args.query.q[`${args.parent}_id_eq`] = args.parentId;
|
16
16
|
}
|
17
17
|
|
18
18
|
args.query.q = { ...args.query.q, ...args.filters };
|
@@ -25,10 +25,12 @@ function collectionSearch(search, args, collection) {
|
|
25
25
|
return Promise.reject('Search term too short');
|
26
26
|
}
|
27
27
|
|
28
|
-
const data = JSON.parse(collection).
|
28
|
+
const data = JSON.parse(collection).filter(
|
29
|
+
(item) => (!args.parent || item[args.parent] === Number(args.parentId)) &&
|
30
|
+
String(item.text).toLowerCase().includes(search.toLowerCase()),
|
31
|
+
).map(
|
29
32
|
(item) => ({ value: String(item.id), text: item.text }),
|
30
|
-
)
|
31
|
-
(item) => String(item.text).toLowerCase().includes(search.toLowerCase()));
|
33
|
+
);
|
32
34
|
|
33
35
|
return Promise.resolve(data);
|
34
36
|
}
|
@@ -48,7 +50,7 @@ function settings(el) {
|
|
48
50
|
const { model, association } = el.dataset;
|
49
51
|
const child = el.closest('.nested_level')
|
50
52
|
.parentNode
|
51
|
-
.querySelector(`.nested_level [data-model=${model}][data-parent=${association}
|
53
|
+
.querySelector(`.nested_level [data-model=${model}][data-parent=${association}]`);
|
52
54
|
|
53
55
|
if (child) {
|
54
56
|
child.slim.setSelected();
|
@@ -2,9 +2,6 @@ const classes = ['tags-input'];
|
|
2
2
|
|
3
3
|
// eslint-disable-next-line max-statements
|
4
4
|
function settings(el) {
|
5
|
-
const model = el.dataset.model;
|
6
|
-
const method = el.dataset.method;
|
7
|
-
const prefix = `${model}_${method}`;
|
8
5
|
const isRelation = el.dataset.relation === 'true';
|
9
6
|
const collection = el.dataset.collection ? JSON.parse(el.dataset.collection) : null;
|
10
7
|
|
@@ -14,38 +11,7 @@ function settings(el) {
|
|
14
11
|
return { ...rest, value: id, selected: !!item.selected };
|
15
12
|
});
|
16
13
|
|
17
|
-
|
18
|
-
const hiddenInput = document.querySelector(`#${prefix}`);
|
19
|
-
hiddenInput.value = values.map(val => val.value).join();
|
20
|
-
}
|
21
|
-
|
22
|
-
const events = {
|
23
|
-
afterChange: (newVal) => {
|
24
|
-
if (isRelation) {
|
25
|
-
const selectedItemsContainer = document.querySelector(`#${prefix}_selected_values`);
|
26
|
-
const itemName = `${model}[${method}][]`;
|
27
|
-
selectedItemsContainer.innerHTML = '';
|
28
|
-
|
29
|
-
newVal.forEach((data) => {
|
30
|
-
const itemId = `${prefix}_${data.value}`;
|
31
|
-
if (document.querySelectorAll(`#${itemId}`).length > 0) {
|
32
|
-
return;
|
33
|
-
}
|
34
|
-
|
35
|
-
const hiddenInput = document.createElement('input');
|
36
|
-
hiddenInput.id = itemId;
|
37
|
-
hiddenInput.name = itemName;
|
38
|
-
hiddenInput.value = data.value;
|
39
|
-
hiddenInput.type = 'hidden';
|
40
|
-
|
41
|
-
selectedItemsContainer.appendChild(hiddenInput);
|
42
|
-
});
|
43
|
-
} else {
|
44
|
-
fillHiddenInput(newVal);
|
45
|
-
}
|
46
|
-
},
|
47
|
-
};
|
48
|
-
|
14
|
+
const events = {};
|
49
15
|
if (!isRelation) {
|
50
16
|
events.addable = (value) => value;
|
51
17
|
}
|
@@ -56,12 +22,7 @@ function settings(el) {
|
|
56
22
|
};
|
57
23
|
}
|
58
24
|
|
59
|
-
function init(el) {
|
60
|
-
el.multiple = true;
|
61
|
-
}
|
62
|
-
|
63
25
|
export {
|
64
26
|
settings,
|
65
27
|
classes,
|
66
|
-
init,
|
67
28
|
};
|
@@ -18,15 +18,8 @@ const selectTypes = {
|
|
18
18
|
tagsSelect,
|
19
19
|
};
|
20
20
|
|
21
|
-
// eslint-disable-next-line max-statements
|
21
|
+
// eslint-disable-next-line max-statements, complexity
|
22
22
|
function setupSelect(el) {
|
23
|
-
const emptyOption = el.querySelector('option[value=""]');
|
24
|
-
if (!emptyOption) {
|
25
|
-
el.insertAdjacentHTML('afterbegin', '<option value=""></option>');
|
26
|
-
}
|
27
|
-
el.querySelector('option[value=""]').dataset.placeholder = true;
|
28
|
-
|
29
|
-
el.style.width = el.dataset.width;
|
30
23
|
let settings = {
|
31
24
|
select: el,
|
32
25
|
settings: {
|
@@ -35,6 +28,31 @@ function setupSelect(el) {
|
|
35
28
|
},
|
36
29
|
};
|
37
30
|
|
31
|
+
const selectStyles = window.getComputedStyle(el);
|
32
|
+
el.style.width = el.dataset.width;
|
33
|
+
el.style.fontSize = selectStyles.fontSize;
|
34
|
+
|
35
|
+
const searchSelectFilter = el.closest('.filter_form_field');
|
36
|
+
if (searchSelectFilter) {
|
37
|
+
if (searchSelectFilter.classList.contains('search_select_filter') ||
|
38
|
+
searchSelectFilter.classList.contains('filter_string')) {
|
39
|
+
settings.settings.allowDeselect = false;
|
40
|
+
}
|
41
|
+
|
42
|
+
if (el.options.length > 0) {
|
43
|
+
el.style.width = el.dataset.width || selectStyles.width;
|
44
|
+
if (selectStyles.display === 'inline-block') {
|
45
|
+
el.style.display = 'inline-flex';
|
46
|
+
}
|
47
|
+
}
|
48
|
+
}
|
49
|
+
|
50
|
+
const emptyOption = el.querySelector('option[value=""]');
|
51
|
+
if (!emptyOption) {
|
52
|
+
el.insertAdjacentHTML('afterbegin', '<option value=""></option>');
|
53
|
+
}
|
54
|
+
el.querySelector('option[value=""]').dataset.placeholder = true;
|
55
|
+
|
38
56
|
Object.keys(selectTypes).forEach((type) => {
|
39
57
|
if (selectTypes[type].classes.some((className) => el.classList.contains(className))) {
|
40
58
|
settings = merge({}, settings, selectTypes[type].settings(el));
|
@@ -44,8 +62,8 @@ function setupSelect(el) {
|
|
44
62
|
}
|
45
63
|
});
|
46
64
|
|
47
|
-
|
48
|
-
|
65
|
+
// eslint-disable-next-line no-new
|
66
|
+
new SlimSelect(settings);
|
49
67
|
}
|
50
68
|
|
51
69
|
function initSelects(node = document) {
|
@@ -11,6 +11,7 @@ module ActiveAdminAddons
|
|
11
11
|
def render
|
12
12
|
raise "you need to install AASM gem first" unless defined? AASM
|
13
13
|
raise "the #{attribute} is not an AASM state" unless state_attribute?
|
14
|
+
|
14
15
|
context.status_tag(model.aasm(machine_name).human_state, class: status_class_for_model)
|
15
16
|
end
|
16
17
|
|
@@ -7,47 +7,5 @@ module ActiveAdminAddons
|
|
7
7
|
include InputOptionsHandler
|
8
8
|
include InputMethods
|
9
9
|
include InputHtmlHelpers
|
10
|
-
|
11
|
-
def to_html
|
12
|
-
load_input_class
|
13
|
-
load_control_attributes
|
14
|
-
render_custom_input
|
15
|
-
if parts.any?
|
16
|
-
return input_wrapping { parts_to_html }
|
17
|
-
else
|
18
|
-
super
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
def input_html_options
|
23
|
-
# maxwidth and size are added by Formtastic::Inputs::StringInput
|
24
|
-
# but according to the HTML standard these are not valid attributes
|
25
|
-
# on the inputs provided by this module
|
26
|
-
super.except(:maxlength, :size).merge(control_attributes)
|
27
|
-
end
|
28
|
-
|
29
|
-
def parts_to_html
|
30
|
-
parts.flatten.join("\n").html_safe
|
31
|
-
end
|
32
|
-
|
33
|
-
def load_input_class
|
34
|
-
load_class(self.class.to_s.underscore.dasherize)
|
35
|
-
end
|
36
|
-
|
37
|
-
def load_control_attributes
|
38
|
-
# Override on child classes if needed
|
39
|
-
end
|
40
|
-
|
41
|
-
def render_custom_input
|
42
|
-
# Override on child classes if needed
|
43
|
-
end
|
44
|
-
|
45
|
-
def parts
|
46
|
-
@parts ||= []
|
47
|
-
end
|
48
|
-
|
49
|
-
def concat(part)
|
50
|
-
parts << part
|
51
|
-
end
|
52
10
|
end
|
53
11
|
end
|
@@ -40,5 +40,47 @@ module ActiveAdminAddons
|
|
40
40
|
value: value
|
41
41
|
)
|
42
42
|
end
|
43
|
+
|
44
|
+
def to_html
|
45
|
+
load_input_class
|
46
|
+
load_control_attributes
|
47
|
+
render_custom_input
|
48
|
+
if parts.any?
|
49
|
+
input_wrapping { parts_to_html }
|
50
|
+
else
|
51
|
+
super
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def input_html_options
|
56
|
+
# maxwidth and size are added by Formtastic::Inputs::StringInput
|
57
|
+
# but according to the HTML standard these are not valid attributes
|
58
|
+
# on the inputs provided by this module
|
59
|
+
super.except(:maxlength, :size).merge(control_attributes)
|
60
|
+
end
|
61
|
+
|
62
|
+
def load_input_class
|
63
|
+
load_class(self.class.to_s.underscore.dasherize)
|
64
|
+
end
|
65
|
+
|
66
|
+
def load_control_attributes
|
67
|
+
# Override on child classes if needed
|
68
|
+
end
|
69
|
+
|
70
|
+
def render_custom_input
|
71
|
+
# Override on child classes if needed
|
72
|
+
end
|
73
|
+
|
74
|
+
def parts_to_html
|
75
|
+
parts.flatten.join("\n").html_safe # rubocop:disable Rails/OutputSafety
|
76
|
+
end
|
77
|
+
|
78
|
+
def concat(part)
|
79
|
+
parts << part
|
80
|
+
end
|
81
|
+
|
82
|
+
def parts
|
83
|
+
@parts ||= []
|
84
|
+
end
|
43
85
|
end
|
44
86
|
end
|
@@ -57,21 +57,19 @@ module ActiveAdminAddons
|
|
57
57
|
end
|
58
58
|
|
59
59
|
def selected_collection
|
60
|
-
@selected_collection ||=
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
end
|
66
|
-
end
|
60
|
+
@selected_collection ||= if active_record_relation?(collection)
|
61
|
+
collection.model.where(id: input_value)
|
62
|
+
else
|
63
|
+
method_model.where(id: input_value)
|
64
|
+
end
|
67
65
|
end
|
68
66
|
|
69
67
|
def selected_item
|
70
68
|
@selected_item ||= begin
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
69
|
+
input_association_value
|
70
|
+
rescue NoMethodError
|
71
|
+
selected_collection.first
|
72
|
+
end
|
75
73
|
end
|
76
74
|
|
77
75
|
private
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require_relative "input_helpers/input_options_handler"
|
2
|
+
require_relative "input_helpers/input_methods"
|
3
|
+
require_relative "input_helpers/input_html_helpers"
|
4
|
+
|
5
|
+
module ActiveAdminAddons
|
6
|
+
class SelectInputBase < Formtastic::Inputs::SelectInput
|
7
|
+
include InputOptionsHandler
|
8
|
+
include InputMethods
|
9
|
+
include InputHtmlHelpers
|
10
|
+
end
|
11
|
+
end
|
data/lib/activeadmin_addons.rb
CHANGED
@@ -5,16 +5,19 @@ module ActiveadminAddons
|
|
5
5
|
|
6
6
|
def default_select
|
7
7
|
return "slim-select" unless @default_select
|
8
|
+
|
8
9
|
@default_select
|
9
10
|
end
|
10
11
|
|
11
12
|
def datetime_picker_default_options
|
12
13
|
return {} unless @datetime_picker_default_options
|
14
|
+
|
13
15
|
@datetime_picker_default_options
|
14
16
|
end
|
15
17
|
|
16
18
|
def datetime_picker_input_format
|
17
19
|
return "%Y-%m-%d %H:%M" unless @datetime_picker_input_format
|
20
|
+
|
18
21
|
@datetime_picker_input_format
|
19
22
|
end
|
20
23
|
|
@@ -3,7 +3,7 @@ ActiveadminAddons.setup do |config|
|
|
3
3
|
# config.default_select = "slim-select"
|
4
4
|
|
5
5
|
# Set default options for DateTimePickerInput. The options you can provide are the same as in
|
6
|
-
# xdan's datetimepicker library (https://github.com/xdan/datetimepicker/tree/2.5.4).
|
6
|
+
# xdan's datetimepicker library (https://github.com/xdan/datetimepicker/tree/2.5.4). You need to
|
7
7
|
# pass a ruby hash, avoid camelCase keys. For example: use min_date instead of minDate key.
|
8
8
|
# config.datetime_picker_default_options = {}
|
9
9
|
|
@@ -11,9 +11,7 @@ module ActiveadminAddons
|
|
11
11
|
def add_stylesheets
|
12
12
|
file_path = 'app/javascript/stylesheets/active_admin.scss'
|
13
13
|
|
14
|
-
|
15
|
-
prepend_file(file_path, css_assets)
|
16
|
-
end
|
14
|
+
prepend_file(file_path, css_assets)
|
17
15
|
end
|
18
16
|
|
19
17
|
def install_package
|
@@ -23,8 +21,7 @@ module ActiveadminAddons
|
|
23
21
|
private
|
24
22
|
|
25
23
|
def js_assets
|
26
|
-
|
27
|
-
to_add
|
24
|
+
"import \"activeadmin_addons\"\n"
|
28
25
|
end
|
29
26
|
|
30
27
|
def css_assets
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activeadmin_addons
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.0.beta.
|
4
|
+
version: 2.0.0.beta.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Platanus
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2023-
|
14
|
+
date: 2023-08-24 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: railties
|
@@ -84,7 +84,7 @@ dependencies:
|
|
84
84
|
- !ruby/object:Gem::Version
|
85
85
|
version: '0'
|
86
86
|
- !ruby/object:Gem::Dependency
|
87
|
-
name: capybara
|
87
|
+
name: capybara
|
88
88
|
requirement: !ruby/object:Gem::Requirement
|
89
89
|
requirements:
|
90
90
|
- - ">="
|
@@ -181,6 +181,20 @@ dependencies:
|
|
181
181
|
- - ">="
|
182
182
|
- !ruby/object:Gem::Version
|
183
183
|
version: '0'
|
184
|
+
- !ruby/object:Gem::Dependency
|
185
|
+
name: pry-byebug
|
186
|
+
requirement: !ruby/object:Gem::Requirement
|
187
|
+
requirements:
|
188
|
+
- - ">="
|
189
|
+
- !ruby/object:Gem::Version
|
190
|
+
version: '0'
|
191
|
+
type: :development
|
192
|
+
prerelease: false
|
193
|
+
version_requirements: !ruby/object:Gem::Requirement
|
194
|
+
requirements:
|
195
|
+
- - ">="
|
196
|
+
- !ruby/object:Gem::Version
|
197
|
+
version: '0'
|
184
198
|
- !ruby/object:Gem::Dependency
|
185
199
|
name: pry-rails
|
186
200
|
requirement: !ruby/object:Gem::Requirement
|
@@ -244,7 +258,7 @@ dependencies:
|
|
244
258
|
- !ruby/object:Gem::Version
|
245
259
|
version: '0'
|
246
260
|
- !ruby/object:Gem::Dependency
|
247
|
-
name:
|
261
|
+
name: rspec_junit_formatter
|
248
262
|
requirement: !ruby/object:Gem::Requirement
|
249
263
|
requirements:
|
250
264
|
- - ">="
|
@@ -258,7 +272,7 @@ dependencies:
|
|
258
272
|
- !ruby/object:Gem::Version
|
259
273
|
version: '0'
|
260
274
|
- !ruby/object:Gem::Dependency
|
261
|
-
name: rspec-
|
275
|
+
name: rspec-rails
|
262
276
|
requirement: !ruby/object:Gem::Requirement
|
263
277
|
requirements:
|
264
278
|
- - ">="
|
@@ -272,7 +286,7 @@ dependencies:
|
|
272
286
|
- !ruby/object:Gem::Version
|
273
287
|
version: '0'
|
274
288
|
- !ruby/object:Gem::Dependency
|
275
|
-
name:
|
289
|
+
name: rspec-retry
|
276
290
|
requirement: !ruby/object:Gem::Requirement
|
277
291
|
requirements:
|
278
292
|
- - ">="
|
@@ -291,16 +305,16 @@ dependencies:
|
|
291
305
|
requirements:
|
292
306
|
- - "~>"
|
293
307
|
- !ruby/object:Gem::Version
|
294
|
-
version:
|
308
|
+
version: '1.50'
|
295
309
|
type: :development
|
296
310
|
prerelease: false
|
297
311
|
version_requirements: !ruby/object:Gem::Requirement
|
298
312
|
requirements:
|
299
313
|
- - "~>"
|
300
314
|
- !ruby/object:Gem::Version
|
301
|
-
version:
|
315
|
+
version: '1.50'
|
302
316
|
- !ruby/object:Gem::Dependency
|
303
|
-
name:
|
317
|
+
name: rubocop-performance
|
304
318
|
requirement: !ruby/object:Gem::Requirement
|
305
319
|
requirements:
|
306
320
|
- - ">="
|
@@ -314,21 +328,49 @@ dependencies:
|
|
314
328
|
- !ruby/object:Gem::Version
|
315
329
|
version: '0'
|
316
330
|
- !ruby/object:Gem::Dependency
|
317
|
-
name:
|
331
|
+
name: rubocop-rails
|
332
|
+
requirement: !ruby/object:Gem::Requirement
|
333
|
+
requirements:
|
334
|
+
- - ">="
|
335
|
+
- !ruby/object:Gem::Version
|
336
|
+
version: '0'
|
337
|
+
type: :development
|
338
|
+
prerelease: false
|
339
|
+
version_requirements: !ruby/object:Gem::Requirement
|
340
|
+
requirements:
|
341
|
+
- - ">="
|
342
|
+
- !ruby/object:Gem::Version
|
343
|
+
version: '0'
|
344
|
+
- !ruby/object:Gem::Dependency
|
345
|
+
name: rubocop-rspec
|
318
346
|
requirement: !ruby/object:Gem::Requirement
|
319
347
|
requirements:
|
320
348
|
- - "~>"
|
321
349
|
- !ruby/object:Gem::Version
|
322
|
-
version: '
|
350
|
+
version: '2.2'
|
323
351
|
type: :development
|
324
352
|
prerelease: false
|
325
353
|
version_requirements: !ruby/object:Gem::Requirement
|
326
354
|
requirements:
|
327
355
|
- - "~>"
|
328
356
|
- !ruby/object:Gem::Version
|
329
|
-
version: '
|
357
|
+
version: '2.2'
|
330
358
|
- !ruby/object:Gem::Dependency
|
331
|
-
name:
|
359
|
+
name: selenium-webdriver
|
360
|
+
requirement: !ruby/object:Gem::Requirement
|
361
|
+
requirements:
|
362
|
+
- - "~>"
|
363
|
+
- !ruby/object:Gem::Version
|
364
|
+
version: '4.10'
|
365
|
+
type: :development
|
366
|
+
prerelease: false
|
367
|
+
version_requirements: !ruby/object:Gem::Requirement
|
368
|
+
requirements:
|
369
|
+
- - "~>"
|
370
|
+
- !ruby/object:Gem::Version
|
371
|
+
version: '4.10'
|
372
|
+
- !ruby/object:Gem::Dependency
|
373
|
+
name: shoulda-matchers
|
332
374
|
requirement: !ruby/object:Gem::Requirement
|
333
375
|
requirements:
|
334
376
|
- - ">="
|
@@ -342,7 +384,21 @@ dependencies:
|
|
342
384
|
- !ruby/object:Gem::Version
|
343
385
|
version: '0'
|
344
386
|
- !ruby/object:Gem::Dependency
|
345
|
-
name:
|
387
|
+
name: shrine
|
388
|
+
requirement: !ruby/object:Gem::Requirement
|
389
|
+
requirements:
|
390
|
+
- - "~>"
|
391
|
+
- !ruby/object:Gem::Version
|
392
|
+
version: '3.0'
|
393
|
+
type: :development
|
394
|
+
prerelease: false
|
395
|
+
version_requirements: !ruby/object:Gem::Requirement
|
396
|
+
requirements:
|
397
|
+
- - "~>"
|
398
|
+
- !ruby/object:Gem::Version
|
399
|
+
version: '3.0'
|
400
|
+
- !ruby/object:Gem::Dependency
|
401
|
+
name: sqlite3
|
346
402
|
requirement: !ruby/object:Gem::Requirement
|
347
403
|
requirements:
|
348
404
|
- - ">="
|
@@ -428,6 +484,7 @@ files:
|
|
428
484
|
- lib/activeadmin_addons/support/input_helpers/input_options_handler.rb
|
429
485
|
- lib/activeadmin_addons/support/input_helpers/select_helpers.rb
|
430
486
|
- lib/activeadmin_addons/support/select_filter_input_extension.rb
|
487
|
+
- lib/activeadmin_addons/support/select_input_base.rb
|
431
488
|
- lib/activeadmin_addons/support/set_datepicker.rb
|
432
489
|
- lib/activeadmin_addons/version.rb
|
433
490
|
- lib/generators/activeadmin_addons/install/install_generator.rb
|
@@ -446,14 +503,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
446
503
|
requirements:
|
447
504
|
- - ">="
|
448
505
|
- !ruby/object:Gem::Version
|
449
|
-
version:
|
506
|
+
version: 2.7.0
|
450
507
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
451
508
|
requirements:
|
452
509
|
- - ">"
|
453
510
|
- !ruby/object:Gem::Version
|
454
511
|
version: 1.3.1
|
455
512
|
requirements: []
|
456
|
-
rubygems_version: 3.
|
513
|
+
rubygems_version: 3.4.10
|
457
514
|
signing_key:
|
458
515
|
specification_version: 4
|
459
516
|
summary: Set of addons to help with the activeadmin ui
|