Add error report for fields on new map.

Display error messages
This commit is contained in:
Paulo Gustavo Veiga
2012-04-07 12:45:35 -03:00
parent e4dc4a50aa
commit 3da0eec842
20 changed files with 311 additions and 186 deletions

View File

@@ -245,7 +245,7 @@ IMPORT_MINDMAP_INFO=You can import FreeMind 0.9 version maps to WiseMapping. Ple
PRINT=Print
FREE_MIND_FILE=FreeMind File
IMPORT_MAP_ERROR=FreeMind file could not be imported. {0}
MAP_TITLE_ALREADY_EXISTS=Map name already exists.
MAP_TITLE_ALREADY_EXISTS=A map already exists with this name.
EMBEDDED_VIEWER=Embed a map viewer in your own web site, blog or post!
EMBEDDED_VIEWER_MESSAGE=Once you make your map public, you will be able to embed a mind map viewer in your own web site, blog or post just as we did it here!<br/>Try it!!, you can drag nodes, pan the map, and zoom in and out.
FREEMIND_EXPORT_IMPORT=Import and Export maps from/to FreeMind

View File

@@ -109,18 +109,6 @@
<!-- Dialog Forms -->
<definition name="newMap" extends="formDialogTemplate">
<put name="title" value="NEW_MINDMAP"/>
<put name="details" value="FIELD_REQUIRED_MSG"/>
<put name="body" value="/jsp/newMap.jsp"/>
</definition>
<definition name="newMapError" extends="pageTemplate">
<put name="title" value="NEW_MINDMAP"/>
<put name="details" value="FIELD_REQUIRED_MSG"/>
<put name="body" value="/jsp/newMapError.jsp"/>
</definition>
<definition name="setting" extends="formDialogTemplate">
<put name="title" value="SETTINGS"/>

View File

@@ -22,6 +22,7 @@
<value>com.wisemapping.rest.model.RestMindmapInfo</value>
<value>com.wisemapping.rest.model.RestMindmapList</value>
<value>com.wisemapping.rest.model.RestUser</value>
<value>com.wisemapping.rest.model.RestErrors</value>
</list>
</property>
</bean>
@@ -88,4 +89,14 @@
<bean id="transformViewWise" class="com.wisemapping.rest.view.ImportTransformationView">
<constructor-arg value="application/wisemapping+xml"/>
</bean>
<bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
<property name="basenames">
<list>
<value>messages</value>
</list>
</property>
</bean>
</beans>

View File

@@ -134,10 +134,6 @@
<property name="mindmapService" ref="mindmapService"/>
</bean>
<bean id="newMapValidator" class="com.wisemapping.validator.MapInfoValidator">
<property name="mindmapService" ref="mindmapService"/>
</bean>
<bean id="importMapValidator" class="com.wisemapping.validator.ImportMapValidator">
<property name="mindmapService" ref="mindmapService"/>
</bean>
@@ -159,19 +155,7 @@
<property name="userService" ref="userService"/>
</bean>
<bean id="newMapController" class="com.wisemapping.controller.NewMindmapController">
<property name="sessionForm" value="false"/>
<property name="commandName" value="newMap"/>
<property name="commandClass" value="com.wisemapping.view.MindMapInfoBean"/>
<property name="validator" ref="newMapValidator"/>
<property name="formView" value="newMap"/>
<property name="errorView" value="newMapError"/>
<property name="mindmapService" ref="mindmapService"/>
<property name="userService" ref="userService"/>
</bean>
<bean id="importMapController" class="com.wisemapping.controller.ImportController">
<bean id="importMapController" class="com.wisemapping.controller.ImportController">
<property name="sessionForm" value="false"/>
<property name="commandName" value="importMap"/>
<property name="commandClass" value="com.wisemapping.view.ImportMapBean"/>
@@ -254,7 +238,6 @@
<prop key="/c/embeddedView.htm">embeddedView</prop>
<prop key="/c/renameMap.htm">renameMapController</prop>
<prop key="/c/importMap.htm">importMapController</prop>
<prop key="/c/newMap.htm">newMapController</prop>
<prop key="/c/history.htm">historyController</prop>
<prop key="/c/installCFG.htm">homeController</prop>
</props>

View File

@@ -5,7 +5,6 @@
<%@ page session="false" contentType="text/html;charset=UTF-8" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%--<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core_rt" %>--%>
<%@taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<%@taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%

View File

