Rally Software

 View Only
  • 1.  Coding Help

    Posted Jun 27, 2022 11:50 AM
    I would like to be able to add a variable number of days to the TimeboxEndDate in order to account for User Stories that are delivered a day or too after the iteration ends. I am new to coding and uncertain of how Should tackle this process. 


    https://github.com/RallyTechServices/committed-vs-delivered


    <!DOCTYPE html>
    <html>
    <head>
    <title>committed-vs-delivered-1.2.3</title>
    <!-- (c) 2017 CA Technologies. All Rights Reserved. -->
    <!-- Build Date: Fri Nov 30 2018 18:26:44 GMT+0000 (UTC) -->

    <script type="text/javascript">
    var APP_BUILD_DATE = "Fri Nov 30 2018 18:26:44 GMT+0000 (UTC)";
    var CHECKSUM = 70913561695;
    </script>

    <script type="text/javascript" src="/apps/2.1/sdk.js"></script>
    <!-- our highcharts (needed so that we can add patterns)
    <script type="text/javascript" src="/apps/2.1/lib/analytics/analytics-all.js"></script>
    -->


    <script type="text/javascript">
    Rally.onReady(function() {
    Ext.override(Rally.ui.gridboard.SharedViewComboBox,{_isViewPreference:function(a){return"preference"===a.self.typePath&&"View"===a.get("Type")&&a.get("AppId")==this.getContext().getAppId()},getSharedViewParam:function(){var a=parent.location.hash,b=a.match(/sharedViewId=(\d+)/);return b&&b[1]},_ensureLatestView:function(a){if(a.objectId&&a.versionId){var b=Ext.create("Deft.Deferred");this.store.model.load(a.objectId,{fetch:["VersionId","Value"],success:function(a){b.resolve(a)}}),this.store.on("load",function(){b.promise.then({success:function(b){b&&b.get("VersionId")!==a.versionId&&this._applyView(this._decodeValue(b))},scope:this})},this,{single:!0})}}}),Ext.define("Utils.AncestorPiAppFilter",{alias:"plugin.UtilsAncestorPiAppFilter",mixins:["Ext.AbstractPlugin","Rally.Messageable"],extend:"Ext.Component",statics:{RENDER_AREA_ID:"utils-ancestor-pi-app-filter"},config:{renderAreaId:"utils-ancestor-pi-app-filter",publisher:!1,allowNoEntry:!0,settingsConfig:{},ancestorLabel:"With ancestor",ancestorLabelWidth:110,ownerLabel:"Owned by",ownerLabelWidth:80,labelStyle:"font-size: medium",singleRowMinWidth:650},portfolioItemTypes:[],readyDeferred:null,piTypesDeferred:null,isSubscriber:!1,changeSubscribers:[],publishedValue:{},constructor:function(a){this.callParent(arguments),Ext.tip.QuickTipManager.init(),this._setupPubSub()},initComponent:function(){this.callParent(arguments),this.addEvents("ready","select")},init:function(a){this.cmp=a,this.cmp.on("resize",this._onCmpResize,this),this.renderArea=this.cmp.down("#"+this.renderAreaId);var b=this.cmp.getSettingsFields;this.cmp.getSettingsFields=function(){return this._getSettingsFields(b.apply(a,arguments))}.bind(this);var c=this.cmp.defaultSettings;c["Utils.AncestorPiAppFilter.enableAncestorPiFilter2"]=!1,c["Utils.AncestorPiAppFilter.showIgnoreProjectScope2"]=!1,c["Utils.AncestorPiAppFilter.ignoreProjectScope2"]=!1,this.cmp.setDefaultSettings(c),this._addControlCmp().then({scope:this,success:function(){this._setReady()}})},notifySubscribers:function(){var a=this._getValue();_.each(this.changeSubscribers,function(b){this.publish(b,a)},this)},getFilterForType:function(a){var b,c=a.toLowerCase(),d=this._getValue();if(d.piTypePath){var e=d.piTypePath,f=d.isPiSelected,g=d.pi,h=this._piTypeAncestors(c,e);if(f&&null!=g&&null!=h){var i;i=this._propertyPrefix(c,h),i&&(b=new Rally.data.wsapi.Filter({property:i,value:g}))}else null!=g&&(b=new Rally.data.wsapi.Filter({property:"ObjectID",value:0}))}return b},getIgnoreProjectScope:function(){return this._getValue().ignoreProjectScope},_setupPubSub:function(){this.publisher?(this.subscribe(this,"registerChangeSubscriber",function(a){_.contains(this.changeSubscribers,a)||this.changeSubscribers.push(a),this.publish(a,this._getValue())},this),this.publish("reRegisterChangeSubscriber")):(this.subscriberEventName=Rally.getApp().getAppId()+this.$className,this.subscribe(this,this.subscriberEventName,function(a){this.intervalTimer&&(clearInterval(this.intervalTimer),delete this.intervalTimer),this.isSubscriber||(this.isSubscriber=!0,this._hideControlCmp()),this.publishedValue=a,this._onSelect()},this),this.publish("registerChangeSubscriber",this.subscriberEventName),this.intervalTimer=setInterval(function(){this.publish("registerChangeSubscriber",this.subscriberEventName)}.bind(this),500),this.subscribe(this,"reRegisterChangeSubscriber",function(){this.publish("registerChangeSubscriber",this.subscriberEventName)},this))},_getValue:function(){var a={};if(this._isSubscriber())a=this.publishedValue||{};else{if(this.piTypeSelector){var b=this.piTypeSelector.getRecord();if(b){var c=b.get("TypePath"),d=this.piSelector.getRecord(),e=this.piSelector.getValue();_.merge(a,{piTypePath:c,isPiSelected:!!d,pi:e})}}a.ignoreProjectScope=this._ignoreProjectScope()}return a},_setReady:function(){this.ready=!0,this.fireEvent("ready",this)},_onSelect:function(){this.ready&&this.fireEvent("select",this)},_getSettingsFields:function(a){var b=[{xtype:"rallycheckboxfield",id:"Utils.AncestorPiAppFilter.enableAncestorPiFilter2",name:"Utils.AncestorPiAppFilter.enableAncestorPiFilter2",fieldLabel:"Show Ancestor Portfolio Item Filter"},{xtype:"rallycheckboxfield",id:"Utils.AncestorPiAppFilter.showIgnoreProjectScope2",name:"Utils.AncestorPiAppFilter.showIgnoreProjectScope2",fieldLabel:"Show Ignore Project Scope Control"},{xtype:"rallycheckboxfield",id:"Utils.AncestorPiAppFilter.ignoreProjectScope2",name:"Utils.AncestorPiAppFilter.ignoreProjectScope2",fieldLabel:"Ignore Project Scope if scope control not shown"}];return b=_.map(b,function(a){return _.merge(a,this.settingsConfig)},this),b.concat(a||[])},_addControlCmp:function(){var a=Ext.create("Deft.Deferred"),b={type:"hbox",align:"middle",defaultMargins:"0 10 0 0"},c=this.ownerLabelWidth;this.cmp.getWidth()<this.singleRowMinWidth&&(b="vbox",c=this.ancestorLabelWidth);var d={xtype:"container",id:"controlsArea",layout:{type:"hbox",align:"top"},items:[{xtype:"container",id:"pubSubIndicatorArea",padding:"6 5 0 0",items:[{xtype:"component",id:"publisherIndicator",html:'<span class="icon-bullhorn icon-large"></span>',hidden:!this.publisher},{xtype:"component",id:"subscriberIndicator",html:'<span class="icon-link icon-large"></span>',hidden:!this._isSubscriber()}]},{xtype:"container",id:"filtersArea",layout:b,items:[{xtype:"container",id:"ancestorFilterArea",layout:{type:"hbox",align:"middle"},items:[{xtype:"container",id:"piTypeArea",layout:{type:"hbox",align:"middle"},hidden:this._isSubscriber()||!this._showAncestorFilter()},{xtype:"container",id:"piSelectorArea",layout:{type:"hbox",align:"middle",padding:"0 0 0 5"},hidden:this._isSubscriber()||!this._showAncestorFilter()}]},{xtype:"container",id:"scopeControlArea",layout:{type:"hbox",align:"middle"},items:[{xtype:"rallycombobox",id:"ignoreScopeControl",stateful:!0,stateId:this.cmp.getContext().getScopedStateId("Utils.AncestorPiAppFilter.ignoreProjectScopeControl"),stateEvents:["select"],hidden:this._isSubscriber()||!this._showIgnoreProjectScopeControl(),displayField:"text",valueField:"value",labelStyle:this.labelStyle,labelWidth:c,fieldLabel:this.ownerLabel,storeConfig:{fields:["text","value"],data:[{text:"Current Project(s)",value:!1},{text:"Any Project",value:!0}]},listeners:{scope:this,change:function(a,b){this._onSelect()}}}]}]}]};return this.renderArea&&this.renderArea.add(d),this._addTooltips(),Rally.data.util.PortfolioItemHelper.getPortfolioItemTypes().then({scope:this,success:function(b){this.portfolioItemTypes=b,this._showAncestorFilter()?(this.piTypeSelector=Ext.create("Rally.ui.combobox.PortfolioItemTypeComboBox",{xtype:"rallyportfolioitemtypecombobox",id:"Utils.AncestorPiAppFilter.piType",name:"Utils.AncestorPiAppFilter.piType",stateful:!0,stateId:this.cmp.getContext().getScopedStateId("Utils.AncestorPiAppFilter.piType"),stateEvents:["select"],fieldLabel:this.ancestorLabel,labelWidth:this.ancestorLabelWidth,labelStyle:this.labelStyle,valueField:"TypePath",allowNoEntry:!1,defaultSelectionPosition:"first",listeners:{scope:this,ready:function(b){b.addListener({scope:this,change:this._onPiTypeChange}),this._addPiSelector(b.getValue()).then({scope:this,success:function(){a.resolve()}})}}}),this.renderArea.down("#piTypeArea").add(this.piTypeSelector)):a.resolve()}}),a.promise},_addTooltips:function(){Ext.tip.QuickTipManager.register({target:"publisherIndicator",text:'This app broadcasts filter settings to any enabled ancestor filtered apps (indicated with <span class="icon-link icon-large"></span>)',showDelay:50,border:!0}),Ext.tip.QuickTipManager.register({target:"subscriberIndicator",text:'This app listens for filter settings from any enabled ancestor filter broadcast app (indicated with <span class="icon-bullhorn icon-large"></span>)',showDelay:50,border:!0})},_onCmpResize:function(a,b){var c={type:"hbox",align:"middle",defaultMargins:"0 10 0 0"};b<this.singleRowMinWidth&&(c={type:"vbox"});var d=this.renderArea.down("#filtersArea"),e=this.renderArea.down("#controlsArea"),f=d.removeAll(!1),g={xtype:"container",id:"filtersArea",layout:c,items:f};e.remove(d,!1),e.add(g)},_hideControlCmp:function(){this.subscriberIndicator&&this._isSubscriber()&&this.subscriberIndicator.show(),this.renderArea.down("#piTypeArea").hide(),this.renderArea.down("#piSelectorArea").hide(),this.renderArea.down("#ignoreScopeControl").hide()},_onPiTypeChange:function(a,b,c){b&&(this._removePiSelector(),this._addPiSelector(b).then({scope:this,success:function(){this._setReady()}}))},_removePiSelector:function(){this.renderArea.down("#piSelectorArea").removeAll()},_addPiSelector:function(a){var b=Ext.create("Deft.Deferred");return this.piSelector=Ext.create("Rally.ui.combobox.ArtifactSearchComboBox",{id:"Utils.AncestorPiAppFilter.piSelector",labelAlign:"top",storeConfig:{models:a,autoLoad:!0,context:{project:null}},stateful:!0,stateId:this.cmp.getContext().getScopedStateId("Utils.AncestorPiAppFilter.piSelector"),stateEvents:["select"],valueField:"_ref",allowClear:!0,clearValue:null,allowNoEntry:this.allowNoEntry,noEntryValue:"",defaultSelectionPosition:null,listeners:{scope:this,select:function(a,b){this._onSelect()},ready:function(a,c){b.resolve()}}}),Ext.override(this.piSelector,{saveState:function(){var a,b=this,c=b.stateful&&b.getStateId(),d=b.hasListeners;c&&(a=b.getState()||{},d.beforestatesave&&b.fireEvent("beforestatesave",b,a)===!1||(Ext.state.Manager.set(c,a),d.statesave&&b.fireEvent("statesave",b,a)))}}),this.renderArea.down("#piSelectorArea").add(this.piSelector),b.promise},_showAncestorFilter:function(){return this.cmp.getSetting("Utils.AncestorPiAppFilter.enableAncestorPiFilter2")},_ignoreProjectScope:function(){var a=!1;return a=this._showIgnoreProjectScopeControl()?this.renderArea.down("#ignoreScopeControl").getValue():this.cmp.getSetting("Utils.AncestorPiAppFilter.ignoreProjectScope2")},_showIgnoreProjectScopeControl:function(){return this.cmp.getSetting("Utils.AncestorPiAppFilter.showIgnoreProjectScope2")},_isSubscriber:function(){return this.isSubscriber},_propertyPrefix:function(a,b){var c;return"hierarchicalrequirement"===a||"userstory"===a?c=b[0].get("Name"):"defect"===a?c="Requirement."+b[0].get("Name"):a.startsWith("portfolioitem")&&(c="Parent"),c&&_.forEach(b.slice(1),function(a){c+=".Parent"},this),c},_piTypeAncestors:function(a,b){var c,d,e=null;return _.contains(["hierarchicalrequirement","userstory","defect"],a)?(c=_.findIndex(this.portfolioItemTypes,function(a){return a.get("TypePath").toLowerCase()===b.toLowerCase()}),e=this.portfolioItemTypes.slice(0,c+1)):a.startsWith("portfolioitem")&&(d=_.findIndex(this.portfolioItemTypes,function(b){return b.get("TypePath").toLowerCase()===a.toLowerCase()}),c=_.findIndex(this.portfolioItemTypes,function(a){return a.get("TypePath").toLowerCase()===b.toLowerCase()}),c>d&&(e=this.portfolioItemTypes.slice(d+1,c+1))),e}}),Rally.ui.renderer.GridEditorFactory.editorRenderers.PreliminaryEstimate=function(a){return{xtype:"rallyrecordcontexteditor",field:{xtype:"rallycombobox",allowNoEntry:!a.required,editable:!1,name:a.name,storeConfig:{autoLoad:!0,model:a.name,remoteFilter:!0,sorters:[{property:"Value"}],listeners:{load:function(){}}}}}},Ext.define("Utils.AncestorPiInlineFilter",{override:"Rally.ui.inlinefilter.QuickFilterPanel",portfolioItemTypes:[],modelName:void 0,customFilterNamePrefix:"AncestorPiInlineFilter.",_hasPiAncestor:function(a){return _.contains(["hierarchicalrequirement","userstory","defect"],a)||a.startsWith("portfolioitem")},_pisAbove:function(a){var b=[];if(_.contains(["hierarchicalrequirement","userstory","defect"],a))b=this.portfolioItemTypes;else if(a.startsWith("portfolioitem")){var c=_.findIndex(this.portfolioItemTypes,function(b){return b.get("TypePath").toLowerCase()===a});c>=0&&c<this.portfolioItemTypes.length-1&&(b=this.portfolioItemTypes.slice(c+1))}return b},initComponent:function(){this.modelName&&(this.modelName=this.modelName.toLowerCase());var a={},b=[];if(this._hasPiAncestor(this.modelName)){var c=this._pisAbove(this.modelName);_.each(c,function(d){var e=d.get("TypePath"),f=this.customFilterNamePrefix+e,g="Portfolio Item / "+d.get("Name");a[f]={xtype:"ancestorpisearchcombobox",portfolioItemType:e,piTypesAbove:c,artifactTypeName:this.modelName,storeConfig:{models:e,autoLoad:!0},allowNoEntry:!0,noEntryValue:null,noEntryText:"No "+g,emptyText:"Search "+g+"s...",allowClear:!1,valueField:"ObjectUUID"},b.push({name:f,displayName:g})},this),_.merge(this.addQuickFilterConfig,{additionalFields:b},function(a,b){return _.isArray(a)?_.uniq(a.concat(b),"name"):void 0}),Ext.override(Rally.ui.inlinefilter.FilterFieldFactory,a)}this.callParent(arguments)},_createFields:function(){this.fields=_.filter(this.fields,function(a){return this._filterInvalidAncestorFilters(a)},this),this.initialFilters=_.filter(this.initialFilters,function(a){return this._filterInvalidAncestorFilters(a.name)},this),this.callParent(arguments)},_filterInvalidAncestorFilters:function(a){return!a.startsWith(this.customFilterNamePrefix)||Rally.ui.inlinefilter.FilterFieldFactory.hasOwnProperty(a)}}),Ext.define("Utils.AncestorPiSearchComboBox",{alias:"widget.ancestorpisearchcombobox",extend:"Rally.ui.combobox.ArtifactSearchComboBox",parentField:"PortfolioItem.Parent.",artifactTypeName:void 0,piTypesAbove:[],statics:{UUID_REGEX:/([a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12})/},initComponent:function(){this.storeConfig.filters=[{property:this.valueField,value:this.value}],this.storeConfig.filters=[],this.callParent(arguments)},getFilter:function(){var a=this.lastValue,b=this.propertyPrefix(),c=[];return a&&this.statics().UUID_REGEX.test(a)?c.push({property:b+".ObjectUUID",value:a}):c.push({property:b,value:null}),Rally.data.wsapi.Filter.or(c)},propertyPrefix:function(){var a;return"hierarchicalrequirement"===this.artifactTypeName||"userstory"===this.artifactTypeName?a=this.piTypesAbove[0].get("Name"):"defect"===this.artifactTypeName?a="Requirement."+this.piTypesAbove[0].get("Name"):this.artifactTypeName.startsWith("portfolioitem")&&(a="Parent"),a&&_.forEach(this.piTypesAbove,function(b){return b.get("TypePath").toLowerCase()==this.portfolioItemType.toLowerCase()?!1:void(a+=".Parent")},this),a}}),Ext.define("CA.technicalservices.userutilities.FieldPicker",{alias:"widget.tsfieldpickerbutton",extend:"Rally.ui.Button",requires:["Rally.ui.popover.Popover","Rally.ui.Button","Rally.ui.picker.FieldPicker","Ext.state.Manager"],toolTipConfig:{html:"Show Columns",anchor:"top"},iconCls:"icon-add-column",cls:"field-picker-btn secondary rly-small",alwaysSelectedValues:["FormattedID","Name"],fieldBlackList:[],fieldPickerConfig:{},buttonConfig:{},modelNames:["User"],rankingEnabled:!1,constructor:function(a){this.config=_.merge({},this.config||{},a||{}),this.callParent([a])},initComponent:function(){if(this.models)return this.on("click",this._createPopover,this),void this.callParent(arguments);if(this.context&&this.modelNames&&this.modelNames.length>0)Rally.data.ModelFactory.getModels({types:this.modelNames,context:this.context,success:function(a){this.models=a},failure:function(a){console.log("failedparam")},scope:this}),this.on("click",this._createPopover,this);else{this.iconCls="icon-none";var a="Please update the CA.technicalservices.FieldPicker configuration with modelNames and context";this.toolTipConfig={html:'<div style="color:red;">'+a+"</div>"},this.on("click",function(){Rally.ui.notify.Notifier.showError({message:a})})}this.callParent(arguments)},getFields:function(){return _.union(this._fields||[],this.alwaysSelectedValues)},_getPickerConfig:function(){var a;return a=_.extend({value:this._fields,fieldBlackList:this.fieldBlackList,alwaysSelectedValues:this.alwaysSelectedValues,context:this.context},this.fieldPickerConfig)},_createPopover:function(a){var b=a.getEl();this.popover=Ext.create("Rally.ui.popover.Popover",{target:b,placement:["bottom","left","top","right"],cls:"field-picker-popover",toFront:Ext.emptyFn,buttonAlign:"center",title:this.getTitle(),listeners:{destroy:function(){this.popover=null},scope:this},buttons:[{xtype:"rallybutton",text:"Apply",cls:"field-picker-apply-btn primary rly-small",listeners:{click:function(){this._onApply(this.popover)},scope:this}},{xtype:"rallybutton",text:"Cancel",cls:"field-picker-cancel-btn secondary dark rly-small",listeners:{click:function(){this.popover.close()},scope:this}}],items:[_.extend({xtype:"rallyfieldpicker",cls:"field-picker",itemId:"fieldpicker",modelTypes:this._getModelTypes(),alwaysExpanded:!0,width:200,emptyText:"Search",selectedTextLabel:"Selected",availableTextLabel:"Available",listeners:{specialkey:function(a,b){b.getKey()===b.ESC&&this.popover.close()},scope:this}},this._getPickerConfig())]})},_getModelTypes:function(){return _.pluck(this._getModels(),"typePath")},_getModels:function(){return _.reduce(this.models,function(a,b){return"artifact"===b.typePath?a=a.concat(b.getArtifactComponentModels()):a.push(b),a},[])},getTitle:function(){return"Show Columns"},updateFields:function(a,b){this._fields=a,this.popover&&this.popover.down("rallyfieldpicker")&&this.popover.down("rallyfieldpicker").setValue(a.join(",")),this.saveState()},getState:function(){return{fields:this._fields}},applyState:function(a){a&&(this._fields=a.fields)},_onApply:function(a){var b=a.down("rallyfieldpicker"),c=_.map(b.getValue(),function(a){return a.get("name")});this.updateFields(c),a.close(),this.fireEvent("fieldsupdated",c)}});var saveAs=saveAs||function(a){"use strict";if(!("undefined"==typeof a||"undefined"!=typeof navigator&&/MSIE [1-9]\./.test(navigator.userAgent))){var b=a.document,c=function(){return a.URL||a.webkitURL||a},d=b.createElementNS("http://www.w3.org/1999/xhtml","a"),e="download"in d,f=function(a){var b=new MouseEvent("click");a.dispatchEvent(b)},g=/constructor/i.test(a.HTMLElement)||a.safari,h=/CriOS\/[\d]+/.test(navigator.userAgent),i=function(b){(a.setImmediate||a.setTimeout)(function(){throw b},0)},j="application/octet-stream",k=4e4,l=function(a){var b=function(){"string"==typeof a?c().revokeObjectURL(a):a.remove()};setTimeout(b,k)},m=function(a,b,c){b=[].concat(b);for(var d=b.length;d--;){var e=a["on"+b[d]];if("function"==typeof e)try{e.call(a,c||a)}catch(f){i(f)}}},n=function(a){return/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(a.type)?new Blob([String.fromCharCode(65279),a],{type:a.type}):a},o=function(b,i,k){k||(b=n(b));var o,p=this,q=b.type,r=q===j,s=function(){m(p,"writestart progress write writeend".split(" "))},t=function(){if((h||r&&g)&&a.FileReader){var d=new FileReader;return d.onloadend=function(){var b=h?d.result:d.result.replace(/^data:[^;]*;/,"data:attachment/file;"),c=a.open(b,"_blank");c||(a.location.href=b),b=void 0,p.readyState=p.DONE,s()},d.readAsDataURL(b),void(p.readyState=p.INIT)}if(o||(o=c().createObjectURL(b)),r)a.location.href=o;else{var e=a.open(o,"_blank");e||(a.location.href=o)}p.readyState=p.DONE,s(),l(o)};return p.readyState=p.INIT,e?(o=c().createObjectURL(b),void setTimeout(function(){d.href=o,d.download=i,f(d),s(),l(o),p.readyState=p.DONE})):void t()},p=o.prototype,q=function(a,b,c){return new o(a,b||a.name||"download",c)};return"undefined"!=typeof navigator&&navigator.msSaveOrOpenBlob?function(a,b,c){return b=b||a.name||"download",c||(a=n(a)),navigator.msSaveOrOpenBlob(a,b)}:(p.abort=function(){},p.readyState=p.INIT=0,p.WRITING=1,p.DONE=2,p.error=p.onwritestart=p.onprogress=p.onwrite=p.onabort=p.onerror=p.onwriteend=null,q)}}("undefined"!=typeof self&&self||"undefined"!=typeof window&&window||this.content);"undefined"!=typeof module&&module.exports?module.exports.saveAs=saveAs:"undefined"!=typeof define&&null!==define&&null!==define.amd&&define("FileSaver.js",function(){return saveAs}),Ext.define("CArABU.technicalservices.FileUtilities",{singleton:!0,saveCSVToFile:function(a,b,c){void 0==c&&(c={type:"text/csv;charset=utf-8"});var d=new Blob([a],c);saveAs(d,b)},saveTextAsFile:function(a,b){var c=new Blob([a],{type:"text/plain"}),d=b,e=document.createElement("a");e.download=d,e.innerHTML="Download File",null!=window.webkitURL?e.href=window.webkitURL.createObjectURL(c):(e.href=window.URL.createObjectURL(c),e.onclick=destroyClickedElement,e.style.display="none",document.body.appendChild(e)),e.click()},destroyClickedElement:function(a){document.body.removeChild(a.target)},convertDataArrayToCSVText:function(a,b){var c="";return Ext.each(Object.keys(b),function(a){c+=b[a]+","}),c=c.replace(/,$/,"\n"),Ext.each(a,function(a){Ext.each(Object.keys(b),function(b){c+=a[b]?"object"==typeof a[b]?a[b].FormattedID?Ext.String.format('"{0}",',a[b].FormattedID):a[b].Name?Ext.String.format('"{0}",',a[b].Name):isNaN(Date.parse(a[b]))?Ext.String.format('"{0}",',a[b].toString()):Ext.String.format('"{0}",',Rally.util.DateTime.formatWithDefaultDateTime(a[b])):Ext.String.format('"{0}",',a[b]):","},this),c=c.replace(/,$/,"\n")},this),c},_getCSVFromWsapiBackedGrid:function(a){for(var b=Ext.create("Deft.Deferred"),c=Ext.create("Rally.data.wsapi.Store",{fetch:a.getStore().config.fetch,filters:a.getStore().config.filters,model:a.getStore().config.model,limit:1/0,pageSize:1/0}),d=a.columns,e=this._getHeadersFromGrid(a),f=(this._getColumnNamesFromGrid(a),a.getStore().getTotalCount()),g=a.getStore().pageSize,h=Math.ceil(f/g),i=[],j=1;h>=j;j++)i.push(this.loadStorePage(a,c,d,j,h));return Deft.Promise.all(i).then({success:function(a){var c=[];c.push('"'+e.join('","')+'"'),_.each(a,function(a){_.each(a,function(a){c.push(a)})}),c=c.join("\r\n"),b.resolve(c),Rally.getApp().setLoading(!1)}}),b.promise},_getCSVFromCustomBackedGridWithPaging:function(a){var b=Ext.create("Deft.Deferred"),c=Ext.create("Rally.data.custom.Store",{model:a.getStore().config.model,filters:a.getStore().config.filters,limit:1/0,pageSize:1/0}),d=a.columns,e=this._getHeadersFromGrid(a),f=(this._getColumnNamesFromGrid(a),a.getStore().getTotalCount()),g=a.getStore().pageSize,h=Math.ceil(f/g),i=[];return i.push(this.loadStorePage(a,c,d,page,h)),Deft.Promise.all(i).then({success:function(a){var c=[];c.push('"'+e.join('","')+'"'),_.each(a,function(a){_.each(a,function(a){c.push(a)})}),c=c.join("\r\n"),b.resolve(c),Rally.getApp().setLoading(!1)}}),b.promise},_getCSVFromCustomBackedGrid:function(a){var b=Ext.create("Deft.Deferred"),c=this;Rally.getApp().setLoading("Assembling data for export...");var d=this._getHeadersFromGrid(a),e=Ext.clone(a.getStore()),f=a.columns,g=(this._getColumnNamesFromGrid(a),a.getStore().getTotalCount()),h=a.getStore().pageSize,i=2e4,j=Math.ceil(g/i);e.pageSize=i;for(var k=[],l=[],m=1;j>=m;m++)k.push(m);return Ext.Array.each(k,function(b){l.push(function(){return c._loadStorePage(a,e,f,b,k.length)})}),Deft.Chain.sequence(l).then({success:function(a){e.pageSize=h,e.loadPage(1);var c=[];c.push('"'+d.join('","')+'"'),_.each(a,function(a){_.each(a,function(a){c.push(a)})}),c=c.join("\r\n"),b.resolve(c),Rally.getApp().setLoading(!1)}}),b.promise},_loadStorePage:function(a,b,c,d,e){var f=Ext.create("Deft.Deferred");return b.loadPage(d,{callback:function(c){for(var d=[],e=0;e<c.length;e++){var g=c[e];d.push(this._getCSVFromRecord(g,a,b))}f.resolve(d)},scope:this}),f.promise},_getHeadersFromGrid:function(a){var b=[],c=a.columns;return Ext.Array.each(c,function(a){(a.dataIndex||a.renderer)&&(a.csvText?b.push(a.csvText.replace("&nbsp;"," ")):a.text&&b.push(a.text.replace("&nbsp;"," ")))}),b},_getColumnNamesFromGrid:function(a){var b=[],c=a.columns;return Ext.Array.each(c,function(a){(a.dataIndex||a.renderer)&&b.push(a.dataIndex)}),b},getCSVFromGrid:function(a,b){return"Ext.data.TreeStore"!=Ext.getClassName(b.getStore())&&"Rally.data.custom.Store"!=Ext.getClassName(b.getStore())?this._getCSVFromWsapiBackedGrid(b):this._getCSVFromCustomBackedGrid(b)},loadStorePage:function(a,b,c,d,e){var f=Ext.create("Deft.Deferred");return b.loadPage(d,{callback:function(c,g,h){var i=[];Rally.getApp().setLoading(Ext.String.format("Page {0} of {1} loaded",d,e));for(var j=0;j<c.length;j++){var k=c[j];i.push(this._getCSVFromRecord(k,a,b))}f.resolve(i)},scope:this}),f},_getCSVFromRecord:function(a,b,c){var d={align:"right",classes:[],cellIndex:9,column:null,columnIndex:9,innerCls:void 0,recordIndex:5,rowIndex:5,style:"",tdAttr:"",tdCls:"x-grid-cell x-grid-td x-grid-cell-headerId-gridcolumn-1029 x-grid-cell-last x-unselectable",unselectableAttr:"unselectable='on'"},e=[],f=b.columns;return Ext.Array.each(f,function(f){if("rallyrowactioncolumn"!=f.xtype)if(f.dataIndex){var g=f.dataIndex,h=a.get(g);!f._csvIgnoreRender&&f.renderer&&(h=f.exportRenderer?f.exportRenderer(h,d,a,0,0,c,b.getView()):f.renderer(h,d,a,0,0,c,b.getView())),e.push(h)}else{var h=null;!f._csvIgnoreRender&&f.renderer&&(h=f.exportRenderer?f.exportRenderer(h,d,a,a,0,0,c,b.getView()):f.renderer(h,d,a,a,0,0,c,b.getView()),e.push(h))}},this),'"'+e.join('","')+'"'}}),Ext.define("Constants",{statics:{CHART_TITLE:"Committed vs. Delivered",PLANNED:"Planned",UNPLANNED:"Unplanned",COMMITTED:"Comitted",DELIVERED:"Delivered",IN_PROGRESS:" (In-Progress)",Y_AXIS_TITLE:"Count",APP_RESERVED_HEIGHT:60,ALWAYS_SELECTED_FIELDS:["FormattedID","Name"],DERIVED_FIELDS:["timeboxName","timeboxStartDate","timeboxEndDate","timeboxAddedDate","Planned","Delivered"],STORY_DEFAULT_FIELDS:["FormattedID","Name","ScheduleState","Iteration","Release","AcceptedDate"],PI_DEFAULT_FIELDS:["FormattedID","Name","State","Release","ActualEndDate"],TIMEBOX_TYPE_ITERATION:"Iteration",TIMEBOX_TYPE_RELEASE:"Release",TIMEBOX_TYPE_ITERATION_LABEL:"Iteration",TIMEBOX_TYPE_RELEASE_LABEL:"Release",UNPLANNED_DESCRIPTION:"added to {timebox} more than {days} days after start"}}),Ext.override(Rally.app.App,{updateSettingsValues:function(a){Rally.data.PreferenceManager.update(Ext.apply(this._getAppSettingsLoadOptions(),{requester:this,settings:a.settings,success:function(b){var c=_.reduce(b,function(a,b){return a[b.get("Name")]=b.get("Value"),a},{});Ext.apply(this.settings,c),a.success&&a.success.call(a.scope)},scope:this}))}}),Ext.define("committed-vs-delivered",{extend:"Rally.app.App",componentCls:"app",layout:{type:"vbox",align:"stretch"},items:[{id:Utils.AncestorPiAppFilter.RENDER_AREA_ID,xtype:"container",layout:{type:"hbox",align:"middle",defaultMargins:"0 10 10 0"}},{xtype:"container",itemId:"controls-area",layout:"hbox"},{xtype:"container",itemId:"filters-area"},{id:"grid-area",xtype:"container",flex:1,type:"vbox",align:"stretch"}],config:{defaultSettings:{artifactType:"HierarchicalRequirement",timeboxType:Constants.TIMEBOX_TYPE_ITERATION,timeboxCount:5,planningWindow:2,currentTimebox:!0}},integrationHeaders:{name:"committed-vs-delivered"},currentData:[],settingsChanged:!1,onTimeboxScopeChange:function(a){this.callParent(arguments),this.viewChange()},launch:function(){Rally.data.util.PortfolioItemHelper.getPortfolioItemTypes().then({scope:this,success:function(a){this.portfolioItemTypes=_.sortBy(a,function(a){return a.get("Ordinal")}),this.lowestPiType=this.portfolioItemTypes[0],this.setModelFieldsForType(this.getSetting("artifactType")),this.setTimeboxFieldsForType(this.getSetting("timeboxType")),this.viewChange()},failure:function(a){this._showError(a)}})},setModelFieldsForType:function(a){this.modelName=a,this.acceptedDateField="AcceptedDate",this.isPiTypeSelected()&&(this.acceptedDateField="ActualEndDate")},setTimeboxFieldsForType:function(a){this.timeboxType=a,this.timeboxType==Constants.TIMEBOX_TYPE_RELEASE?(this.timeboxStartDateField="ReleaseStartDate",this.timeboxEndDateField="ReleaseDate"):this.timeboxType==Constants.TIMEBOX_TYPE_ITERATION&&(this.timeboxStartDateField="StartDate",this.timeboxEndDateField="EndDate")},addControls:function(){var a=Ext.create("Deft.Deferred"),b=this.getContext(),c=this.down("#controls-area");return c.removeAll(),c.add([{xtype:"rallyinlinefilterbutton",modelNames:[this.modelName],context:b,stateful:!0,stateId:b.getScopedStateId(this.modelName+"filters"),inlineFilterPanelConfig:{quickFilterPanelConfig:{portfolioItemTypes:this.portfolioItemTypes,modelName:this.modelName}},listeners:{scope:this,inlinefilterready:function(a){this.down("#filters-area").add(a)},inlinefilterchange:function(b){"pending"==a.getState()?(this.filterButton=b,a.resolve()):this.viewChange()}}},{xtype:"container",flex:1},{xtype:"tsfieldpickerbutton",margin:"0 10 0 0",toolTipConfig:{html:"Columns to Export",anchor:"top"},getTitle:function(){return"Export Columns"},modelNames:[this.modelName],_fields:this.isPiTypeSelected()?Constants.PI_DEFAULT_FIELDS:Constants.STORY_DEFAULT_FIELDS,context:b,stateful:!0,stateId:b.getScopedStateId(this.modelName+"fields"),alwaysSelectedValues:Constants.ALWAYS_SELECTED_FIELDS.concat(this.acceptedDateField),listeners:{fieldsupdated:function(a){this.viewChange()},scope:this}},{xtype:"rallybutton",style:{"float":"right"},cls:"secondary rly-small",frame:!1,itemId:"actions-menu-button",iconCls:"icon-export",listeners:{click:function(a){var b=Ext.widget({xtype:"rallymenu",items:[{text:"Export to CSV...",handler:function(){var a=CArABU.technicalservices.FileUtilities.convertDataArrayToCSVText(this.currentData,this.getExportFieldsHash());CArABU.technicalservices.FileUtilities.saveCSVToFile(a,"comitted.csv")},scope:this}]});b.showBy(a.getEl()),a.toolTip&&a.toolTip.hide()},scope:this}}]),a.promise},getFieldsFromButton:function(){var a=this.down("tsfieldpickerbutton"),b=[];return a&&(b=a.getFields()),b},getExportFieldsHash:function(){var a=this.getFieldsFromButton();return a=_.without(a,this.acceptedDateField),a.push(this.acceptedDateField),a=a.concat(Constants.DERIVED_FIELDS),_.reduce(a,function(a,b){return a[b]=this.headerName(b),a},{},this)},headerName:function(a){var b;switch(a){case"Iteration":b="Currently linked to Iteration";break;case"Release":b="Currently linked to Release";break;case"timeboxName":b=this.timeboxType;break;case"timeboxStartDate":b=this.timeboxType+" Start Date";break;case"timeboxEndDate":b=this.timeboxType+" End Date";break;case"timeboxAddedDate":b="Linked to "+this.timeboxType+" on";break;default:b=a}return b},getFiltersFromButton:function(){var a=null;try{a=this.filterButton.getWsapiFilter()}catch(b){}return a},onResize:function(){this.callParent(arguments);var a=this.down("#grid-area"),b=this.down("rallygridboard");a&&b&&b.setHeight(a.getHeight()-Constants.APP_RESERVED_HEIGHT)},_buildChartConfig:function(){return this.getTimeboxes().then({scope:this,success:function(a){var b=_.map(a,function(a){var b=a[0],c=Ext.Date.add(b.get(this.timeboxStartDateField),Ext.Date.DAY,this.getSetting("planningWindow")).toISOString(),d=b.get(this.timeboxEndDateField).toISOString(),e=b.get(this.timeboxStartDateField).toISOString(),f={};return this.getSnapshotsFromTimeboxGroup(a).then({scope:this,success:function(a){if(a&&0!=a.length){var g=[];_.each(a,function(a){var b=a.get("ObjectID");g.push({property:"ObjectID",value:b}),f[b]=a},this);var h=Rally.data.wsapi.Filter.or(g),i=this.getFiltersFromButton();i?(h=h.and(i),this.advancedFiltersString=i.toString()):this.advancedFiltersString="";var j=Ext.create("Rally.data.wsapi.Store",{model:this.modelName,fetch:this.getFieldsFromButton(),autoLoad:!1,enablePostGet:!0,filters:h});return j.load().then({scope:this,success:function(a){return _.each(a,function(a){var g=f[a.get("ObjectID")],h=g.get("_ValidFrom");c>=h&&a.set("Planned",!0);var i=a.get(this.acceptedDateField);if(i){var j=i.toISOString();d>=j&&a.set("Delivered",!0),e>j&&a.set("AcceptedBeforeTimeboxStart",!0)}a.set("timeboxAddedDate",new Date(h)),a.set("timeboxName",b.get("Name")),a.set("timeboxStartDate",b.get(this.timeboxStartDateField)),a.set("timeboxEndDate",b.get(this.timeboxEndDateField))},this),{timebox:b,artifactStore:j}}})}return{timebox:b,artifactStore:null}}})},this);return Deft.Promise.all(b)}}).then({scope:this,success:function(a){return this.data=a,this.getChartConfig(this.data)}})},getChartConfig:function(a){var b=_.sortBy(a,function(a){return a.timebox.get(this.timeboxStartDateField).toISOString()},this),c=[],d=[],e=[],f=[],g=[];this.currentData=[],_.each(b,function(a,b,h){var i=0,j=0,k=0,l=0,m=a.timebox.get("Name");this.getSetting("currentTimebox")&&b==h.length-1&&a.timebox.get(this.timeboxEndDateField)>=new Date&&(m+=Constants.IN_PROGRESS),
    c.push(m),a.artifactStore&&a.artifactStore.each(function(a){a.get("AcceptedBeforeTimeboxStart")||(this.currentData.push(a.data),a.get("Planned")?(i++,a.get("Delivered")&&j++):(k++,a.get("Delivered")&&l++))},this),d.push(i),e.push(j),f.push(k),g.push(l)},this);var h="Stories";return this.isPiTypeSelected()&&(h=this.lowestPiType.get("Name")+"s"),{xtype:"rallychart",loadMask:!1,chartColors:["#FAD200","#8DC63F"],chartConfig:{chart:{type:"column",animation:!1},title:{text:h+" "+Constants.CHART_TITLE+" by "+this.timeboxType},legend:{layout:"vertical",labelFormatter:function(){var a=this.name;if(this.name==Constants.UNPLANNED){var b=Rally.getApp(),c=b.getSetting("timeboxType"),d=b.getSetting("planningWindow");a=this.name+" ("+Constants.UNPLANNED_DESCRIPTION.replace("{timebox}",c).replace("{days}",d)+")"}return a}},plotOptions:{column:{stacking:"normal"},series:{animation:!1,dataLabels:{align:"center",verticalAlign:"top"},events:{legendItemClick:function(){return!1}}}},yAxis:{allowDecimals:!1,title:{text:Constants.Y_AXIS_TITLE}}},chartData:{categories:c,series:[{dataLabels:{enabled:!0,format:"{total} "+Constants.COMMITTED,inside:!1,y:-20,overflow:"justify"},data:f,stack:0,legendIndex:2,name:Constants.UNPLANNED},{data:d,stack:0,legendIndex:1,name:Constants.PLANNED},{dataLabels:{enabled:!0,format:"{total} "+Constants.DELIVERED,inside:!1,y:-20,overflow:"justify"},data:g,stack:1,showInLegend:!1,name:Constants.UNPLANNED},{data:e,stack:1,showInLegend:!1,name:Constants.PLANNED}]}}},getTimeboxes:function(){var a=this.timeboxEndDateField;return this.getSetting("currentTimebox")&&(a=this.timeboxStartDateField),Ext.create("Rally.data.wsapi.Store",{model:this.timeboxType,autoLoad:!1,context:{projectScopeDown:!1,projectScopeUp:!1},sorters:[{property:a,direction:"DESC"}],filters:[{property:a,operator:"<=",value:"today"}],pageSize:this.getSetting("timeboxCount")}).load().then({scope:this,success:function(a){var b=_.map(a,function(a){return Rally.data.wsapi.Filter.and([{property:"Name",value:a.get("Name")},{property:this.timeboxStartDateField,value:a.get(this.timeboxStartDateField)},{property:this.timeboxEndDateField,value:a.get(this.timeboxEndDateField)}])},this);return b.length?Rally.data.wsapi.Filter.or(b):null}}).then({scope:this,success:function(a){return a?Ext.create("Rally.data.wsapi.Store",{model:this.timeboxType,autoLoad:!1,fetch:["ObjectID",this.timeboxStartDateField,this.timeboxEndDateField,"Name"],enablePostGet:!0,sorters:[{property:this.timeboxEndDateField,direction:"DESC"}],filters:[a]}).load():[]}}).then({scope:this,success:function(a){return _.groupBy(a,function(a){return a.get("Name")})}})},getSnapshotsFromTimeboxGroup:function(a){var b=a[0],c=_.map(a,function(a){return a.get("ObjectID")}),d=b.get(this.timeboxEndDateField).toISOString(),e=Ext.Date.add(b.get(this.timeboxStartDateField),Ext.Date.DAY,this.getSetting("planningWindow")).toISOString(),f=Rally.data.lookback.QueryFilter.and([{property:"_ValidFrom",operator:"<=",value:d},{property:"_ValidTo",operator:">=",value:e}]),g=this.getContext().getDataContext(),h=[{property:"_TypeHierarchy",value:this.modelName},{property:this.timeboxType,operator:"in",value:c},{property:"_ProjectHierarchy",value:Rally.util.Ref.getOidFromRef(g.project)},f],i=Ext.create("Rally.data.lookback.SnapshotStore",{autoLoad:!1,context:g,fetch:[this.timeboxType,"_ValidFrom","_ValidTo","ObjectID"],hydrate:[this.timeboxType],remoteSort:!1,compress:!0,enablePostGet:!0,filters:h});return i.load()},_addGridboard:function(a){var b=this.down("#grid-area");b.removeAll();var c=[],d=this.getContext().getTimeboxScope();d&&d.isApplicable(this.modelName)&&c.push(d.getQueryFilter());var e=this.getContext();this.gridboard=b.add({xtype:"rallygridboard",context:e,modelNames:[this.modelName],toggleState:"chart",height:b.getHeight()-Constants.APP_RESERVED_HEIGHT,chartConfig:a,listeners:{scope:this,viewchange:this.viewChange}})},isPiTypeSelected:function(){return this.modelName==this.lowestPiType.get("TypePath")},getConfigItems:function(){var a=Ext.create("Ext.data.Store",{fields:["name","value"],data:[{name:Constants.TIMEBOX_TYPE_ITERATION_LABEL,value:Constants.TIMEBOX_TYPE_ITERATION},{name:Constants.TIMEBOX_TYPE_RELEASE_LABEL,value:Constants.TIMEBOX_TYPE_RELEASE}]}),b=[{name:"User Story",value:"HierarchicalRequirement"}];this.lowestPiType&&b.push({name:this.lowestPiType.get("Name"),value:this.lowestPiType.get("TypePath")});var c=Ext.create("Ext.data.Store",{fields:["name","value"],data:b});return[{xtype:"combobox",name:"artifactType",value:this.getSetting("artifactType"),fieldLabel:"Artifact type",labelWidth:150,store:c,queryMode:"local",displayField:"name",valueField:"value",listeners:{scope:this,change:function(a,b,c){if(b!=c){this.updateSettingsValues({settings:{artifactType:b}}),this.setModelFieldsForType(b);var d=Ext.ComponentManager.get("timeboxType");this.isPiTypeSelected()?(d.setValue(Constants.TIMEBOX_TYPE_RELEASE),d.disable()):d.enable()}}}},{xtype:"combobox",name:"timeboxType",id:"timeboxType",value:this.getSetting("timeboxType"),fieldLabel:"Timebox type",labelWidth:150,store:a,queryMode:"local",displayField:"name",valueField:"value",disabled:this.isPiTypeSelected(),listeners:{scope:this,change:function(a,b,c){b!=c&&(this.updateSettingsValues({settings:{timeboxType:b}}),this.setTimeboxFieldsForType(b))}}},{xtype:"rallynumberfield",name:"timeboxCount",value:this.getSetting("timeboxCount"),fieldLabel:"Timebox Count",labelWidth:150,minValue:1,allowDecimals:!1,listeners:{scope:this,change:function(a,b,c){b!=c&&this.updateSettingsValues({settings:{timeboxCount:b}})}}},{xtype:"rallynumberfield",name:"planningWindow",value:this.getSetting("planningWindow"),fieldLabel:"Timebox planning window (days)",labelWidth:150,minValue:0,allowDecimals:!1,listeners:{scope:this,change:function(a,b,c){b!=c&&this.updateSettingsValues({settings:{planningWindow:b}})}}},{xtype:"rallycheckboxfield",name:"currentTimebox",value:this.getSetting("currentTimebox"),fieldLabel:"Show current, in-progress timebox",labelWidth:150,listeners:{scope:this,change:function(a,b,c){b!=c&&this.updateSettingsValues({settings:{currentTimebox:b}})}}}]},viewChange:function(){this.setLoading(!0),this.addControls().then({scope:this,success:this._buildChartConfig}).then({scope:this,success:function(a){this._addGridboard(a),this.setLoading(!1)}})},onSettingsClose:function(){this.settingsChanged&&(this.settingsChanged=!1,this.viewChange())},updateSettingsValues:function(a){this.settingsChanged=!0,this.callParent(arguments)},getModelScopedStateId:function(a,b){return this.getContext().getScopedStateId(a+"-"+b)},getSettingsFields:function(){return this.getConfigItems()}});

    Rally.launchApp('committed-vs-delivered', {
    name: 'committed-vs-delivered'
    });
    });
    </script>

    <style type="text/css">

    .app {}

    .settings-popover {
    background-color: #FFF;
    }

    </style>

    </head>
    <body></body>
    </html>


  • 2.  RE: Coding Help

    Posted Jun 29, 2022 05:10 PM
    https://github.com/nikantonelli/committed-vs-delivered/blob/master/deploy/App.txt

    Found my answer!