-
Notifications
You must be signed in to change notification settings - Fork 87
/
branch.html
95 lines (90 loc) · 3.31 KB
/
branch.html
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<div class="branch">
<div class="modal-header">
<a class="close" data-dismiss="modal">×</a>
<h3>Branch</h3>
</div>
<div class="modal-body">
<label class="radio">To existing project<input class="existingRadio" type="radio" name="to" value="existing"/></label>
<label class="radio">To new project<input class="newRadio" type="radio" name="to" value="new"/></label>
<form class="form-horizontal">
<div class="form-group projectGroup">
<label class="projectLabel control-label">Project</label>
<div class="controls">
<select class="projectsSelect"></select>
</div>
</div>
<div class="form-group projectnameGroup">
<label class="projectNameLabel control-label">Project name</label>
<div class="controls">
<input type="text" class="projectName"/>
</div>
</div>
<div class="form-group commentGroup">
<label class="commentLabel control-label">Comment</label>
<div class="controls">
<input type="text" class="comment"/>
</div>
</div>
</form>
</div>
<div class="modal-footer">
<a class="btn btn-default closeButton" style="margin-right: 8px" data-dismiss="modal">Close</a>
<a class="branchButton btn btn-primary" style="margin-right: 8px" data-dismiss="modal">Branch</a>
</div>
</div>
<script>
function Branch(containerDiv, main, roid) {
var othis = this;
this.radioChange = function(){
var val = containerDiv.find("input[type=radio]:checked").val();
if (val == "existing") {
containerDiv.find(".projectGroup").show();
containerDiv.find(".projectnameGroup").hide();
containerDiv.find(".commentGroup").show();
} else if (val == "new") {
containerDiv.find(".projectGroup").hide();
containerDiv.find(".projectnameGroup").show();
containerDiv.find(".commentGroup").show();
} else {
containerDiv.find(".projectGroup").hide();
containerDiv.find(".projectnameGroup").hide();
containerDiv.find(".commentGroup").hide();
}
};
this.branch = function(){
var val = containerDiv.find("input[type=radio]:checked").val();
if (val == "existing") {
Global.bimServerApi.call("ServiceInterface", "branchToExistingProject", {
roid: roid,
destPoid: containerDiv.find(".projectsSelect").val(),
comment: containerDiv.find(".comment").val(),
sync: true
}, function(topicId){
Global.bimServerApi.call("ServiceInterface", "getLongActionState", {topicId: topicId}, function(data){
console.log(data.state);
});
});
} else if (val == "new") {
Global.bimServerApi.call("ServiceInterface", "branchToNewProject", {
roid: roid,
projectName: containerDiv.find(".projectName").val(),
comment: containerDiv.find(".comment").val(),
sync: true
}, function(topicId){
Global.bimServerApi.call("ServiceInterface", "getLongActionState", {topicId: topicId}, function(data){
console.log(data.state);
});
});
}
};
Global.bimServerApi.call("ServiceInterface", "getAllProjects", {onlyTopLevel: false, onlyActive: true}, function(projects){
projects.forEach(function(project){
var option = $("<option value=\"" + project.oid + "\">" + project.name + "</option>");
containerDiv.find(".projectsSelect").append(option);
});
});
containerDiv.find(".existingRadio, .branch .newRadio").change(othis.radioChange);
containerDiv.find(".branchButton").click(othis.branch);
othis.radioChange();
}
</script>