码迷,mamicode.com
首页 > 其他好文 > 详细

(59) 解决在列表视图复制导致打开详细内容

时间:2017-12-29 19:01:28      阅读:115      评论:0      收藏:0      [点我收藏+]

标签:cti   tostring   view   static   turn   attr   pos   cli   current   

现象:
在列表视图中,当你要复制一个内容,就触发click事件,就打开form视图了
为了区分click mousedown mousemove muuseup 事件,从而放弃click事件
用后面那几个事件组合来解决是要打开,还是复制内容事件

改动代码如下:
\addons\web\static\src\js\view_list.js

var hasMove =false;
        this.$current = $(‘<tbody>‘)
            .delegate(‘input[readonly=readonly]‘, ‘click‘, function (e) {
                /*
                    Against all logic and sense, as of right now @readonly
                    apparently does nothing on checkbox and radio inputs, so
                    the trick of using @readonly to have, well, readonly
                    checkboxes (which still let clicks go through) does not
                    work out of the box. We *still* need to preventDefault()
                    on the event, otherwise the checkbox‘s state *will* toggle
                    on click
                 */
                e.preventDefault();
            })
            .delegate(‘th.oe_list_record_selector‘, ‘click‘, function (e) {
                e.stopPropagation();
                var selection = self.get_selection();
                var checked = $(e.currentTarget).find(‘input‘).prop(‘checked‘);
                $(self).trigger(
                        ‘selected‘, [selection.ids, selection.records, ! checked]);
            })
            .delegate(‘td.oe_list_record_delete button‘, ‘click‘, function (e) {
                e.stopPropagation();
                var $row = $(e.target).closest(‘tr‘);
                $(self).trigger(‘deleted‘, [[self.row_id($row)]]);
            })
            .delegate(‘td.oe_list_field_cell button‘, ‘click‘, function (e) {
                e.stopPropagation();
                var $target = $(e.currentTarget),
                      field = $target.closest(‘td‘).data(‘field‘),
                       $row = $target.closest(‘tr‘),
                  record_id = self.row_id($row);
               
                if ($target.attr(‘disabled‘)) {
                    return;
                }
                $target.attr(‘disabled‘, ‘disabled‘);

                // note: $.data converts data to number if it‘s composed only
                // of digits, nice when storing actual numbers, not nice when
                // storing strings composed only of digits. Force the action
                // name to be a string
                $(self).trigger(‘action‘, [field.toString(), record_id, function (id) {
                    $target.removeAttr(‘disabled‘);
                    return self.reload_record(self.records.get(id));
                }]);
            })
            .delegate(‘a‘, ‘click‘, function (e) {
                e.stopPropagation();
            })
            .delegate(‘tr‘, ‘mousedown‘, function (e) {

                hasMove=false;
            })

            .delegate(‘tr‘, ‘mousemove‘, function (e) {

                hasMove=true;
            })

            .delegate(‘tr‘, ‘mouseup‘, function (e) {
                if (hasMove){

                }else{
                var row_id = self.row_id(e.currentTarget);
                if (row_id) {
                    e.stopPropagation();
                    if (!self.dataset.select_id(row_id)) {
                        throw new Error(_t("Could not find id in dataset"));
                    }
                    self.row_clicked(e);
                }
                }
                hasMove =false;
            });

(59) 解决在列表视图复制导致打开详细内容

标签:cti   tostring   view   static   turn   attr   pos   cli   current   

原文地址:https://www.cnblogs.com/toby2chen/p/8145808.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!