过滤看板上的史诗

时间:2012-04-03 19:24:09

标签: rally kanban

我首先要说的是我已阅读Rally Kanban - hiding Epic Stories,但我仍然无法根据Estimation Board应用中的过滤流程实施我的过滤器。目前我正在尝试将一个项目过滤器添加到我的纸板查询对象中。查询对象调用this._getItems以返回要过滤的项数组。据我所知,查询调用该函数,加载一两秒,然后不显示任何结果。欢迎任何意见,建议或替代解决方案。

这是我的代码

$that._redisplayBoard = function() {


            that._getAndStorePrefData(displayBoard);

            this._getItems = function(callback) {

            //Build types based on checkbox selections
            var queries = [];

                    queries.push({key:"HierarchicalRequirement",
                        type: "HierarchicalRequirement",
                        fetch: "Name,FormattedID,Owner,ObjectID,Rank,PlanEstimate,Children,Ready,Blocked",
                        order: "Rank"

                    });



            function bucketItems(results) {
                var items = [];

                rally.forEach(queries, function(query) {
                    if (results[query.key]) {
                        rally.forEach(results[query.key], function(item) {
                            //exclude epic stories since estimates cannot be altered
                            if ((item._type !== 'HierarchicalRequirement') ||
                                    (item._type === 'HierarchicalRequirement' && item.Children.length === 0)) {
                                items = items.concat(item);

                            }
                        });
      }
                });


               callback(items);
                }

                 rallyDataSource.findAll(queries, bucketItems);

            };

            function displayBoard() {

                artifactTypes = [];



                var cardboardConfig = {

                    types: [],

                    items: that._getItems,

                    attribute: kanbanField,

                    sortAscending: true,

                    maxCardsPerColumn: 200,

                    order: "Rank",

                    cardRenderer: KanbanCardRenderer,

                    cardOptions: {

                        showTaskCompletion: showTaskCompletion,

                        showAgeAfter: showAgeAfter

                    },

                    columnRenderer: KanbanColumnRenderer,

                    columns: columns,

                    fetch: "Name,FormattedID,Owner,ObjectID,Rank,Ready,Blocked,LastUpdateDate,Tags,State,Priority,StoryType,Children"

                };



                if (showTaskCompletion) {

                    cardboardConfig.fetch += ",Tasks";

                }



                if (hideLastColumnIfReleased) {

                    cardboardConfig.query = new rally.sdk.util.Query("Release = null").or(kanbanField + " != " + '"' + lastState + '"');

                }



                if (filterByTagsDropdown && filterByTagsDropdown.getDisplayedValue()) {

                    cardboardConfig.cardOptions.filterBy = { field: FILTER_FIELD, value: filterByTagsDropdown.getDisplayedValue() };

                }



                cardboardConfig.types.push("HierarchicalRequirement");



                if (cardboard) {

                    cardboard.destroy();

                }



                artifactTypes = cardboardConfig.types;






                cardboard = new rally.sdk.ui.CardBoard(cardboardConfig, rallyDataSource);




                cardboard.addEventListener("preUpdate", that._onBeforeItemUpdated); 
                cardboard.addEventListener("onDataRetrieved", function(cardboard,args){ console.log(args.items); }); 

                cardboard.display("kanbanBoard");

            }

        };


        that.display = function(element) {



            //Build app layout

            this._createLayout(element);



            //Redisplay the board

            this._redisplayBoard();

        };

    };

3 个答案:

答案 0 :(得分:2)

Charles'提示Rally Kanban - hiding Epic Stories

这是我在Charles'之后接近这个问题的方法。提示拉力赛目录看板。首先,修改cardboardConfig中的fetch语句,使其包含Children集合,因此:

      fetch: "Name,FormattedID,Children,Owner,ObjectID,Rank,Ready,Blocked,LastUpdateDate,Tags,State"

接下来,在这句话之间:

      cardboard.addEventListener("preUpdate", that._onBeforeItemUpdated);   

这句话:

     cardboard.display("kanbanBoard");

添加以下事件侦听器和回调:

    cardboard.addEventListener("onDataRetrieved", 
        function(cardboard, args){
            // Grab items hash
            filteredItems = args.items;

            // loop through hash keys (states)
            for (var key in filteredItems) {

                // Grab the workproducts objects (Stories, defects)                 
                workproducts = filteredItems[key];
                // Array to hold filtered results, childless work products
                childlessWorkProducts = new Array();
                // loop through 'em and filter for the childless
                for (i=0;i<workproducts.length;i++) {
                    thisWorkProduct = workproducts[i];                      
                    // Check first if it's a User Story, since Defects don't have children
                    if (thisWorkProduct._type == "HierarchicalRequirement") {
                        if (thisWorkProduct.Children.length === 0 ) {
                            childlessWorkProducts.push(thisWorkProduct);
                        }
                    } else {
                        // If it's a Defect, it has no children so push it
                        childlessWorkProducts.push(thisWorkProduct);
                    } 
                }
                filteredItems[key] = childlessWorkProducts;
            }
            // un-necessary call to cardboard.setItems() was here - removed
        }
    );

此回调应仅过滤叶节点项。

答案 1 :(得分:1)

不确定这是您的问题,但您的纸板配置未设置“查询”问题。领域。 fetch是要检索的所有数据的类型,如果要过滤它,则添加&#34;查询:&#34;配置对象的值。 类似的东西:

        var cardboardConfig = {
         types: ["PortfolioItem", "HierarchicalRequirement", "Feature"],
         attribute: dropdownAttribute,
         fetch:"Name,FormattedID,Owner,ObjectID,ClassofService",
         query : fullQuery,
         cardRenderer: PriorityCardRenderer
    };

可以使用Rally查询对象构造fullQuery。您可以通过在SDK中搜索找到它。希望这可能有所帮助。

答案 2 :(得分:1)

当调用cardboard.setItems(filteredItems)时,Mark的回答导致了一个模糊的崩溃。但是,由于过滤代码实际上是在操纵实际引用,因此实际上并不需要setItems()方法。我把它拉了出来,现在它已经过滤了。