Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add back functionality to open accordion from the presenter #5693

Merged
merged 1 commit into from
Dec 10, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions app/assets/javascripts/miq_application.js
Original file line number Diff line number Diff line change
Expand Up @@ -1198,6 +1198,9 @@ function miqSelectPickerEvent(element, url, options){
}

function miqAccordSelect(e) {
if (ManageIQ.noCollapseEvent) { // implicitly return true when the noCollapseEvent is set
return true;
}
if (!miqCheckForChanges()) {
return false;
} else {
Expand All @@ -1207,6 +1210,29 @@ function miqAccordSelect(e) {
}
}

// Function to expand/collapse a pair of accordions
function miqAccordionSwap(collapse, expand) {
/*
* Blocked by: https://github.com/twbs/bootstrap/issues/18418
* TODO: uncomment this and delete below when the issue is fixed
*
* // Fire an one-time event after the collapse is done
* $(collapse).one('hidden.bs.collapse', function () {
* $(expand).collapse('show');
* });
* // Fire an one-time event fater the expand is done
* $(expand).one('shown.bs.collapse', function () {
* ManageIQ.noCollapseEvent = false;
* })
* ManageIQ.noCollapseEvent = true;
* $(collapse).collapse('hide');
*
*/
ManageIQ.noCollapseEvent = true;
$(expand).parent().find('.panel-heading a').trigger('click');
ManageIQ.noCollapseEvent = false;
}

// This function is called in miqOnLoad
function miqInitToolbars() {
$("#toolbar button:not(.dropdown-toggle), #toolbar ul.dropdown-menu > li > a, #toolbar .toolbar-pf-view-selector > ul.list-inline > li > a").off('click');
Expand Down
1 change: 1 addition & 0 deletions app/assets/javascripts/miq_global.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ if (typeof(ManageIQ) === 'undefined') {
IEButtonPressed: null, // pressed save/reset button identificator
oneTrans: null, // used to generate Ajax request only once for a drawn screen
},
noCollapseEvent: false, // enable/disable events fired after collapsing an accordion
expEditor: {
prefillCount: 0, //
first: {
Expand Down
4 changes: 0 additions & 4 deletions app/controllers/report_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -741,7 +741,6 @@ def replace_right_cell(options = {}) # :replace_trees key can be an array of tr
presenter[:update_partials][:main_div] = r[:partial => partial]
case x_active_tree
when :db_tree
presenter[:open_accord] = 'db' # have to make db accordion active incase coming from report list
if @in_a_form
if @edit[:new][:dashboard_order]
@right_cell_text = _("Editing %{model} sequence for \"%{name}\"") % {:name => @sb[:group_desc], :model => "Dashboard"}
Expand All @@ -757,7 +756,6 @@ def replace_right_cell(options = {}) # :replace_trees key can be an array of tr
@right_cell_text = _("Import / Export")
when :reports_tree
if params[:pressed] == "miq_report_schedule_add"
presenter[:open_accord] = 'schedules'
if @in_a_form
presenter[:build_calendar] = true
@right_cell_text = @schedule.id ?
Expand All @@ -771,15 +769,13 @@ def replace_right_cell(options = {}) # :replace_trees key can be an array of tr
end
end
when :schedules_tree
presenter[:open_accord] = 'schedules'
if @in_a_form
presenter[:build_calendar] = true
@right_cell_text = @schedule.id ?
_("Editing %{model} \"%{name}\"") % {:name => @schedule.name, :model => ui_lookup(:model => 'MiqSchedule')} :
_("Adding a new %s") % ui_lookup(:model => 'MiqSchedule')
end
when :widgets_tree
presenter[:open_accord] = 'widgets'
if @in_a_form
presenter[:build_calendar] = {
:date_from => Time.now.in_time_zone(@edit[:tz]),
Expand Down
5 changes: 5 additions & 0 deletions app/presenters/explorer_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ def process

@out << "miqDeleteDynatreeCookies('#{@options[:clear_tree_cookies]}')" if @options[:clear_tree_cookies]

# Open an accordion inside an other AJAX call
unless @options[:open_accord].to_s.empty?
@out << "miqAccordionSwap('#accordion .panel-collapse.collapse.in', '##{j(@options[:open_accord])}_accord');"
end

if @options[:remove_nodes]
@out << "miqRemoveNodeChildren('#{@options[:active_tree]}',
'#{@options[:add_nodes][:key]}'
Expand Down