@@ -3,10 +3,16 @@ Ext.define("custom-grid-with-deep-export", {
33 componentCls : 'app' ,
44 logger : new Rally . technicalservices . Logger ( ) ,
55 layout : {
6- type : 'vbox' ,
6+ type :'vbox' ,
77 align : 'stretch'
88 } ,
9-
9+ items : [ {
10+ id : 'grid-area' ,
11+ xtype : 'container' ,
12+ flex : 1 ,
13+ type : 'vbox' ,
14+ align : 'stretch'
15+ } ] ,
1016 config : {
1117 defaultSettings : {
1218 columnNames : [ 'FormattedID' , 'Name' , 'ScheduleState' ] ,
@@ -28,25 +34,39 @@ Ext.define("custom-grid-with-deep-export", {
2834 statePrefix : 'customlist' ,
2935 allowExpansionStateToBeSaved : false ,
3036 enableAddNew : true ,
31-
3237 onTimeboxScopeChange : function ( newTimeboxScope ) {
3338 this . callParent ( arguments ) ;
3439 this . _buildStore ( ) ;
3540 } ,
36-
3741 launch : function ( ) {
38- this . fetchPortfolioItemTypes ( ) . then ( {
42+ Rally . data . util . PortfolioItemHelper . getPortfolioItemTypes ( )
43+ . then ( {
3944 success : function ( portfolioItemTypes ) {
40- this . portfolioItemTypes = portfolioItemTypes ;
45+ this . portfolioItemTypes = _ . sortBy ( portfolioItemTypes , function ( type ) {
46+ return type . get ( 'Ordinal' ) ;
47+ } ) ;
4148 this . _buildStore ( ) ;
4249 } ,
4350 failure : function ( msg ) {
4451 this . _showError ( msg ) ;
4552 } ,
4653 scope : this
4754 } ) ;
48-
55+ var listenerConfig = {
56+ scope : this
57+ }
4958 } ,
59+
60+ // Usual monkey business to size gridboards
61+ onResize : function ( ) {
62+ this . callParent ( arguments ) ;
63+ var gridArea = this . down ( '#grid-area' ) ;
64+ var gridboard = this . down ( 'rallygridboard' ) ;
65+ if ( gridArea && gridboard ) {
66+ gridboard . setHeight ( gridArea . getHeight ( ) )
67+ }
68+ } ,
69+
5070 _buildStore : function ( ) {
5171
5272 this . modelNames = [ this . getSetting ( 'type' ) ] ;
@@ -69,8 +89,8 @@ Ext.define("custom-grid-with-deep-export", {
6989 } ) ;
7090 } ,
7191 _addGridboard : function ( store ) {
72-
73- this . removeAll ( ) ;
92+ var gridArea = this . down ( '#grid-area' )
93+ gridArea . removeAll ( ) ;
7494
7595 var filters = this . getSetting ( 'query' ) ? [ Rally . data . wsapi . Filter . fromQueryString ( this . getSetting ( 'query' ) ) ] : [ ] ;
7696 var timeboxScope = this . getContext ( ) . getTimeboxScope ( ) ;
@@ -85,31 +105,32 @@ Ext.define("custom-grid-with-deep-export", {
85105 dataContext . project = null ;
86106 }
87107 var summaryRowFeature = Ext . create ( 'Rally.ui.grid.feature.SummaryRow' ) ;
88- this . gridboard = this . add ( {
108+ var currentModelName = this . modelNames [ 0 ] ;
109+ this . gridboard = gridArea . add ( {
89110 xtype : 'rallygridboard' ,
90- flex : 1 ,
91111 context : context ,
92112 modelNames : this . modelNames ,
93113 toggleState : 'grid' ,
114+ height : gridArea . getHeight ( ) ,
115+ listeners : {
116+ scope : this ,
117+ viewchange : this . viewChange ,
118+ } ,
94119 plugins : [
95120 'rallygridboardaddnew' ,
96121 {
97122 ptype : 'rallygridboardinlinefiltercontrol' ,
98123 inlineFilterButtonConfig : {
99124 stateful : true ,
100- stateId : this . getContext ( ) . getScopedStateId ( 'filters-1 ' ) ,
125+ stateId : this . getModelScopedStateId ( currentModelName , 'filters' ) ,
101126 modelNames : this . modelNames ,
102127 inlineFilterPanelConfig : {
103128 quickFilterPanelConfig : {
129+ portfolioItemTypes : this . portfolioItemTypes ,
130+ modelName : currentModelName ,
104131 whiteListFields : [
105132 'Tags' ,
106133 'Milestones'
107- ] ,
108- defaultFields : [
109- 'ArtifactSearch' ,
110- 'Owner' ,
111- 'ModelType' ,
112- 'Milestones'
113134 ]
114135 }
115136 }
@@ -120,7 +141,7 @@ Ext.define("custom-grid-with-deep-export", {
120141 headerPosition : 'left' ,
121142 modelNames : this . modelNames ,
122143 stateful : true ,
123- stateId : this . getContext ( ) . getScopedStateId ( 'field-picker ')
144+ stateId : this . getModelScopedStateId ( currentModelName , 'fields ')
124145 } ,
125146 {
126147 ptype : 'rallygridboardactionsmenu' ,
@@ -131,8 +152,12 @@ Ext.define("custom-grid-with-deep-export", {
131152 } ,
132153 {
133154 ptype : 'rallygridboardsharedviewcontrol' ,
134- stateful : true ,
135- stateId : this . getContext ( ) . getScopedStateId ( 'shared-views' )
155+ sharedViewConfig : {
156+ enableUrlSharing : this . isFullPageApp !== false ,
157+ stateful : true ,
158+ stateId : this . getModelScopedStateId ( currentModelName , 'views' ) ,
159+ stateEvents : [ 'select' , 'beforedestroy' ]
160+ } ,
136161 }
137162 ] ,
138163 cardBoardConfig : {
@@ -167,6 +192,15 @@ Ext.define("custom-grid-with-deep-export", {
167192 }
168193 } ) ;
169194 } ,
195+
196+ viewChange : function ( ) {
197+ this . _buildStore ( ) ;
198+ } ,
199+
200+ getModelScopedStateId : function ( modelName , id ) {
201+ return this . getContext ( ) . getScopedStateId ( modelName + '-' + id ) ;
202+ } ,
203+
170204 _getExportMenuItems : function ( ) {
171205 var result = [ ] ;
172206 this . logger . log ( '_getExportMenuItems' , this . modelNames [ 0 ] ) ;
@@ -256,7 +290,9 @@ Ext.define("custom-grid-with-deep-export", {
256290 return result ;
257291 } ,
258292 getPortfolioItemTypeNames : function ( ) {
259- return _ . pluck ( this . portfolioItemTypes , 'typePath' ) ;
293+ return _ . map ( this . portfolioItemTypes , function ( type ) {
294+ return type . get ( 'TypePath' ) ;
295+ } ) ;
260296 } ,
261297
262298 _showError : function ( msg ) {
@@ -413,57 +449,5 @@ Ext.define("custom-grid-with-deep-export", {
413449 return Rally . technicalservices . CustomGridWithDeepExportSettings . getFields ( {
414450 showSearchAllProjects : this . isMilestoneScoped ( )
415451 } ) ;
416- } ,
417- //onSettingsUpdate: Override
418- onSettingsUpdate : function ( settings ) {
419- this . logger . log ( 'onSettingsUpdate' , settings ) ;
420- // Ext.apply(this, settings);
421- this . _buildStore ( ) ;
422- } ,
423- fetchPortfolioItemTypes : function ( ) {
424- var deferred = Ext . create ( 'Deft.Deferred' ) ;
425-
426- var store = Ext . create ( 'Rally.data.wsapi.Store' , {
427- model : 'TypeDefinition' ,
428- fetch : [ 'TypePath' , 'Ordinal' , 'Name' ] ,
429- filters : [
430- {
431- property : 'Parent.Name' ,
432- operator : '=' ,
433- value : 'Portfolio Item'
434- } ,
435- {
436- property : 'Creatable' ,
437- operator : '=' ,
438- value : 'true'
439- }
440- ] ,
441- sorters : [ {
442- property : 'Ordinal' ,
443- direction : 'ASC'
444- } ]
445- } ) ;
446- store . load ( {
447- callback : function ( records , operation , success ) {
448-
449- if ( success ) {
450- var portfolioItemTypes = new Array ( records . length ) ;
451- _ . each ( records , function ( d ) {
452- //Use ordinal to make sure the lowest level portfolio item type is the first in the array.
453- var idx = Number ( d . get ( 'Ordinal' ) ) ;
454- portfolioItemTypes [ idx ] = { typePath : d . get ( 'TypePath' ) . toLowerCase ( ) , name : d . get ( 'Name' ) } ;
455- //portfolioItemTypes.reverse();
456- } ) ;
457- deferred . resolve ( portfolioItemTypes ) ;
458- } else {
459- var error_msg = '' ;
460- if ( operation && operation . error && operation . error . errors ) {
461- error_msg = operation . error . errors . join ( ',' ) ;
462- }
463- deferred . reject ( 'Error loading Portfolio Item Types: ' + error_msg ) ;
464- }
465- }
466- } ) ;
467- return deferred . promise ;
468452 }
469453} ) ;
0 commit comments