diff --git a/wise-webapp/src/main/webapp/jsp/mindmapImport.jsp b/wise-webapp/src/main/webapp/jsp/mindmapImport.jsp
index d9c84cbd..b6345cf9 100644
--- a/wise-webapp/src/main/webapp/jsp/mindmapImport.jsp
+++ b/wise-webapp/src/main/webapp/jsp/mindmapImport.jsp
@@ -25,7 +25,7 @@
@@ -46,12 +46,47 @@
$('#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;
+ 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 ...
jQuery.ajax("c/restful/maps?title=" + encodeURI(title) + "&description=" + encodeURI(description),
{
@@ -60,37 +95,9 @@
type:'POST',
dataType:'json',
contentType:contentType,
- success:function (data, textStatus, jqXHR) {
- var resourceId = jqXHR.getResponseHeader("ResourceId");
- window.location = "c/maps/" + resourceId + "/edit";
- },
- 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();
- }
+ statusCode: {
+ 201: onSuccess,
+ 400: onError
}
});
event.preventDefault();