<commit_before>odoo.define('web_kanban.Column', function (require) {
"use strict";

var core = require('web.core');
var Dialog = require('web.Dialog');
var form_common = require('web.form_common');
var Widget = require('web.Widget');
var quick_create = require('web_kanban.quick_create');
var KanbanRecord = require('web_kanban.Record');

var _t = core._t;
var QWeb = core.qweb;
var RecordQuickCreate = quick_create.RecordQuickCreate;

var KanbanColumn = Widget.extend({
    template: "KanbanView.Group",

    events: {
        'click .o_kanban_toggle_fold': function (e) {
            e.preventDefault();
            e.stopPropagation();
            this.folded = true;
            this.update_column();
        },
        'click .o_column_edit': 'edit_column',
        'click .o_column_delete': 'delete_column',
        'click .o_column_archive': 'archive_records',
        'click .o_column_unarchive': 'unarchive_records',
        'click .o_kanban_quick_add': 'add_quick_create',
        'click .o_kanban_load_more': 'load_more',
    },

    custom_events: {
        'kanban_record_delete': 'delete_record',
        'cancel_quick_create': 'cancel_quick_create',
        'quick_create_add_record': 'quick_create_add_record',
    },

    init: function(parent, group_data, options, record_options) {
        this._super(parent);
        this.data_records = group_data.records;
        this.dataset = group_data.dataset;
        this.records = [];
        this.title = group_data.title;
        this.id = group_data.id;
        this.folded = group_data.attributes.folded;
        this.fields = options.fields;
        this.values = group_data.values;

        this.quick_create = options.quick_create;
        this.grouped_by_m2o = options.grouped_by_m2o;
        this.editable = options.editable;
        this.deletable = options.deletable;
        this.has_active_field = options.has_active_field;
        this.records_editable = options.records_editable;
        this.records_deletable = options.records_deletable;
        this.relation = options.relation;
        this.offset = 0;
        this.remaining = this.dataset.size() - this.data_records.length;

        this.record_options = _.extend(_.clone(record_options), {
            group_info: this.values,
        });

        var self = this;
        if (group_data.options && group_data.options.group_by_tooltip) {
            this.tooltip_info = _.map(group_data.options.group_by_tooltip, function (key, value, list) {
                return (self.values && self.values[value] && "<div>" +key + "<br>" + self.values[value] + "</div>") || '';
            }).join('');
        } else {
            this.tooltip_info = "";
        }
    },

    start: function() {
        var self = this;
        this.$header = this.$('.o_kanban_header');

        for (var i = 0; i < this.data_records.length; i++) {
            this.add_record(this.data_records[i], {no_update: true});
        }
        this.$header.tooltip();

        this.$el.sortable({
            connectWith: '.o_kanban_group',
            revert: 0,
            delay: 0,
            items: '> .o_kanban_record',
            helper: 'clone',
            cursor: 'move',
            over: function () {
                self.$el.addClass('o_kanban_hover');
                self.update_column();
            },
            out: function () {
                self.$el.removeClass('o_kanban_hover');
            },
            update: function (event, ui) {
                var record = ui.item.data('record');
                var index = self.records.indexOf(record);
                var test2 = $.contains(self.$el[0], record.$el[0]);
                record.$el.removeAttr('style');  // jqueryui sortable add display:block inline
                if (index >= 0 && test2) {
                    // resequencing records
                    self.trigger_up('kanban_column_resequence');
                } else if (index >= 0 && !test2) {
                    // removing record from this column
                    self.records.splice(self.records.indexOf(record), 1);
                    self.dataset.remove_ids([record.id]);
                } else {
                    // adding record to this column
                    self.records.push(record);
                    record.setParent(self);
                    self.trigger_up('kanban_column_add_record', {record: record});
                }
                self.update_column();
            }
        });
        this.update_column();
        this.$el.click(function (event) {
            if (self.$el.hasClass('o_column_folded')) {
                event.preventDefault();
                self.folded = false;
                self.update_column();
            }
        });
    },

    is_empty: function () {
        return !this.records.length;<commit_msg>[FIX] web_kanban: disable jquery sortable in mobile mode<commit_after>odoo.define('web_kanban.Column', function (require) {
"use strict";

var config = require('web.config');
var core = require('web.core');
var Dialog = require('web.Dialog');
var form_common = require('web.form_common');
var Widget = require('web.Widget');
var quick_create = require('web_kanban.quick_create');
var KanbanRecord = require('web_kanban.Record');

var _t = core._t;
var QWeb = core.qweb;
var RecordQuickCreate = quick_create.RecordQuickCreate;

var KanbanColumn = Widget.extend({
    template: "KanbanView.Group",

    events: {
        'click .o_kanban_toggle_fold': function (e) {
            e.preventDefault();
            e.stopPropagation();
            this.folded = true;
            this.update_column();
        },
        'click .o_column_edit': 'edit_column',
        'click .o_column_delete': 'delete_column',
        'click .o_column_archive': 'archive_records',
        'click .o_column_unarchive': 'unarchive_records',
        'click .o_kanban_quick_add': 'add_quick_create',
        'click .o_kanban_load_more': 'load_more',
    },

    custom_events: {
        'kanban_record_delete': 'delete_record',
        'cancel_quick_create': 'cancel_quick_create',
        'quick_create_add_record': 'quick_create_add_record',
    },

    init: function(parent, group_data, options, record_options) {
        this._super(parent);
        this.data_records = group_data.records;
        this.dataset = group_data.dataset;
        this.records = [];
        this.title = group_data.title;
        this.id = group_data.id;
        this.folded = group_data.attributes.folded;
        this.fields = options.fields;
        this.values = group_data.values;

        this.quick_create = options.quick_create;
        this.grouped_by_m2o = options.grouped_by_m2o;
        this.editable = options.editable;
        this.deletable = options.deletable;
        this.has_active_field = options.has_active_field;
        this.records_editable = options.records_editable;
        this.records_deletable = options.records_deletable;
        this.relation = options.relation;
        this.offset = 0;
        this.remaining = this.dataset.size() - this.data_records.length;

        this.record_options = _.extend(_.clone(record_options), {
            group_info: this.values,
        });

        var self = this;
        if (group_data.options && group_data.options.group_by_tooltip) {
            this.tooltip_info = _.map(group_data.options.group_by_tooltip, function (key, value, list) {
                return (self.values && self.values[value] && "<div>" +key + "<br>" + self.values[value] + "</div>") || '';
            }).join('');
        } else {
            this.tooltip_info = "";
        }
    },

    start: function() {
        var self = this;
        this.$header = this.$('.o_kanban_header');

        for (var i = 0; i < this.data_records.length; i++) {
            this.add_record(this.data_records[i], {no_update: true});
        }
        this.$header.tooltip();

        if (config.device.size_class > config.device.SIZES.XS) {
            // deactivate sortable in mobile mode.  It does not work anyway,
            // and it breaks horizontal scrolling in kanban views.  Someday, we
            // should find a way to use the touch events to make sortable work.
            this.$el.sortable({
                connectWith: '.o_kanban_group',
                revert: 0,
                delay: 0,
                items: '> .o_kanban_record',
                helper: 'clone',
                cursor: 'move',
                over: function () {
                    self.$el.addClass('o_kanban_hover');
                    self.update_column();
                },
                out: function () {
                    self.$el.removeClass('o_kanban_hover');
                },
                update: function (event, ui) {
                    var record = ui.item.data('record');
                    var index = self.records.indexOf(record);
                    var test2 = $.contains(self.$el[0], record.$el[0]);
                    record.$el.removeAttr('style');  // jqueryui sortable add display:block inline
                    if (index >= 0 && test2) {
                        // resequencing records
                        self.trigger_up('kanban_column_resequence');
                    } else if (index >= 0 && !test2) {
                        // removing record from this column
                        self.records.splice(self.records.indexOf(record), 1);
                        self.dataset.remove_ids([record.id]);
                    } else {
                        // adding record to this column
                        self.records.push(record);
                        record.setParent(self);
                        self.trigger_up('kanban_column_add_record', {record: record});
                    }
                    self.update_column();
                }
            });
        }
        this.update_column();
        this.$el.click(function (event) {
            if (self.$el.hasClass('o_column_folded')) {
                event.preventDefault();
                self.folded = false;
                self.update_column();
            }
        });
    },

    is_empty: function () {
        return !this.records.length;
{'fraction_non_alphanumeric': 0.1249385628624791, 'fraction_numerical': 0.0027523837609358106, 'mean_word_length': 1.894452347083926, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 16, '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': '6881146', 'n_tokens_mistral': 2941, 'n_tokens_neox': 2849, 'n_words': 533}