Publish button changes label depending on publishing access

Needed for the switch between send to pub and save and pub. So the
controller on the server handles the rest, same method called ideally
This commit is contained in:
perploug
2013-10-30 22:16:31 +01:00
parent 06d3f15fa0
commit 67903d7590
2 changed files with 16 additions and 4 deletions

View File

@@ -6,7 +6,7 @@
* @description
* The controller for the content editor
*/
function ContentEditController($scope, $routeParams, $q, $timeout, $window, contentResource, navigationService, notificationsService, angularHelper, serverValidationManager, contentEditingHelper, fileManager, formHelper) {
function ContentEditController($scope, $routeParams, $q, $timeout, $window, contentResource, navigationService, localizationService, notificationsService, angularHelper, serverValidationManager, contentEditingHelper, fileManager, formHelper) {
if ($routeParams.create) {
//we are creating so get an empty content item
@@ -31,9 +31,23 @@ function ContentEditController($scope, $routeParams, $q, $timeout, $window, cont
// after the redirect, so we will bind all subscriptions which will show the server validation errors
// if there are any and then clear them so the collection no longer persists them.
serverValidationManager.executeAndClearAllSubscriptions();
contentResource.checkPermission("P", $routeParams.id).then(function(hasPermission){
var key = "buttons_sendToPublish"
if(hasPermission){
key = "buttons_saveAndPublish";
}
localizationService.localize(key).then(function(label){
$scope.publishButtonLabel = label;
});
});
});
}
$scope.unPublish = function () {
if (formHelper.submitForm({ scope: $scope, statusMessage: "Unpublishing...", skipValidation: true })) {

View File

@@ -27,9 +27,7 @@
<div class="btn-group">
<a class="btn btn-success" href="#" ng-click="saveAndPublish()" prevent-default data-hotkey="ctrl+p">
<localize key="buttons_saveAndPublish">Publish</localize>
</a>
<a class="btn btn-success" href="#" ng-click="saveAndPublish()" prevent-default data-hotkey="ctrl+p">{{publishButtonLabel}}</a>
<a class="btn btn-success dropdown-toggle" data-toggle="dropdown">
<span class="caret"></span>