mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-12-25 12:43:50 +01:00
fixing import dialog, parameters modification and redirect
This commit is contained in:
parent
7b512ea2f6
commit
1ff3cf2127
@ -25,7 +25,7 @@
|
|||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="description" class="control-label col-md-2"><spring:message code="DESCRIPTION"/>: </label>
|
<label for="description" class="control-label col-md-2"><spring:message code="DESCRIPTION"/>: </label>
|
||||||
<div class="col-md-10">
|
<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>
|
placeholder="<spring:message code="MAP_DESCRIPTION_HINT"/>" class="form-control" maxlength="255"></textarea>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -46,12 +46,47 @@
|
|||||||
|
|
||||||
$('#dialogMainForm').submit(function (event) {
|
$('#dialogMainForm').submit(function (event) {
|
||||||
// Load form parameters ...
|
// Load form parameters ...
|
||||||
var title = $('#dialogMainForm #title').attr('value');
|
var title = $('#dialogMainForm #title').val();
|
||||||
title = title == undefined ? "" : title;
|
title = title == undefined ? "" : title;
|
||||||
|
|
||||||
var description = $('#dialogMainForm #description').attr('value');
|
var description = $('#dialogMainForm #description').val();
|
||||||
description = description == undefined ? "" : description;
|
description = description == undefined ? "" : description;
|
||||||
|
|
||||||
|
var onSuccess = function (data, textStatus, jqXHR) {
|
||||||
|
console.log('hola');
|
||||||
|
var resourceId = data.getResponseHeader("ResourceId");
|
||||||
|
window.location = "c/maps/" + resourceId + "/edit";
|
||||||
|
};
|
||||||
|
|
||||||
|
var onError = function (jqXHR, textStatus, errorThrown) {
|
||||||
|
if (jqXHR.status == 400) {
|
||||||
|
var errors = JSON.parse(jqXHR.responseText);
|
||||||
|
// Mark fields with errors ...
|
||||||
|
var fieldErrors = errors.fieldErrors;
|
||||||
|
if (fieldErrors) {
|
||||||
|
for (var fieldName in fieldErrors) {
|
||||||
|
// Mark the field with errors ...
|
||||||
|
var message = fieldErrors[fieldName];
|
||||||
|
var inputField = $("#dialogMainForm input[name='" + fieldName + "']");
|
||||||
|
$("#dialogMainForm").find(".errorMessage").text(message).addClass("alert alert-danger");
|
||||||
|
inputField.parent().addClass('error');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var globalErrors = errors.globalErrors;
|
||||||
|
if (globalErrors) {
|
||||||
|
for (var error in globalErrors) {
|
||||||
|
// Mark the field with errors ...
|
||||||
|
$("#dialogMainForm").find(".errorMessage").text(error).addClass("alert alert-danger");
|
||||||
|
inputField.parent().addClass('error');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
console.log(errorThrown);
|
||||||
|
console.log(jqXHR);
|
||||||
|
$('#messagesPanel div').text(errorThrown).parent().show();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// Save status on click ...
|
// Save status on click ...
|
||||||
jQuery.ajax("c/restful/maps?title=" + encodeURI(title) + "&description=" + encodeURI(description),
|
jQuery.ajax("c/restful/maps?title=" + encodeURI(title) + "&description=" + encodeURI(description),
|
||||||
{
|
{
|
||||||
@ -60,37 +95,9 @@
|
|||||||
type:'POST',
|
type:'POST',
|
||||||
dataType:'json',
|
dataType:'json',
|
||||||
contentType:contentType,
|
contentType:contentType,
|
||||||
success:function (data, textStatus, jqXHR) {
|
statusCode: {
|
||||||
var resourceId = jqXHR.getResponseHeader("ResourceId");
|
201: onSuccess,
|
||||||
window.location = "c/maps/" + resourceId + "/edit";
|
400: onError
|
||||||
},
|
|
||||||
error:function (jqXHR, textStatus, errorThrown) {
|
|
||||||
if (jqXHR.status == 400) {
|
|
||||||
var errors = JSON.parse(jqXHR.responseText);
|
|
||||||
// Mark fields with errors ...
|
|
||||||
var fieldErrors = errors.fieldErrors;
|
|
||||||
if (fieldErrors) {
|
|
||||||
for (var fieldName in fieldErrors) {
|
|
||||||
// Mark the field with errors ...
|
|
||||||
var message = fieldErrors[fieldName];
|
|
||||||
var inputField = $("#dialogMainForm input[name='" + fieldName + "']");
|
|
||||||
$("#dialogMainForm").find(".errorMessage").text(message).addClass("alert alert-danger");
|
|
||||||
inputField.parent().addClass('error');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
var globalErrors = errors.globalErrors;
|
|
||||||
if (globalErrors) {
|
|
||||||
for (var error in globalErrors) {
|
|
||||||
// Mark the field with errors ...
|
|
||||||
$("#dialogMainForm").find(".errorMessage").text(error).addClass("alert alert-danger");
|
|
||||||
inputField.parent().addClass('error');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
console.log(errorThrown);
|
|
||||||
console.log(jqXHR);
|
|
||||||
$('#messagesPanel div').text(errorThrown).parent().show();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
Loading…
Reference in New Issue
Block a user