[FIX] correctly display char[password] as stars in list views
authorXavier Morel <xmo@openerp.com>
Thu, 6 Jun 2013 09:13:25 +0000 (11:13 +0200)
committerXavier Morel <xmo@openerp.com>
Thu, 6 Jun 2013 09:13:25 +0000 (11:13 +0200)
lp bug: https://launchpad.net/bugs/1113419 fixed

bzr revid: xmo@openerp.com-20130606091325-q2wgizk8yq4xkgj6

addons/web/static/src/js/view_list.js

index b69ec6d..840effa 100644 (file)
@@ -578,7 +578,7 @@ instance.web.ListView = instance.web.View.extend( /** @lends instance.web.ListVi
         this.no_leaf = !!context['group_by_no_leaf'];
         this.grouped = !!group_by;
 
-        return this.load_view(context).then(
+        return this.alive(this.load_view(context)).then(
             this.proxy('reload_content'));
     },
     /**
@@ -895,8 +895,9 @@ instance.web.ListView.List = instance.web.Class.extend( /** @lends instance.web.
 
         this.record_callbacks = {
             'remove': function (event, record) {
-                var $row = self.$current.children(
-                    '[data-id=' + record.get('id') + ']');
+                var id = record.get('id');
+                self.dataset.remove_ids([id])
+                var $row = self.$current.children('[data-id=' + id + ']');
                 var index = $row.data('index');
                 $row.remove();
             },
@@ -2060,6 +2061,7 @@ instance.web.list.columns = new instance.web.Registry({
     'field': 'instance.web.list.Column',
     'field.boolean': 'instance.web.list.Boolean',
     'field.binary': 'instance.web.list.Binary',
+    'field.char': 'instance.web.list.Char',
     'field.progressbar': 'instance.web.list.ProgressBar',
     'field.handle': 'instance.web.list.Handle',
     'button': 'instance.web.list.Button',
@@ -2228,6 +2230,20 @@ instance.web.list.Binary = instance.web.list.Column.extend({
         });
     }
 });
+instance.web.list.Char = instance.web.list.Column.extend({
+    replacement: '*',
+    /**
+     * If password field, only display replacement characters (if value is
+     * non-empty)
+     */
+    _format: function (row_data, options) {
+        var value = row_data[this.id].value;
+        if (value && this.password === 'True') {
+            return value.replace(/[\s\S]/g, _.escape(this.replacement))
+        }
+        return this._super(row_data, options);
+    }
+});
 instance.web.list.ProgressBar = instance.web.list.Column.extend({
     /**
      * Return a formatted progress bar display