/*
 * Copyright 2018 Scytl Secure Electronic Voting SA
 *
 * All rights reserved
 *
 * See our extended copyright notice in *file 'Copyright.txt' which is part of this source code package
 */
(function() {
    'use strict';

    angular.module('app.dialogs', [])
        .factory('CustomDialog', function($mdDialog, gettextCatalog,gettext) {


            return function CustomDialog() {
                var _title = '';
                var _content = '';

                this.title = function(title) {
                    _title = title;
                    return this;
                };

                this.cannotPerform = function(entityName) {
                    var CANNOT_PERFORM = gettextCatalog.
                        getString(gettext('You cannot perform the action for one or more'));
                    var name = ' $NAME. ';
                    var review = gettextCatalog.getString(
                        gettext('Review your selections'));
                    _content = CANNOT_PERFORM.concat(name).concat(review).replace('$NAME', entityName);
                    return this;
                };

                this.error = function() {
                    var ERROR = gettextCatalog.
                        getString(gettext('Something went wrong. Contact with Support'));
                    _content = ERROR;
                    return this;
                };

                this.show = function() {
                    return $mdDialog.show(
                        $mdDialog.customAlert({
                            locals: {
                                title: _title,
                                content: _content
                            }
                        })
                    );
                };
            };
        });


})();