Skip to content

Commit 5588f4b

Browse files
committed
Compatibility with new folder structure and multiple layout support
1 parent 261eafa commit 5588f4b

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

assets/javascripts/gtt_print.js

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@ $(function() {
44

55
if ($('form.print_box').length > 0) {
66
var server = $('form.print_box').attr('action').replace(/\/?$/, '/');
7+
var tracker = $('select#issue_tracker_id option:selected').text();
78

89
$.getJSON(server + "print/apps.json", function (data) {
910
$.each(data, function(key, value) {
1011
// "default" profile does not really work for some reason
11-
if (value != "default" && value.split("_")[0] != "DEMO") {
12-
var option = $("<option></option>").attr("value",value).text(value.split("_")[1]);
12+
if (value === tracker) {
13+
var option = $("<option></option>").attr("value",value).text(value);
1314
$('form.print_box select[name=template]').append(option);
1415
}
1516
});
@@ -22,7 +23,7 @@ $(function() {
2223
apikey = $('#content > div.box > pre', $(data)).first().text();
2324
});
2425

25-
$('form.print_box select').on('change', function (e) {
26+
$('form.print_box select[name=template]').on('change', function (e) {
2627
$.ajax({
2728
type: 'GET',
2829
url: server + "print/" + $('form.print_box select').val() + "/capabilities.json",
@@ -52,7 +53,8 @@ $(function() {
5253
url: server + "print/" + appId + "/exampleRequest.json",
5354
dataType: 'json',
5455
success: function (data) {
55-
requestPrint(appId, capabilities, JSON.parse(data.requestData));
56+
var layout = $('form.print_box select[name=layout] option:selected').text();
57+
requestPrint(appId, capabilities, JSON.parse(data[layout]));
5658
}
5759
});
5860
});
@@ -63,11 +65,6 @@ $(function() {
6365
var format = $('form.print_box select[name=format]').val();
6466
var layout = $('form.print_box select[name=layout]').val();
6567

66-
// var paramObj = {};
67-
// $.each($('#issue-form').serializeArray(), function(_, kv) {
68-
// paramObj[kv.name] = kv.value;
69-
// });
70-
7168
$.ajax({
7269
type: 'GET',
7370
url: $('#issue-form').attr("action") + ".json",

0 commit comments

Comments
 (0)