Fixes: U4-4782 Duplicate content after validation error correction
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
* Another thing this directive does is to ensure that any .control-group that contains form elements that are invalid will
|
||||
* be marked with the 'error' css class. This ensures that labels included in that control group are styled correctly.
|
||||
**/
|
||||
function valFormManager(serverValidationManager, $rootScope, $log, $timeout, notificationsService, eventsService) {
|
||||
function valFormManager(serverValidationManager, $rootScope, $log, $timeout, notificationsService, eventsService, $routeParams) {
|
||||
return {
|
||||
require: "form",
|
||||
restrict: "A",
|
||||
@@ -37,6 +37,12 @@ function valFormManager(serverValidationManager, $rootScope, $log, $timeout, not
|
||||
var savingEventName = attr.savingEvent ? attr.savingEvent : "formSubmitting";
|
||||
var savedEvent = attr.savedEvent ? attr.savingEvent : "formSubmitted";
|
||||
|
||||
//This tracks if the user is currently saving a new item, we use this to determine
|
||||
// if we should display the warning dialog that they are leaving the page - if a new item
|
||||
// is being saved we never want to display that dialog, this will also cause problems when there
|
||||
// are server side validation issues.
|
||||
var isSavingNewItem = false;
|
||||
|
||||
//we should show validation if there are any msgs in the server validation collection
|
||||
if (serverValidationManager.items.length > 0) {
|
||||
element.addClass(className);
|
||||
@@ -45,6 +51,9 @@ function valFormManager(serverValidationManager, $rootScope, $log, $timeout, not
|
||||
//listen for the forms saving event
|
||||
scope.$on(savingEventName, function (ev, args) {
|
||||
element.addClass(className);
|
||||
|
||||
//set the flag so we can check to see if we should display the error.
|
||||
isSavingNewItem = $routeParams.create;
|
||||
});
|
||||
|
||||
//listen for the forms saved event
|
||||
@@ -60,7 +69,7 @@ function valFormManager(serverValidationManager, $rootScope, $log, $timeout, not
|
||||
//This handles the 'unsaved changes' dialog which is triggered when a route is attempting to be changed but
|
||||
// the form has pending changes
|
||||
var locationEvent = $rootScope.$on('$locationChangeStart', function(event, nextLocation, currentLocation) {
|
||||
if (!formCtrl.$dirty) {
|
||||
if (!formCtrl.$dirty || isSavingNewItem) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user