microsoft / vsts-extension-multivalue-control

A work item form control which allows selection of multiple values.
MIT License
47 stars 45 forks source link

Support for external values #18

Closed jjslagace closed 6 years ago

jjslagace commented 7 years ago

Hi,

This is more a question than an issue.

We currently use the former MultiValuecontrol from CodePlex on TFS2015. We plan on moving to TFS2017 and are looking for another multivalue control based on the new extension model that would support external suggested value from an URL or else.

Could you tell me if your extension currently support that?

Thank you

Stéphane

mmanela commented 7 years ago

Currently, this does not support pulling from a URL but that is an interesting idea. Currently, this control has two options: either it will pull the suggested values from a field you choose OR you can manually specify a list of values to use.

jjslagace commented 7 years ago

Thanks mmanela,

We currently use the MultivalueControl to identify wich of our customers is interrested by a specific feature.

Ideally, it would fetch the matching values only when the user types a few characters. We use the attributes in the control definition to specify the url.

It would be very nice to also get this from your control.

Stéphane

mmanela commented 7 years ago

It is an interesting use case but we have no immediate plans to add this functionality. I would recommend forking the extension and building your own version that has this functionality.

JFConklin commented 7 years ago

We have the same need - we'd like to bind values to the control via webapi. With the legacy custom controls, we are able to bind values from an external source. Is there any sort of binding mechanism in the new controls? Thanks! JC

mmanela commented 7 years ago

Well it is great to see other people have the same requirement. How would this work though? Would you just give a url? What would that URL return?

JFConklin commented 7 years ago

In the legacy extensions, in the _init function, we created a "bind" function that was tied to the _changed event. Like so:

_init: function () {
             this._base();
             this.controlListId = this._options.fieldName.replace("Jts.", "");
             this._control = $("<div class ='dropdown'><select id='" + this.controlListId + "'/></div>").appendTo(this._container);
             $(this._control).children("#" + this.controlListId).bind("change", delegate(this, this._changed));
         },

         bind: function (workItem) {
             this._base(workItem);
             var fd = this._getField(); var wk = this._workItem;
             if (typeof fd !== "undefined" && fd != null && typeof wk !== "undefined" && wk != null) {
                 this.getList(fd, wk);
             }
         };

The getList function made a $.ajax call to the url, which was stored in the DataProvider attribute in the control declaration in the workitem template.

`
 <Control FieldName="Acme.ProductGroupId" Type="ABC.ProductGroupList" Label="Product Group" LabelPosition="Left" 
DataProvider="/AcmeWebApi/AcmeData/ProductGroups">
<CustomControlOptions />
</Control>
`

So there are two key aspects to this working: 
1) the _changed Event and 
2) the DataProvider in the control in the workitem template.  

If both of these still exist, then hopefully we can figure out how to do binding in the new control.
mmanela commented 7 years ago

How would this deal with cross-origin calls?

@mohitbagra for thoughts

JFConklin commented 7 years ago

That I don't know. We are on-prem so we have a lot of leeway. We created an application called AcmeWebApi under the Team Foundation Server in IIS. That application makes the calls to our external source.

ostreifel commented 6 years ago

It appears that at the time of filing this extension did not exist but this issue should be satisfied by the Rest Multivalue Control