Fabien Meghazi (OpenERP) has proposed merging
lp:~openerp-dev/openerp-web/trunk-listview-pencil-fme into lp:openerp-web.
Requested reviews:
Xavier (Open ERP) (xmo)
For more details, see:
https://code.launchpad.net/~openerp-dev/openerp-web/trunk-listview-pencil-fme/+merge/85714
Adds pencil icon in list view and editable lists.
The special cases (listviews that shall hide this link) can be done afterward
using flags.list.edit_link
--
https://code.launchpad.net/~openerp-dev/openerp-web/trunk-listview-pencil-fme/+merge/85714
Your team OpenERP R&D Team is subscribed to branch
lp:~openerp-dev/openerp-web/trunk-listview-pencil-fme.
=== modified file 'addons/web/static/src/css/base.css'
--- addons/web/static/src/css/base.css 2011-12-14 13:12:46 +0000
+++ addons/web/static/src/css/base.css 2011-12-14 17:39:13 +0000
@@ -822,9 +822,12 @@
border-bottom: 1px solid #E3E3E3;
}
-.openerp .oe-listview .oe-record-selector {
+.openerp .oe-listview .oe-record-selector, .openerp .oe-listview .oe-record-edit-link {
border-bottom: 1px solid #E3E3E3;
}
+.openerp .oe-listview .oe-record-edit-link {
+ cursor: pointer;
+}
.openerp .oe-listview .oe-field-cell {
cursor: pointer;
@@ -1193,6 +1196,7 @@
}
.openerp .oe_datepicker_root {
display: inline-block;
+ width: 100%;
}
.openerp .oe_forms.oe_frame .oe_datepicker_root {
width: 100%;
=== added file 'addons/web/static/src/img/pencil.gif'
Binary files addons/web/static/src/img/pencil.gif 1970-01-01 00:00:00 +0000 and addons/web/static/src/img/pencil.gif 2011-12-14 17:39:13 +0000 differ
=== modified file 'addons/web/static/src/js/view_list.js'
--- addons/web/static/src/js/view_list.js 2011-12-14 17:18:11 +0000
+++ addons/web/static/src/js/view_list.js 2011-12-14 17:39:13 +0000
@@ -17,7 +17,9 @@
// sorted it can not be reordered anymore
'sortable': true,
// whether the view rows can be reordered (via vertical drag & drop)
- 'reorderable': true
+ 'reorderable': true,
+ // display an edit icon linking to form view
+ 'edit_link': true
},
/**
* Core class for list-type displays.
@@ -120,8 +122,8 @@
'action': function (e, action_name, id, callback) {
self.do_button_action(action_name, id, callback);
},
- 'row_link': function (e, id, dataset) {
- self.do_activate_record(dataset.index, id, dataset);
+ 'row_link': function (e, id, dataset, view) {
+ self.do_activate_record(dataset.index, id, dataset, view);
}
});
},
@@ -556,9 +558,9 @@
* @param {Object} id identifier of the activated record
* @param {openerp.web.DataSet} dataset dataset in which the record is available (may not be the listview's dataset in case of nested groups)
*/
- do_activate_record: function (index, id, dataset) {
+ do_activate_record: function (index, id, dataset, view) {
this.dataset.ids = dataset.ids;
- this.select_record(index);
+ this.select_record(index, view);
},
/**
* Handles signal for the addition of a new record (can be a creation,
@@ -818,15 +820,19 @@
if (!self.dataset.select_id(row_id)) {
throw "Could not find id in dataset"
}
- self.row_clicked(e);
+ var view;
+ if ($(e.toElement).is('.oe-record-edit-link-img')) {
+ view = 'form';
+ }
+ self.row_clicked(e, view);
}
});
},
- row_clicked: function () {
+ row_clicked: function (e, view) {
$(this).trigger(
'row_link',
[this.dataset.ids[this.dataset.index],
- this.dataset]);
+ this.dataset, view]);
},
render_cell: function (record, column) {
var value;
@@ -887,6 +893,9 @@
if (this.options.selectable) {
cells.push('<th class="oe-record-selector"></td>');
}
+ if (this.options.edit_link) {
+ cells.push('<th class="oe-record-edit-link"></td>');
+ }
_(this.columns).each(function(column) {
if (column.invisible === '1') {
return;
=== modified file 'addons/web/static/src/js/view_list_editable.js'
--- addons/web/static/src/js/view_list_editable.js 2011-12-11 15:30:10 +0000
+++ addons/web/static/src/js/view_list_editable.js 2011-12-14 17:39:13 +0000
@@ -116,7 +116,7 @@
openerp.web.ListView.List.include(/** @lends openerp.web.ListView.List# */{
row_clicked: function (event) {
if (!this.options.editable) {
- return this._super(event);
+ return this._super.apply(this, arguments);
}
this.edit_record($(event.currentTarget).data('id'));
},
@@ -248,7 +248,10 @@
.end()
.find('td:last').removeClass('oe-field-cell').end();
if (self.options.selectable) {
- $new_row.prepend('<td>');
+ $new_row.prepend('<th>');
+ }
+ if (self.options.edit_link) {
+ $new_row.prepend('<th>');
}
// pad in case of groupby
_(self.columns).each(function (column) {
=== modified file 'addons/web/static/src/xml/base.xml'
--- addons/web/static/src/xml/base.xml 2011-12-14 14:43:17 +0000
+++ addons/web/static/src/xml/base.xml 2011-12-14 17:39:13 +0000
@@ -567,7 +567,7 @@
</tr>
<table t-name="ListView" class="oe-listview-content">
- <t t-set="columns_count" t-value="visible_columns.length + (options.selectable ? 1 : 0) + (options.deletable ? 1 : 0)"/>
+ <t t-set="columns_count" t-value="visible_columns.length + (options.selectable ? 1 : 0) + (options.deletable ? 1 : 0) + (options.edit_link ? 1 : 0)"/>
<thead class="ui-widget-header">
<tr t-if="options.action_buttons !== false or options.pager !== false">
<th t-att-colspan="columns_count">
@@ -596,6 +596,7 @@
</t>
<th t-if="options.selectable" width="1" >
<input type="checkbox" class="all-record-selector"/> </th>
+ <th t-if="options.edit_link" width="1"> </th>
<t t-foreach="columns" t-as="column">
<th t-if="!column.meta and column.invisible !== '1'" t-att-data-id="column.id"
t-att-class="((options.sortable and column.tag !== 'button') ? 'oe-sortable' : null)">
@@ -609,6 +610,7 @@
<tfoot class="ui-widget-header">
<tr>
<td t-if="options.selectable"/>
+ <td t-if="options.edit_link"/>
<td t-foreach="aggregate_columns" t-as="column" class="oe-list-footer oe-number"
t-att-data-field="column.id" t-att-title="column.label">
</td>
@@ -666,6 +668,9 @@
<th t-if="options.selectable" class="oe-record-selector" width="1">
<input t-att-type="options.radio? 'radio': 'checkbox'" name ="radiogroup" t-att-checked="options.select_view_id == record.get('id')? true: null"/>
</th>
+ <th t-if="options.edit_link" class="oe-record-edit-link" width="1">
+ <img src="/web/static/src/img/pencil.gif" width="12" height="12" class="oe-record-edit-link-img"/>
+ </th>
<t t-foreach="columns" t-as="column">
<t t-set="align" t-value="column.type === 'integer' or column.type == 'float'"/>
<td t-if="!column.meta and column.invisible !== '1'" t-att-title="column.help"
@@ -1419,6 +1424,7 @@
-->
<t t-jquery="> :first" t-operation="before">
<td t-if="edited and !options.selectable" class="oe-listview-padding"/>
+ <td t-if="edited and !options.edit_link" class="oe-listview-padding"/>
</t>
<t t-jquery="> :last" t-operation="after">
<td t-if="edited and !options.deletable" class="oe-listview-padding"/>
_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help : https://help.launchpad.net/ListHelp