[ADD] ListView: Added pencil icon linking to form view

bzr revid: fme@openerp.com-20111214172952-xp4c6h6fccbyzt8r
This commit is contained in:
Fabien Meghazi 2011-12-14 18:29:52 +01:00
parent d1ddc1ee78
commit ef954a8a95
5 changed files with 34 additions and 12 deletions

View File

@ -822,9 +822,12 @@ label.error {
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 @@ label.error {
}
.openerp .oe_datepicker_root {
display: inline-block;
width: 100%;
}
.openerp .oe_forms.oe_frame .oe_datepicker_root {
width: 100%;

Binary file not shown.

After

Width:  |  Height:  |  Size: 129 B

View File

@ -17,7 +17,9 @@ openerp.web.ListView = openerp.web.View.extend( /** @lends openerp.web.ListView#
// 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 @@ openerp.web.ListView = openerp.web.View.extend( /** @lends openerp.web.ListView#
'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 @@ openerp.web.ListView = openerp.web.View.extend( /** @lends openerp.web.ListView#
* @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 @@ openerp.web.ListView.List = openerp.web.Class.extend( /** @lends openerp.web.Lis
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 @@ openerp.web.ListView.List = openerp.web.Class.extend( /** @lends openerp.web.Lis
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;

View File

@ -116,7 +116,7 @@ openerp.web.list_editable = function (openerp) {
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 @@ openerp.web.list_editable = function (openerp) {
.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) {

View File

@ -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="&gt; :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="&gt; :last" t-operation="after">
<td t-if="edited and !options.deletable" class="oe-listview-padding"/>