<commit_before>define(function(require) {
    'use strict';

    var InlineEditingPlugin;
    var _ = require('underscore');
    var __ = require('orotranslation/js/translator');
    var $ = require('jquery');
    var mediator = require('oroui/js/mediator');
    var BasePlugin = require('oroui/js/app/plugins/base/plugin');
    var CellIterator = require('../../../datagrid/cell-iterator');
    var backdropManager = require('oroui/js/tools/backdrop-manager');
    require('orodatagrid/js/app/components/cell-popup-editor-component');
    require('orodatagrid/js/app/views/editor/text-editor-view');

    InlineEditingPlugin = BasePlugin.extend({
        /**
         * true if any cell is in edit mode
         *
         * @type {boolean}
         */
        editModeEnabled: false,

        /**
         * This component is used by default for inline editing
         */
        DEFAULT_COMPONENT: 'orodatagrid/js/app/components/cell-popup-editor-component',

        /**
         * This view is used by default for editing
         */
        DEFAULT_VIEW: 'orodatagrid/js/app/views/editor/text-editor-view',

        /**
         * This view is used by default for editing
         */
        DEFAULT_COLUMN_TYPE: 'string',

        /**
         * If true interface should not respond to user actions.
         * Usefull for grid page switching support
         */
        lockUserActions: false,

        /**
         * Key codes
         */
        TAB_KEY_CODE: 9,
        ENTER_KEY_CODE: 13,
        ESCAPE_KEY_CODE: 27,
        ARROW_LEFT_KEY_CODE: 37,
        ARROW_TOP_KEY_CODE: 38,
        ARROW_RIGHT_KEY_CODE: 39,
        ARROW_BOTTOM_KEY_CODE: 40,

        constructor: function() {
            this.onKeyDown = _.bind(this.onKeyDown, this);
            this.hidePopover = _.bind(this.hidePopover, this);
            InlineEditingPlugin.__super__.constructor.apply(this, arguments);
        },

        enable: function() {
            this.listenTo(this.main, {
                afterMakeCell: this.onAfterMakeCell,
                shown: this.onGridShown,
                rowClicked: this.onGridRowClicked
            });
            if (!this.options.metadata.inline_editing.save_api_accessor) {
                throw new Error('"save_api_accessor" option is required');
            }
            var ApiAccesor = this.options.metadata.inline_editing.save_api_accessor['class'];
            this.saveApiAccessor = new ApiAccesor(
                _.omit(this.options.metadata.inline_editing.save_api_accessor, 'class'));
            this.main.body.refresh();
            InlineEditingPlugin.__super__.enable.call(this);
        },

        disable: function() {
            if (this.editModeEnabled) {
                this.exitEditMode(true);
            }
            InlineEditingPlugin.__super__.disable.call(this);
            this.hidePopover();
            this.main.body.refresh();
        },

        dispose: function() {
            if (this.disposed) {
                return;
            }
            this.destroyPopover();
            return InlineEditingPlugin.__super__.dispose.call(this);
        },<commit_msg>CRM-4320 Inline editing fixes<commit_after>define(function(require) {
    'use strict';

    var InlineEditingPlugin;
    var _ = require('underscore');
    var __ = require('orotranslation/js/translator');
    var $ = require('jquery');
    var mediator = require('oroui/js/mediator');
    var BasePlugin = require('oroui/js/app/plugins/base/plugin');
    var CellIterator = require('../../../datagrid/cell-iterator');
    var backdropManager = require('oroui/js/tools/backdrop-manager');
    require('orodatagrid/js/app/components/cell-popup-editor-component');
    require('orodatagrid/js/app/views/editor/text-editor-view');

    InlineEditingPlugin = BasePlugin.extend({
        /**
         * true if any cell is in edit mode
         *
         * @type {boolean}
         */
        editModeEnabled: false,

        /**
         * This component is used by default for inline editing
         */
        DEFAULT_COMPONENT: 'orodatagrid/js/app/components/cell-popup-editor-component',

        /**
         * This view is used by default for editing
         */
        DEFAULT_VIEW: 'orodatagrid/js/app/views/editor/text-editor-view',

        /**
         * This view is used by default for editing
         */
        DEFAULT_COLUMN_TYPE: 'string',

        /**
         * If true interface should not respond to user actions.
         * Usefull for grid page switching support
         */
        lockUserActions: false,

        /**
         * Key codes
         */
        TAB_KEY_CODE: 9,
        ENTER_KEY_CODE: 13,
        ESCAPE_KEY_CODE: 27,
        ARROW_LEFT_KEY_CODE: 37,
        ARROW_TOP_KEY_CODE: 38,
        ARROW_RIGHT_KEY_CODE: 39,
        ARROW_BOTTOM_KEY_CODE: 40,

        constructor: function() {
            this.onKeyDown = _.bind(this.onKeyDown, this);
            this.hidePopover = _.bind(this.hidePopover, this);
            InlineEditingPlugin.__super__.constructor.apply(this, arguments);
        },

        enable: function() {
            this.listenTo(this.main, {
                afterMakeCell: this.onAfterMakeCell,
                shown: this.onGridShown,
                rowClicked: this.onGridRowClicked
            });
            if (!this.options.metadata.inline_editing.save_api_accessor) {
                throw new Error('"save_api_accessor" option is required');
            }
            var ApiAccesor = this.options.metadata.inline_editing.save_api_accessor['class'];
            this.saveApiAccessor = new ApiAccesor(
                _.omit(this.options.metadata.inline_editing.save_api_accessor, 'class'));
            this.main.body.refresh();
            this.listenTo(mediator, 'page:beforeChange', this.exitEditMode);
        },

        disable: function() {
            if (this.editModeEnabled) {
                this.exitEditMode(true);
            }
            InlineEditingPlugin.__super__.disable.call(this);
            this.hidePopover();
            this.main.body.refresh();
        },

        dispose: function() {
            if (this.disposed) {
                return;
            }
            this.destroyPopover();
            return InlineEditingPlugin.__super__.dispose.call(this);
        },
{'fraction_non_alphanumeric': 0.11148007590132827, 'fraction_numerical': 0.004743833017077799, 'mean_word_length': 1.9309545875810936, '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': '7254604', 'n_tokens_mistral': 1860, 'n_tokens_neox': 1782, 'n_words': 317}