forked from sficarrotta/WSJF_Grid
/
App.html
27 lines (20 loc) · 5.21 KB
/
App.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<!DOCTYPE html>
<html>
<head>
<title>wsjf_grid</title>
<script type="text/javascript" src="/apps/2.1/sdk.js"></script>
<script type="text/javascript">
Rally.onReady(function () {
var Ext=window.Ext4||window.Ext;Ext.define("CustomApp",{extend:"Rally.app.App",componentCls:"app",launch:function(){var that=this;that.TimeCriticalityField=that.getSetting("TimeCriticalityField"),that.RROEValueField=that.getSetting("RROEValueField"),that.UserBusinessValueField=that.getSetting("UserBusinessValueField"),that.WSJFScoreField=that.getSetting("WSJFScoreField"),that.JobSizeField=that.getSetting("JobSizeField"),that.ShowValuesAfterDecimal=that.getSettingsFields("ShowValuesAfterDecimal"),this._grid=null,this._piCombobox=this.add({xtype:"rallyportfolioitemtypecombobox",padding:5,listeners:{select:this._onPICombobox,scope:this}})},_onPICombobox:function(){var selectedType=this._piCombobox.getRecord(),model=selectedType.get("TypePath");null!==this._grid&&this._grid.destroy(),Ext.create("Rally.data.wsapi.TreeStoreBuilder").build({models:[model],listeners:{load:function(store){var records=store.getRootNode().childNodes;this._calculateScore(records,!0)},update:function(store,rec,modified,opts){this._calculateScore([rec],!1)},scope:this},enableHierarchy:!0}).then({success:this._onStoreBuilt,scope:this})},_onStoreBuilt:function(store,records){var that=this,selectedType=this._piCombobox.getRecord(),modelNames=selectedType.get("TypePath"),context=this.getContext();this._grid=this.add({xtype:"rallygridboard",context:context,modelNames:[modelNames],toggleState:"grid",stateful:!1,plugins:[{ptype:"rallygridboardinlinefiltercontrol",filterChildren:!1,inlineFilterButtonConfig:{modelNames:[modelNames],stateful:!0,stateId:context.getScopedStateId("custom-filter-example"),inlineFilterPanelConfig:{quickFilterPanelConfig:{defaultFields:["ArtifactSearch"],addQuickFilterConfig:{whiteListFields:["Milestones","Tags"]}},advancedFilterPanelConfig:{advancedFilterRowsConfig:{propertyFieldConfig:{whiteListFields:["Milestones","Tags"]}}}}}},{ptype:"rallygridboardfieldpicker",headerPosition:"left",modelNames:[modelNames],stateful:!0,stateId:context.getScopedStateId("columns-example")},{ptype:"rallygridboardactionsmenu",menuItems:[{text:"Export...",handler:function(){window.location=Rally.ui.gridboard.Export.buildCsvExportUrl(this.down("rallygridboard").getGridOrBoard())},scope:this}],buttonConfig:{iconCls:"icon-export"}}],gridConfig:{store:store,columnCfgs:["Name",that.TimeCriticalityField,that.RROEValueField,that.UserBusinessValueField,that.JobSizeField,this.getSetting("useExecutiveMandateField")===!0?this.getSetting("ExecutiveMandateField"):null,{text:"WSJF Score",dataIndex:that.WSJFScoreField,editor:null}]},height:this.getHeight()})},_calculateScore:function(records,loading){var that=this;Ext.Array.each(records,function(feature){var execMandate=that.getSetting("useExecutiveMandateField")===!0?feature.data[that.getSetting("ExecutiveMandateField")]:1;execMandate=_.isUndefined(execMandate)||_.isNull(execMandate)||0===execMandate?1:execMandate;var jobSize=feature.data[that.JobSizeField];jobSize=_.isUndefined(jobSize)||_.isNull(jobSize)?0:jobSize;var timeValue=feature.data[that.TimeCriticalityField];timeValue=_.isUndefined(timeValue)||_.isNull(timeValue)?0:timeValue;var OERR=feature.data[that.RROEValueField];OERR=_.isUndefined(OERR)||_.isNull(OERR)?0:OERR;var userValue=feature.data[that.UserBusinessValueField];userValue=_.isUndefined(userValue)||_.isNull(userValue)?0:userValue;var oldScore=feature.data[that.WSJFScoreField];oldScore=_.isUndefined(oldScore)||_.isNull(oldScore)?0:oldScore;var isChecked=that.getSetting("ShowValuesAfterDecimal");if(jobSize>0){var score;isChecked?score=Math.floor((userValue+timeValue+OERR)*execMandate/jobSize*100)/100:(score=(userValue+timeValue+OERR)*execMandate/jobSize,score=Math.round(score)),oldScore!==score&&(feature.set(that.WSJFScoreField,score),loading&&feature.save())}})},getSettingsFields:function(){var values=[{name:"ShowValuesAfterDecimal",xtype:"rallycheckboxfield",label:"Show Values After the Decimal",labelWidth:200},{name:"useExecutiveMandateField",xtype:"rallycheckboxfield",label:"Use Custom Executive Mandate Field",labelWidth:200},{name:"ExecutiveMandateField",xtype:"rallytextfield",label:"Executive Mandate Field",labelWidth:200},{name:"TimeCriticalityField",xtype:"rallytextfield",label:"Time Criticality Field",labelWidth:200},{name:"RROEValueField",xtype:"rallytextfield",label:"RROEValue Field",labelWidth:200},{name:"UserBusinessValueField",xtype:"rallytextfield",label:"User Business Value Field",labelWidth:200},{name:"WSJFScoreField",xtype:"rallytextfield",label:"WSJFScore Field",labelWidth:200},{name:"JobSizeField",xtype:"rallytextfield",label:"Job Size Field",labelWidth:200}];return values},config:{defaultSettings:{ShowValuesAfterDecimal:!1,useExecutiveMandateField:!1,ExecutiveMandateField:"c_ExecutiveMandate",TimeCriticalityField:"TimeCriticality",RROEValueField:"RROEValue",UserBusinessValueField:"UserBusinessValue",WSJFScoreField:"WSJFScore",JobSizeField:"JobSize"}}});
Rally.launchApp('CustomApp', {
name:"wsjf_grid",
parentRepos:""
});
});
</script>
<style type="text/css">
</style>
</head>
<body>
</body>
</html>