var suggestionBox=angular.module("silverpeas.suggestionBox",["silverpeas.services","silverpeas.directives"]);
suggestionBox.controller("mainController",["context","SuggestionBox","$scope",function(context,SuggestionBox,$scope){var suggestionBox=SuggestionBox.get({id:context.suggestionBoxId,componentInstanceId:context.component});$scope.suggestionBox=suggestionBox;if(typeof context.suggestionId!=="undefined")suggestionBox.suggestions.get(context.suggestionId).then(function(suggestion){$scope.suggestion=suggestion});if(context.userRole!=="ADMIN"&&context.userRole!=="PUBLISHER"&&context.userRole!=="WRITER")$scope.readerView=
"lecteur-view";$scope.goAt=function(url){window.location=url};$scope.maxItemsToRender=3}]);
suggestionBox.controller("suggestionsInDraftController",["context","$scope","$rootScope",function(context,$scope,$rootScope){var suggestionBox=$scope.suggestionBox;$scope.publish=function(suggestion){suggestionBox.suggestions.publish(suggestion).then(function(suggestionUpdated){$rootScope.$broadcast("suggestionModified",suggestionUpdated)})};$scope.loadInDraft=function(){suggestionBox.suggestions.get("inDraft").then(function(theSuggestions){$scope.inDraftSuggestions=theSuggestions})};$scope.loadInDraft();
$scope.$on("suggestionModified",function(theSuggestionId){$scope.loadInDraft()})}]);suggestionBox.controller("myOutOfDraftSuggestionsController",["context","$scope","$rootScope",function(context,$scope,$rootScope){var suggestionBox=$scope.suggestionBox;$scope.loadMyOutOfDraft=function(){suggestionBox.suggestions.get("outOfDraft").then(function(theSuggestions){$scope.myOutOfDraftSuggestions=theSuggestions})};$scope.loadMyOutOfDraft();$scope.$on("suggestionModified",function(theSuggestionId){$scope.loadMyOutOfDraft()})}]);
suggestionBox.controller("publishedSuggestionsController",["context","$scope","$rootScope",function(context,$scope,$rootScope){var suggestionBox=$scope.suggestionBox;$scope.loadPublished=function(){suggestionBox.suggestions.get("published",{page:{number:1,size:$scope.maxItemsToRender},sortby:"validation.validationDate"}).then(function(theSuggestions){$scope.publishedSuggestions=theSuggestions})};$scope.loadPublished();$scope.$on("suggestionModified",function(theSuggestionId){$scope.loadPublished()})}]);
suggestionBox.controller("buzzPublishedSuggestionsController",["context","$scope",function(context,$scope){var suggestionBox=$scope.suggestionBox;$scope.loadBuzzPublished=function(){suggestionBox.suggestions.get("published",{page:{number:1,size:$scope.maxItemsToRender},sortby:"commentCount"}).then(function(theSuggestions){$scope.buzzPublishedSuggestions=[];$scope.buzzPublishedSuggestions.maxlength=theSuggestions.maxlength;for(var i=0;i<theSuggestions.length;i++)if(theSuggestions[i].commentCount>0)$scope.buzzPublishedSuggestions.push(theSuggestions[i])})};
$scope.loadBuzzPublished();$scope.$on("suggestionModified",function(theSuggestionId){$scope.loadBuzzPublished()})}]);suggestionBox.controller("lastCommentsController",["context","$scope",function(context,$scope){var suggestionBox=$scope.suggestionBox;suggestionBox.suggestions.lastComments($scope.maxItemsToRender).then(function(theComments){$scope.lastComments=theComments})}]);