Merge lp:~openerp-dev/openerp-web/trunk-bug-878108-kbh into lp:openerp-web

Proposed by Khushboo Bhatt(openerp)
Status: Merged
Approved by: Xavier (Open ERP)
Approved revision: 1336
Merged at revision: 1356
Proposed branch: lp:~openerp-dev/openerp-web/trunk-bug-878108-kbh
Merge into: lp:openerp-web
Diff against target: 47 lines (+9/-2)
2 files modified
addons/web/static/src/js/view_list.js (+7/-1)
addons/web/static/src/xml/base.xml (+2/-1)
To merge this branch: bzr merge lp:~openerp-dev/openerp-web/trunk-bug-878108-kbh
Reviewer Review Type Date Requested Status
Xavier (Open ERP) Pending
Review via email: mp+80296@code.launchpad.net

This proposal supersedes a proposal from 2011-10-25.

Description of the change

"The issue of checkbutton select all/none in tree view."

To post a comment you must log in.
Revision history for this message
Xavier (Open ERP) (xmo-deactivatedaccount) wrote : Posted in a previous version of this proposal

* Don't use IDs, there's a risk it's going to break with multiple lists present on the screen (and in any case it's not semantically correct).
* The code is short and not expected to be overridden (I'd think), so I'd suggest keeping it inline, not split as a separate method.
* Could you try using .prop() instead of .attr? I'm pretty sure it'd work just as well, and that's what it's for (technically, we're manipulating the "checked" attribute)
* Your setting of the check state looks very debatable, from what I understand it's going to set all checkboxes to the opposite of what the first one is, irrespective of what the checkbox which was just clicked is. So if you check the header checkbox, then uncheck the first row's checkbox, and uncheck the header checkbox… it's going to keep everything checked (and re-check the first row).
* I don't see the point of using `:checkbox` in your selector (in `this.$element.find('.oe-record-selector :checkbox')`): there's only ever a single input (a checkbox) in `.oe-record-selector`, so `:checkbox` does not avoid selecting anything which should not be selected, it just makes the code slower.

review: Needs Fixing
Revision history for this message
Khushboo Bhatt(openerp) (kbh-openerp) wrote : Posted in a previous version of this proposal

hello,

improved as per suggestion.

thank you.
kbh.

Revision history for this message
Xavier (Open ERP) (xmo-deactivatedaccount) wrote : Posted in a previous version of this proposal

why did you leave the old code for #all_checked?

Also, why did you go from selecting checkboxes with `.oe-record-selector :checkbox` to just `:checkbox`?

review: Needs Information
Revision history for this message
Khushboo Bhatt(openerp) (kbh-openerp) wrote : Posted in a previous version of this proposal

> why did you leave the old code for #all_checked?
- it is my mistake for left the old code so i remove it.

> Also, why did you go from selecting checkboxes with `.oe-record-selector
> :checkbox` to just `:checkbox`?
-from :checkbox i can get checkbox of all records thats why i use it.

thanks,
kbh.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'addons/web/static/src/js/view_list.js'
2--- addons/web/static/src/js/view_list.js 2011-10-20 16:22:55 +0000
3+++ addons/web/static/src/js/view_list.js 2011-10-25 06:28:24 +0000
4@@ -201,8 +201,12 @@
5 this.setup_columns(this.fields_view.fields, grouped);
6
7 this.$element.html(QWeb.render("ListView", this));
8-
9 // Head hook
10+ this.$element.find('.all-record-selector').click(function(){
11+ self.$element.find(':checkbox').prop('checked',
12+ self.$element.find('.all-record-selector').prop('checked') || false);
13+ });
14+
15 this.$element.find('.oe-list-add')
16 .click(this.do_add_record)
17 .attr('disabled', grouped && this.options.editable);
18@@ -269,6 +273,7 @@
19 this.set_common_sidebar_sections(this.sidebar);
20 }
21 },
22+
23 /**
24 * Configures the ListView pager based on the provided dataset's information
25 *
26@@ -650,6 +655,7 @@
27 $first_header.attr('colspan', parseInt(colspan, 10) + count);
28 }
29 // Padding for column titles, footer and data rows
30+
31 var $rows = this.$element
32 .find('.oe-listview-header-columns, tr:not(thead tr)')
33 .not(options['except']);
34
35=== modified file 'addons/web/static/src/xml/base.xml'
36--- addons/web/static/src/xml/base.xml 2011-10-24 15:20:56 +0000
37+++ addons/web/static/src/xml/base.xml 2011-10-25 06:28:24 +0000
38@@ -579,7 +579,8 @@
39 <t t-esc="column.string"/>
40 </th>
41 </t>
42- <th t-if="options.selectable" width="1"/>
43+ <th t-if="options.selectable" width="1" >
44+ <input type="checkbox" class="all-record-selector"/> </th>
45 <t t-foreach="columns" t-as="column">
46 <th t-if="!column.meta and column.invisible !== '1'" t-att-data-id="column.id"
47 t-att-class="((options.sortable and column.tag !== 'button') ? 'oe-sortable' : null)">