简体   繁体   English

如何使用户能够在内部部署TFS 2015中编辑HtmlFieldControl源?

[英]How to enable users to edit HtmlFieldControl source in TFS 2015 on-premise?

If you insert an image into the 'Description' HtmlFieldControl when editing a work item, then the html img src attribute will have an absolute url like <img src='http://mytfsserver:8080/tfs/dc/_api/_wit/DownloadAttachment?fileGuid=03e65645..." .. > 如果在编辑工作项时将图像插入“说明” HtmlFieldControl,则html img src属性将具有绝对URL,例如<img src='http://mytfsserver:8080/tfs/dc/_api/_wit/DownloadAttachment?fileGuid=03e65645..." .. >

Images then wont be shown when working with a reverse proxy, where users from outside our company access our tfs with an url like ' https://tfs.mycompany.com/tfs ', because from outside there is no access to ' http://mytfsserver:8080/tfs ' 然后,当使用反向代理时,图像将不会显示,其中来自公司外部的用户使用' https://tfs.mycompany.com/tfs '之类的URL访问我们的tfs,因为无法从外部访问' http: // mytfsserver:8080 / tfs '

My idea is now to convert the absolute url to a relative one, like <img src='/tfs/dc/_api/_wit/DownloadAttachment?fileGuid=03e65645..." .. > . After editing the html of the System.Description field manually and save it, the image gets shown properly shown as well from inside tfs users as to external users who use the reverse proxy. 我的想法是现在将绝对URL转换为相对URL,例如<img src='/tfs/dc/_api/_wit/DownloadAttachment?fileGuid=03e65645..." .. > 。在编辑系统的html之后。手动保存并在“描述”字段中保存,从tfs用户内部以及使用反向代理的外部用户可以正确显示图像。

I found out a VSTS extension can react on an onFieldChanged event, and I want to change the img src accordingly in the html of System.Descripton field. 我发现VSTS扩展可以对onFieldChanged事件做出反应,并且我想在System.Descripton字段的html中相应地更改img src。

Since TFS 2017 there is a new element called 'WebLayout and Control elements', which would be the perfect approach. 从TFS 2017开始,有一个名为'WebLayout and Control elements'的新元素,这将是完美的方法。 Unfortunately, our company still uses TFS 2015 on-premise, and the update will be done not earlier than end of this year. 不幸的是,我们公司仍在内部使用TFS 2015,并且更新将在今年年底之前完成。

So my question is , can I use an already existing way to develop functionality to provide automatically or manually replace the absolute with the relative url? 所以我的问题是 ,我可以使用一种现有的方式来开发功能来自动提供还是手动用相对URL替换绝对值?

I found no way to use VSTS extensions ON an existing work item form with TFS 2015. And it seems to be impossible to enhance the default HtmlFieldControl. 我发现没有办法用VSTS扩展现有的工作项形式TFS 2015年。它似乎是不可能的提升默认HtmlFieldControl。 Or could I write a customized HtmlFieldControl? 还是可以编写自定义的HtmlFieldControl?

It is not possible to put another control like 'FieldControl' for System.Description onto the wit form, it's not supported. 无法将其他控件(如System.Description的“ FieldControl”)放置到wit表单上,不支持该控件。 It would be tedious to edit the html by hand always after inserting an image in the HtmlFieldControl, save it, reload and edit it in the plain FieldControl. 在将图像插入HtmlFieldControl之后,总是手动编辑html,将其保存,重新加载并在普通的FieldControl中进行编辑将很繁琐。 But even that would be accepted as a workaround. 但是,即使那样也可以作为解决方法。

Finally it easy: 最后很容易:

var descriptionField = that._workItem.getField("System.Description");
var descriptionHTML = descriptionField._getValue().toString();
...
descriptionHTML = descriptionHTML.replace(toReplace,replaceWith);
descriptionField.setValue(descriptionHTML);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM