Skip to content

Commit

Permalink
Fire new event when toolbar click finish, set extra classes for GTL i…
Browse files Browse the repository at this point in the history
…f GTL is present and click on toolbar finish

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1530939
  • Loading branch information
karelhala committed Jan 8, 2018
1 parent dee7ecf commit 7298178
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
5 changes: 4 additions & 1 deletion app/assets/javascripts/controllers/report_data_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
var TREE_TABS_WITHOUT_PARENT = ['action_tree', 'alert_tree', 'schedules_tree'];
var USE_TREE_ID = ['automation_manager'];
var DEFAULT_VIEW = 'grid';
var TOOLBAR_CLICK_FINISH = 'TOOLBAR_CLICK_FINISH';

function isAllowedParent(initObject) {
return TREES_WITHOUT_PARENT.indexOf(ManageIQ.controller) === -1 &&
Expand Down Expand Up @@ -88,6 +89,8 @@
} else if (event.unsubscribe && event.unsubscribe === CONTROLLER_NAME) {
this.onUnsubscribe();
} else if (event.toolbarEvent && (event.toolbarEvent === 'itemClicked')) {
this.setExtraClasses();
} else if (event.type === TOOLBAR_CLICK_FINISH && document.querySelector('miq-tile-view')) {
this.setExtraClasses(this.initObject.gtlType);
} else if (event.refreshData && event.refreshData.name === CONTROLLER_NAME) {
this.refreshData();
Expand Down Expand Up @@ -224,7 +227,7 @@
}
var url = prefix + itemId;
$.post(url).always(function() {
this.setExtraClasses(this.initObject.gtlType);
this.setExtraClasses();
}.bind(this));
} else if (prefix !== "true") {
var lastChar = prefix[prefix.length - 1];
Expand Down
4 changes: 3 additions & 1 deletion app/assets/javascripts/controllers/toolbar_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,9 @@
}

sendDataWithRx({toolbarEvent: 'itemClicked'});
miqToolbarOnClick.bind($event.delegateTarget)($event);
miqToolbarOnClick.bind($event.delegateTarget)($event).then(function(data) {
sendDataWithRx({type: 'TOOLBAR_CLICK_FINISH', payload: data});
});
};
})
.value();
Expand Down
8 changes: 5 additions & 3 deletions app/assets/javascripts/miq_application.js
Original file line number Diff line number Diff line change
Expand Up @@ -1316,7 +1316,10 @@ function miqInitToolbars() {
$('#toolbar:not(.miq-toolbar-menu) button:not(.dropdown-toggle), ' +
'#toolbar:not(.miq-toolbar-menu) ul.dropdown-menu > li > a, '+
'#toolbar:not(.miq-toolbar-menu) .toolbar-pf-view-selector > ul.list-inline > li > a'
).click(miqToolbarOnClick);
).click(function() {
miqToolbarOnClick();
return false;
});
}

// Function to run transactions when toolbar button is clicked
Expand Down Expand Up @@ -1432,8 +1435,7 @@ function miqToolbarOnClick(_e) {
data: paramstring,
};

miqJqueryRequest(tb_url, options);
return false;
return miqJqueryRequest(tb_url, options);

function getParams(urlParms, sendChecked) {
var params = [];
Expand Down

0 comments on commit 7298178

Please sign in to comment.