(function () { "use strict"; angular .module('shared') .component('storylineLessonAssignButton', { transclude: true, templateUrl: '/js/angular/assignment/storyline-lesson-assign-button.html', controller: 'storylineLessonAssignButton', bindings: { lessonId: '@' } }) .controller('storylineLessonAssignButton', storylineLessonAssignButton); storylineLessonAssignButton.$inject = ['$scope', 'storylineLesson', 'LazModalService', 'messageHandler', 'studentList', 'Authorization', 'SiteHelper', 'FeatureCheck']; function storylineLessonAssignButton($scope, storylineLesson, LazModalService, messageHandler, studentList, Authorization, SiteHelper, FeatureCheck) { var ctrl = this; ctrl.assign = assign; ctrl.$onInit = function() { var resources = storylineLesson.getLessonsForStoryline(ctrl.lessonId); ctrl.showButton = resources.length > 0; }; function assign() { var resources = storylineLesson.getLessonsForStoryline(ctrl.lessonId); studentList.annotateSelectableStudents([ Authorization.studentWithoutPrivilegeCheckerFactory(SiteHelper.SAZ_SITE_ABBREVIATION), Authorization.studentWithoutResourceLicenseCheckerFactory(Authorization.getLicenseTypeForResourceCollection(resources), resources.length === 1 ? 'this resource' : 'these resources') ]); LazModalService.showModal({ templateUrl: '/js/angular/assignment/storyline-lesson-assign-modal.html', controller: 'storylineLessonAssignModal', controllerAs: '$ctrl', hideCloseButton: 'true', overrideClass: 'js-none', overrideStyle: 'height: 95vh;', inputs: { resources: resources, lessonId: ctrl.lessonId } }) .catch(function (reason) { messageHandler.publishError( 'There was a problem showing the assignment. Try again later'); }); } } })();