'use strict';
import angular from 'angular';
import PathModalCtrl from './path.controller.js';
import GroveModalCtrl from './grove.controller.js';
import MapModalCtrl from './map.controller.js';
import ConnectionModalCtrl from './connection.controller.js';
import ChapterModalCtrl from './chapter.controller.js';
import ProblemModalCtrl from './problem.controller.js';

// Create the home module where our functionality can attach to
let modalsModule = angular.module('app.modals', []);

modalsModule.factory('pathModal', $uibModal => {
        return (path, map) => $uibModal.open({
                templateUrl: 'modals/pathModal.html',
                controller: PathModalCtrl,
                controllerAs: 'ctrl',
                size: 'lg',
                resolve: {
                    path: () => path,
                    map: () => map
                }
            }).result;
        });

modalsModule.factory('groveModal', $uibModal => {
        return grove => $uibModal.open({
                templateUrl: 'modals/groveModal.html',
                controller: GroveModalCtrl,
                controllerAs: 'ctrl',
                size: 'sm',
                resolve: {
                    grove: () => grove
                }
            }).result;
        });

modalsModule.factory('mapModal', $uibModal => {
        return map => $uibModal.open({
                templateUrl: 'modals/mapModal.html',
                controller: MapModalCtrl,
                controllerAs: 'ctrl',
                size: 'sm',
                resolve: {
                    map: () => map
                }
            }).result;
        });

modalsModule.factory('connectionModal', $uibModal => {
        return (concept, connection) => $uibModal.open({
                templateUrl: 'modals/connectionModal.html',
                controller: ConnectionModalCtrl,
                controllerAs: 'ctrl',
                size: 'lg',
                resolve: {
                    concept: () => concept,
                    connection: () => connection
                }
            }).result;
        });

modalsModule.factory('chapterModal', $uibModal => {
        return chapter => $uibModal.open({
                templateUrl: 'modals/chapterModal.html',
                controller: ChapterModalCtrl,
                controllerAs: 'ctrl',
                size: 'lg',
                resolve: {
                    chapter: () => chapter
                }
            }).result;
        });

modalsModule.factory('walkModal', $uibModal => {
        return walk => $uibModal.open({
                templateUrl: 'modals/walkModal.html',
                controller: WalkModalCtrl,
                controllerAs: 'ctrl',
                size: 'lg',
                resolve: {
                    walk: () => walk
                }
            }).result;
        });

modalsModule.factory('problemModal', $uibModal => {
        return (problem, grove) => $uibModal.open({
                templateUrl: 'modals/problemModal.html',
                controller: ProblemModalCtrl,
                controllerAs: 'ctrl',
                size: 'lg',
                resolve: {
                    problem: () => problem,
                    grove: () => grove
                }
            }).result;
        });

export default modalsModule;
