Use the REST API in the web interface for editing jobsets
This commit is contained in:
@ -44,7 +44,7 @@
|
||||
</table>
|
||||
[% END %]
|
||||
|
||||
<form class="form-horizontal" action="[% IF create %][% c.uri_for('/project' project.name 'create-jobset/submit') %][% ELSE %][% c.uri_for('/jobset' project.name jobset.name 'submit') %][% END %]" method="post">
|
||||
<form class="form-horizontal">
|
||||
|
||||
<fieldset>
|
||||
|
||||
@ -132,7 +132,7 @@
|
||||
[% INCLUDE renderJobsetInputs %]
|
||||
|
||||
<div class="form-actions">
|
||||
<button type="submit" class="btn btn-primary"><i class="icon-ok icon-white"></i> [%IF create %]Create[% ELSE %]Apply changes[% END %]</button>
|
||||
<button id="submit-jobset" type="submit" class="btn btn-primary"><i class="icon-ok icon-white"></i> [%IF create %]Create[% ELSE %]Apply changes[% END %]</button>
|
||||
</div>
|
||||
|
||||
</fieldset>
|
||||
@ -145,26 +145,42 @@
|
||||
[% INCLUDE renderJobsetInputAlt alt=alt %]
|
||||
</tt>
|
||||
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
var id = 0;
|
||||
|
||||
$(".add-input").click(function() {
|
||||
var newid = "input-" + id++;
|
||||
var x = $("#input-template").clone(true).attr("id", "").insertBefore($(this).parents("tr")).show();
|
||||
$("#input-template-name", x).attr("name", newid + "-name");
|
||||
$("#input-template-type", x).attr("name", newid + "-type");
|
||||
$("#input-template", x).attr("id", newid);
|
||||
return false;
|
||||
});
|
||||
|
||||
$(".add-inputalt").click(function() {
|
||||
var x = $("#inputalt-template").clone(true).insertBefore($(this)).attr("id", "").show();
|
||||
$("input", x).attr("name", x.parents(".inputalts").attr("id") + "-values");
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
</form>
|
||||
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
var id = 0;
|
||||
|
||||
$(".add-input").click(function() {
|
||||
var newid = "input-" + id++;
|
||||
var x = $("#input-template").clone(true).attr("id", "").insertBefore($(this).parents("tr")).show();
|
||||
$("#input-template-name", x).attr("name", newid + "-name");
|
||||
$("#input-template-type", x).attr("name", newid + "-type");
|
||||
$("#input-template", x).attr("id", newid);
|
||||
return false;
|
||||
});
|
||||
|
||||
$(".add-inputalt").click(function() {
|
||||
var x = $("#inputalt-template").clone(true).insertBefore($(this)).attr("id", "").show();
|
||||
$("input", x).attr("name", x.parents(".inputalts").attr("id") + "-values");
|
||||
});
|
||||
});
|
||||
|
||||
$("#submit-jobset").click(function() {
|
||||
requestJSON({
|
||||
[% IF create %]
|
||||
url: "[% c.uri_for('/jobset' project.name '.new') %]",
|
||||
[% ELSE %]
|
||||
url: "[% c.uri_for('/jobset' project.name jobset.name) %]",
|
||||
[% END %]
|
||||
data: $(this).parents("form").serialize(),
|
||||
type: 'PUT',
|
||||
success: function(data) {
|
||||
window.location = data.redirect;
|
||||
},
|
||||
});
|
||||
return false;
|
||||
});
|
||||
</script>
|
||||
|
||||
[% END %]
|
||||
|
@ -57,23 +57,6 @@
|
||||
<button id="submit-project" type="submit" class="btn btn-primary">
|
||||
<i class="icon-ok icon-white"></i>
|
||||
[%IF create %]Create[% ELSE %]Apply changes[% END %]
|
||||
<script type="text/javascript">
|
||||
$("#submit-project").click(function() {
|
||||
requestJSON({
|
||||
[% IF create %]
|
||||
url: "[% c.uri_for('/project' '.new') %]",
|
||||
[% ELSE %]
|
||||
url: "[% c.uri_for('/project' project.name) %]",
|
||||
[% END %]
|
||||
data: $(this).parents("form").serialize(),
|
||||
type: 'PUT',
|
||||
success: function(data) {
|
||||
window.location = data.redirect;
|
||||
},
|
||||
});
|
||||
return false;
|
||||
});
|
||||
</script>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
@ -81,4 +64,23 @@
|
||||
|
||||
</form>
|
||||
|
||||
<script type="text/javascript">
|
||||
$("#submit-project").click(function() {
|
||||
requestJSON({
|
||||
[% IF create %]
|
||||
url: "[% c.uri_for('/project' '.new') %]",
|
||||
[% ELSE %]
|
||||
url: "[% c.uri_for('/project' project.name) %]",
|
||||
[% END %]
|
||||
data: $(this).parents("form").serialize(),
|
||||
type: 'PUT',
|
||||
success: function(data) {
|
||||
window.location = data.redirect;
|
||||
},
|
||||
});
|
||||
return false;
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
[% END %]
|
||||
|
@ -74,7 +74,7 @@ $(document).ready(function() {
|
||||
|
||||
var tabsLoaded = {};
|
||||
|
||||
var makeLazyTab = function(tabName, uri) {
|
||||
function makeLazyTab(tabName, uri) {
|
||||
$('.nav-tabs').bind('show', function(e) {
|
||||
var pattern = /#.+/gi;
|
||||
var id = e.target.toString().match(pattern)[0];
|
||||
@ -87,9 +87,13 @@ var makeLazyTab = function(tabName, uri) {
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
var requestJSON = function(args) {
|
||||
function escapeHTML(s) {
|
||||
return $('<div/>').text(s).html();
|
||||
};
|
||||
|
||||
function requestJSON(args) {
|
||||
args.dataType = 'json';
|
||||
args.error = function(data) {
|
||||
json = {};
|
||||
@ -99,18 +103,18 @@ var requestJSON = function(args) {
|
||||
} catch (err) {
|
||||
}
|
||||
if (json.error)
|
||||
bootbox.alert(json.error);
|
||||
bootbox.alert(escapeHTML(json.error));
|
||||
else if (data.responseText)
|
||||
bootbox.alert("Server error: " + data.responseText);
|
||||
bootbox.alert("Server error: " + escapeHTML(data.responseText));
|
||||
else
|
||||
bootbox.alert("Unknown server error!");
|
||||
};
|
||||
return $.ajax(args);
|
||||
}
|
||||
};
|
||||
|
||||
var redirectJSON = function(args) {
|
||||
function redirectJSON(args) {
|
||||
args.success = function(data) {
|
||||
window.location = data.redirect;
|
||||
};
|
||||
return requestJSON(args);
|
||||
}
|
||||
};
|
||||
|
Reference in New Issue
Block a user