Disable Access Control step when editing a feed without Admin access
@@ -4,7 +4,8 @@ define(['angular','feed-mgr/feeds/module-name'], function (angular,moduleName) {
*
* @constructor
*/
- var EditFeedController = function($scope, $http, $q, $mdDialog, $transition$, FeedService, RestUrlService, StateService, VisualQueryService,AccessControlService,FeedSecurityGroups) {
+ var EditFeedController = function ($scope, $http, $q, $mdDialog, $transition$, FeedService, RestUrlService, StateService, VisualQueryService, AccessControlService, FeedSecurityGroups,
+ StepperService, EntityAccessControlService) {
var self = this;
/**
@@ -69,6 +70,8 @@ define(['angular','feed-mgr/feeds/module-name'], function (angular,moduleName) {
self.stepperUrl = "js/feed-mgr/feeds/define-feed/define-feed-no-table-stepper.html";
self.totalSteps = 5;
}
+
+ self.onStepperInitialized();
};
var errorFn = function () {
var alert = $mdDialog.alert()
@@ -86,20 +89,23 @@ define(['angular','feed-mgr/feeds/module-name'], function (angular,moduleName) {
/**
* initialize the stepper and setup step display
- * @param stepper
*/
- self.onStepperInitialized = function(stepper) {
- var accessChecks = {entityAccess: AccessControlService.checkEntityAccessControlled(), securityGroups: FeedSecurityGroups.isEnabled()};
+ self.onStepperInitialized = function () {
+ if (self.model.loaded && self.totalSteps > 2 && StepperService.getStep("EditFeedStepper", self.totalSteps - 2) !== null) {
+ var entityAccess = AccessControlService.checkEntityAccessControlled();
+ var accessChecks = {
+ changeFeedPermissions: entityAccess && FeedService.hasEntityAccess(EntityAccessControlService.ENTITY_ACCESS.FEED.CHANGE_FEED_PERMISSIONS, self.model),
+ securityGroups: FeedSecurityGroups.isEnabled()
+ };
$q.all(accessChecks).then(function (response) {
- var entityAccess = AccessControlService.isEntityAccessControlled();
- var securityGroupsAccess = response.securityGroups;
//disable the access control step
- if(!entityAccess && !securityGroupsAccess) {
- //Access Control is second to last step 0 based array indexc
- stepper.deactivateStep(self.totalSteps -2);
+ if (!response.changeFeedPermissions && !response.securityGroups) {
+ //Access Control is second to last step 0 based array index
+ StepperService.deactivateStep("EditFeedStepper", self.totalSteps - 2);
}
});
}
+ };
/**
* Resets the editor state.
@@ -114,7 +120,6 @@ define(['angular','feed-mgr/feeds/module-name'], function (angular,moduleName) {
self.init();
};
- angular.module(moduleName).controller("EditFeedController", ["$scope","$http","$q","$mdDialog","$transition$","FeedService","RestUrlService","StateService","VisualQueryService","AccessControlService","FeedSecurityGroups",EditFeedController]);
-
-
+ angular.module(moduleName).controller("EditFeedController", ["$scope", "$http", "$q", "$mdDialog", "$transition$", "FeedService", "RestUrlService", "StateService", "VisualQueryService",
+ "AccessControlService", "FeedSecurityGroups", "StepperService", "EntityAccessControlService", EditFeedController]);
});
