<commit_before>import AbstractFormView     from '../../../Service/Form/View/AbstractFormView'
import Application          from '../../Application'
import ApplicationError     from '../../../Service/Error/ApplicationError'
import Content              from '../../Model/Content/Content'
import Contents             from '../../Collection/Content/Contents'
import FormViewButtonsMixin from '../../../Service/Form/Mixin/FormViewButtonsMixin'
import ContentToolbarView   from './ContentToolbarView'
import ContentVersionsView  from './ContentVersionsView'
import FlashMessageBag      from '../../../Service/FlashMessage/FlashMessageBag'

/**
 * @class ContentFormView
 */
class ContentFormView extends mix(AbstractFormView).with(FormViewButtonsMixin) 
{
    /**
     * Pre initialize
     * @param {Object} options
     */
    preinitialize(options) {
        super.preinitialize(options);
        this.events['change #oo_content_status'] = this._toggleCheckboxSaveOldPublishedVersion;
    }

    /**
     * Initialize
     * @param {Form}        form
     * @param {String}      name
     * @param {ContentType} contentType
     * @param {String}      language
     * @param {Array}       siteLanguageUrl
     * @param {String}      contentId
     * @param {String}      version
     */
    initialize({form, name, contentType, language, siteLanguageUrl, contentId, version}) {
        super.initialize({form : form});
        this._name = name;
        this._contentType = contentType;
        this._language = language;
        this._siteLanguageUrl = siteLanguageUrl;
        this._contentId = contentId;
        this._version = version;
    }

    /**
     * @inheritdoc
     */
    render() {
        let template = this._renderTemplate('Content/contentEditView', {
            contentTypeId: this._contentType.get('content_type_id'),
            language: this._language,
            name: this._name,
            siteLanguageUrl: this._siteLanguageUrl,
            messages: FlashMessageBag.getMessages()
        });
        this.$el.html(template);
        this._$formRegion = $('.form-edit', this.$el);
        super.render();

        return this;
    }

    /**
     * @inheritDoc
     */
    _renderForm() {
        if (true === this._contentType.get('defining_versionable')) {
            this._renderContentActionToolbar($('.content-action-toolbar', this.$el));
        }
        super._renderForm();
        // hide checkbox oo_content_saveOldPublishedVersion by default
        $('#oo_content_saveOldPublishedVersion', this.$el).closest('.form-group').hide();
    }

    /**
     * @param {Object} $selector
     * @private
     */
    _renderContentActionToolbar($selector) {
        this._displayLoader($selector);
        new Contents().fetch({
            apiContext: 'list-version',
            urlParameter: {<commit_msg>Fix active tab edit content (#2108)<commit_after>import AbstractFormView     from '../../../Service/Form/View/AbstractFormView'
import Application          from '../../Application'
import ApplicationError     from '../../../Service/Error/ApplicationError'
import Content              from '../../Model/Content/Content'
import Contents             from '../../Collection/Content/Contents'
import FormViewButtonsMixin from '../../../Service/Form/Mixin/FormViewButtonsMixin'
import ContentToolbarView   from './ContentToolbarView'
import ContentVersionsView  from './ContentVersionsView'
import FlashMessageBag      from '../../../Service/FlashMessage/FlashMessageBag'

/**
 * @class ContentFormView
 */
class ContentFormView extends mix(AbstractFormView).with(FormViewButtonsMixin) 
{
    /**
     * Pre initialize
     * @param {Object} options
     */
    preinitialize(options) {
        super.preinitialize(options);
        this.events['change #oo_content_status'] = this._toggleCheckboxSaveOldPublishedVersion;
    }

    /**
     * Initialize
     * @param {Form}        form
     * @param {String}      name
     * @param {ContentType} contentType
     * @param {String}      language
     * @param {Array}       siteLanguageUrl
     * @param {String}      contentId
     * @param {String}      version
     */
    initialize({form, name, contentType, language, siteLanguageUrl, contentId, version}) {
        super.initialize({form : form});
        this._name = name;
        this._contentType = contentType;
        this._language = language;
        this._siteLanguageUrl = siteLanguageUrl;
        this._contentId = contentId;
        this._version = version;
    }

    /**
     * @inheritdoc
     */
    render() {
        let template = this._renderTemplate('Content/contentEditView', {
            contentTypeId: this._contentType.get('content_type_id'),
            language: this._language,
            name: this._name,
            siteLanguageUrl: this._siteLanguageUrl,
            messages: FlashMessageBag.getMessages()
        });
        this.$el.html(template);
        this._$formRegion = $('.form-edit', this.$el);
        super.render();

        return this;
    }

    /**
     * @inheritDoc
     */
    _renderForm() {
        if (true === this._contentType.get('defining_versionable')) {
            this._renderContentActionToolbar($('.content-action-toolbar', this.$el));
        }
        super._renderForm();
        // hide checkbox oo_content_saveOldPublishedVersion by default
        $('#oo_content_saveOldPublishedVersion', this.$el).closest('.form-group').hide();

        // activate tab data
        $('.nav-tabs a.nav-tab-data', this._$formRegion).tab('show');
        $('.tab-content .tab-pane', this._$formRegion).removeClass('active');
        $('.tab-content .tab-data', this._$formRegion).addClass('active');
    }

    /**
     * @param {Object} $selector
     * @private
     */
    _renderContentActionToolbar($selector) {
        this._displayLoader($selector);
        new Contents().fetch({
            apiContext: 'list-version',
            urlParameter: {
{'fraction_non_alphanumeric': 0.13438602385351922, 'fraction_numerical': 0.0006719301192675962, 'mean_word_length': 2.400342661336379, 'pattern_counts': {'":': 0, '<': 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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3756710', 'n_tokens_mistral': 1575, 'n_tokens_neox': 1572, 'n_words': 303}