summaryrefslogtreecommitdiff
path: root/addons/web/static/src
diff options
context:
space:
mode:
authorFabien Meghazi <fme@openerp.com>2011-12-14 18:29:52 +0100
committerFabien Meghazi <fme@openerp.com>2011-12-14 18:29:52 +0100
commitef954a8a957bddafbf7eb67418a4300892f88997 (patch)
treed98b2318ff77c387f5331a157433633fc43ad3f3 /addons/web/static/src
parentd1ddc1ee7824dd571ac564359883198a73a747b5 (diff)
[ADD] ListView: Added pencil icon linking to form view
bzr revid: fme@openerp.com-20111214172952-xp4c6h6fccbyzt8r
Diffstat (limited to 'addons/web/static/src')
-rw-r--r--addons/web/static/src/css/base.css6
-rw-r--r--addons/web/static/src/img/pencil.gifbin0 -> 129 bytes
-rw-r--r--addons/web/static/src/js/view_list.js25
-rw-r--r--addons/web/static/src/js/view_list_editable.js7
-rw-r--r--addons/web/static/src/xml/base.xml8
5 files changed, 34 insertions, 12 deletions
diff --git a/addons/web/static/src/css/base.css b/addons/web/static/src/css/base.css
index 04fff6c9375..4bc0575a797 100644
--- a/addons/web/static/src/css/base.css
+++ b/addons/web/static/src/css/base.css
@@ -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%;
diff --git a/addons/web/static/src/img/pencil.gif b/addons/web/static/src/img/pencil.gif
new file mode 100644
index 00000000000..6e9aa5ef659
--- /dev/null
+++ b/addons/web/static/src/img/pencil.gif
Binary files differ
diff --git a/addons/web/static/src/js/view_list.js b/addons/web/static/src/js/view_list.js
index ad253586591..5e185ed0c3e 100644
--- a/addons/web/static/src/js/view_list.js
+++ b/addons/web/static/src/js/view_list.js
@@ -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;
diff --git a/addons/web/static/src/js/view_list_editable.js b/addons/web/static/src/js/view_list_editable.js
index b2edf55b314..50a3028d837 100644
--- a/addons/web/static/src/js/view_list_editable.js
+++ b/addons/web/static/src/js/view_list_editable.js
@@ -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) {
diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml
index cf517fef490..503e6ac3318 100644
--- a/addons/web/static/src/xml/base.xml
+++ b/addons/web/static/src/xml/base.xml
@@ -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"/>