<commit_before>﻿app.settings = {
    root: "",
    getMessageType: function (type) {
        if (type === 0) {
            return "success";
        } else if (type === 1) {
            return "info";
        } else if (type === 2) {
            return "warning";
        } else if (type === 3) {
            return "danger";
        } else {
            return "";
        }
    },
    init: function () {
        $("[data-module]").each(function () {
            var $this = $(this);
            var module = $this.data("module");
            var action = $this.data("action");
            var parameters = window[$this.data("parameters") || {}];
            
            if (app[module] && app[module][action]) app[module][action].call($this, parameters);
        });

        $(".grid-bind").each(function () {
            var $grid = $(this);
            var options = {
                form: $grid.data("form") || "#filter",
                load: true,
                fieldPrefix: $grid.data("field-prefix") || "Filter",
                pageSize: $grid.data("page-size") || 25,
                loadOnDelete: true,
                successOnDelete: $grid.data("success-on-delete") || undefined
            };

            if ($grid.data("load") !== undefined) {
                options.load = $grid.data("load") === "true";
            }

            if ($grid.data("load-on-delete") !== undefined) {
                options.loadOnDelete = $grid.data("load-on-delete") === "true";
            }

            if (options.successOnDelete !== undefined && window[options.successOnDelete] !== undefined) {
                options.successOnDelete = window[options.successOnDelete];
            }

            $.thunder.grid($grid, options);

            $grid.on("click", ".btn-delete-row", function(e) {
                var $button = $(this);

                e.preventDefault();

                $.thunder.confirm("Deseja realmente excluir esse registro?", {
                    onYes: function() {
                        $.ajax({
                            url: $button.is("a") ? $button.attr("href") : $button.data("url"),
                            type: "delete",
                            headers: {
                                "Url-Parent": window.location.pathname
                            },
                            success: function (result) {
                                if (result.type === 0) {
                                    if (options.loadOnDelete) {
                                        $.thunder.grid($grid, "reload");
                                    }

                                    if ($.isFunction(options.successOnDelete)) {
                                        options.successOnDelete.call($button, $grid);
                                    }
                                } else {
                                    $.thunder.alert(result.data || result.messages, {
                                        type: app.settings.getMessageType(result.type)
                                    });
                                }
                            }
                        });
                    }
                });
            });
        });
       
        $.ajaxSetup({
            statusCode: {
                401: function () {
                    $.thunder.alert("Você não possui permissão de acesso à esta funcionalidade!", {
                        type: "warning"
                    });
                }
            }
        });

        $(document).ajaxComplete(function (e, response) {<commit_msg>ajuste de retorno do ajax quando o usuário não possui acesso<commit_after>﻿app.settings = {
    root: "",
    getMessageType: function (type) {
        if (type === 0) {
            return "success";
        } else if (type === 1) {
            return "info";
        } else if (type === 2) {
            return "warning";
        } else if (type === 3) {
            return "danger";
        } else {
            return "";
        }
    },
    init: function () {
        $("[data-module]").each(function () {
            var $this = $(this);
            var module = $this.data("module");
            var action = $this.data("action");
            var parameters = window[$this.data("parameters") || {}];
            
            if (app[module] && app[module][action]) app[module][action].call($this, parameters);
        });

        $(".grid-bind").each(function () {
            var $grid = $(this);
            var options = {
                form: $grid.data("form") || "#filter",
                load: true,
                fieldPrefix: $grid.data("field-prefix") || "Filter",
                pageSize: $grid.data("page-size") || 25,
                loadOnDelete: true,
                successOnDelete: $grid.data("success-on-delete") || undefined
            };

            if ($grid.data("load") !== undefined) {
                options.load = $grid.data("load") === "true";
            }

            if ($grid.data("load-on-delete") !== undefined) {
                options.loadOnDelete = $grid.data("load-on-delete") === "true";
            }

            if (options.successOnDelete !== undefined && window[options.successOnDelete] !== undefined) {
                options.successOnDelete = window[options.successOnDelete];
            }

            $.thunder.grid($grid, options);

            $grid.on("click", ".btn-delete-row", function(e) {
                var $button = $(this);

                e.preventDefault();

                $.thunder.confirm("Deseja realmente excluir esse registro?", {
                    onYes: function() {
                        $.ajax({
                            url: $button.is("a") ? $button.attr("href") : $button.data("url"),
                            type: "delete",
                            headers: {
                                "Url-Parent": window.location.pathname
                            },
                            success: function (result) {
                                if (result.type === 0) {
                                    if (options.loadOnDelete) {
                                        $.thunder.grid($grid, "reload");
                                    }

                                    if ($.isFunction(options.successOnDelete)) {
                                        options.successOnDelete.call($button, $grid);
                                    }
                                } else {
                                    $.thunder.alert(result.data || result.messages, {
                                        type: app.settings.getMessageType(result.type)
                                    });
                                }
                            }
                        });
                    }
                });
            });
        });
       
        $.ajaxSetup({
            statusCode: {
                403: function () {
                    $.thunder.alert("Você não possui permissão de acesso à esta funcionalidade!", {
                        type: "warning"
                    });
                }
            }
        });

        $(document).ajaxComplete(function (e, response) {
{'fraction_non_alphanumeric': 0.13711126468555632, 'fraction_numerical': 0.0027643400138217, 'mean_word_length': 1.0297335203366058, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 22, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '240292', 'n_tokens_mistral': 1772, 'n_tokens_neox': 1672, 'n_words': 318}