Jira Gadget:未保存配置以供重新配置
我正在为 Jira 编写一个带有一些配置选项的小工具。这些配置选项之一是“项目或过滤器选择器”。
我的问题在于当我想重新配置小工具的首选项时。我已经阅读了 timessince-gadget 的代码作为示例,我认为相关部分如下:
if (/^jql-/.test(gadget.getPref("projectOrFilterId"))){
projectAndFilterPicker =
{
userpref: "projectOrFilterId",
type: "hidden",
value: gadgets.util.unescapeString(this.getPref("projectOrFilterId"))
};
} else {
projectAndFilterPicker = AJS.gadget.fields.projectOrFilterPicker(gadget, "projectOrFilterId", args.options);
}
基本上我已经从 timessince-gadget 复制了代码。不幸的是,即使已经配置,JavaScript 总是进入 else 部分。
问题是,我没有使用 jql 的经验,也不完全理解 if 子句。
但通常(例如,当调用其余 api 并处理配置信息时)
gadget.getPref("projectOrFilterId")
返回一个包含所选项目或过滤器 id 的字符串。
现在的问题是:如何让我的小工具记住最后的配置,就像其他一些 Jira 小工具所做的那样?
我真的希望任何人都可以帮助我。
I am writing a gadget for Jira with some configuration options. One of these configuration options is a "project or filter picker".
My problem lies in the part, when I want to reconfigure the gadget's preferences. I have read the code of the timesince-gadget as an example and I think the relevant part is the following:
if (/^jql-/.test(gadget.getPref("projectOrFilterId"))){
projectAndFilterPicker =
{
userpref: "projectOrFilterId",
type: "hidden",
value: gadgets.util.unescapeString(this.getPref("projectOrFilterId"))
};
} else {
projectAndFilterPicker = AJS.gadget.fields.projectOrFilterPicker(gadget, "projectOrFilterId", args.options);
}
Basicly I've copied the code from the timesince-gadget. Unfortunately even if already configured, the javascript always enters the else part.
A problem is, that I ve no experience with jql and don't totally understand the if clause.
But usually (e.g. when calling the rest api and processing the config infos)
gadget.getPref("projectOrFilterId")
returns a string containing the id of the picked project or filter.
Question is now: How can I make my gadget remember the last configuration like it's done with some many other Jira gadgets?
I really hope anyone can help me with that.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
事实证明,答案比我想象的还要简单。
第一:在描述符中,您可以完全忘记上面的 if 部分。正是
需要的。
第二:在休息资源中检索项目或过滤器的名称,这应该不是问题,因为您已经想要使用处理后的 ID。然后将此名称返回到 JavaScript 的视图部分并输入类似的内容
And tada: reconfiguration 将显示旧的配置名称!
It turnes out, the answer is even simplier then I thought.
First: In the descriptor you can totally forget the if part from above. Just
is needed.
Second: Retrieve the project's or filter's name in your rest resource, which shouldn't be a problem, since you already want to use the processed id. Then return this name back to the view part of your javascript and type in something like
And tada: reconfiguration will display the old configured name!
当我忘记在 Gadget XML 文件中指定选项时,我遇到了这个问题。我通过将以下内容添加到 XML 来解决这个问题:
I had this problem once when I forgot to specify the option in the Gadget XML file. I solved it by adding this to the XML: