-
Notifications
You must be signed in to change notification settings - Fork 87
/
addrepoextendeddataschema.html
120 lines (109 loc) · 3.62 KB
/
addrepoextendeddataschema.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
<div class="addrepoextendeddata">
<div class="well well-sm noschemas initialhide">
No (unused) extended data schemas available
</div>
<table class="table">
<thead>
<tr>
<th>Name</th>
<th>Content Type</th>
<th>Description</th>
<th>Add</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
<div class="well well-sm">
<button class="btn btn-default cancelButton">Cancel</button>
<button class="btn btn-primary addAllButton">Add all</button>
</div>
</div>
<script>
function AddRepoExtendedDataSchema(main, serversettings) {
var othis = this;
this.show = function(){};
this.close = function() {
};
this.addButtonClick = function() {
serversettings.showAddExtendedDataSchema($(this).parents("tr").data("extendeddataschema"));
};
this.addExtendedDataSchema = function(extendedDataSchema) {
var tr = $("<tr>");
var td = $("<td>");
if (extendedDataSchema.url != null && extendedDataSchema.url != "") {
var link = $("<a>");
link.html(extendedDataSchema.name);
link.attr("href", extendedDataSchema.url);
td.append(link);
} else {
td.append(extendedDataSchema.name);
}
tr.data("extendeddataschema", extendedDataSchema);
tr.append(td);
tr.append("<td>" + extendedDataSchema.contentType + "</td>");
tr.append("<td>" + extendedDataSchema.description + "</td>");
td = $("<td>");
var addButton = $("<button class=\"btn btn-default\">Add</button>");
addButton.click(othis.addButtonClick);
td.append(addButton);
tr.append(td);
$(".addrepoextendeddata table tbody").append(tr);
};
this.loadExtendedDataSchemas = function() {
var schemas = {};
Global.bimServerApi.call("ServiceInterface", "getAllExtendedDataSchemas", {}, function(extendedDataSchemas){
extendedDataSchemas.forEach(function(extendedDataSchema){
schemas[extendedDataSchema.name] = extendedDataSchema;
});
});
Global.bimServerApi.call("ServiceInterface", "getAllRepositoryExtendedDataSchemas", {usePre: false}, function(data){
$("addrepoextendeddata table tbody tr").remove();
data.forEach(function(extendedDataSchema){
if (schemas[extendedDataSchema.name] == null) {
othis.addExtendedDataSchema(extendedDataSchema);
}
});
if ($(".addrepoextendeddata .table tbody tr").length == 0) {
$(".addrepoextendeddata .noschemas").show();
$(".addrepoextendeddata .table").hide();
} else {
$(".addrepoextendeddata .noschemas").hide();
$(".addrepoextendeddata .table").show();
}
});
};
this.cancelClick = function(event) {
event.preventDefault();
main.showServerSettings(null, function(){
main.current.showExtendedDataSchemas();
});
};
this.addAllClick = function(){
var schemas = {};
Global.bimServerApi.call("ServiceInterface", "getAllExtendedDataSchemas", {}, function(extendedDataSchemas){
extendedDataSchemas.forEach(function(extendedDataSchema){
schemas[extendedDataSchema.name] = extendedDataSchema;
});
});
Global.bimServerApi.call("ServiceInterface", "getAllRepositoryExtendedDataSchemas", {usePre: false}, function(data){
var requests = [];
$("addrepoextendeddata table tbody tr").remove();
data.forEach(function(extendedDataSchema){
if (schemas[extendedDataSchema.name] == null) {
var request = [
"ServiceInterface", "addExtendedDataSchema", {extendedDataSchema: extendedDataSchema}
];
requests.push(request);
}
});
Global.bimServerApi.multiCall(requests, function(){
serversettings.showExtendedDataSchemas();
});
});
};
$(".addrepoextendeddata .cancelButton").click(othis.cancelClick);
$(".addrepoextendeddata .addAllButton").click(othis.addAllClick);
this.loadExtendedDataSchemas();
}
</script>