@@ -161,10 +161,14 @@
$("#buttons .newMap").button({
icons: { primary: "ui-icon-circle-plus" }
}).click(function() {
// Clean previous dialog content ...
$("#new-dialog-modal div[id='errorMessage']").text("").removeClass("ui-state-highlight");
$("#new-dialog-modal").dialog({
modal: true,
buttons: {
"Create": function() {
var formData = {};
$('#new-dialog-modal input').each(function(index, elem) {
formData[elem.name] = elem.value;
@@ -180,12 +184,37 @@
var mapId = jqXHR.getResponseHeader("ResourceId");
window.location = "c/editor.htm?action=open&mapId=" + mapId;
},
error: function() {
alert("Unexpected error removing maps. Refresh before continue.");
error: function(jqXHR, textStatus, errorThrown) {
if (jqXHR.status == 400) {
var errors = JSON.parse(jqXHR.responseText);
// Clean previous marks ....
$('#new-dialog-modal input').each(function(index, elem) {
$(elem).removeClass("ui-state-error");
});
// Mark fields with errors ...
var fieldErrors = errors.fieldErrors;
if (fieldErrors) {
for (var fieldName in fieldErrors) {
// Mark the field ...
var message = fieldErrors[fieldName];
var inputField = $("#new-dialog-modal input[name='" + fieldName + "']");
$(inputField).addClass("ui-state-error");
$("#new-dialog-modal div[id='errorMessage']").text(message).addClass("ui-state-highlight");
}
}
} else {
alert("Unexpected error removing maps. Refresh before continue.");
}
}
});
},
Cancel: function() {
Cancel:function() {
$(this).dialog("close");
}
}
@@ -221,7 +250,8 @@
});
}
});
});
})
;
</script>
</head>
<body>
@@ -241,7 +271,9 @@
<div id="delete-dialog-modal" title="Delete maps" style="display: none">
<p>Are you sure you want to delete maps <span></span> ?</p>
</div>
<div id="new-dialog-modal" title="New" style="display: none">
<div id="new-dialog-modal" title="Add new map" style="display: none">
<div id="errorMessage"></div>
<table>
<tr>
<td class="formLabel">
@@ -281,7 +313,7 @@
</div>
</div>
<div id="map-table">
<table cellpadding="0" cellspacing="0" border="0" class="display" id="mindmapListTable">
<table class="display" id="mindmapListTable">
</table>
</div>

View File

@@ -1,49 +0,0 @@
<%@ include file="/jsp/init.jsp" %>
<h1>
</h1>
<div>
<form:form method="post" commandName="newMap">
<table>
<tr>
<td class="formLabel">
<span class="fieldRequired">*</span>
<spring:message code="NAME"/>
:
</td>
<td>
<form:input path="title" id="title" tabindex="1"/>
<form:errors path="title" cssClass="errorMsg"/>
</td>
</tr>
<tr>
<td class="formLabel">
<spring:message code="DESCRIPTION"/>
:
</td>
<td>
<form:input path="description" id="description" tabindex="2"/>
<form:errors path="description" cssClass="errorMsg"/>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<input type="submit" value="Accept" class="btn-primary">
<c:choose>
<c:when test="${!errorView}">
<input type="button" value="<spring:message code="CANCEL"/>" class="btn-secondary"
onclick="MOOdalBox.close();">
</c:when>
<c:otherwise>
<input type="button" value="<spring:message code="BACK"/>" class="btn-secondary"
onclick="window.location='mymaps.htm'">
</c:otherwise>
</c:choose>
</td>
</tr>
</table>
</form:form>
</div>

View File

@@ -1,11 +0,0 @@
<%@ include file="/jsp/init.jsp" %>
<h1>
<spring:message code="${requestScope.title}"/>
</h1>
<p style="font-weight:bold;">
<spring:message code="${requestScope.details}"/>
</p>
<jsp:include page="/jsp/newMap.jsp"/>

View File

@@ -23,10 +23,6 @@
<link rel="stylesheet" type="text/css" href="../css/wisehome.css"/>
<link rel="icon" href="${pageContext.request.contextPath}/images/favicon.ico" type="image/x-icon"/>
<link rel="shortcut icon" href="${pageContext.request.contextPath}/images/favicon.ico" type="image/x-icon"/>
<script type='text/javascript'
src='https://ajax.googleapis.com/ajax/libs/mootools/1.3.2/mootools-yui-compressed.js'></script>
<script type='text/javascript' src='../js/mootools-more.js'></script>
</head>
<body>