<commit_before>/*jslint nomen:true*/
/*global define*/
define(function(require) {
    'use strict';

    var BaseComponent = require('oroui/js/app/components/base/component');
    var TransitionHandler = require('oroworkflow/js/transition-handler');
    var $ = require('jquery');
    var __ = require('orotranslation/js/translator');
    var mediator = require('oroui/js/mediator');

    var ButtonComponent = BaseComponent.extend({

        /**
         * @property {Object}
         */
        options: {
            displayType: ''
        },

        /**
         * @property {jQuery.Element}
         */
        $button: null,

        /**
         * @inheritDoc
         */
        initialize: function(options) {
            ButtonComponent.__super__.initialize.apply(this, arguments);

            this.options = options || {};

            this.$button = $(this.options._sourceElement);

            this._processButton();
        },

        /**
         * @private
         */
        _processButton: function() {
            var self = this;
            if (this.$button.data('enabled')) {
                if (this.options.displayType === 'dialog') {
                    this.$button.data('executor', function() {
                        TransitionHandler.call(self.$button);
                    });
                    this.$button.on('click', function(e) {
                        e.preventDefault();

                        self._onClickButtonEnabledDisplayTypeDialog(this);
                    });
                } else {
                    this.$button.on('click', function(e) {
                        e.preventDefault();

                        self._onClickButtonEnabledDisplayTypeNotDialog(this);
                    });
                }
            } else {
                this.$button.on('click', function(e) {
                    e.preventDefault();
                });
                if (this.$button.data('transition-condition-messages')) {
                    this.$button.popover({
                        'html': true,
                        'placement': 'bottom',
                        'container': $('body'),
                        'trigger': 'hover',
                        'title': '<i class="fa-exclamation-circle"></i>' + __('Unmet conditions'),
                        'content': this.$button.data('transition-condition-messages')
                    });
                }
            }
        },

        /**
         * @param clickedButton
         * @private
         */
        _onClickButtonEnabledDisplayTypeDialog: function(clickedButton) {
            $(clickedButton).data('executor').call();
        },

        /**
         * @param clickedButton
         * @private
         */
        _onClickButtonEnabledDisplayTypeNotDialog: function(clickedButton) {
            mediator.execute('redirectTo', {url: this.$button.data('transition-url')}, {redirect: true});
        },

        dispose: function() {
            if (this.disposed) {
                return;
            }

            this.$button.off();

            ButtonComponent.__super__.dispose.call(this);
        }
    });

    return ButtonComponent;
});<commit_msg>BB-13216: Remove disable SL buttons and show validation message  - refactor create order button<commit_after>/*jslint nomen:true*/
/*global define*/
define(function(require) {
    'use strict';

    var BaseComponent = require('oroui/js/app/components/base/component');
    var TransitionHandler = require('oroworkflow/js/transition-handler');
    var $ = require('jquery');
    var __ = require('orotranslation/js/translator');
    var mediator = require('oroui/js/mediator');

    var ButtonComponent = BaseComponent.extend({

        /**
         * @property {Object}
         */
        options: {
            displayType: ''
        },

        /**
         * @property {jQuery.Element}
         */
        $button: null,

        /**
         * @inheritDoc
         */
        initialize: function(options) {
            ButtonComponent.__super__.initialize.apply(this, arguments);

            this.options = options || {};

            this.$button = $(this.options._sourceElement);

            this._processButton();
        },

        /**
         * @private
         */
        _processButton: function() {
            var self = this;
            if (this.$button.data('enabled')) {
                if (this.options.displayType === 'dialog') {
                    this.$button.data('executor', function() {
                        TransitionHandler.call(self.$button);
                    });
                    this.$button.on('click', function(e) {
                        e.preventDefault();

                        self._onClickButtonExecutor(this);
                    });
                } else {
                    this.$button.on('click', function(e) {
                        e.preventDefault();

                        self._onClickButtonRedirect(this);
                    });
                }
            } else {
                this.$button.on('click', function(e) {
                    e.preventDefault();
                });
                if (this.$button.data('transition-condition-messages')) {
                    this.$button.popover({
                        'html': true,
                        'placement': 'bottom',
                        'container': $('body'),
                        'trigger': 'hover',
                        'title': '<i class="fa-exclamation-circle"></i>' + __('Unmet conditions'),
                        'content': this.$button.data('transition-condition-messages')
                    });
                }
            }
        },

        /**
         * @param clickedButton
         * @private
         */
        _onClickButtonExecutor: function(clickedButton) {
            $(clickedButton).data('executor').call();
        },

        /**
         * @param clickedButton
         * @private
         */
        _onClickButtonRedirect: function(clickedButton) {
            mediator.execute('redirectTo', {url: this.$button.data('transition-url')}, {redirect: true});
        },

        dispose: function() {
            if (this.disposed) {
                return;
            }

            this.$button.off();

            ButtonComponent.__super__.dispose.call(this);
        }
    });

    return ButtonComponent;
});
{'fraction_non_alphanumeric': 0.1340738423028786, 'fraction_numerical': 0.0007822277847309136, 'mean_word_length': 1.3581704168203614, 'pattern_counts': {'":': 0, '<': 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': '1223493', 'n_tokens_mistral': 1593, 'n_tokens_neox': 1493, 'n_words': 234}