-
Notifications
You must be signed in to change notification settings - Fork 87
/
Copy pathaddproject.html
141 lines (130 loc) · 4.5 KB
/
addproject.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
<div class="addproject">
<form class="form-horizontal" role="form">
<div class="form-group">
<label class="col-lg-3 control-label" for="inputName">Name</label>
<div class="col-lg-5">
<input type="text" id="inputName" class="form-control inputName" placeholder="Name">
</div>
</div>
<div class="form-group">
<label class="col-lg-3 control-label" for="descriptionInput">Description</label>
<div class="col-lg-5">
<textarea class="descriptionInput form-control span6" id="descriptionInput" placeholder="Description" cols="60" rows="7"></textarea>
</div>
</div>
<div class="form-group">
<label class="col-lg-3 control-label" for="lengthMeasureInput">Uniform length measure for combined download</label>
<div class="col-lg-5">
<select class="lengthMeasureInput form-control span6" id="lengthMeasureInput">
<option>meter</option>
<option>attometer</option>
<option>femtometer</option>
<option>picometer</option>
<option>nanometer</option>
<option>micrometer</option>
<option>millimeter</option>
<option>centimeter</option>
<option>decimeter</option>
<option>decameter</option>
<option>hectometer</option>
<option>kilometer</option>
<option>megameter</option>
<option>gigameter</option>
<option>terameter</option>
<option>petameter</option>
<option>exameter</option>
</select>
</div>
</div>
<div class="form-group schemaGroup">
<label class="col-lg-3 control-label" for="schema">Schema</label>
<div class="col-lg-5">
<select class="schemaInput form-control span6" id="schema">
<option value="ifc2x3tc1">Ifc2x3tc1</option>
<option value="ifc4">Ifc4</option>
</select>
</div>
</div>
<div class="well well-small buttonBar">
<button type="button" class="btn btn-primary addButton">Add</button>
</div>
</form>
</div>
<div id="warning" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="confirmationModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="warningLabel">Subproject</h4>
</div>
<div class="modal-body">
<p>Parent project has concrete revisions. Do you still want to add a subproject?</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" id="cancel">Cancel</button>
<button type="button" class="btn btn-primary" data-dismiss="modal">OK</button>
</div>
</div>
</div>
</div>
<script>
function AddProject(containerDiv, main, parentProject) {
var othis = this;
var history = History.getState().data;
if (parentProject!=null && parentProject.concreteRevisions.length>0) {
const modal = containerDiv.find("#warning");
modal.modal({
backdrop: "static",
keyboard: false
});
modal.find("#cancel").click(function () {
$("#warning").modal("hide");
$(".modal-backdrop").remove();
window.history.back();
});
}
this.show = function(){
if (parentProject != null && parentProject.schema == "ifc4") {
containerDiv.find(".schemaInput").val("ifc4");
}
};
this.close = function(){
};
this.updateProject = function(project) {
project.description = $(".descriptionInput").val();
project.exportLengthMeasurePrefix = $(".lengthMeasureInput").val();
Global.bimServerApi.call("ServiceInterface", "updateProject", {sProject: project}, function(){
main.showProject(project.oid, null, true);
});
};
this.addProject = function() {
if (parentProject != null) {
Global.bimServerApi.callWithFullIndication("ServiceInterface", "addProjectAsSubProject", {
schema: $(".schemaInput").val(),
parentPoid: parentProject.oid,
projectName: $(".addproject .inputName").val()
}, function(data){
othis.updateProject(data);
});
} else {
Global.bimServerApi.callWithFullIndication("ServiceInterface", "addProject", {
schema: $(".schemaInput").val(),
projectName: $(".addproject .inputName").val()
}, function(data){
othis.updateProject(data);
});
}
};
$(".addproject .addButton").click(othis.addProject);
$(".addproject .inputName").keypress(function(event){
if (event.which == 13) {
event.preventDefault();
othis.addProject();
}
});
$(".addproject .inputName").focus();
window.addEventListener("popstate", function (event) {
$("#warning").modal("hide");
$(".modal-backdrop").remove();
});
}
</script>