Skip to content

Commit 14f0023

Browse files
committed
Merge branch 'master' into framework-ui
2 parents d9c03ba + 842be9a commit 14f0023

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

app/assets/javascripts/jquery/active_scaffold.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@
4141
jQuery(document).on('blur', ':input', function(e) { ActiveScaffold.last_focus = e.relatedTarget; });
4242
jQuery(document).click(function(event) {
4343
if (!jQuery(event.target).closest('.action_group.dyn').length) {
44-
jQuery('.action_group.dyn > ul').remove();
44+
jQuery('.action_group.dyn > .dynamic-menu').each(function() {
45+
ActiveScaffold.remove_dynamic_action_group(this);
46+
});
4547
}
4648
});
4749
jQuery(document).on('ajax:beforeSend', 'form.as_form', function(event) {
@@ -304,12 +306,12 @@
304306
return true;
305307
} else return false;
306308
});
307-
jQuery(document).on('ajax:complete', '.action_group.dyn > ul a', function(event) {
309+
jQuery(document).on('ajax:complete', '.action_group.dyn > .dynamic-menu a', function(event) {
308310
var action_link = ActiveScaffold.find_action_link(event.target), link = jQuery(event.target);
309311
if (action_link && action_link.loading_indicator) action_link.loading_indicator.css('visibility', 'hidden');
310312
setTimeout(function() {
311313
if (!link.parent().is('.action_group.dyn')) {
312-
link.closest('.action_group.dyn > ul').remove();
314+
ActiveScaffold.remove_dynamic_action_group(link.closest('.action_group.dyn > .dynamic-menu'));
313315
}
314316
}, 100);
315317
});
@@ -1030,10 +1032,16 @@
10301032
if (ActiveScaffold.config.dynamic_group_parent_class) {
10311033
container.addClass(ActiveScaffold.config.dynamic_group_parent_class);
10321034
}
1033-
container.find('> ul.dynamic-menu').remove();
1035+
container.find('> .dynamic-menu').remove();
10341036
container.append(html);
10351037
},
10361038

1039+
remove_dynamic_action_group: function(group) {
1040+
group = jQuery(group);
1041+
group.closest('.action_group.dyn').removeClass(ActiveScaffold.config.dynamic_group_parent_class);
1042+
group.remove();
1043+
},
1044+
10371045
scroll_to: function(element, checkInViewport) {
10381046
if (typeof checkInViewport == 'undefined') checkInViewport = true;
10391047
if (typeof(element) == 'string') element = '#' + element;

lib/active_scaffold/helpers/action_link_helpers.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ def action_link_authorized?(link, *args) # rubocop:disable Naming/PredicateMetho
2424
def display_dynamic_action_group(action_link, links, record_or_ul_options = nil, ul_options = nil)
2525
ul_options = record_or_ul_options if ul_options.nil? && record_or_ul_options.is_a?(Hash)
2626
record = record_or_ul_options unless record_or_ul_options.is_a?(Hash)
27-
html = as_element :dynamic_action_group, ul_options do
27+
ul_options ||= {}
28+
ul_options[:class] = [ul_options[:class], 'dynamic-menu'].compact.join(' ')
29+
html = as_element :dynamic_action_group, **ul_options do
2830
safe_join(links.map { |link| as_element :dynamic_action_group_element, link })
2931
end
3032
raw "ActiveScaffold.display_dynamic_action_group('#{get_action_link_id action_link, record}', '#{escape_javascript html}');" # rubocop:disable Rails/OutputSafety

0 commit comments

Comments
 (0)