<commit_before>﻿module Kitos.GlobalAdmin.HelpTexts {
    "use strict";

    export class HelpTextsController {

        public static $inject: string[] = ['$rootScope', '$scope', '$http', 'notify', 'user', 'helpTexts', '$uibModal', '_'];
        public selectedHelpText;
        public tinymceOptions;

        constructor(private $rootScope, private $scope: ng.IScope, private $http, private notify, private user, private helpTexts, private $uibModal, private _) {
            $rootScope.page.title = 'Hjælpetekter';
            this.selectDefaultHelpText();
            this.tinymceOptions = {
                plugins: 'link image code',
                skin: 'lightgray',
                theme: 'modern'
            };
        }

        private selectHelpText = function (helpText) {
            this.selectedHelpText = helpText;
        }

        private selectDefaultHelpText() {
            if (this.helpTexts.length > 0) {
                this.selectedHelpText = this.helpTexts[0];
            } else {
                this.selectedHelpText = null;
            }
        }

        private save() {
            var msg = this.notify.addInfoMessage("Gemmer...", false);
            this.$http({ method: 'PATCH', url: "odata/HelpTexts(" + this.selectedHelpText.Id + ")", data: this.selectedHelpText, ignoreLoadingBar: true })
                .success(function () {
                    msg.toSuccessMessage("Feltet er gemt.");
                })
                .error(function (result, status) {
                    if (status === 409) {
                        msg.toErrorMessage("Fejl! Feltet kunne ikke ændres da værdien den allerede findes i KITOS!");
                    } else {
                        msg.toErrorMessage("Fejl! Feltet kunne ikke ændres!");
                    }
                });
        }<commit_msg>OS2KITOS-597 duplicates<commit_after>﻿module Kitos.GlobalAdmin.HelpTexts {
    "use strict";

    export class HelpTextsController {

        public static $inject: string[] = ['$rootScope', '$scope', '$http', 'notify', 'user', 'helpTexts', '$uibModal', '_'];
        public selectedHelpText;
        public tinymceOptions;

        constructor(private $rootScope, private $scope: ng.IScope, private $http, private notify, private user, private helpTexts, private $uibModal, private _) {
            $rootScope.page.title = 'Hjælpetekter';
            this.selectDefaultHelpText();
            this.tinymceOptions = {
                plugins: 'link image code',
                skin: 'lightgray',
                theme: 'modern'
            };
        }

        private selectHelpText = function (helpText) {
            this.selectedHelpText = helpText;
        }

        private selectDefaultHelpText() {
            if (this.helpTexts.length > 0) {
                this.selectedHelpText = this.helpTexts[0];
            } else {
                this.selectedHelpText = null;
            }
        }

        private save() {
            //Check duplicates
            var key = this.selectedHelpText.Key;
            var id = this.selectedHelpText.Id;
            if (_.find(this.helpTexts, function (o: Models.IHelpText) { return (o.Id != id && o.Key === key); })) {
                this.notify.addErrorMessage("Fejl! Der findes allerede en hjælpetekst med den angivne key.", true);
                return;
            }

            var msg = this.notify.addInfoMessage("Gemmer...", false);
            this.$http({ method: 'PATCH', url: "odata/HelpTexts(" + this.selectedHelpText.Id + ")", data: this.selectedHelpText, ignoreLoadingBar: true })
                .success(function () {
                    msg.toSuccessMessage("Feltet er gemt.");
                })
                .error(function (result, status) {
                    if (status === 409) {
                        msg.toErrorMessage("Fejl! Feltet kunne ikke ændres da værdien den allerede findes i KITOS!");
                    } else {
                        msg.toErrorMessage("Fejl! Feltet kunne ikke ændres!");
                    }
                });
        }
{'fraction_non_alphanumeric': 0.11653581943081452, 'fraction_numerical': 0.0034347399411187437, 'mean_word_length': 1.7270903010033445, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1119789', 'n_tokens_mistral': 1154, 'n_tokens_neox': 1076, 'n_words': 251}