/*global angular */

angular.module('taskRunner').
	factory('taskModalService', function ($uibModal) {
		'use strict';
		var modalInstance = null;

		return {

			showTaskValidationError: function(errorMessage, constraintFormats) {
				$uibModal.open({
					template: require('./task-error-dialog.html'),
					controller: 'TaskErrorCtrl',
					size: 'lg',
					resolve: {
						errorMessage: function() {
							return errorMessage;
						},
						constraintFormats: function() {
							return constraintFormats;
						}
					}
				});
			},

			showInvalidTaskItems: function(invalidTaskItems) {
				modalInstance = $uibModal.open({
					template: require('./invalid-items-dialog.html'),
					controller: 'InvalidItemsCtrl',
					size: 'lg',
					resolve: {
						invalidTaskItems: function() {
							return invalidTaskItems;
						}
					}
				});
				return modalInstance;
			},

			showStatusModal: function() {
				modalInstance = $uibModal.open({
					template: require('./status_modal.html'),
					controller: 'StatusCtrl',
					size: 'lg'
				});
				return modalInstance;
			},

			close: function() {
				modalInstance.close();
			}
		};

	});
