gpt4 book ai didi

javascript - 所有者下拉列表不过滤故事纸板

转载 作者:行者123 更新时间:2023-11-28 09:23:18 25 4
gpt4 key购买 nike

我构建了一个自定义纸板混搭来显示“已提交”迭代中且属于当前项目或任何子项目的所有用户故事。这一点效果很好。然后,我添加了一个所有者下拉框(仅限团队成员),以过滤纸板上的故事。生成的查询值似乎格式良好,但没有显示任何故事。我使用警报复制查询字符串并将其粘贴到自定义网格中,该网格返回了预期的故事列表。

下面是我的代码。如有任何帮助,我们将不胜感激。




        var rallyDataSource;
var cardboard;
var ownerDropdown;

function refreshCardboard() {

var cardboardConfig = {
types: ["Defect", "HierarchicalRequirement"],
attribute: "ScheduleState",
fetch: "Name,FormattedID,Owner,ObjectID"
};

var query = rally.sdk.util.Query.and(['Iteration.Name != ""', 'Iteration.State = "Committed"']);

if (ownerDropdown) {
var ownerQuery = ownerDropdown.getValue();
if (ownerQuery != 'ALL') {
query = '(' + query + ' AND Owner.Name = "' + ownerQuery + '")';
}
}

cardboardConfig.query = query;
if (!cardboard) {
cardboard = new rally.sdk.ui.CardBoard(cardboardConfig, rallyDataSource);
cardboard.display("cardboardDiv");
} else {
cardboard.refresh(cardboardConfig);
}
}

function buildOwnerDropdown() {

var teamMembersQuery = {
key: "teamMembers",
type: "User",
fetch: "UserName,DisplayName",
query: '(TeamMemberships = /project/__PROJECT_OID__)'
};

rallyDataSource.findAll(teamMembersQuery, function (results) {

var ownerItems = [{ label: "-- ALL --", value: "ALL"}];
rally.forEach(results.teamMembers, function (teamMember) {
ownerItems.push({ label: teamMember.DisplayName, value: teamMember.UserName });
});

ownerItems.sort();

var ownerDropdownConfig = {
showLabel: true,
label: "Owner:",
items: ownerItems
};

ownerDropdown = new rally.sdk.ui.basic.Dropdown(ownerDropdownConfig);
ownerDropdown.display("ownerDropdownDiv");
});
}

function onLoad() {

rallyDataSource = new rally.sdk.data.RallyDataSource(
'__WORKSPACE_OID__',
'__PROJECT_OID__',
'__PROJECT_SCOPING_UP__',
'__PROJECT_SCOPING_DOWN__');

buildOwnerDropdown();

refreshCardboard();
}

rally.addOnLoad(onLoad);

</script>

</head>
<body>
<div id="ownerDropdownDiv"></div>
<input id="refreshButton" type="button" value="Filter" onclick="refreshCardboard()"/>
<div id="cardboardDiv"></div>
</body>

最佳答案

你真的很接近目标 - 问题就在这里:

        var query = rally.sdk.util.Query.and(['Iteration.Name != ""', 'Iteration.State = "Committed"']);

if (ownerDropdown) {
var ownerQuery = ownerDropdown.getValue();
if (ownerQuery != 'ALL') {
query = '(' + query + ' AND Owner.Name = "' + ownerQuery + '")';
}
}

在添加另一个 AND 条件时,Rally 的查询语法需要另一组嵌套的括号。因此,当您连接第三个条件时,您最终会得到一个如下所示的查询子句:

((Iteration.Name != "") AND (Iteration.State = "已提交")) AND (Owner.Name = "user@company.com")

当它需要看起来像这样时:

(((Iteration.Name != "") AND (Iteration.State = "已提交")) AND (Owner.Name = "user@company.com"))

我稍微修改了您的refreshCardboard()函数的查询逻辑,如下所示,您的代码现在似乎对我有用。

    ....        
var queryArray = new Array('Iteration.Name != ""', 'Iteration.State = "Committed"');
var query;

var selectedOwner = ownerDropdown.getValue();

if (ownerDropdown) {
if (selectedOwner != 'ALL') {
var ownerClause = 'Owner.Name = "' + selectedOwner + '"';
queryArray.push(ownerClause);
}
}

query = rally.sdk.util.Query.and(queryArray);

cardboardConfig.query = query;
....

关于javascript - 所有者下拉列表不过滤故事纸板,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14716080/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com