Updates the validation warning for media and members

This commit is contained in:
Shannon
2019-02-19 12:06:55 +11:00
parent c06c996ccf
commit 4b7520b6f8
3 changed files with 70 additions and 53 deletions

View File

@@ -810,47 +810,42 @@
};
$scope.preview = function (content) {
// Chromes popup blocker will kick in if a window is opened
// without the initial scoped request. This trick will fix that.
//
var previewWindow = $window.open('preview/?init=true', 'umbpreview');
// Build the correct path so both /#/ and #/ work.
var query = 'id=' + content.id;
if ($scope.culture) {
query += "#?culture=" + $scope.culture;
}
var redirect = Umbraco.Sys.ServerVariables.umbracoSettings.umbracoPath + '/preview/?' + query;
if (!$scope.busy) {
// Chromes popup blocker will kick in if a window is opened
// without the initial scoped request. This trick will fix that.
//
var previewWindow = $window.open('preview/?init=true', 'umbpreview');
// Build the correct path so both /#/ and #/ work.
var query = 'id=' + content.id;
//The user cannot save if they don't have access to do that, in which case we just want to preview
//and that's it otherwise they'll get an unauthorized access message
if (!_.contains(content.allowedActions, "A")) {
previewWindow.location.href = redirect;
}
else {
var selectedVariant = $scope.content.variants[0];
if ($scope.culture) {
query += "#?culture=" + $scope.culture;
}
var redirect = Umbraco.Sys.ServerVariables.umbracoSettings.umbracoPath + '/preview/?' + query;
//The user cannot save if they don't have access to do that, in which case we just want to preview
//and that's it otherwise they'll get an unauthorized access message
if (!_.contains(content.allowedActions, "A")) {
previewWindow.location.href = redirect;
}
else {
var selectedVariant = $scope.content.variants[0];
if ($scope.culture) {
var found = _.find($scope.content.variants, function (v) {
return (v.language && v.language.culture === $scope.culture);
});
if(found){
selectedVariant = found;
}
}
//ensure the save flag is set
selectedVariant.save = true;
performSave({ saveMethod: $scope.saveMethod(), action: "save" }).then(function (data) {
previewWindow.location.href = redirect;
}, function (err) {
//validation issues ....
var found = _.find($scope.content.variants, function (v) {
return (v.language && v.language.culture === $scope.culture);
});
if (found) {
selectedVariant = found;
}
}
//ensure the save flag is set
selectedVariant.save = true;
performSave({ saveMethod: $scope.saveMethod(), action: "save" }).then(function (data) {
previewWindow.location.href = redirect;
}, function (err) {
//validation issues ....
});
}
};

View File

@@ -7,7 +7,7 @@
* The controller for the media editor
*/
function mediaEditController($scope, $routeParams, $q, appState, mediaResource,
entityResource, navigationService, notificationsService, angularHelper,
entityResource, navigationService, notificationsService, localizationService,
serverValidationManager, contentEditingHelper, fileManager, formHelper,
editorState, umbRequestHelper, $http, eventsService) {
@@ -155,12 +155,25 @@ function mediaEditController($scope, $routeParams, $q, appState, mediaResource,
});
}
}
/** Just shows a simple notification that there are client side validation issues to be fixed */
function showValidationNotification() {
//TODO: We need to make the validation UI much better, there's a lot of inconsistencies in v8 including colors, issues with the property groups and validation errors between variants
//need to show a notification else it's not clear there was an error.
localizationService.localizeMany([
"speechBubbles_validationFailedHeader",
"speechBubbles_validationFailedMessage"
]
).then(function (data) {
notificationsService.error(data[0], data[1]);
});
}
$scope.save = function () {
if (!$scope.busy && formHelper.submitForm({ scope: $scope })) {
$scope.busy = true;
if (formHelper.submitForm({ scope: $scope })) {
$scope.page.saveButtonState = "busy";
mediaResource.save($scope.content, create, fileManager.getFiles())
@@ -176,7 +189,6 @@ function mediaEditController($scope, $routeParams, $q, appState, mediaResource,
});
editorState.set($scope.content);
$scope.busy = false;
syncTreeNode($scope.content, data.path);
@@ -199,12 +211,12 @@ function mediaEditController($scope, $routeParams, $q, appState, mediaResource,
});
editorState.set($scope.content);
$scope.busy = false;
$scope.page.saveButtonState = "error";
});
}else{
$scope.busy = false;
}
else {
showValidationNotification();
}
};

View File

@@ -6,7 +6,7 @@
* @description
* The controller for the member editor
*/
function MemberEditController($scope, $routeParams, $location, $q, $window, appState, memberResource, entityResource, navigationService, notificationsService, angularHelper, serverValidationManager, contentEditingHelper, fileManager, formHelper, umbModelMapper, editorState, umbRequestHelper, $http) {
function MemberEditController($scope, $routeParams, $location, appState, memberResource, entityResource, navigationService, notificationsService, localizationService, serverValidationManager, contentEditingHelper, fileManager, formHelper, editorState, umbRequestHelper, $http) {
//setup scope vars
$scope.page = {};
@@ -18,7 +18,6 @@ function MemberEditController($scope, $routeParams, $location, $q, $window, appS
$scope.page.listViewPath = null;
$scope.page.saveButtonState = "init";
$scope.page.exportButton = "init";
$scope.busy = false;
$scope.page.listViewPath = ($routeParams.page && $routeParams.listName)
? "/member/member/list/" + $routeParams.listName + "?page=" + $routeParams.page
@@ -131,14 +130,26 @@ function MemberEditController($scope, $routeParams, $location, $q, $window, appS
if(content.membershipScenario === 0) {
$scope.page.nameLocked = true;
}
}
/** Just shows a simple notification that there are client side validation issues to be fixed */
function showValidationNotification() {
//TODO: We need to make the validation UI much better, there's a lot of inconsistencies in v8 including colors, issues with the property groups and validation errors between variants
//need to show a notification else it's not clear there was an error.
localizationService.localizeMany([
"speechBubbles_validationFailedHeader",
"speechBubbles_validationFailedMessage"
]
).then(function (data) {
notificationsService.error(data[0], data[1]);
});
}
$scope.save = function() {
if (!$scope.busy && formHelper.submitForm({ scope: $scope })) {
if (formHelper.submitForm({ scope: $scope })) {
$scope.busy = true;
$scope.page.saveButtonState = "busy";
memberResource.save($scope.content, $routeParams.create, fileManager.getFiles())
@@ -155,7 +166,6 @@ function MemberEditController($scope, $routeParams, $location, $q, $window, appS
});
editorState.set($scope.content);
$scope.busy = false;
$scope.page.saveButtonState = "success";
var path = buildTreePath(data);
@@ -172,12 +182,12 @@ function MemberEditController($scope, $routeParams, $location, $q, $window, appS
});
editorState.set($scope.content);
$scope.busy = false;
$scope.page.saveButtonState = "error";
});
}else{
$scope.busy = false;
}
else {
showValidationNotification();
}
};