summaryrefslogtreecommitdiff
path: root/addons/base/static/src
diff options
context:
space:
mode:
authorXavier Morel <xmo@openerp.com>2011-06-03 16:16:38 +0200
committerXavier Morel <xmo@openerp.com>2011-06-03 16:16:38 +0200
commitaaa459a29daf862fcb6343786bd576ec74798dd0 (patch)
treefaaac7d037a5f25ba39a093b2ed7405b16202609 /addons/base/static/src
parent9250a5a3f6142908292333800a84ed9fbd603787 (diff)
[ADD] edition cancelling
bzr revid: xmo@openerp.com-20110603141638-giwlzwrp795bq78h
Diffstat (limited to 'addons/base/static/src')
-rw-r--r--addons/base/static/src/js/list-editable.js32
-rw-r--r--addons/base/static/src/js/list.js3
-rw-r--r--addons/base/static/src/xml/base.xml6
3 files changed, 33 insertions, 8 deletions
diff --git a/addons/base/static/src/js/list-editable.js b/addons/base/static/src/js/list-editable.js
index 0ece61d1f99..ee2af7d258b 100644
--- a/addons/base/static/src/js/list-editable.js
+++ b/addons/base/static/src/js/list-editable.js
@@ -2,6 +2,9 @@
* @namespace handles editability case for lists, because it depends on form and forms already depends on lists it had to be split out
*/
openerp.base.list.editable = function (openerp) {
+ var KEY_RETURN = 13,
+ KEY_ESCAPE = 27;
+
// editability status of list rows
openerp.base.ListView.prototype.defaults.editable = null;
@@ -47,13 +50,22 @@ openerp.base.list.editable = function (openerp) {
onclick: function (e) {e.stopPropagation();}
}).replaceAll(row)
.keyup(function (e) {
- if (e.which !== 13) {
- return;
+ switch (e.which) {
+ case KEY_RETURN:
+ self.save_row(row_num, true);
+ break;
+ case KEY_ESCAPE:
+ self.cancel_edition(row_num);
+ break;
+ default:
+ return;
}
- self.save_row(row_num, true);
})
- .delegate('button.oe-list-save', 'click', function () {
+ .delegate('button.oe-edit-row-save', 'click', function () {
self.save_row(row_num);
+ })
+ .delegate('button.oe-edit-row-cancel', 'click', function () {
+ self.cancel_edition(row_num);
});
this.edition_form = _.extend(new openerp.base.FormView(
null, this.group.view.session, $new_row.attr('id'),
@@ -96,7 +108,7 @@ openerp.base.list.editable = function (openerp) {
self.edition_form.stop();
delete self.edition_form;
if (edit_next && self.rows.length > row_num + 1) {
- self.dataset.index += 1;
+ self.dataset.index++;
self.row_clicked({
currentTarget: self.$current.children().eq(row_num + 1)
}, row_num + 1);
@@ -104,6 +116,16 @@ openerp.base.list.editable = function (openerp) {
}
);
});
+ },
+ /**
+ * Cancels the edition of the row at index ``row_num``.
+ *
+ * @param {Number} row_num index of the row being edited
+ */
+ cancel_edition: function (row_num) {
+ this.reload_record(row_num);
+ this.edition_form.stop();
+ delete this.edition_form;
}
});
openerp.base.list = {form: {}};
diff --git a/addons/base/static/src/js/list.js b/addons/base/static/src/js/list.js
index 03c8eba97fb..c627330fd70 100644
--- a/addons/base/static/src/js/list.js
+++ b/addons/base/static/src/js/list.js
@@ -690,7 +690,8 @@ openerp.base.ListView.List = Class.extend( /** @lends openerp.base.ListView.List
return QWeb.render('ListView.row', {
columns: this.columns,
options: this.options,
- row: this.rows[record_index]
+ row: this.rows[record_index],
+ row_parity: (record_index % 2 === 0) ? 'even' : 'odd'
});
}
// drag and drop
diff --git a/addons/base/static/src/xml/base.xml b/addons/base/static/src/xml/base.xml
index d1633bdb150..f1c1d3df4cf 100644
--- a/addons/base/static/src/xml/base.xml
+++ b/addons/base/static/src/xml/base.xml
@@ -802,8 +802,10 @@
.replaceAll(this)
.before($(document.createElement('td')).append(
$(document.createElement('button')).attr({
- 'class': 'oe-list-save', 'type': 'button'}).text('Save')))
- .after($(document.createElement('td')))
+ 'class': 'oe-edit-row-save', 'type': 'button'}).text('Save')))
+ .after($(document.createElement('td')).append(
+ $(document.createElement('button')).attr({
+ 'class': 'oe-edit-row-cancel', 'type': 'button'}).text('Cancel')))
.unwrap();
</t>
</t>