Question

I am trying to create a simple rallycardboard app that displays projects as columns with the project backlog stories as cards. Then allow the drag/drop of cards to set the project. Code is attached.

If I specify 'Project" as the attribute, the board contains columns for all projects in the workspace. I wish to limit the columns shown to either

  1. Scoped parent and children, or
  2. Code a list of project columns. I have tried the manipulate the columns, columnConfig, context settings, but nothing produces the desired results.

    <!DOCTYPE html>
    <html>
    <head>
        <title>CardBoard Example</title>
    
        <script type="text/javascript" src="/apps/2.0rc2/sdk.js"></script>
    
        <script type="text/javascript">
            Rally.onReady(function() {
                Ext.define('ProjBoard', {
                    extend: 'Rally.app.App',
    
                    launch: function() {
                        if (cardBoardConfig) {
                            cardBoardConfig.destroy();
                        }
    
                        var cardBoardConfig = {
                            xtype: 'rallycardboard',
                            types: ['User Story'],
                            attribute: 'Project',
                            fieldToDisplay: 'Project',
                            cardConfig: {
                                fields: ['Project', 'Parent','Iteration']
                            },
                            storeConfig: {
                                filters: [
                                    { property: 'ScheduleState', operator: '<', value: 'In-Progress' },
                                    { property: 'Iteration', operator: '=', value: '' }
                                ],
                                sorters: [
                                    { property: 'Rank', direction: 'DESC' }
                                ],
                                //Specify current project and scoping
                                context: this.getContext().getDataContext()
                            }
                        };
    
                        this.add(cardBoardConfig);
                    }
                });
                Rally.launchApp('ProjBoard', {
                  name: 'Backlog Project Board'
                });
            });
        </script>
        <style type="text/css">
        </style>
    </head>
    <body></body>
    </html>
    
Was it helpful?

Solution

You should be able to specify the columns via config:

https://help.rallydev.com/apps/2.0rc2/doc/#!/api/Rally.ui.cardboard.CardBoard-cfg-columns

columns: [
    {
        value: '/project/12345',
        columnHeaderConfig: {
            headerTpl: '{project}',
            headerData: {project: 'Project 1'}
        }
    },
    //more columns...
]

OTHER TIPS

The code below allowed me to cut down a dozen of project columns to three. First I get current project and query a collection of its child projects to build an array of projects I want to have on the board (you may choose a different criteria for what projects you want on the board), and then I extended Rally.ui.cardboard.CardBoard to overwrite its _buildColumnsFromModel method where only columns that meet this condition are filtered in :

retrievedColumns = _.select(retrievedColumns, function(project){    
     return that.arrayOfProjectRefs.indexOf(project.value) != -1
});

Here is the full js file. Apart from those changes, this is your code.

    Ext.define('CustomApp', { extend: 'Rally.app.App', componentCls: 'app',
        launch: function() {
            var that = this;
            that.arrayOfProjectRefs = [];
            var p = this.getContext().getProject();
            Ext.create('Rally.data.wsapi.Store', {
                model: 'Project',
                fetch: ['Children'],
                filters:[
                    {
                        Property: '_ref',
                        value: p
                    }
                ],
                pageSize: 1,
                autoLoad: true,
                listeners: {
                    load: function(store, records) {
                        var project = records[0];
                        var childProjects = project.get('Children');
                        var childProjectsCount = project.get('Children').Count;
                        console.log('childProjectsCount', childProjectsCount);
                        that.arrayOfProjectRefs.push(project.get('_ref'));
                        project.getCollection('Children').load({
                            fetch: ['_ref', 'Name', 'State'],
                            callback: function(records, operation, success) {
                                Ext.Array.each(records, function(child) {
                                    console.log(child.get('_ref') + ' - ' + child.get('Name') + child.get('State'));
                                    if (child.get('State') === 'Open') {
                                        that.arrayOfProjectRefs.push(child.get('_ref'));
                                        --childProjectsCount;
                                        if (childProjectsCount === 0) {
                                            that._buildBoard();
                                        }
                                    }
                                });
                            }
                        });
                    }
                }
            });
        },

        _buildBoard:function(){
         var that = this;
        console.log('app._arrayOfProjectRefs', this.arrayOfProjectRefs);   
        Ext.define('ProjectCardboard', {extend: 'Rally.ui.cardboard.CardBoard',
          xtype: 'projectCardboard',

         _buildColumnsFromModel: function() {
                var model = this.models[0];
                if (model) {
                    var attribute = model.getField('Project');
                    if (attribute) {
                        attribute.getAllowedValueStore().load({
                            callback: function(records, operation, success) {
                                var retrievedColumns = _.map(records, function(allowedValue) {
                                    var displayValue, value = allowedValue.get('StringValue');
                                    if (!value && attribute.attributeDefinition.AttributeType.toLowerCase() === 'rating') {
                                        value = "None";
                                    } else if (attribute.attributeDefinition.AttributeType.toLowerCase() === 'object') {
                                        displayValue = value;
                                        value = allowedValue.get('_ref');
                                        if (value === 'null') {
                                            value = null;
                                        }
                                    }

                                    return {
                                        value: value,
                                        columnHeaderConfig: {
                                            headerTpl: displayValue || value || 'None'
                                        }
                                    };
                                });

                                this.fireEvent('columnsretrieved', this, retrievedColumns);

                                retrievedColumns = _.select(retrievedColumns, function(project){    
                                    return that.arrayOfProjectRefs.indexOf(project.value) != -1
                                });
                                 console.log('retrievedColumns after filter', retrievedColumns)
                                this.columnDefinitions = [];
                                _.each(retrievedColumns, this.addColumn, this);
                                this.renderColumns();
                            },
                            scope: this
                        });
                    }
                }
            }       
    }); 

            var addNewConfig = {
                xtype: 'rallyaddnew',
                recordTypes: ['User Story'],
                ignoredRequiredFields: ['Name', 'Iteration'],
                showAddWithDetails: false,
            };

            this.addNew = this.add(addNewConfig);
            var myCardConfig = {
                   xtype: 'rallycard',
                   fields: ['ScheduleState','Name'], 
                   maxHeight: 100
                } 

            var cardBoardConfig = {
                xtype: 'projectCardboard',
                types: ['User Story'], 
                attribute: 'Project', 
                cardConfig: myCardConfig
            };

            this.cardBoard = this.add(cardBoardConfig);
   }
});
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top