summaryrefslogtreecommitdiff
path: root/addons/web/static/src
diff options
context:
space:
mode:
Diffstat (limited to 'addons/web/static/src')
-rw-r--r--addons/web/static/src/js/fields/relational_fields.js28
-rw-r--r--addons/web/static/src/js/views/form/form_controller.js11
2 files changed, 19 insertions, 20 deletions
diff --git a/addons/web/static/src/js/fields/relational_fields.js b/addons/web/static/src/js/fields/relational_fields.js
index c6db91778ec..b97cecdd49e 100644
--- a/addons/web/static/src/js/fields/relational_fields.js
+++ b/addons/web/static/src/js/fields/relational_fields.js
@@ -1210,12 +1210,7 @@ var FieldX2Many = AbstractField.extend(WidgetAdapterMixin, {
return this.renderer.confirmUpdate(state, command.id, fieldNames, ev.initialEvent);
}
}
- return this._super.apply(this, arguments).then(() => {
- if (this.view) {
- this._renderButtons();
- this._updateControlPanel();
- }
- });
+ return this._super.apply(this, arguments);
},
/**
@@ -1348,7 +1343,7 @@ var FieldX2Many = AbstractField.extend(WidgetAdapterMixin, {
columnInvisibleFields: this.currentColInvisibleFields,
keepWidths: true,
}).then(() => {
- this._updateControlPanel({ size: this.value.count });
+ return this._updateControlPanel({ size: this.value.count });
});
}
var arch = this.view.arch;
@@ -1460,9 +1455,16 @@ var FieldX2Many = AbstractField.extend(WidgetAdapterMixin, {
*/
_updateControlPanel: function (pagingState) {
if (this._controlPanelWrapper) {
+ this._renderButtons();
+ const pagerProps = Object.assign(this.pagingState, pagingState, {
+ // sometimes, we temporarily want to increase the pager limit
+ // (for instance, when we add a new record on a page that already
+ // contains the maximum number of records)
+ limit: Math.max(this.value.limit, this.value.data.length),
+ });
const newProps = {
cp_content: { $buttons: this.$buttons },
- pager: Object.assign(this.pagingState, pagingState),
+ pager: pagerProps,
};
return this._controlPanelWrapper.update(newProps);
}
@@ -1851,16 +1853,6 @@ var FieldOne2Many = FieldX2Many.extend({
var index = 0;
if (self.editable !== 'top') {
index = self.value.data.length - 1;
- // we consider that a new record, created in the bottom,
- // does not count as a record worth mentioning in the
- // pager, at least not until the line has been saved.
- // We prevent the pager from increasing its size, which
- // means that the pager is not displayed when we just
- // reach the limit. For example, if limit is 3, if we
- // have 3 records, and we click on add, we will see the
- // 4 records on the same page, but we do not want a
- // pager.
- self._updateControlPanel({ size: self.value.count - 1 });
}
var newID = self.value.data[index].id;
self.renderer.editRecord(newID);
diff --git a/addons/web/static/src/js/views/form/form_controller.js b/addons/web/static/src/js/views/form/form_controller.js
index 81327f36598..0f38649d0bc 100644
--- a/addons/web/static/src/js/views/form/form_controller.js
+++ b/addons/web/static/src/js/views/form/form_controller.js
@@ -514,7 +514,10 @@ var FormController = BasicController.extend({
* @private
*/
_onDiscard: function () {
- this._discardChanges();
+ this._disableButtons();
+ this._discardChanges()
+ .then(this._enableButtons.bind(this))
+ .guardedCatch(this._enableButtons.bind(this));
},
/**
* Called when the user clicks on 'Duplicate Record' in the action menus
@@ -533,9 +536,13 @@ var FormController = BasicController.extend({
* @private
*/
_onEdit: function () {
+ this._disableButtons();
// wait for potential pending changes to be saved (done with widgets
// allowing to edit in readonly)
- this.mutex.getUnlockedDef().then(this._setMode.bind(this, 'edit'));
+ this.mutex.getUnlockedDef()
+ .then(this._setMode.bind(this, 'edit'))
+ .then(this._enableButtons.bind(this))
+ .guardedCatch(this._enableButtons.bind(this));
},
/**
* This method is called when someone tries to freeze the order, most likely