/**
 * ProjectsOverviewCtrl Controller
 * Extracted from bookings module
 */

Bookings.controller('ProjectsOverviewCtrl', ['$scope', 'ActivityLog', 'ErrorsHandler', function ($scope, ActivityLog, ErrorsHandler) {

	// ------------------------------------------------------------------------
	//
	//	SCOPE VARIABLES BELOW -->
	//
	// ------------------------------------------------------------------------

	$scope.logs_page = 1;

	// ------------------------------------------------------------------------
	//
	//	FUNCTIONS BELOW THIS LINE -->
	//
	// ------------------------------------------------------------------------

	$scope.loadMoreLogs = function () {
		$scope.disable_logs_scroll = true;

		ActivityLog.get({ objectId: $scope.projectId, objectType: 'project', page: ++$scope.logs_page }, function (response) {
			if (response.data.length > 0) {
				$scope.activity_logs = $scope.activity_logs.concat(response.data);
				$scope.disable_logs_scroll = false;
			}

			$scope.logs_page = response.current_page;
		}, ErrorsHandler);
	};

}]);
