fixing some validation issues

This commit is contained in:
Shannon
2018-08-29 15:24:50 +10:00
parent c85128dd11
commit 016ed4a49d
3 changed files with 32 additions and 6 deletions

View File

@@ -132,17 +132,39 @@
initVariant(activeVariant);
var variantCulture = activeVariant.language ? activeVariant.language.culture : "invariant";
//If there are no editors yet then create one with the current content.
//if there's already a main editor then update it with the current content.
if ($scope.editors.length === 0) {
var editor = {
content: activeVariant
content: activeVariant,
//used for "track-by" ng-repeat
culture: variantCulture
};
$scope.editors.push(editor);
}
else {
//this will mean there is only one
$scope.editors[0].content = activeVariant;
//check if the current editor is the same culture
var currentIndex = _.findIndex($scope.editors, function (e) {
return e.culture === variantCulture;
});
if (currentIndex < 0) {
//not the current culture which means we need to modify the array,
//if we just replace the content object at the zero index, the rg-repeat will not update
//which means directives do not refresh which cause problems
$scope.editors.splice(0, 1, {
content: activeVariant,
//used for "track-by" ng-repeat
culture: variantCulture
});
}
else {
//replace the content for the same culture
$scope.editors[0].content = activeVariant;
}
if ($scope.editors.length > 1) {
//now re-sync any other editor content (i.e. if split view is open)

View File

@@ -599,8 +599,8 @@ function contentEditingHelper(fileManager, $q, $location, $routeParams, notifica
//add model state errors to notifications
if (args.showNotifications) {
for (var e in modelState) {
notificationsService.error("Validation", modelState[e][0]);
for (var e in args.err.data.ModelState) {
notificationsService.error("Validation", args.err.data.ModelState[e][0]);
}
}

View File

@@ -7,7 +7,10 @@
<umb-editor-view ng-if="!page.loading">
<div class="umb-split-views">
<div class="umb-split-view" ng-class="{'umb-split-view--collapsed': editor.collapsed}" ng-repeat="editor in editors">
<div class="umb-split-view"
ng-class="{'umb-split-view--collapsed': editor.collapsed}"
ng-repeat="editor in editors track by editor.culture">
<umb-variant-content
page="page"
content="content"
@@ -16,6 +19,7 @@
init-variant="initVariant(variant)"
on-split-view-changed="splitViewChanged()">
</umb-variant-content>
</div>
</div>