'use strict';

angular
    .module('member-create', [])
    .controller('ErrorModal', [
        '$scope', 'AppUtil', '$uibModalInstance', 'data', 'util',

        function ($scope, AppUtil, $uibModalInstance, data, util) {

            $scope.onClose = function () {
                $uibModalInstance.close();
            };

            $scope.errorList = data.error_list;

            $scope.getError = function (item) {
                if (item.error_type !== 12) {
                    return util.translate("error_type_CSV." + item.error_type);
                } else {
                    return AppUtil.getPasswordPolicyError(JSON.parse(item.data_attached));
                }
            };

            $scope.handleLessLength25 = function (str) {
                if (str) {
                    return str.length > 25 ? str.substring(0, 25) + '...' : str;
                } else {
                    return '';
                }
            }

        }]
    );
