Skip to content

Commit

Permalink
Merge pull request #740 from jpwhite4/refresh_button
Browse files Browse the repository at this point in the history
Fix refesh button for Metric Explorer
  • Loading branch information
jpwhite4 authored Dec 7, 2018
2 parents 8a3661a + 1f9dda5 commit 0a8ff79
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 23 deletions.
9 changes: 7 additions & 2 deletions html/gui/js/DurationToolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,11 @@ Ext.extend(CCR.xdmod.ui.DurationToolbar, Ext.Toolbar, {
getDurationLabel: function () {
return this.cannedDateButton.getText();
},
onHandle: function () {
onHandle: function (refreshButtonClicked) {
var changed = true;
if (refreshButtonClicked) {
changed = this.startDateField.didChange() || this.endDateField.didChange();
}
var refreshBtn = Ext.getCmp('refresh_button_' + this.id);
if (refreshBtn) refreshBtn.removeClass('dateframe_refresh_button_highlight');
Ext.getCmp('start_field_' + this.id).updatePreviousValue();
Expand All @@ -279,6 +283,7 @@ Ext.extend(CCR.xdmod.ui.DurationToolbar, Ext.Toolbar, {
if (this.handler) {
this.handler.call(this.scope || this, {
preset: this.getDurationLabel(),
changed: changed,
aggregation_unit: this.getAggregationUnit(),
start_date: this.getStartDate().format('Y-m-d'),
end_date: this.getEndDate().format('Y-m-d')
Expand Down Expand Up @@ -680,7 +685,7 @@ Ext.extend(CCR.xdmod.ui.DurationToolbar, Ext.Toolbar, {
tooltip: 'Refresh using selected time frame',
scope: this,
handler: function () {
this.onHandle();
this.onHandle(true);
}
});

Expand Down
27 changes: 6 additions & 21 deletions html/gui/js/modules/metric_explorer/MetricExplorer.js
Original file line number Diff line number Diff line change
Expand Up @@ -2962,8 +2962,12 @@ Ext.extend(XDMoD.Module.MetricExplorer, XDMoD.PortalModule, {

// ---------------------------------------------------------

this.on('duration_change', function( /*d*/ ) {
this.saveQuery();
this.on('duration_change', function (duration) {
if (duration.changed) {
this.saveQuery();
} else {
this.reloadChart();
}
});

// ---------------------------------------------------------
Expand Down Expand Up @@ -6277,25 +6281,6 @@ Ext.extend(XDMoD.Module.MetricExplorer, XDMoD.PortalModule, {
XDMoD.Module.MetricExplorer.superclass.initComponent.apply(this, arguments);

this.addEvents("dwdesc_loaded");
var durationToolbar = this.getDurationSelector();
var origRefreshOnHandle = durationToolbar.refreshButton.handler;
durationToolbar.refreshButton.handler = function() {
var changed = function(component) {
if (CCR.exists(component)) {
if (CCR.isType(component.didChange, CCR.Types.Function)) {
return component.didChange();
}
}
return undefined;
};

var startChanged = changed(this.startDateField);
var endChanged = changed(this.endDateField);

if (startChanged || endChanged) {
origRefreshOnHandle.call(durationToolbar);
}
};
}, //initComponent

listeners: {
Expand Down

0 comments on commit 0a8ff79

Please sign in to comment.