define require exports TFS WorkItemTracking Services VSS Controls VSS

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
define(["require", "exports", "TFS/WorkItemTracking/Services", "q", "VSS/Controls", "VSS/Controls/Combos"], function (require, exports, WitService, Q, Controls, Combos) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var Controller = (function () {
function Controller() {
this._initialize();
}
Controller.prototype._initialize = function () {
var _this = this;
_this.field;
_this.initField();
};
Controller.prototype._updateInternal = function (fieldName, value) {
var _this = this;
WitService.WorkItemFormService.getService().then(function (service) {
service.setFieldValue(fieldName, value);
});
};
Controller.prototype.initField = function () {
var container = $("#container");
var _this = this;
return WitService.WorkItemFormService.getService().then(function (service) {
var fieldName = VSS.getConfiguration().witInputs["FieldName"];
var isReadOnly = VSS.getConfiguration().witInputs["IsReadOnly"] == "true";
var action = VSS.getConfiguration().witInputs["Url"];
Q.spread([service.getFieldValue(fieldName)], function (currentValue) {
_this._api(action, currentValue).done(function (data) {
if(isReadOnly){
_this.field = $("<label>").html(data).appendTo(container);
}
else{
_this.field = $("#input").val(data);
$("#input-container").show();
}
})
})
})
}
Controller.prototype._api = function (url, data) {
return $.ajax({
type: "GET",
url: url + data,
crossDomain: true,
data: JSON.stringify(data),
dataType: "json",
contentType: "application/json;charset=utf-8"
});
}
return Controller;
}());
exports.Controller = Controller;
});