diff --git a/.gitignore b/.gitignore index ac96ad1..ca3fe92 100644 --- a/.gitignore +++ b/.gitignore @@ -7,4 +7,5 @@ App-local.html #IDE Files .idea .c9revisions -node_modules \ No newline at end of file +node_modules +.DS_Store diff --git a/Calculator.js b/Calculator.js index 935f821..a6c947c 100644 --- a/Calculator.js +++ b/Calculator.js @@ -23,11 +23,12 @@ Ext.define('Calculator', { }); } else { seriesData = _.map(data, function(value, key) { - var planEstimateTotal = _.reduce(value, function(total, r) { - return total + r.get('PlanEstimate'); - }, 0); - return [key, planEstimateTotal]; - }); + var valueTotal = _.reduce(value, function(total, r) { + var valueField = this._getValueFieldForCalculationType(); + return total + r.get(valueField); + }, 0, this); + return [key, valueTotal]; + }, this); } return { @@ -40,5 +41,16 @@ Ext.define('Calculator', { } ] }; + }, + + _getValueFieldForCalculationType: function() { + switch(this.calculationType) { + case 'leafplanest': + return 'LeafStoryPlanEstimateTotal'; + case 'prelimest': + return 'PreliminaryEstimateValue'; + default: + return 'PlanEstimate'; + } } }); diff --git a/CustomChartApp.js b/CustomChartApp.js index 087cf39..cf4a6fb 100644 --- a/CustomChartApp.js +++ b/CustomChartApp.js @@ -28,6 +28,7 @@ Ext.define('CustomChartApp', { }, getSettingsFields: function() { + var me = this; return [ { name: 'chartType', @@ -139,9 +140,27 @@ Ext.define('CustomChartApp', { fields: ['name', 'value'], data: [ { name: 'Count', value: 'count' }, - { name: 'Plan Estimate', value: 'estimate' } + { name: 'Plan Estimate', value: 'estimate' }, + { name: 'Leaf Story Plan Estimate Total', value: 'leafplanest' }, + { name: 'Preliminary Estimate Value', value: 'prelimest' } ] - }) + }), + handlesEvents: { + typeselected: function (types, context) { + var type = Ext.Array.from(types)[0]; + Rally.data.ModelFactory.getModel({ + type: type, + success: function(model) { + this.store.filterBy(function(record) { + return record.get('value') === 'count' || + model.hasField(me._getFieldForAggregationType(record.get('value'))); + }); + }, + scope: this + }); + + } + }, }, { type: 'query' } ]; @@ -261,10 +280,25 @@ Ext.define('CustomChartApp', { _getChartFetch: function() { var field = this.getSetting('aggregationField'), - fetch = ['FormattedID', 'Name', 'PlanEstimate', field]; + aggregationType = this.getSetting('aggregationType'), + fetch = ['FormattedID', 'Name', field]; + + if (aggregationType !== 'count') { + fetch.push(this._getFieldForAggregationType(aggregationType)); + } return fetch; }, + _getFieldForAggregationType: function(aggregationType) { + if (aggregationType === 'estimate') { + return 'PlanEstimate'; + } else if (aggregationType === 'prelimest') { + return 'PreliminaryEstimateValue'; + } else if (aggregationType === 'leafplanest') { + return 'LeafStoryPlanEstimateTotal'; + } + }, + _getChartSort: function() { return [{ property: this.getSetting('aggregationField'), diff --git a/deploy/App-external.html b/deploy/App-external.html index eb8514e..3de5bea 100644 --- a/deploy/App-external.html +++ b/deploy/App-external.html @@ -7,12 +7,12 @@