[IMP] DOWNCASE ALL THE THINGS

apparently and contrary to what I remembered, we're still supposed to use underscore_separated method names, not camelCase

bzr revid: xmo@openerp.com-20120717132308-wvpldtprt33heee3
This commit is contained in:
Xavier Morel 2012-07-17 15:23:08 +02:00
parent c3368bf2bb
commit 01e6e3ec07
5 changed files with 110 additions and 113 deletions

View File

@ -3122,7 +3122,7 @@ instance.web.form.FieldOne2Many = instance.web.form.AbstractField.extend({
} }
return res; return res;
} else if (this.viewmanager.active_view === "list") { } else if (this.viewmanager.active_view === "list") {
var res = $.when(view.ensureSaved()); var res = $.when(view.ensure_saved());
if (!res.isResolved() && !res.isRejected()) { if (!res.isResolved() && !res.isRejected()) {
console.warn("Asynchronous get_value() is not supported in list view."); console.warn("Asynchronous get_value() is not supported in list view.");
} }
@ -3209,22 +3209,22 @@ instance.web.form.One2ManyListView = instance.web.ListView.extend({
this._super(parent, dataset, view_id, _.extend(options || {}, { this._super(parent, dataset, view_id, _.extend(options || {}, {
ListType: instance.web.form.One2ManyList ListType: instance.web.form.One2ManyList
})); }));
this.on('edit:before', this, this.proxy('_beforeEdit')); this.on('edit:before', this, this.proxy('_before_edit'));
this.on('save:before cancel:before', this, this.proxy('_beforeUnEdit')); this.on('save:before cancel:before', this, this.proxy('_before_unedit'));
this.records this.records
.bind('add', this.proxy("changedRecords")) .bind('add', this.proxy("changed_records"))
.bind('edit', this.proxy("changedRecords")) .bind('edit', this.proxy("changed_records"))
.bind('remove', this.proxy("changedRecords")); .bind('remove', this.proxy("changed_records"));
}, },
start: function () { start: function () {
var ret = this._super(); var ret = this._super();
this.$element this.$element
.off('mousedown.handleButtons') .off('mousedown.handleButtons')
.on('mousedown.handleButtons', 'table button', this.proxy('_buttonDown')); .on('mousedown.handleButtons', 'table button', this.proxy('_button_down'));
return ret; return ret;
}, },
changedRecords: function () { changed_records: function () {
this.o2m.trigger_on_change(); this.o2m.trigger_on_change();
}, },
is_valid: function () { is_valid: function () {
@ -3308,21 +3308,21 @@ instance.web.form.One2ManyListView = instance.web.ListView.extend({
} }
var parent_form = this.o2m.view; var parent_form = this.o2m.view;
var self = this; var self = this;
this.ensureSaved().pipe(function () { this.ensure_saved().pipe(function () {
return parent_form.do_save(); return parent_form.do_save();
}).then(function () { }).then(function () {
self.handleButton(name, id, callback); self.handle_button(name, id, callback);
}); });
}, },
_beforeEdit: function () { _before_edit: function () {
this.__ignore_blur = false; this.__ignore_blur = false;
this.editor.form.on('blurred', this, this._onFormBlur); this.editor.form.on('blurred', this, this._on_form_blur);
}, },
_beforeUnEdit: function () { _before_unedit: function () {
this.editor.form.off('blurred', this, this._onFormBlur); this.editor.form.off('blurred', this, this._on_form_blur);
}, },
_buttonDown: function () { _button_down: function () {
// If a button is clicked (usually some sort of action button), it's // If a button is clicked (usually some sort of action button), it's
// the button's responsibility to ensure the editable list is in the // the button's responsibility to ensure the editable list is in the
// correct state -> ignore form blurring // correct state -> ignore form blurring
@ -3332,12 +3332,12 @@ instance.web.form.One2ManyListView = instance.web.ListView.extend({
* Handles blurring of the nested form (saves the currently edited row), * Handles blurring of the nested form (saves the currently edited row),
* unless the flag to ignore the event is set to ``true`` * unless the flag to ignore the event is set to ``true``
*/ */
_onFormBlur: function () { _on_form_blur: function () {
if (this.__ignore_blur) { if (this.__ignore_blur) {
this.__ignore_blur = false; this.__ignore_blur = false;
return; return;
} }
this.saveEdition(); this.save_edition();
}, },
keyup_ENTER: function () { keyup_ENTER: function () {
// blurring caused by hitting the [Return] key, should skip the // blurring caused by hitting the [Return] key, should skip the

View File

@ -676,7 +676,7 @@ instance.web.ListView = instance.web.View.extend( /** @lends instance.web.ListVi
* @param {Function} callback should be called after the action is executed, if non-null * @param {Function} callback should be called after the action is executed, if non-null
*/ */
do_button_action: function (name, id, callback) { do_button_action: function (name, id, callback) {
this.handleButton(name, id, callback); this.handle_button(name, id, callback);
}, },
/** /**
* Base handling of buttons, can be called when overriding do_button_action * Base handling of buttons, can be called when overriding do_button_action
@ -688,7 +688,7 @@ instance.web.ListView = instance.web.View.extend( /** @lends instance.web.ListVi
* @param {Object} id id of the record the action should be called on * @param {Object} id id of the record the action should be called on
* @param {Function} callback should be called after the action is executed, if non-null * @param {Function} callback should be called after the action is executed, if non-null
*/ */
handleButton: function (name, id, callback) { handle_button: function (name, id, callback) {
var action = _.detect(this.columns, function (field) { var action = _.detect(this.columns, function (field) {
return field.name === name; return field.name === name;
}); });

View File

@ -12,11 +12,11 @@ openerp.web.list_editable = function (instance) {
var self = this; var self = this;
this._super.apply(this, arguments); this._super.apply(this, arguments);
this.editor = this.makeEditor(); this.editor = this.make_editor();
// Stores records of {field, cell}, allows for re-rendering fields // Stores records of {field, cell}, allows for re-rendering fields
// depending on cell state during and after resize events // depending on cell state during and after resize events
this.fields_for_resize = []; this.fields_for_resize = [];
instance.web.bus.on('resize', this, this.resizeFields); instance.web.bus.on('resize', this, this.resize_fields);
$(this.groups).bind({ $(this.groups).bind({
'edit': function (e, id, dataset) { 'edit': function (e, id, dataset) {
@ -39,7 +39,7 @@ openerp.web.list_editable = function (instance) {
}); });
}, },
destroy: function () { destroy: function () {
instance.web.bus.off('resize', this, this.resizeFields); instance.web.bus.off('resize', this, this.resize_fields);
this._super(); this._super();
}, },
/** /**
@ -86,7 +86,7 @@ openerp.web.list_editable = function (instance) {
if (this.options.editable) { if (this.options.editable) {
this.$element.find('table:first').show(); this.$element.find('table:first').show();
this.$element.find('.oe_view_nocontent').remove(); this.$element.find('.oe_view_nocontent').remove();
this.startEdition(); this.start_edition();
} else { } else {
this._super(); this._super();
} }
@ -103,24 +103,24 @@ openerp.web.list_editable = function (instance) {
// FIXME: any hook available to ensure this is only done once? // FIXME: any hook available to ensure this is only done once?
this.$buttons this.$buttons
.off('click', '.oe_list_save') .off('click', '.oe_list_save')
.on('click', '.oe_list_save', this.proxy('saveEdition')) .on('click', '.oe_list_save', this.proxy('save_edition'))
.off('click', '.oe_list_discard') .off('click', '.oe_list_discard')
.on('click', '.oe_list_discard', function (e) { .on('click', '.oe_list_discard', function (e) {
e.preventDefault(); e.preventDefault();
self.cancelEdition(); self.cancel_edition();
}); });
this.$element this.$element
.off('click', 'tbody td:not(.oe_list_field_cell)') .off('click', 'tbody td:not(.oe_list_field_cell)')
.on('click', 'tbody td:not(.oe_list_field_cell)', function () { .on('click', 'tbody td:not(.oe_list_field_cell)', function () {
if (!self.editor.isEditing()) { if (!self.editor.is_editing()) {
self.startEdition(); self.start_edition();
} }
}); });
// Editor is not restartable due to formview not being // Editor is not restartable due to formview not being
// restartable // restartable
this.editor = this.makeEditor(); this.editor = this.make_editor();
var editor_ready = this.editor.prependTo(this.$element) var editor_ready = this.editor.prependTo(this.$element)
.then(this.proxy('setupEvents')); .then(this.proxy('setup_events'));
return $.when(result, editor_ready); return $.when(result, editor_ready);
} }
@ -132,13 +132,13 @@ openerp.web.list_editable = function (instance) {
* *
* @return {instance.web.list.Editor} * @return {instance.web.list.Editor}
*/ */
makeEditor: function () { make_editor: function () {
return new instance.web.list.Editor(this); return new instance.web.list.Editor(this);
}, },
do_button_action: function () { do_button_action: function () {
var self = this, args = arguments; var self = this, args = arguments;
this.ensureSaved().then(function () { this.ensure_saved().then(function () {
self.handleButton.apply(self, args); self.handle_button.apply(self, args);
}); });
}, },
/** /**
@ -149,11 +149,11 @@ openerp.web.list_editable = function (instance) {
* *
* @returns {$.Deferred} * @returns {$.Deferred}
*/ */
ensureSaved: function () { ensure_saved: function () {
if (!this.editor.isEditing()) { if (!this.editor.is_editing()) {
return $.when(); return $.when();
} }
return this.saveEdition(); return this.save_edition();
}, },
/** /**
* Set up the edition of a record of the list view "inline" * Set up the edition of a record of the list view "inline"
@ -161,7 +161,7 @@ openerp.web.list_editable = function (instance) {
* @param {instance.web.list.Record} [record] record to edit, leave empty to create a new record * @param {instance.web.list.Record} [record] record to edit, leave empty to create a new record
* @return {jQuery.Deferred} * @return {jQuery.Deferred}
*/ */
startEdition: function (record) { start_edition: function (record) {
var self = this; var self = this;
var item = false; var item = false;
if (record) { if (record) {
@ -174,14 +174,14 @@ openerp.web.list_editable = function (instance) {
.each(function (field) { attrs[field] = false; }); .each(function (field) { attrs[field] = false; });
record = new instance.web.list.Record(attrs); record = new instance.web.list.Record(attrs);
this.records.add(record, { this.records.add(record, {
at: this.isPrependOnCreate() ? 0 : null}); at: this.prepends_on_create() ? 0 : null});
} }
var $recordRow = this.groups.getRowFor(record); var $recordRow = this.groups.get_row_for(record);
var cells = this.getCellsFor($recordRow); var cells = this.get_cells_for($recordRow);
return this.ensureSaved().pipe(function () { return this.ensure_saved().pipe(function () {
self.fields_for_resize.splice(0, self.fields_for_resize.length); self.fields_for_resize.splice(0, self.fields_for_resize.length);
return self.withEvent('edit', { return self.with_event('edit', {
record: record.attributes, record: record.attributes,
cancel: false cancel: false
}, function () { }, function () {
@ -197,13 +197,13 @@ openerp.web.list_editable = function (instance) {
self.fields_for_resize.push({field: field, cell: cell}); self.fields_for_resize.push({field: field, cell: cell});
}).pipe(function () { }).pipe(function () {
$recordRow.addClass('oe_edition'); $recordRow.addClass('oe_edition');
self.resizeFields(); self.resize_fields();
return record.attributes; return record.attributes;
}); });
}); });
}); });
}, },
getCellsFor: function ($row) { get_cells_for: function ($row) {
var cells = {}; var cells = {};
$row.children('td').each(function (index, el) { $row.children('td').each(function (index, el) {
cells[el.getAttribute('data-field')] = el cells[el.getAttribute('data-field')] = el
@ -214,11 +214,11 @@ openerp.web.list_editable = function (instance) {
* If currently editing a row, resizes all registered form fields based * If currently editing a row, resizes all registered form fields based
* on the corresponding row cell * on the corresponding row cell
*/ */
resizeFields: function () { resize_fields: function () {
if (!this.editor.isEditing()) { return; } if (!this.editor.is_editing()) { return; }
for(var i=0, len=this.fields_for_resize.length; i<len; ++i) { for(var i=0, len=this.fields_for_resize.length; i<len; ++i) {
var item = this.fields_for_resize[i]; var item = this.fields_for_resize[i];
this.resizeField(item.field, item.cell); this.resize_field(item.field, item.cell);
} }
}, },
/** /**
@ -228,7 +228,7 @@ openerp.web.list_editable = function (instance) {
* @param {instance.web.form.AbstractField} field * @param {instance.web.form.AbstractField} field
* @param {jQuery} cell * @param {jQuery} cell
*/ */
resizeField: function (field, cell) { resize_field: function (field, cell) {
var $cell = $(cell); var $cell = $(cell);
var position = $cell.position(); var position = $cell.position();
@ -242,9 +242,9 @@ openerp.web.list_editable = function (instance) {
/** /**
* @return {jQuery.Deferred} * @return {jQuery.Deferred}
*/ */
saveEdition: function () { save_edition: function () {
var self = this; var self = this;
return this.withEvent('save', { return this.with_event('save', {
editor: this.editor, editor: this.editor,
form: this.editor.form, form: this.editor.form,
cancel: false cancel: false
@ -262,7 +262,7 @@ openerp.web.list_editable = function (instance) {
// onwrite callback could be altering & reloading the // onwrite callback could be altering & reloading the
// record which has *just* been saved, so first perform all // record which has *just* been saved, so first perform all
// onwrites then do a final reload of the record // onwrites then do a final reload of the record
return self.handleOnWrite(record) return self.handle_onwrite(record)
.pipe(function () { .pipe(function () {
return self.reload_record(record); }) return self.reload_record(record); })
.pipe(function () { .pipe(function () {
@ -273,9 +273,9 @@ openerp.web.list_editable = function (instance) {
/** /**
* @return {jQuery.Deferred} * @return {jQuery.Deferred}
*/ */
cancelEdition: function () { cancel_edition: function () {
var self = this; var self = this;
return this.withEvent('cancel', { return this.with_event('cancel', {
editor: this.editor, editor: this.editor,
form: this.editor.form, form: this.editor.form,
cancel: false cancel: false
@ -310,7 +310,7 @@ openerp.web.list_editable = function (instance) {
* @param {Array} [trigger_params] supplementary arguments provided to the ``:after`` sub-event, before anything fetched by the ``action`` function * @param {Array} [trigger_params] supplementary arguments provided to the ``:after`` sub-event, before anything fetched by the ``action`` function
* @return {jQuery.Deferred} * @return {jQuery.Deferred}
*/ */
withEvent: function (event_name, event, action) { with_event: function (event_name, event, action) {
var self = this; var self = this;
event = event || {}; event = event || {};
this.trigger(event_name + ':before', event); this.trigger(event_name + ':before', event);
@ -324,7 +324,7 @@ openerp.web.list_editable = function (instance) {
.concat(_.toArray(arguments))); .concat(_.toArray(arguments)));
}); });
}, },
editionView: function (editor) { edition_view: function (editor) {
var view = $.extend(true, {}, this.fields_view); var view = $.extend(true, {}, this.fields_view);
view.arch.tag = 'form'; view.arch.tag = 'form';
_.extend(view.arch.attrs, { _.extend(view.arch.attrs, {
@ -341,7 +341,7 @@ openerp.web.list_editable = function (instance) {
}); });
return view; return view;
}, },
handleOnWrite: function (source_record) { handle_onwrite: function (source_record) {
var self = this; var self = this;
var on_write_callback = self.fields_view.arch.attrs.on_write; var on_write_callback = self.fields_view.arch.attrs.on_write;
if (!on_write_callback) { return $.when(); } if (!on_write_callback) { return $.when(); }
@ -349,10 +349,10 @@ openerp.web.list_editable = function (instance) {
.pipe(function (ids) { .pipe(function (ids) {
return $.when.apply( return $.when.apply(
null, _(ids).map( null, _(ids).map(
_.bind(self.handleOnWriteRecord, self, source_record))); _.bind(self.handle_onwrite_record, self, source_record)));
}); });
}, },
handleOnWriteRecord: function (id, source_record) { handle_onwrite_record: function (id, source_record) {
var record = this.records.get(id); var record = this.records.get(id);
if (!record) { if (!record) {
// insert after the source record // insert after the source record
@ -363,10 +363,10 @@ openerp.web.list_editable = function (instance) {
} }
return this.reload_record(record); return this.reload_record(record);
}, },
isPrependOnCreate: function () { prepends_on_create: function () {
return this.options.editable === 'top'; return this.options.editable === 'top';
}, },
setupEvents: function () { setup_events: function () {
var self = this; var self = this;
this.editor.$element.on('keyup', function (e) { this.editor.$element.on('keyup', function (e) {
var key = _($.ui.keyCode).chain() var key = _($.ui.keyCode).chain()
@ -380,19 +380,19 @@ openerp.web.list_editable = function (instance) {
}); });
}, },
keyup_ENTER: function () { keyup_ENTER: function () {
if (!this.editor.isEditing()) { return; } if (!this.editor.is_editing()) { return; }
var self = this; var self = this;
return this.saveEdition().pipe(function (saveInfo) { return this.save_edition().pipe(function (saveInfo) {
if (saveInfo.created) { if (saveInfo.created) {
return self.startEdition(); return self.start_edition();
} }
return self.startEdition( return self.start_edition(
self.records.succ(saveInfo.record, {wraparound: true})); self.records.succ(saveInfo.record, {wraparound: true}));
}); });
}, },
keyup_ESCAPE: function () { keyup_ESCAPE: function () {
if (!this.editor.isEditing()) { return; } if (!this.editor.is_editing()) { return; }
return this.cancelEdition(); return this.cancel_edition();
} }
}); });
@ -429,32 +429,32 @@ openerp.web.list_editable = function (instance) {
start: function () { start: function () {
var self = this; var self = this;
var _super = this._super(); var _super = this._super();
this.form.embedded_view = this._validateView( this.form.embedded_view = this._validate_view(
this.delegate.editionView(this)); this.delegate.edition_view(this));
var form_ready = this.form.appendTo(this.$element).then( var form_ready = this.form.appendTo(this.$element).then(
self.form.proxy('do_hide')); self.form.proxy('do_hide'));
return $.when(_super, form_ready); return $.when(_super, form_ready);
}, },
_validateView: function (edition_view) { _validate_view: function (edition_view) {
if (!edition_view) { if (!edition_view) {
throw new Error("editor delegate's #editionView must return " throw new Error("editor delegate's #edition_view must return "
+ "a view descriptor"); + "a view descriptor");
} }
var arch = edition_view.arch; var arch = edition_view.arch;
if (!(arch && arch.children instanceof Array)) { if (!(arch && arch.children instanceof Array)) {
throw new Error("Editor delegate's #editionView must have a" + throw new Error("Editor delegate's #edition_view must have a" +
" non-empty arch") " non-empty arch")
} }
if (!(arch.tag === "form")) { if (!(arch.tag === "form")) {
throw new Error("Editor delegate's #editionView must have a" + throw new Error("Editor delegate's #edition_view must have a" +
" 'form' root node"); " 'form' root node");
} }
if (!(arch.attrs && arch.attrs.version === "7.0")) { if (!(arch.attrs && arch.attrs.version === "7.0")) {
throw new Error("Editor delegate's #editionView must be a" + throw new Error("Editor delegate's #edition_view must be a" +
" version 7 view"); " version 7 view");
} }
if (!/\boe_form_container\b/.test(arch.attrs['class'])) { if (!/\boe_form_container\b/.test(arch.attrs['class'])) {
throw new Error("Editor delegate's #editionView must have the" + throw new Error("Editor delegate's #edition_view must have the" +
" class 'oe_form_container' on its root" + " class 'oe_form_container' on its root" +
" element"); " element");
} }
@ -462,7 +462,7 @@ openerp.web.list_editable = function (instance) {
return edition_view; return edition_view;
}, },
isEditing: function () { is_editing: function () {
return !!this.record; return !!this.record;
}, },
edit: function (record, configureField) { edit: function (record, configureField) {
@ -496,7 +496,7 @@ openerp.web.list_editable = function (instance) {
save: function () { save: function () {
var self = this; var self = this;
return this.form return this.form
.do_save(null, this.delegate.isPrependOnCreate()) .do_save(null, this.delegate.prepends_on_create())
.pipe(function (result) { .pipe(function (result) {
var created = result.created && !self.record.id; var created = result.created && !self.record.id;
if (created) { if (created) {
@ -519,9 +519,9 @@ openerp.web.list_editable = function (instance) {
instance.web.ListView.Groups.include(/** @lends instance.web.ListView.Groups# */{ instance.web.ListView.Groups.include(/** @lends instance.web.ListView.Groups# */{
passtrough_events: instance.web.ListView.Groups.prototype.passtrough_events + " edit saved", passtrough_events: instance.web.ListView.Groups.prototype.passtrough_events + " edit saved",
getRowFor: function (record) { get_row_for: function (record) {
return _(this.children).chain() return _(this.children).chain()
.invoke('getRowFor', record) .invoke('get_row_for', record)
.compact() .compact()
.first() .first()
.value(); .value();
@ -534,7 +534,7 @@ openerp.web.list_editable = function (instance) {
return this._super.apply(this, arguments); return this._super.apply(this, arguments);
} }
var record_id = $(event.currentTarget).data('id'); var record_id = $(event.currentTarget).data('id');
this.view.startEdition(record_id ? this.records.get(record_id) : null); this.view.start_edition(record_id ? this.records.get(record_id) : null);
}, },
/** /**
* If a row mapping to the record (@data-id matching the record's id or * If a row mapping to the record (@data-id matching the record's id or
@ -544,7 +544,7 @@ openerp.web.list_editable = function (instance) {
* @param {Record} record the record to get a row for * @param {Record} record the record to get a row for
* @return {jQuery|null} * @return {jQuery|null}
*/ */
getRowFor: function (record) { get_row_for: function (record) {
var id; var id;
var $row = this.$current.children('[data-id=' + record.get('id') + ']'); var $row = this.$current.children('[data-id=' + record.get('id') + ']');
if ($row.length) { if ($row.length) {

View File

@ -73,7 +73,7 @@ $(document).ready(function () {
asyncTest('base-state', 2, function () { asyncTest('base-state', 2, function () {
var e = new instance.web.list.Editor({ var e = new instance.web.list.Editor({
dataset: {}, dataset: {},
editionView: function () { edition_view: function () {
return makeFormView(); return makeFormView();
} }
}); });
@ -81,7 +81,7 @@ $(document).ready(function () {
.always(start) .always(start)
.fail(function (error) { ok(false, error && error.message); }) .fail(function (error) { ok(false, error && error.message); })
.done(function () { .done(function () {
ok(!e.isEditing(), "should not be editing"); ok(!e.is_editing(), "should not be editing");
ok(e.form instanceof instance.web.FormView, ok(e.form instanceof instance.web.FormView,
"should use default form type"); "should use default form type");
}); });
@ -100,8 +100,8 @@ $(document).ready(function () {
}; };
var e = new instance.web.list.Editor({ var e = new instance.web.list.Editor({
dataset: new instance.web.DataSetSearch(), dataset: new instance.web.DataSetSearch(),
isPrependOnCreate: function () { return false; }, prepends_on_create: function () { return false; },
editionView: function () { edition_view: function () {
return makeFormView([ field('a'), field('b'), field('c') ]); return makeFormView([ field('a'), field('b'), field('c') ]);
} }
}); });
@ -113,14 +113,14 @@ $(document).ready(function () {
}); });
}) })
.pipe(function (form) { .pipe(function (form) {
ok(e.isEditing(), "should be editing"); ok(e.is_editing(), "should be editing");
equal(counter, 3, "should have configured all fields"); equal(counter, 3, "should have configured all fields");
return e.save(); return e.save();
}) })
.always(start) .always(start)
.fail(function (error) { ok(false, error && error.message); }) .fail(function (error) { ok(false, error && error.message); })
.done(function (record) { .done(function (record) {
ok(!e.isEditing(), "should have stopped editing"); ok(!e.is_editing(), "should have stopped editing");
equal(record.id, 42, "should have newly created id"); equal(record.id, 42, "should have newly created id");
}) })
}); });
@ -130,8 +130,8 @@ $(document).ready(function () {
}; };
var e = new instance.web.list.Editor({ var e = new instance.web.list.Editor({
dataset: new instance.web.DataSetSearch(), dataset: new instance.web.DataSetSearch(),
isPrependOnCreate: function () { return false; }, prepends_on_create: function () { return false; },
editionView: function () { edition_view: function () {
return makeFormView([ field('a'), field('b'), field('c') ]); return makeFormView([ field('a'), field('b'), field('c') ]);
} }
}); });
@ -148,7 +148,7 @@ $(document).ready(function () {
.always(start) .always(start)
.fail(function (error) { ok(false, error && error.message); }) .fail(function (error) { ok(false, error && error.message); })
.done(function (record) { .done(function (record) {
ok(!e.isEditing(), "should have stopped editing"); ok(!e.is_editing(), "should have stopped editing");
ok(!record.id, "should have no id"); ok(!record.id, "should have no id");
}) })
}); });
@ -161,8 +161,8 @@ $(document).ready(function () {
warnings++; warnings++;
}, },
dataset: new instance.web.DataSetSearch(), dataset: new instance.web.DataSetSearch(),
isPrependOnCreate: function () { return false; }, prepends_on_create: function () { return false; },
editionView: function () { edition_view: function () {
return makeFormView([ return makeFormView([
field('a', {required: true}), field('b'), field('c') ]); field('a', {required: true}), field('b'), field('c') ]);
} }
@ -182,7 +182,7 @@ $(document).ready(function () {
.done(function () { ok(false, "cancel should not succeed"); }) .done(function () { ok(false, "cancel should not succeed"); })
.fail(function () { .fail(function () {
equal(warnings, 1, "should have been warned"); equal(warnings, 1, "should have been warned");
ok(e.isEditing(), "should have kept editing"); ok(e.is_editing(), "should have kept editing");
}) })
}); });
@ -246,12 +246,12 @@ $(document).ready(function () {
l.appendTo($fix) l.appendTo($fix)
.pipe(l.proxy('reload_content')) .pipe(l.proxy('reload_content'))
.pipe(function () { .pipe(function () {
return l.startEdition(); return l.start_edition();
}) })
.always(start) .always(start)
.pipe(function () { .pipe(function () {
ok(got_defaults, "should have fetched default values for form"); ok(got_defaults, "should have fetched default values for form");
return l.saveEdition(); return l.save_edition();
}) })
.pipe(function (result) { .pipe(function (result) {
ok(result.created, "should yield newly created record"); ok(result.created, "should yield newly created record");
@ -314,10 +314,10 @@ $(document).ready(function () {
.pipe(function () { .pipe(function () {
ok(l.options.editable, "should be editable"); ok(l.options.editable, "should be editable");
equal(o.counter, 0, "should have seen no event yet"); equal(o.counter, 0, "should have seen no event yet");
return l.startEdition(l.records.get(1)); return l.start_edition(l.records.get(1));
}) })
.pipe(function () { .pipe(function () {
ok(l.editor.isEditing(), "should be editing"); ok(l.editor.is_editing(), "should be editing");
equal(o.counter, 2, "should have seen two edition events"); equal(o.counter, 2, "should have seen two edition events");
}) })
.fail(function (e) { ok(false, e && e.message); }); .fail(function (e) { ok(false, e && e.message); });
@ -339,11 +339,11 @@ $(document).ready(function () {
.always(start) .always(start)
.pipe(function () { .pipe(function () {
ok(l.options.editable, "should be editable"); ok(l.options.editable, "should be editable");
return l.startEdition(); return l.start_edition();
}) })
// cancelling an event rejects the deferred // cancelling an event rejects the deferred
.pipe($.Deferred().reject(), function () { .pipe($.Deferred().reject(), function () {
ok(!l.editor.isEditing(), "should not be editing"); ok(!l.editor.is_editing(), "should not be editing");
ok(!edit_after, "should not have fired the edit:after event"); ok(!edit_after, "should not have fired the edit:after event");
return $.when(); return $.when();
}) })

View File

@ -122,7 +122,7 @@ view, on top of implementing the :js:class:`EditorDelegate` protocol:
Interaction Methods Interaction Methods
+++++++++++++++++++ +++++++++++++++++++
.. js:function:: openerp.web.ListView.ensureSaved .. js:function:: openerp.web.ListView.ensure_saved
Attempts to resolve the pending edition, if any, by saving the Attempts to resolve the pending edition, if any, by saving the
edited row's current state. edited row's current state.
@ -131,7 +131,7 @@ Interaction Methods
rejected if a pending edition could not be saved rejected if a pending edition could not be saved
(e.g. validation failure) (e.g. validation failure)
.. js:function:: openerp.web.ListView.startEdition([record]) .. js:function:: openerp.web.ListView.start_edition([record])
Starts editing the provided record inline, through an overlay form Starts editing the provided record inline, through an overlay form
view of editable fields in the record. view of editable fields in the record.
@ -145,7 +145,7 @@ Interaction Methods
:type record: :js:class:`~openerp.web.list.Record` :type record: :js:class:`~openerp.web.list.Record`
:returns: delegate to the form used for the edition :returns: delegate to the form used for the edition
.. js:function:: openerp.web.ListView.saveEdition .. js:function:: openerp.web.ListView.save_edition
Resolves the pending edition. Resolves the pending edition.
@ -155,7 +155,7 @@ Interaction Methods
updated) and ``record`` the reloaded record having been updated) and ``record`` the reloaded record having been
edited. edited.
.. js:function:: openerp.web.ListView.cancelEdition .. js:function:: openerp.web.ListView.cancel_edition
Cancels pending edition, cleans up the list view in case of Cancels pending edition, cleans up the list view in case of
creation (removes the empty record being created). creation (removes the empty record being created).
@ -163,7 +163,7 @@ Interaction Methods
Utility Methods Utility Methods
+++++++++++++++ +++++++++++++++
.. js:function:: openerp.web.ListView.getCellsFor(row) .. js:function:: openerp.web.ListView.get_cells_for(row)
Extracts the cells from a listview row, and puts them in a Extracts the cells from a listview row, and puts them in a
{fieldname: cell} mapping for analysis and manipulation. {fieldname: cell} mapping for analysis and manipulation.
@ -171,7 +171,7 @@ Utility Methods
:param jQuery row: :param jQuery row:
:rtype: Object :rtype: Object
.. js:function:: openerp.web.ListView.withEvent(event_name, event, action[, args][, trigger_params]) .. js:function:: openerp.web.ListView.with_event(event_name, event, action[, args][, trigger_params])
Executes ``action`` in the context of the view's editor, Executes ``action`` in the context of the view's editor,
bracketing it with cancellable event signals. bracketing it with cancellable event signals.
@ -193,7 +193,7 @@ Utility Methods
Behavioral Customizations Behavioral Customizations
+++++++++++++++++++++++++ +++++++++++++++++++++++++
.. js:function:: openerp.web.ListView.handleOnWrite(record) .. js:function:: openerp.web.ListView.handle_onwrite(record)
Implements the handling of the ``onwrite`` listview attribute: Implements the handling of the ``onwrite`` listview attribute:
calls the RPC methods specified by ``@onwrite``, and if that calls the RPC methods specified by ``@onwrite``, and if that
@ -287,7 +287,7 @@ formview, delegating instead to its
:type parent: :js:class:`~openerp.web.Widget` :type parent: :js:class:`~openerp.web.Widget`
:param EditorOptions options: :param EditorOptions options:
.. js:function:: openerp.web.list.Editor.isEditing .. js:function:: openerp.web.list.Editor.is_editing
Indicates whether the editor is currently in the process of Indicates whether the editor is currently in the process of
providing edition for a field. providing edition for a field.
@ -356,7 +356,7 @@ formview, delegating instead to its
The dataset passed to the form view to synchronize the form The dataset passed to the form view to synchronize the form
view and the outer widget. view and the outer widget.
.. js:function:: EditorDelegate.editionView(editor) .. js:function:: EditorDelegate.edition_view(editor)
Called by the :js:class:`~openerp.web.list.Editor` object to Called by the :js:class:`~openerp.web.list.Editor` object to
get a form view (JSON) to pass along to the form view it get a form view (JSON) to pass along to the form view it
@ -371,7 +371,7 @@ formview, delegating instead to its
:returns: form view :returns: form view
:rtype: Object :rtype: Object
.. js:function:: EditorDelegate.isPrependOnCreate .. js:function:: EditorDelegate.prepends_on_create
By default, the :js:class:`~openerp.web.list.Editor` will By default, the :js:class:`~openerp.web.list.Editor` will
append the ids of newly created records to the append the ids of newly created records to the
@ -395,21 +395,18 @@ Changes from 6.1
:js:func:`~openerp.web.ListView.List.row_clicked` is still :js:func:`~openerp.web.ListView.List.row_clicked` is still
overridden. overridden.
* A new method ``getRowFor(record) -> jQuery(tr) | null`` has been * A new method ``get_row_for(record) -> jQuery(tr) | null`` has been
added to both ListView.List and ListView.Group, it can be called added to both ListView.List and ListView.Group, it can be called
from the list view to get the table row matching a record (if such from the list view to get the table row matching a record (if such
a row exists). a row exists).
* ``ListView#ensure_saved`` has been re-capitalized to
:js:func:`~openerp.web.ListView.ensureSaved`
* :js:func:`~openerp.web.ListView.do_button_action`'s core behavior * :js:func:`~openerp.web.ListView.do_button_action`'s core behavior
has been split away to has been split away to
:js:func:`~openerp.web.ListView.handleButton`. This allows bypassing :js:func:`~openerp.web.ListView.handle_button`. This allows bypassing
overrides of :js:func:`~openerp.web.ListView.do_button_action` in a overrides of :js:func:`~openerp.web.ListView.do_button_action` in a
parent class. parent class.
Ideally, :js:func:`~openerp.web.ListView.handleButton` should not be Ideally, :js:func:`~openerp.web.ListView.handle_button` should not be
overridden. overridden.
* Modifiers handling has been improved (all modifiers information * Modifiers handling has been improved (all modifiers information