Skip to content

Commit

Permalink
Merge pull request #3192 from karelhala/toolbarClickFinish
Browse files Browse the repository at this point in the history
Fire new event when toolbar click finish
  • Loading branch information
martinpovolny authored Jan 10, 2018
2 parents c1a7b38 + 10754ad commit db59822
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
13 changes: 12 additions & 1 deletion app/assets/javascripts/controllers/report_data_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,21 @@
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 &&
TREE_TABS_WITHOUT_PARENT.indexOf(initObject.activeTree) === -1;
}

function tileViewSelector() {
return document.querySelector('miq-tile-view');
}

function tableViewSelector() {
return document.querySelector('miq-data-table');
}

function constructSuffixForTreeUrl(initObject, item) {
var itemId = initObject.showUrl.indexOf('xx-') !== -1 ? '_-' + item.id : '-' + item.id;
if (item.parent_id && item.parent_id[item.parent_id.length - 1] !== '-') {
Expand Down Expand Up @@ -88,6 +97,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 && (tileViewSelector() || tableViewSelector())) {
this.setExtraClasses(this.initObject.gtlType);
} else if (event.refreshData && event.refreshData.name === CONTROLLER_NAME) {
this.refreshData();
Expand Down Expand Up @@ -224,7 +235,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.bind(this)();
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 db59822

Please sign in to comment.