Rally ut如何覆盖拖动结果以及如何为第一项添加选择器面板。(您可以更好地将其抽象到自己的类中)

Rally ut如何覆盖拖动结果以及如何为第一项添加选择器面板。(您可以更好地将其抽象到自己的类中),rally,Rally,完整内容: <!DOCTYPE html> <html> <head> <title>cardboard</title> <script type="text/javascript" src="/apps/2.0p3/sdk.js"></script> <script type="text/javascript"> Rally.onReady(functio

完整内容:

<!DOCTYPE html>
<html>
<head>
    <title>cardboard</title>

    <script type="text/javascript" src="/apps/2.0p3/sdk.js"></script>

    <script type="text/javascript">
        Rally.onReady(function() {
            /*global console, Ext */

            Ext.define( 'DependencyColumn', {
                extend: 'Rally.ui.cardboard.Column',
                alias: 'widget.dependencycolumn',
                constructor: function(config) {
                    this.mergeConfig(config);
                    this.callParent([this.config]);
                },
                initComponent: function() {
                    this.callParent(arguments);
                },
                _queryForData: function() {
                    var allRecords = [];

                    var records = this.store.queryBy( function( record ) {
                        if ( record.data._column === this.getValue() ) { allRecords.push( record ); }
                    }, this);

                    this.createAndAddCards( allRecords );
                },
                getColumnHeightFromCards: function() {
                    var contentMinHeight = 500,
                        bottomPadding = 30,
                        cards = this.query(this.cardConfig.xtype),
                        height = bottomPadding;

                    for(var i = 0, l = cards.length; i < l; ++i) {
                        if ( cards[i].el ) {
                             height += cards[i].getHeight();
                        } else {
                            height += 100;
                        }

                    }

                    height = Math.max(height, contentMinHeight);
                    height += this.down('#columnHeader').getHeight();

                    return height;
                } 

            });
            /*global console, Ext */

            Ext.define( 'DependencyCardboard', {
                extend: 'Rally.ui.cardboard.CardBoard',
                alias: 'widget.dependencycardboard',
                constructor: function(config) {
                    this.mergeConfig(config);
                    this.callParent([this.config]);
                },
                initComponent: function() {
                    this.callParent(arguments);
                },
                _retrieveModels: function(success) {
                    if ( this.store ) {
                        this.models = [ this.store.getProxy().getModel() ];
                        success.apply( this, arguments );
                    }
                }

            });
            /*global console, Ext */
            Ext.define('CustomApp', {
                extend: 'Rally.app.App',
                componentCls: 'app',
                items: [ { xtype: 'container', itemId: 'outer_box' }],
                launch: function() {
                    Ext.create('Rally.data.WsapiDataStore', {
                        model: "hierarchicalrequirement",
                        autoLoad: true,
                        fetch: ['Name','Predecessors','Successors','FormattedID','ObjectID','_ref'],
                        filters: [ {
                            property: 'FormattedID', operator: 'contains', value: '37'
                        } ],
                        listeners: { 
                            load: function(store,data,success) {
                                if ( data.length === 1 ) {
                                    var base_story = data[0].data;
                                    var modified_records = [];

                                    base_story._column = "base";
                                    modified_records.push( base_story );

                                    Ext.Array.each( base_story.Predecessors, function( story ) {
                                        story._column = "predecessor";
                                        modified_records.push( story );
                                    } );

                                    Ext.Array.each( base_story.Successors, function(story) {
                                        story._column = "successor";
                                        modified_records.push( story );
                                    } );

                                    Ext.define('CardModel', { 
                                        extend: 'Ext.data.Model',
                                        fields: [
                                            { name: '_ref', type: 'string' },
                                            { name: 'ObjectID', type: 'number'},
                                            { name: 'Name', type: 'string', attributeDefinition: { AttributeType: 'STRING'} },
                                            { name: 'FormattedID', type: 'string'},
                                            { name: '_column', type: 'string' },
                                            { name: 'ScheduleState', type: 'string' } ] ,
                                        getField: function(name) {
                                            if ( this.data[name] ) { 
                                                var return_field = null;
                                                Ext.Array.each( this.store.model.getFields(), function(field) {
                                                    if ( field.name === name ) {
                                                        return_field = field;
                                                    }
                                                } );

                                                return return_field;
                                            } else {
                                                return null;
                                            }
                                        } 
                                    });

                                    var cardStore = Ext.create('Ext.data.Store',{
                                        model: 'CardModel',
                                        data: modified_records
                                    });

                                    var cardboard = Ext.create('DependencyCardboard', {
                                        attribute: '_column',
                                        store: cardStore,
                                        height: 500,
                                        columns: [{
                                            xtype: 'dependencycolumn',
                                            displayValue: 'predecessor',
                                            value: 'predecessor',
                                            store: cardStore
                                        }, 
                                        {
                                            xtype: 'dependencycolumn',
                                            displayValue: 'base',
                                            value: 'base',
                                            store: cardStore
                                        },
                                        {
                                            xtype: 'dependencycolumn',
                                            displayValue: 'successor',
                                            value: 'successor',
                                            store: cardStore
                                        }]
                                    });

                                    this.down('#outer_box').add( cardboard );
                                }
                            },
                            scope: this
                        }
                    });
                }
            });

            Rally.launchApp('CustomApp', {
                name: 'cardboard'
            });
        });
    </script>

    <style type="text/css">
        .app {
             /* Add app styles here */
        }
    </style>
</head>
<body></body>
</html>

硬纸板
onReady(函数(){
/*全球控制台*/
Ext.define('DependencyColumn'{
扩展:“Rally.ui.carboard.Column”,
别名:“widget.dependencycolumn”,
构造函数:函数(配置){
这个.mergeConfig(config);
this.callParent([this.config]);
},
initComponent:function(){
this.callParent(参数);
},
_queryForData:function(){
var-allRecords=[];
var records=this.store.queryBy(函数(记录){
if(record.data._column==this.getValue()){allRecords.push(record);}
},这个);
这是。创建和添加卡片(所有记录);
},
getColumnHeightFromCards:function(){
var CONTENTMINHEIGH=500,
底部填充=30,
cards=this.query(this.cardConfig.xtype),
高度=底部填充物;
对于(变量i=0,l=cards.length;i                        Ext.define('CardModel', { 
                            extend: 'Ext.data.Model',
                            fields: [
                                { name: '_ref', type: 'string' },
                                { name: 'ObjectID', type: 'number'},
                                { name: 'Name', type: 'string', attributeDefinition: { AttributeType: 'STRING'} },
                                { name: 'FormattedID', type: 'string'},
                                { name: '_column', type: 'string' },
                                { name: 'ScheduleState', type: 'string' } ] ,
                            getField: function(name) {
                                if ( this.data[name] ) { 
                                    var return_field = null;
                                    Ext.Array.each( this.store.model.getFields(), function(field) {
                                        if ( field.name === name ) {
                                            return_field = field;
                                        }
                                    } );

                                    return return_field;
                                } else {
                                    return null;
                                }
                            } 
                        });

                        var cardStore = Ext.create('Ext.data.Store',{
                            model: 'CardModel',
                            data: modified_records
                        });
                        var cardboard = Ext.create('DependencyCardboard', {
                            attribute: '_column',
                            store: cardStore, /* special to our new cardboard type */
                            height: 500,
                            columns: [{
                                xtype: 'dependencycolumn',
                                displayValue: 'predecessor',
                                value: 'predecessor',
                                store: cardStore
                            }, 
                            {
                                xtype: 'dependencycolumn',
                                displayValue: 'base',
                                value: 'base',
                                store: cardStore
                            },
                            {
                                xtype: 'dependencycolumn',
                                displayValue: 'successor',
                                value: 'successor',
                                store: cardStore
                            }]
                        });
Ext.define( 'DependencyCardboard', {
    extend: 'Rally.ui.cardboard.CardBoard',
    alias: 'widget.dependencycardboard',
    constructor: function(config) {
        this.mergeConfig(config);
        this.callParent([this.config]);
    },
    initComponent: function() {
        this.callParent(arguments);
    },
    _retrieveModels: function(success) {
        if ( this.store ) {
            this.models = [ this.store.getProxy().getModel() ];
            success.apply( this, arguments );
        }
    }

});
_queryForData: function() {
        var allRecords = [];

        var records = this.store.queryBy( function( record ) {
            if ( record.data._column === this.getValue() ) { allRecords.push( record ); }
        }, this);

        this.createAndAddCards( allRecords );
    },
    getColumnHeightFromCards: function() {
        var contentMinHeight = 500,
            bottomPadding = 30,
            cards = this.query(this.cardConfig.xtype),
            height = bottomPadding;

        for(var i = 0, l = cards.length; i < l; ++i) {
            if ( cards[i].el ) {
                 height += cards[i].getHeight();
            } else {
                height += 100;
            }

        }

        height = Math.max(height, contentMinHeight);
        height += this.down('#columnHeader').getHeight();

        return height;
    } 
<!DOCTYPE html>
<html>
<head>
    <title>cardboard</title>

    <script type="text/javascript" src="/apps/2.0p3/sdk.js"></script>

    <script type="text/javascript">
        Rally.onReady(function() {
            /*global console, Ext */

            Ext.define( 'DependencyColumn', {
                extend: 'Rally.ui.cardboard.Column',
                alias: 'widget.dependencycolumn',
                constructor: function(config) {
                    this.mergeConfig(config);
                    this.callParent([this.config]);
                },
                initComponent: function() {
                    this.callParent(arguments);
                },
                _queryForData: function() {
                    var allRecords = [];

                    var records = this.store.queryBy( function( record ) {
                        if ( record.data._column === this.getValue() ) { allRecords.push( record ); }
                    }, this);

                    this.createAndAddCards( allRecords );
                },
                getColumnHeightFromCards: function() {
                    var contentMinHeight = 500,
                        bottomPadding = 30,
                        cards = this.query(this.cardConfig.xtype),
                        height = bottomPadding;

                    for(var i = 0, l = cards.length; i < l; ++i) {
                        if ( cards[i].el ) {
                             height += cards[i].getHeight();
                        } else {
                            height += 100;
                        }

                    }

                    height = Math.max(height, contentMinHeight);
                    height += this.down('#columnHeader').getHeight();

                    return height;
                } 

            });
            /*global console, Ext */

            Ext.define( 'DependencyCardboard', {
                extend: 'Rally.ui.cardboard.CardBoard',
                alias: 'widget.dependencycardboard',
                constructor: function(config) {
                    this.mergeConfig(config);
                    this.callParent([this.config]);
                },
                initComponent: function() {
                    this.callParent(arguments);
                },
                _retrieveModels: function(success) {
                    if ( this.store ) {
                        this.models = [ this.store.getProxy().getModel() ];
                        success.apply( this, arguments );
                    }
                }

            });
            /*global console, Ext */
            Ext.define('CustomApp', {
                extend: 'Rally.app.App',
                componentCls: 'app',
                items: [ { xtype: 'container', itemId: 'outer_box' }],
                launch: function() {
                    Ext.create('Rally.data.WsapiDataStore', {
                        model: "hierarchicalrequirement",
                        autoLoad: true,
                        fetch: ['Name','Predecessors','Successors','FormattedID','ObjectID','_ref'],
                        filters: [ {
                            property: 'FormattedID', operator: 'contains', value: '37'
                        } ],
                        listeners: { 
                            load: function(store,data,success) {
                                if ( data.length === 1 ) {
                                    var base_story = data[0].data;
                                    var modified_records = [];

                                    base_story._column = "base";
                                    modified_records.push( base_story );

                                    Ext.Array.each( base_story.Predecessors, function( story ) {
                                        story._column = "predecessor";
                                        modified_records.push( story );
                                    } );

                                    Ext.Array.each( base_story.Successors, function(story) {
                                        story._column = "successor";
                                        modified_records.push( story );
                                    } );

                                    Ext.define('CardModel', { 
                                        extend: 'Ext.data.Model',
                                        fields: [
                                            { name: '_ref', type: 'string' },
                                            { name: 'ObjectID', type: 'number'},
                                            { name: 'Name', type: 'string', attributeDefinition: { AttributeType: 'STRING'} },
                                            { name: 'FormattedID', type: 'string'},
                                            { name: '_column', type: 'string' },
                                            { name: 'ScheduleState', type: 'string' } ] ,
                                        getField: function(name) {
                                            if ( this.data[name] ) { 
                                                var return_field = null;
                                                Ext.Array.each( this.store.model.getFields(), function(field) {
                                                    if ( field.name === name ) {
                                                        return_field = field;
                                                    }
                                                } );

                                                return return_field;
                                            } else {
                                                return null;
                                            }
                                        } 
                                    });

                                    var cardStore = Ext.create('Ext.data.Store',{
                                        model: 'CardModel',
                                        data: modified_records
                                    });

                                    var cardboard = Ext.create('DependencyCardboard', {
                                        attribute: '_column',
                                        store: cardStore,
                                        height: 500,
                                        columns: [{
                                            xtype: 'dependencycolumn',
                                            displayValue: 'predecessor',
                                            value: 'predecessor',
                                            store: cardStore
                                        }, 
                                        {
                                            xtype: 'dependencycolumn',
                                            displayValue: 'base',
                                            value: 'base',
                                            store: cardStore
                                        },
                                        {
                                            xtype: 'dependencycolumn',
                                            displayValue: 'successor',
                                            value: 'successor',
                                            store: cardStore
                                        }]
                                    });

                                    this.down('#outer_box').add( cardboard );
                                }
                            },
                            scope: this
                        }
                    });
                }
            });

            Rally.launchApp('CustomApp', {
                name: 'cardboard'
            });
        });
    </script>

    <style type="text/css">
        .app {
             /* Add app styles here */
        }
    </style>
</head>
<body></body>
</html>