<commit_before>Imcms.define("imcms-templates-tab-builder",
    [
        "imcms-bem-builder", "imcms-components-builder", "imcms-templates-rest-api",
        "imcms-page-info-tabs-linker"
    ],
    function (BEM, components, templatesRestApi, linker) {

        return {
            name: "templates",
            data: {},
            buildTab: function (index) {
                var $templateSelectContainer = components.selects.selectContainer("<div>", {
                        name: "template",
                        text: "Template"
                    }),
                    $templateSelect = $templateSelectContainer.getSelect(),

                    $defaultChildTemplateSelectContainer = components.selects.selectContainer("<div>", {
                        name: "childTemplate",
                        text: "Default child template"
                    }),
                    $defaultChildTemplateSelect = $defaultChildTemplateSelectContainer.getSelect();

                this.data.$templateSelect = $templateSelect;
                this.data.$defaultChildTemplateSelect = $defaultChildTemplateSelect;

                templatesRestApi.read(null)
                    .done(function (templates) {
                        var templatesDataMapped = templates.map(function (template) {
                            return {
                                text: template.name,
                                "data-value": template.id
                            }
                        });

                        components.selects.addOptionsToSelect(templatesDataMapped, $templateSelect);
                        components.selects.addOptionsToSelect(templatesDataMapped, $defaultChildTemplateSelect);
                    });

                var blockElements = [
                    $templateSelectContainer,
                    $defaultChildTemplateSelectContainer
                ];
                return linker.buildFormBlock(blockElements, index);
            },
            fillTabDataFromDocument: function (document) {
                var templatesTab = this.data;

                templatesTab.$templateSelect.selectValue(document.template);
                templatesTab.$defaultChildTemplateSelect.selectValue(document.childTemplate);
            },
            clearTabData: function () {
                var templatesTab = this.data;

                templatesTab.$templateSelect.selectFirst();
                templatesTab.$defaultChildTemplateSelect.selectFirst();
            }
        };
    }
);<commit_msg>IMCMS-255 - Upgrade server side to work with new client: - Fixed templates data filling in Page Info.<commit_after>Imcms.define("imcms-templates-tab-builder",
    [
        "imcms-bem-builder", "imcms-components-builder", "imcms-templates-rest-api",
        "imcms-page-info-tabs-linker"
    ],
    function (BEM, components, templatesRestApi, linker) {

        return {
            name: "templates",
            data: {},
            buildTab: function (index) {
                var $templateSelectContainer = components.selects.selectContainer("<div>", {
                        name: "template",
                        text: "Template"
                    }),
                    $templateSelect = $templateSelectContainer.getSelect(),

                    $defaultChildTemplateSelectContainer = components.selects.selectContainer("<div>", {
                        name: "childTemplate",
                        text: "Default child template"
                    }),
                    $defaultChildTemplateSelect = $defaultChildTemplateSelectContainer.getSelect();

                this.data.$templateSelect = $templateSelect;
                this.data.$defaultChildTemplateSelect = $defaultChildTemplateSelect;

                templatesRestApi.read(null)
                    .done(function (templates) {
                        var templatesDataMapped = templates.map(function (template) {
                            return {
                                text: template.name,
                                "data-value": template.name
                            }
                        });

                        components.selects.addOptionsToSelect(templatesDataMapped, $templateSelect);
                        components.selects.addOptionsToSelect(templatesDataMapped, $defaultChildTemplateSelect);
                    });

                var blockElements = [
                    $templateSelectContainer,
                    $defaultChildTemplateSelectContainer
                ];
                return linker.buildFormBlock(blockElements, index);
            },
            fillTabDataFromDocument: function (document) {
                var templatesTab = this.data;

                templatesTab.$templateSelect.selectValue(document.template.templateName);
                templatesTab.$defaultChildTemplateSelect.selectValue(document.template.childrenTemplateName);
            },
            clearTabData: function () {
                var templatesTab = this.data;

                templatesTab.$templateSelect.selectFirst();
                templatesTab.$defaultChildTemplateSelect.selectFirst();
            }
        };
    }
);
{'fraction_non_alphanumeric': 0.0892343120322395, 'fraction_numerical': 0.0005757052389176742, 'mean_word_length': 1.5399610136452242, 'pattern_counts': {'":': 2, '<': 7, '<?xml version=': 0, '>': 7, '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': '2281949', 'n_tokens_mistral': 1175, 'n_tokens_neox': 1074, 'n_words': 171}