英文:
How to create a button (calling JS code) in a work item configuration?
问题
我想在工作项的XML定义中添加一个可点击的按钮。目前,工作项定义的(感兴趣的部分是):
<Section>
<Group Label="*****">
<Control Label="*****" Type="FieldControl" FieldName="*****" />
<Control Label="*****" Type="LabelControl">
<Link UrlRoot="http://*****.html" />
</Control>
</Group>
</Section>
我成功创建了一个按钮,使用Type="WebpageControl"
:
<Control Type="WebpageControl">
<WebpageControlOptions>
<Content>
<![CDATA[<button><a target="_blank" onclick="console.log('test');"><b>Testt</b></a></button>]]>
</Content>
</WebpageControlOptions>
</Control>
然而,我无法在包含其他Controls
的Group
中使用Type="WebpageControl"
。是否有办法让我的按钮直接放在与其他Controls
相同的Group
中?我还尝试过使用Type="LabelControl"
,但无法成功调用JavaScript。否则,是否有解决方法?
英文:
I'd like to add a clickable button to the XML definition of a work item. Currently, the (interesting part of the) work item definition is:
<Section>
<Group Label="*****">
<Control Label="*****" Type="FieldControl" FieldName="*****" />
<Control Label="*****" Type="LabelControl">
<Link UrlRoot="http://*****.html" />
</Control>
</Group>
</Section>
I managed to create a button using Type="WebpageControl"
:
<Control Type="WebpageControl">
<WebpageControlOptions>
<Content>
<![CDATA[<button><a target="_blank" onclick="console.log('test');"><b>Testt</b></a></button>]]>
</Content>
</WebpageControlOptions>
</Control>
However, I can't use Type="WebpageControl"
in a Group
containing other Controls
. Is there a way to have my button directly in the same Group
as the other Controls
? I also tried using Type="LabelControl"
but I failed to call JS with it. Otherwise, is there a workaround ?
答案1
得分: 0
感谢 @Daniel Mann,我查找了一个扩展,并使用了 Work Item REST Request Button,通过它我能够定义一个按钮如下所示:
<ControlContribution Label="*****" Id="Apodemus.RESTRequestButton.RESTRequestButton">
<Inputs>
<Input Id="ButtonTitle" Value="*****" />
<Input Id="Fields" Value="System.Title, System.AssignedTo" />
<Input Id="Endpoint" Value="https://*****.com:*****/my/api" />
<Input Id="SendUser" Value="true" />
<Input Id="ShowResponseBody" Value="true" />
<Input Id="Method" Value="POST" />
</Inputs>
</ControlContribution>
英文:
Thanks to @Daniel Mann, I looked for an extension, and used Work Item REST Request Button, with which I was able to define a button like this:
<ControlContribution Label="*****" Id="Apodemus.RESTRequestButton.RESTRequestButton">
<Inputs>
<Input Id="ButtonTitle" Value="*****" />
<Input Id="Fields" Value="System.Title, System.AssignedTo" />
<Input Id="Endpoint" Value="https://*****.com:*****/my/api" />
<Input Id="SendUser" Value="true" />
<Input Id="ShowResponseBody" Value="true" />
<Input Id="Method" Value="POST" />
</Inputs>
</ControlContribution>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论