如何在工作项配置中创建一个按钮(调用JS代码)?

huangapple go评论120阅读模式
英文:

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> 

然而,我无法在包含其他ControlsGroup中使用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>

huangapple
  • 本文由 发表于 2023年7月31日 22:43:04
  • 转载请务必保留本文链接:https://go.coder-hub.com/76804709.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定