Fixes issue with umb-editor-sub-views so that each view is actually rendered out and not replaced otherwise when you switch sections all of the wired up validation gets removed. This will also enable us to highlight the menu header when validation errors exist on that section. We also now show a single validation error message even when there is client side validation errors.

This commit is contained in:
Shannon
2015-10-21 17:52:58 +02:00
parent 65b080b03f
commit 73fb761c4d
11 changed files with 42 additions and 12 deletions

View File

@@ -7,7 +7,7 @@
* A utility class used to streamline how forms are developed, to ensure that validation is check and displayed consistently and to ensure that the correct events
* fire when they need to.
*/
function formHelper(angularHelper, serverValidationManager, $timeout, notificationsService, dialogService) {
function formHelper(angularHelper, serverValidationManager, $timeout, notificationsService, dialogService, localizationService) {
return {
/**
@@ -157,7 +157,7 @@ function formHelper(angularHelper, serverValidationManager, $timeout, notificati
*
* @param {object} err The error object returned from the http promise
*/
handleServerValidation: function(modelState) {
handleServerValidation: function (modelState) {
for (var e in modelState) {
//This is where things get interesting....
@@ -204,6 +204,7 @@ function formHelper(angularHelper, serverValidationManager, $timeout, notificati
//add to notifications
notificationsService.error("Validation", modelState[e][0]);
}
}
};

View File

@@ -1,5 +1,4 @@
<div class="umb-editor-sub-views">
<div ng-if="activeView.view && activeView.active" ng-include="activeView.view"></div>
<div ng-repeat="sub in subViews" ng-include="sub.view" ng-show="activeView.name == sub.name" ng-class="'sub-view-' + sub.name"></div>
<div ng-if="!activeView.view && activeView.active" ng-transclude></div>
</div>
</div>

View File

@@ -9,7 +9,7 @@
(function () {
"use strict";
function DocumentTypesEditController($scope, $routeParams, modelsResource, contentTypeResource, dataTypeResource, editorState, contentEditingHelper, formHelper, navigationService, iconHelper, contentTypeHelper, notificationsService, $filter, $q) {
function DocumentTypesEditController($scope, $routeParams, modelsResource, contentTypeResource, dataTypeResource, editorState, contentEditingHelper, formHelper, navigationService, iconHelper, contentTypeHelper, notificationsService, $filter, $q, localizationService) {
var vm = this;
@@ -219,6 +219,13 @@
if (err) {
editorState.set($scope.content);
}
else {
localizationService.localize("speechBubbles_validationFailedHeader").then(function (headerValue) {
localizationService.localize("speechBubbles_validationFailedMessage").then(function(msgValue) {
notificationsService.error(headerValue, msgValue);
});
});
}
vm.page.saveButtonState = "error";

View File

@@ -9,7 +9,7 @@
(function () {
"use strict";
function MediaTypesEditController($scope, $routeParams, mediaTypeResource, dataTypeResource, editorState, contentEditingHelper, formHelper, navigationService, iconHelper, contentTypeHelper, notificationsService, $filter, $q) {
function MediaTypesEditController($scope, $routeParams, mediaTypeResource, dataTypeResource, editorState, contentEditingHelper, formHelper, navigationService, iconHelper, contentTypeHelper, notificationsService, $filter, $q, localizationService) {
var vm = this;
@@ -151,6 +151,13 @@
if (err) {
editorState.set($scope.content);
}
else {
localizationService.localize("speechBubbles_validationFailedHeader").then(function (headerValue) {
localizationService.localize("speechBubbles_validationFailedMessage").then(function (msgValue) {
notificationsService.error(headerValue, msgValue);
});
});
}
vm.page.saveButtonState = "error";

View File

@@ -9,7 +9,7 @@
(function () {
"use strict";
function MemberTypesEditController($scope, $rootScope, $routeParams, $log, $filter, memberTypeResource, dataTypeResource, editorState, iconHelper, formHelper, navigationService, contentEditingHelper, notificationsService, $q) {
function MemberTypesEditController($scope, $rootScope, $routeParams, $log, $filter, memberTypeResource, dataTypeResource, editorState, iconHelper, formHelper, navigationService, contentEditingHelper, notificationsService, $q, localizationService) {
var vm = this;
@@ -102,6 +102,13 @@
if (err) {
editorState.set($scope.content);
}
else {
localizationService.localize("speechBubbles_validationFailedHeader").then(function (headerValue) {
localizationService.localize("speechBubbles_validationFailedMessage").then(function (msgValue) {
notificationsService.error(headerValue, msgValue);
});
});
}
vm.page.saveButtonState = "error";

View File

@@ -5,7 +5,7 @@ describe('edit content controller tests', function () {
beforeEach(module('umbraco'));
//inject the contentMocks service
beforeEach(inject(function ($rootScope, $controller, angularHelper, $httpBackend, contentMocks, entityMocks, mocksUtils) {
beforeEach(inject(function ($rootScope, $controller, angularHelper, $httpBackend, contentMocks, entityMocks, mocksUtils, localizationMocks) {
//for these tests we don't want any authorization to occur
mocksUtils.disableAuth();
@@ -17,6 +17,7 @@ describe('edit content controller tests', function () {
//see /mocks/content.mocks.js for how its setup
contentMocks.register();
entityMocks.register();
localizationMocks.register();
//this controller requires an angular form controller applied to it
scope.contentForm = angularHelper.getNullForm("contentForm");

View File

@@ -5,7 +5,7 @@ describe('edit media controller tests', function () {
beforeEach(module('umbraco'));
//inject the contentMocks service
beforeEach(inject(function ($rootScope, $controller, angularHelper, $httpBackend, mediaMocks, entityMocks, mocksUtils) {
beforeEach(inject(function ($rootScope, $controller, angularHelper, $httpBackend, mediaMocks, entityMocks, mocksUtils, localizationMocks) {
//for these tests we don't want any authorization to occur
mocksUtils.disableAuth();
@@ -16,6 +16,7 @@ describe('edit media controller tests', function () {
//see /mocks/content.mocks.js for how its setup
mediaMocks.register();
entityMocks.register();
localizationMocks.register();
//this controller requires an angular form controller applied to it
scope.contentForm = angularHelper.getNullForm("contentForm");

View File

@@ -5,7 +5,7 @@ describe('Content picker controller tests', function () {
beforeEach(module('umbraco'));
//inject the contentMocks service
beforeEach(inject(function ($rootScope, $controller, angularHelper, $httpBackend, entityMocks, mocksUtils) {
beforeEach(inject(function ($rootScope, $controller, angularHelper, $httpBackend, entityMocks, mocksUtils, localizationMocks) {
//for these tests we don't want any authorization to occur
mocksUtils.disableAuth();
@@ -28,6 +28,7 @@ describe('Content picker controller tests', function () {
//have the contentMocks register its expect urls on the httpbackend
//see /mocks/content.mocks.js for how its setup
entityMocks.register();
localizationMocks.register();
controller = $controller('Umbraco.PropertyEditors.ContentPickerController', {
$scope: scope,

View File

@@ -8,7 +8,9 @@ describe('contentEditingHelper tests', function () {
//Only for 1.2: beforeEach(module('ngRoute'));
beforeEach(inject(function ($injector) {
beforeEach(inject(function ($injector, localizationMocks) {
localizationMocks.register();
contentEditingHelper = $injector.get('contentEditingHelper');
$routeParams = $injector.get('$routeParams');
serverValidationManager = $injector.get('serverValidationManager');

View File

@@ -785,6 +785,8 @@ To manage your website, simply open the Umbraco back office and start adding con
<key alias="sortPleaseWait"><![CDATA[ Please wait. Items are being sorted, this can take a while.<br/> <br/> Do not close this window during sorting]]></key>
</area>
<area alias="speechBubbles">
<key alias="validationFailedHeader">Validation</key>
<key alias="validationFailedMessage">Validation errors must be fixed before the item can be saved</key>
<key alias="operationFailedHeader">Failed</key>
<key alias="invalidUserPermissionsText">Insufficient user permissions, could not complete the operation</key>
<key alias="operationCancelledHeader">Cancelled</key>

View File

@@ -785,6 +785,8 @@ To manage your website, simply open the Umbraco back office and start adding con
<key alias="sortPleaseWait"><![CDATA[ Please wait. Items are being sorted, this can take a while.<br/> <br/> Do not close this window during sorting]]></key>
</area>
<area alias="speechBubbles">
<key alias="validationFailedHeader">Validation</key>
<key alias="validationFailedMessage">Validation errors must be fixed before the item can be saved</key>
<key alias="operationFailedHeader">Failed</key>
<key alias="invalidUserPermissionsText">Insufficient user permissions, could not complete the operation</key>
<key alias="operationCancelledHeader">Cancelled</key>