<commit_before>/*
 * This file is part of Report Portal.
 *
 * Report Portal is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Report Portal is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with Report Portal.  If not, see <http://www.gnu.org/licenses/>.
 */
define(function (require, exports, module) {
    'use strict';

    var SingletonLaunchFilterCollection = require('filters/SingletonLaunchFilterCollection');

    var $ = require('jquery');
    var _ = require('underscore');
    var Backbone = require('backbone');
    var Epoxy = require('backbone-epoxy');
    var App = require('app');
    var LaunchSuiteStepItemModel = require('launches/common/LaunchSuiteStepItemModel');
    var Util = require('util');
    var MergeAction = require('launches/multipleActions/mergeAction');
    var CompareAction = require('launches/multipleActions/compareAction');
    var EditDefectAction = require('launches/multipleActions/editDefectAction');
    var ForceFinishAction = require('launches/multipleActions/forceFinishAction');
    var RemoveAction = require('launches/multipleActions/removeAction');
    var ChangeModeAction = require('launches/multipleActions/changeModeAction');
    var PostBugAction = require('launches/multipleActions/postBugAction');
    var LoadBugAction = require('launches/multipleActions/loadBugAction');

    var config = App.getInstance();

    var LaunchMultipleSelectItem = Epoxy.View.extend({
        className: 'multi-select-item',
        template: 'tpl-launch-multiple-selected-item',

        events: {
            'click [data-ja-close-item]': 'onClickClose',
        },

        bindings: {
            '[data-js-item-name]': 'text: format("$1$2", name, numberText)',
            ':el': 'attr: {title: invalidMessage}, classes: {"error-validate": invalidMessage}',
        },

        initialize: function() {
            this.render();
            this.listenTo(this.model, 'remove', this.destroy);
        },
        render: function() {
            this.$el.html(Util.templates(this.template, {}));
        },
        onClickClose: function() {
            var type = this.model.get('type');
            switch (type) {
                case 'LAUNCH':
                    config.trackingDispatcher.trackEventNumber(67);
                    break;
                case 'SUITE':
                case 'TEST':
                    config.trackingDispatcher.trackEventNumber(100.2);
                    break;
                default:
                    config.trackingDispatcher.trackEventNumber(161);

            }

            this.model.set({select: false, invalidMessage: ''});
        },
        destroy: function () {
            this.$el.remove();
            this.undelegateEvents();
            this.stopListening();
            this.unbind();
            delete this;
        },
    });

    var SelectedItemsCollection = Backbone.Collection.extend({
        model: LaunchSuiteStepItemModel,
    });


    var LaunchMultipleSelectView = Epoxy.View.extend({
        template: 'tpl-launch-multiple-selected',

        events: {
            'click [data-ja-close]': 'onClickClose',
            'click [data-js-proceed]': 'onClickProceed',
        },

        actionValidators: {
            merge: function() {
                _.each(this.collection.models, function(model) {
                    model.set({invalidMessage: model.validate.merge()});
                });
            },
            compare: function() {
                _.each(this.collection.models, function(model) {
                    model.set({invalidMessage: ''})
                })
            },
            editdefect: function(){
                _.each(this.collection.models, function(model) {
                    model.set({invalidMessage: model.validate.editDefect()})
                })
            },
            changemode: function() {
                _.each(this.collection.models, function(model) {
                    model.set({invalidMessage: model.validate.changeMode()})
                })
            },
            forcefinish: function() {
                _.each(this.collection.models, function(model) {
                    model.set({invalidMessage: model.validate.forceFinish()})
                })
            },
            remove: function() {
                _.each(this.collection.models, function(model) {
                     model.set({invalidMessage: model.validate.remove()})
                })
            },
            postbug: function() {
                _.each(this.collection.models, function(model) {
                    model.set({invalidMessage: model.validate.postbug()})
                })
            },
            loadbug: function() {
                _.each(this.collection.models, function(model) {
                    model.set({invalidMessage: model.validate.loadbug()})
                })
            },
        },
        actionCall: {
            merge: function() {
                var self = this;
                this.mergeAction = new MergeAction({
                    items: this.collection.models,
                })
                this.mergeAction.getAsync().done(function() {
                    self.collectionItems.load();
                    self.mergeAction = null;
                    self.reset();
                })
            },
            compare: function() {
                var self = this;
                this.compareAction = new CompareAction({
                    items: this.collection.models,
                });
                this.compareAction.getAsync().done(function() {
                    self.compareAction = null;
                    self.reset();
                });
            },
            editdefect: function(){
                var self = this;
                this.editDefectAction = new EditDefectAction({
                    items: this.collection.models,
                });
                this.editDefectAction.getAsync().done(function() {
                    self.editDefectAction = null;
                    self.reset();
                });
            },
            changemode: function() {
                var self = this;
                ChangeModeAction({items: this.collection.models}).done(function() {
                    self.collectionItems.load(true);
                    self.reset();
                })
            },
            forcefinish: function() {
                var self = this;
                ForceFinishAction({items: this.collection.models}).done(function() {
                    self.collectionItems.load();
                    self.reset();
                })
            },
            remove: function() {
                var self = this;
                RemoveAction({items: this.collection.models}).done(function() {
                    self.compareAction = null;
                    self.collectionItems.load(true);
                    var parentModel = self.collectionItems.parentModel || self.collectionItems.launchModel;
                    parentModel && parentModel.updateData(true);
                    self.reset();<commit_msg>update launch crumbs items after remove item<commit_after>/*
 * This file is part of Report Portal.
 *
 * Report Portal is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Report Portal is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with Report Portal.  If not, see <http://www.gnu.org/licenses/>.
 */
define(function (require, exports, module) {
    'use strict';

    var SingletonLaunchFilterCollection = require('filters/SingletonLaunchFilterCollection');

    var $ = require('jquery');
    var _ = require('underscore');
    var Backbone = require('backbone');
    var Epoxy = require('backbone-epoxy');
    var App = require('app');
    var LaunchSuiteStepItemModel = require('launches/common/LaunchSuiteStepItemModel');
    var Util = require('util');
    var MergeAction = require('launches/multipleActions/mergeAction');
    var CompareAction = require('launches/multipleActions/compareAction');
    var EditDefectAction = require('launches/multipleActions/editDefectAction');
    var ForceFinishAction = require('launches/multipleActions/forceFinishAction');
    var RemoveAction = require('launches/multipleActions/removeAction');
    var ChangeModeAction = require('launches/multipleActions/changeModeAction');
    var PostBugAction = require('launches/multipleActions/postBugAction');
    var LoadBugAction = require('launches/multipleActions/loadBugAction');

    var config = App.getInstance();

    var LaunchMultipleSelectItem = Epoxy.View.extend({
        className: 'multi-select-item',
        template: 'tpl-launch-multiple-selected-item',

        events: {
            'click [data-ja-close-item]': 'onClickClose',
        },

        bindings: {
            '[data-js-item-name]': 'text: format("$1$2", name, numberText)',
            ':el': 'attr: {title: invalidMessage}, classes: {"error-validate": invalidMessage}',
        },

        initialize: function() {
            this.render();
            this.listenTo(this.model, 'remove', this.destroy);
        },
        render: function() {
            this.$el.html(Util.templates(this.template, {}));
        },
        onClickClose: function() {
            var type = this.model.get('type');
            switch (type) {
                case 'LAUNCH':
                    config.trackingDispatcher.trackEventNumber(67);
                    break;
                case 'SUITE':
                case 'TEST':
                    config.trackingDispatcher.trackEventNumber(100.2);
                    break;
                default:
                    config.trackingDispatcher.trackEventNumber(161);

            }

            this.model.set({select: false, invalidMessage: ''});
        },
        destroy: function () {
            this.$el.remove();
            this.undelegateEvents();
            this.stopListening();
            this.unbind();
            delete this;
        },
    });

    var SelectedItemsCollection = Backbone.Collection.extend({
        model: LaunchSuiteStepItemModel,
    });


    var LaunchMultipleSelectView = Epoxy.View.extend({
        template: 'tpl-launch-multiple-selected',

        events: {
            'click [data-ja-close]': 'onClickClose',
            'click [data-js-proceed]': 'onClickProceed',
        },

        actionValidators: {
            merge: function() {
                _.each(this.collection.models, function(model) {
                    model.set({invalidMessage: model.validate.merge()});
                });
            },
            compare: function() {
                _.each(this.collection.models, function(model) {
                    model.set({invalidMessage: ''})
                })
            },
            editdefect: function(){
                _.each(this.collection.models, function(model) {
                    model.set({invalidMessage: model.validate.editDefect()})
                })
            },
            changemode: function() {
                _.each(this.collection.models, function(model) {
                    model.set({invalidMessage: model.validate.changeMode()})
                })
            },
            forcefinish: function() {
                _.each(this.collection.models, function(model) {
                    model.set({invalidMessage: model.validate.forceFinish()})
                })
            },
            remove: function() {
                _.each(this.collection.models, function(model) {
                     model.set({invalidMessage: model.validate.remove()})
                })
            },
            postbug: function() {
                _.each(this.collection.models, function(model) {
                    model.set({invalidMessage: model.validate.postbug()})
                })
            },
            loadbug: function() {
                _.each(this.collection.models, function(model) {
                    model.set({invalidMessage: model.validate.loadbug()})
                })
            },
        },
        actionCall: {
            merge: function() {
                var self = this;
                this.mergeAction = new MergeAction({
                    items: this.collection.models,
                })
                this.mergeAction.getAsync().done(function() {
                    self.collectionItems.load();
                    self.mergeAction = null;
                    self.reset();
                })
            },
            compare: function() {
                var self = this;
                this.compareAction = new CompareAction({
                    items: this.collection.models,
                });
                this.compareAction.getAsync().done(function() {
                    self.compareAction = null;
                    self.reset();
                });
            },
            editdefect: function(){
                var self = this;
                this.editDefectAction = new EditDefectAction({
                    items: this.collection.models,
                });
                this.editDefectAction.getAsync().done(function() {
                    self.editDefectAction = null;
                    self.reset();
                });
            },
            changemode: function() {
                var self = this;
                ChangeModeAction({items: this.collection.models}).done(function() {
                    self.collectionItems.load(true);
                    self.reset();
                })
            },
            forcefinish: function() {
                var self = this;
                ForceFinishAction({items: this.collection.models}).done(function() {
                    self.collectionItems.load();
                    self.reset();
                })
            },
            remove: function() {
                var self = this;
                RemoveAction({items: this.collection.models}).done(function() {
                    self.compareAction = null;
                    self.collectionItems.load(true);
                    var parentModel = self.collectionItems.parentModel || self.collectionItems.launchModel;
                    if(parentModel) {
                        _.each(parentModel.collection.models, function (model) {
                            model.updateData(true);
                        });
                    }
                    self.reset();
{'fraction_non_alphanumeric': 0.11322848006265092, 'fraction_numerical': 0.0015662729230568426, 'mean_word_length': 1.6493775933609958, 'pattern_counts': {'":': 2, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '1792354', 'n_tokens_mistral': 3779, 'n_tokens_neox': 3563, 'n_words': 752}