fixing import dialog, parameters modification and redirect

This commit is contained in:
Claudio Barril 2014-08-20 23:31:14 -03:00
parent 7b512ea2f6
commit 1ff3cf2127

View File

@ -25,7 +25,7 @@
<div class="form-group">
<label for="description" class="control-label col-md-2"><spring:message code="DESCRIPTION"/>: </label>
<div class="col-md-10">
<textarea type="text" name="description" id="description"
<textarea name="description" id="description"
placeholder="<spring:message code="MAP_DESCRIPTION_HINT"/>" class="form-control" maxlength="255"></textarea>
</div>
</div>
@ -46,25 +46,19 @@
$('#dialogMainForm').submit(function (event) {
// Load form parameters ...
var title = $('#dialogMainForm #title').attr('value');
var title = $('#dialogMainForm #title').val();
title = title == undefined ? "" : title;
var description = $('#dialogMainForm #description').attr('value');
var description = $('#dialogMainForm #description').val();
description = description == undefined ? "" : description;
// Save status on click ...
jQuery.ajax("c/restful/maps?title=" + encodeURI(title) + "&description=" + encodeURI(description),
{
async:false,
data:fileContent,
type:'POST',
dataType:'json',
contentType:contentType,
success:function (data, textStatus, jqXHR) {
var resourceId = jqXHR.getResponseHeader("ResourceId");
var onSuccess = function (data, textStatus, jqXHR) {
console.log('hola');
var resourceId = data.getResponseHeader("ResourceId");
window.location = "c/maps/" + resourceId + "/edit";
},
error:function (jqXHR, textStatus, errorThrown) {
};
var onError = function (jqXHR, textStatus, errorThrown) {
if (jqXHR.status == 400) {
var errors = JSON.parse(jqXHR.responseText);
// Mark fields with errors ...
@ -91,6 +85,19 @@
console.log(jqXHR);
$('#messagesPanel div').text(errorThrown).parent().show();
}
};
// Save status on click ...
jQuery.ajax("c/restful/maps?title=" + encodeURI(title) + "&description=" + encodeURI(description),
{
async:false,
data:fileContent,
type:'POST',
dataType:'json',
contentType:contentType,
statusCode: {
201: onSuccess,
400: onError
}
});
event.preventDefault();