我写了CardBoard Rally sdk 2应用程序,我添加了过滤器,但我想添加两个不同的过滤器,一个用于发布,一个用于积压

时间:2015-01-22 05:59:44

标签: extjs extjs4 rally

我写了CardBoard Rally sdk 2应用程序,我添加了适用于Backlog和Releases的过滤器。但我想添加两个不同的过滤器,一个用于发布,一个用于积压 请参阅附图中的图片,您可以看到一列用于Backlog,另一列用于版本 所以我应该可以说现在过滤Backlog功能,现在过滤发布功能 enter image description here

以下是我的一些代码段

        Ext.define('CustomApp', {
            extend: 'Rally.app.App',
            componentCls: 'app',
            autoScroll: true,
            all_releases: [],
            items:[{ xtype: 'container', itemId: 'filter_box', padding: 5},{xtype:'container',itemId:'button_box', padding: 5}],                
            logger: new Rally.technicalservices.logger(),
            launch: function() {
                //var allReleases = this._getReleases();
                this._drawCardBoard(this, filters= null);
                this.down('#button_box').add({
                    xtype: 'rallybutton',
                    text: 'Filter Criteria',
                    itemId: 'run-button',
                    scope: this,
                    handler: this._run,
                    margin: '0 0 0 10'
                });
                this.down('#button_box').add({
                    xtype: 'rallybutton',
                    text: 'Prev',
                    itemId: 'prev-button',
                    scope: this,
                    handler: this._setPrevReleaseDate,
                    margin: '0 0 0 100'
                }); 
                this.down('#button_box').add({
                    xtype: 'rallybutton',
                    text: 'Next',
                    itemId: 'next-button',
                    scope: this,
                    handler: this._setNextReleaseDate,
                    margin: '0 0 0 650'
                });                     
            },
            _setPrevReleaseDate: function() {
                if (this.globalVar == undefined) {
                    this.globalVar = new Date();
                } else {
                    this.globalVar = new Date(this.globalVar);
                };
                this.globalVar = Rally.util.DateTime.formatWithDefault(Ext.Date.subtract(this.globalVar, Ext.Date.DAY, 224));
                this._drawCardBoard(this, filters= null);
            },
            _setNextReleaseDate: function() {
                if (this.globalVar == undefined) {
                    this.globalVar = new Date();
                } else {
                    this.globalVar = new Date(this.globalVar);
                };
                this.globalVar = Rally.util.DateTime.formatWithDefault(Ext.Date.add(this.globalVar, Ext.Date.DAY, 224));
                this._drawCardBoard(this, filters= null);
            },                  
            _getFilters: function(records) {
                var filters = null;
                if (records.length >= 1) {
                    if (records[0].data.PortfolioItemTypeName == "MMF") {
                        filters = Ext.create('Rally.data.QueryFilter',{
                            property: 'Parent',
                            operator: '=',
                            value: records[0].get("_ref")
                        });
                    } else if (records[0].data.PortfolioItemTypeName == "Epic") {
                        filters = Ext.create('Rally.data.QueryFilter',{
                            property: 'Parent.Parent',
                            operator: '=',
                            value: records[0].get("_ref")
                        }); 
                    } else if (records[0].data.PortfolioItemTypeName == "Program") {
                        filters = Ext.create('Rally.data.QueryFilter',{
                            property: 'Parent.Parent.Parent',
                            operator: '=',
                            value: records[0].get("_ref")
                        });                     
                    }   
                    for ( var i=1;i<records.length;i++ ) {
                        if (records[i].data.PortfolioItemTypeName == "MMF") {
                            filters = filters.or(Ext.create('Rally.data.QueryFilter',{
                                property: 'Parent',
                                operator: '=',
                                value: records[i].get("_ref")
                            }));
                        } else if (records[i].data.PortfolioItemTypeName == "Epic") {   
                            filters = filters.or(Ext.create('Rally.data.QueryFilter',{
                                property: 'Parent.Parent',
                                operator: '=',
                                value: records[i].get("_ref")
                            }));                                
                        } else if (records[i].data.PortfolioItemTypeName == "Program") {    
                            filters = filters.or(Ext.create('Rally.data.QueryFilter',{
                                property: 'Parent.Parent.Parent',
                                operator: '=',
                                value: records[i].get("_ref")
                            }));    
                        }       
                    }
                }
                return filters; 
            },
            _drawCardBoard: function(that, filters){
                if (that.cardboard) {
                    that.cardboard.destroy();
                };
                var me = that;
                if (filters == null) {
                    filters = [];
                }
                me.cardboard = Ext.create('Rally.ui.cardboard.CardBoard',{
                    types: ['PortfolioItem/Feature'],
                    attribute: 'Release',
                    config: {globalVar: this.globalVar},
                    columnConfig: {
                        xtype: 'rallycardboardcolumn',
                        displayField: 'Name',
                        valueField: '_ref',
                        plugins: [
                            {ptype:'rallycolumndropcontroller'},
                            {ptype:'rallycardboardcardrecordprocessor'},
                            {ptype:'tscolumnheaderupdater'}  /*,
                            {ptype:'tscolumnheaderupdater', field_to_aggregate: 'LeafStoryPlanEstimateTotal'}*/
                        ],
                        storeConfig: { 
                            filters: filters,
                            context: this.getContext().getDataContext()
                        }                           
                    },
                    addColumn: function (columnConfig, index) {
                        console.log(columnConfig, index,"columnConfig, index");
                        var column = this._createColumnDefinition(columnConfig);
                        Ext.Array.insert(this.columnDefinitions, Ext.isNumber(index) ? index : this.columnDefinitions.length, [column]);
                        return column;
                    },                              
                    cardConfig: {
                        editable: true,             
                        showIconsAndHighlightBorder: false, 
                        showReadyIcon: true,
                        showBlockedIcon: true,
                        showColorIcon: true,
                        showPlusIcon: true,
                        showGearIcon: true,                         
                        fields: [
                            'FormattedID',
                            'Name',
                            'Parent',
                            'ReleaseDate',
                            'ReleaseStartDate',
                            { name: 'Project', renderer: me._renderProject },
                            { name: 'PercentDoneByStoryPlanEstimate' },
                            { name: 'PreliminaryEstimate', fetch: ['PreliminaryEstimate', 'Name'], renderTpl: Ext.create('Ext.XTemplate', '{PreliminaryEstimate.Name}')},
                            { name: 'LeafStoryPlanEstimateTotal', fetch: ['LeafStoryPlanEstimateTotal'], renderTpl: Ext.create('Ext.XTemplate', 'Plan Estimate Total: {LeafStoryPlanEstimateTotal}')}                               
                        ],
                    },
                    listeners: {
                        beforeShow: this._onTeamMembersLoaded,
                        added: function(card,container){
                            //card.set('DisplayColor', "blue");
                            me.logger.log(this,card,container);
                        },
                        fieldClick: function(eOpts) {
                            me.logger.log(this,eOpts);
                            if ( eOpts == "PercentDoneByStoryPlanEstimate" ) {
                                me._showDoneTooltip(eOpts,this);
                            }
                        },
                        scope: this
                    }
                });
            _getLocalReleases: function(retrievedColumns, today_iso) {
                var me = this; 
                if (today_iso == undefined) {
                    today_iso = Rally.util.DateTime.toIsoString(new Date(),false);
                }   
                var filters = [{property:'ReleaseDate',operator:'>',value:today_iso}];
                var iteration_names = [];
                Ext.create('Rally.data.WsapiDataStore',{
                    model:me.attribute,
                    autoLoad: true,
                    filters: filters,
                    context: { projectScopeUp: false, projectScopeDown: false },
                    sorters: [
                        {
                            property: 'ReleaseDate',
                            direction: 'ASC'
                        }
                    ],
                    //limit: Infinity,
                    pageSize: 4,
                    //buffered: true,
                    //purgePageCount: 4,
                    fetch: ['Name','ReleaseStartDate','ReleaseDate','PlannedVelocity'],
                    listeners: {
                        load: function(store,records) {
                            Ext.Array.each(records, function(record){
                                var start_date = Rally.util.DateTime.formatWithNoYearWithDefault(record.get('ReleaseStartDate'));
                                var end_date = Rally.util.DateTime.formatWithNoYearWithDefault(record.get('ReleaseDate'));
                                iteration_names.push(record.get('Name'));
                                //iteration_names.push(record.get('ReleaseDate'));
                                retrievedColumns.push({
                                    value: record,
                                    _planned_velocity: 0,
                                    _missing_estimate: false,
                                    columnHeaderConfig: {
                                        headerTpl: "{name}<br/>{start_date} - {end_date}",
                                        headerData: {
                                            name: record.get('Name'),
                                            start_date: start_date,
                                            end_date: end_date,
                                            planned_velocity: 0,
                                            missing_estimate: false
                                        }
                                    }
                                });
                            });
                            this._getAllReleases(retrievedColumns,iteration_names);
                        },
                        scope: this
                    }
                });
            },
            applyLocalFilters: function() {
                this.applyFilters(this.localFilters);
            },          
            _getAllReleases: function(retrievedColumns,iteration_names, today_iso) {
                var me = this; 
                if (today_iso == undefined) {
                    today_iso = Rally.util.DateTime.toIsoString(new Date(),false);
                }   
                var filters = [{property:'ReleaseDate',operator:'>',value:today_iso}];
                Ext.create('Rally.data.WsapiDataStore',{
                    model:me.attribute,
                    autoLoad: true,
                    filters: filters,
                    sorters: [
                        {
                            property: 'ReleaseDate',
                            direction: 'ASC'
                        }
                    ],
                    fetch: ['Name','Project','PlannedVelocity'],
                    listeners: {
                        load: function(store,records) {
                            Ext.Array.each(records, function(record){
                                var planned_velocity = record.get('PlannedVelocity') || 0;
                                var index = Ext.Array.indexOf(iteration_names[0],record.get('Name'));
                                if (planned_velocity == 0 ) {
                                    retrievedColumns[index+1]._missing_estimate = true;
                                }
                                retrievedColumns[index+1]._planned_velocity += planned_velocity;
                            });
                            this.fireEvent('columnsretrieved',this,retrievedColumns);
                            this.columnDefinitions = [];
                            _.map(retrievedColumns,this.addColumn,this);
                            this._renderColumns();
                        },
                        scope: this
                    }
                });
            },
            _createColumnDefinition: function (columnConfig) {
                var config = Ext.merge({
                    enableCrossColumnRanking: this.enableCrossColumnRanking
                }, this.columnConfig, columnConfig);

                var enableRanking = this.enableRanking;
                if (this.context) {
                    var workspace = this.context.getWorkspace();
                    if (workspace) {
                        enableRanking = enableRanking && workspace.WorkspaceConfiguration.DragDropRankingEnabled;
                    }
                }

                var listenersConfig = {
                    ready: this._onColumnReady,
                    select: this._onCardSelect,
                    deselect: this._onCardDeselect,
                    cardinvalid: this._onCardInvalid,
                    cardready: this._onCardReady,
                    scope: this
                };
                if (!this.serverSideFiltering) {
                    listenersConfig.filter = this.applyLocalFilters;
                }

                Ext.merge(config, {
                    cardConfig: Ext.clone(this.cardConfig),
                    columnHeaderConfig: Ext.clone(this.columnHeaderConfig),
                    model: this.models,
                    attribute: this.attribute,
                    storeConfig: Ext.clone(this.storeConfig),
                    enableRanking: enableRanking,
                    filterCollection: this.filterCollection ? this.filterCollection.clone() : undefined,
                    ownerCardboard: this,
                    listeners: listenersConfig,
                    ddGroup: this.ddGroup
                });

                if (this.readOnly) {
                    config.dropControllerConfig = false;
                }

                //merge configs, unioning collections
                var cardConfig = config.cardConfig;
                if (columnConfig.cardConfig) {
                    Ext.Object.merge(cardConfig, columnConfig.cardConfig);
                    cardConfig.fields = Ext.Array.merge(columnConfig.cardConfig.fields || [], this.cardConfig.fields || []);
                }
                var storeConfig = config.storeConfig;
                if (columnConfig.storeConfig) {
                    Ext.Object.merge(storeConfig, columnConfig.storeConfig);
                    storeConfig.filters = Ext.Array.merge(columnConfig.storeConfig.filters || [], this.storeConfig.filters || []);
                }
                console.log("columnConfig", Ext.clone(columnConfig));
                console.log("storeConfig", Ext.clone(storeConfig));
                return Ext.widget(config.xtype, config);
            },
        });

        Ext.override(Rally.ui.cardboard.Card,{
            _setupPlugins: function() {
                var cardContentRightPlugin = {ptype: 'rallycardcontentright'};

                this.plugins.push(cardContentRightPlugin);
                this.plugins.push({ptype: 'rallycardcontentleft'});

                if (this.record.get('updatable')) {
                    if (this.editable) {
                        this.addCls('editable');
                        this.plugins.push({ptype: 'rallycardediting'});

                        var predicateFn = Rally.predicate.RecordPredicates.hasField('PlanEstimate');
                        if (predicateFn(this.record) && Ext.Array.contains(this.getFields(), 'PlanEstimate')) {
                            cardContentRightPlugin.showPlanEstimate = true;
                        }

                        if (this.enableValidationUi) {
                            this.plugins.push({ptype: 'rallycardvalidation'});
                            this.plugins.push({ptype: 'rallycardvalidationui', notificationFieldNames: ['PlanEstimate']});
                        }
                    }

                    if (this.showIconsAndHighlightBorder) {
                        this.plugins.push({
                            ptype: 'rallycardicons',
                            showMenus: this.showIconMenus,
                            showColorPopover: this.showColorPopover
                        });
                    }
                }

                if (this.showAge > -1) {
                    this.plugins.push({ptype: 'rallycardage'});
                }

                this.plugins.push({ptype:'tscardreleasealignment'});
            }
        }),
        Ext.override(Rally.ui.cardboard.Column,{
            getStoreFilter: function(model) {
                var property = this.attribute;
                var value = this.getValue();
                if ( this.attribute == "Release" ) {
                    property = "Release.Name";
                    if ( value ) {
                        value = value.get('Name');
                    }
                }
                return {
                    property:property,
                    operator: '=',
                    value: value
                };
            },
            isMatchingRecord: function(record) {
                var recordValue = record.get(this.attribute);
                if (recordValue) {
                    recordValue = recordValue.Name;
                }
                var columnValue = this.getValue();
                if ( columnValue ) {
                    columnValue = columnValue.get('Name');
                }

                return (columnValue === recordValue );
            },
            addCard: function(card, index, highlight) {
                var record = card.getRecord();
                var target_value = this.getValue();
                if ( target_value && typeof(target_value.get) === "function" ) {
                    target_value = this.getValue().get('_ref');
                }
                record.set(this.attribute,target_value);
                if (target_value) {
                    record.set("PlannedStartDate",this.getValue().get('ReleaseStartDate'));
                    record.set("PlannedEndDate",this.getValue().get('ReleaseDate'));
                } else {    
                    record.set("PlannedStartDate",null);
                    record.set("PlannedEndDate",null);              
                }
                if (!Ext.isNumber(index)) {
                    //find where it should go
                    var records = Ext.clone(this.getRecords());
                    records.push(record);
                    this._sortRecords(records);

                    var recordIndex = 0;
                    for (var iIndex = 0, l = records.length; iIndex < l; iIndex++) {
                        var i = records[iIndex];
                        if (i.get("ObjectID") === record.get("ObjectID")) {
                            recordIndex = iIndex;
                            break;
                        }
                    }
                    index = recordIndex;
                }

                this._renderCard(card, index);

                if (highlight) {
                    card.highlight();
                }

                this.fireEvent('addcard');
                card.fireEvent('ready', card);
            },

0 个答案:

没有答案