[IMP] web: Deactivate swipe between form view in mobile
The swipe between the form view is taking too long to load, and the pager is a more clean option to switch between form view. Moreover, the swipe on tabs is not clear anymore. - Deactivate swipe between form view - Swipe should only be available on tabs when tabs are too long to fit in one screen. Was originally introduced by https://github.com/odoo/odoo/commit/f4ee61f950dc1eeb7b3653ca96ea72721512b5e5 Related task: 1924764 closes odoo/odoo#30413
This commit is contained in:
committed by
Adrien Dieudonne
parent
3dac18f9e9
commit
9f7e6bb798
@@ -312,30 +312,6 @@ var FormRenderer = BasicRenderer.extend({
|
||||
});
|
||||
});
|
||||
},
|
||||
/**
|
||||
* Enable swipe event to allow navigating through records
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
_enableSwipe: function () {
|
||||
var self = this;
|
||||
this.$('.o_form_sheet').swipe({
|
||||
swipeLeft: function () {
|
||||
this.css({
|
||||
transform: 'translateX(-100%)',
|
||||
transition: '350ms'
|
||||
});
|
||||
self.trigger_up('swipe_left');
|
||||
},
|
||||
swipeRight: function () {
|
||||
this.css({
|
||||
transform: 'translateX(100%)',
|
||||
transition: '350ms'
|
||||
});
|
||||
self.trigger_up('swipe_right');
|
||||
},
|
||||
});
|
||||
},
|
||||
/**
|
||||
* @private
|
||||
* @param {string} name
|
||||
@@ -943,11 +919,6 @@ var FormRenderer = BasicRenderer.extend({
|
||||
this.$el.toggleClass('o_form_editable', this.mode === 'edit');
|
||||
this.$el.toggleClass('o_form_readonly', this.mode === 'readonly');
|
||||
|
||||
// Enable swipe for mobile when formview is in readonly mode and there are multiple records
|
||||
if (config.device.isMobile && this.mode === 'readonly' && this.state.count > 1) {
|
||||
this._enableSwipe();
|
||||
}
|
||||
|
||||
// Attach the tooltips on the fields' label
|
||||
_.each(this.allFieldWidgets[this.state.id], function (widget) {
|
||||
var idForLabel = self.idsForLabels[widget.name];
|
||||
|
||||
@@ -1,92 +0,0 @@
|
||||
odoo.define('web.form_mobile_tests', function (require) {
|
||||
"use strict";
|
||||
|
||||
var FormView = require('web.FormView');
|
||||
var testUtils = require('web.test_utils');
|
||||
|
||||
var createView = testUtils.createView;
|
||||
|
||||
QUnit.module('Views', {
|
||||
beforeEach: function () {
|
||||
this.data = {
|
||||
partner: {
|
||||
fields: {
|
||||
display_name: { string: "Displayed name", type: "char" },
|
||||
foo: {string: "Foo", type: "char", default: "My little Foo Value"},
|
||||
bar: {string: "Bar", type: "boolean"},
|
||||
},
|
||||
records: [{
|
||||
id: 1,
|
||||
display_name: "first record",
|
||||
bar: true,
|
||||
foo: "yop",
|
||||
}, {
|
||||
id: 2,
|
||||
display_name: "second record",
|
||||
bar: true,
|
||||
foo: "blip",
|
||||
}, {
|
||||
id: 4,
|
||||
display_name: "aaa",
|
||||
state: "ef",
|
||||
}, {
|
||||
id: 5,
|
||||
display_name: "aaa",
|
||||
foo:'',
|
||||
bar: false,
|
||||
}],
|
||||
onchanges: {},
|
||||
},
|
||||
};
|
||||
}
|
||||
}, function () {
|
||||
|
||||
QUnit.module('FormView');
|
||||
|
||||
QUnit.test('switching to next/previous record on swipe in readonly mode', function (assert) {
|
||||
assert.expect(6);
|
||||
|
||||
// mimic touchSwipe library's swipe method
|
||||
var oldSwipe = $.fn.swipe;
|
||||
var swipeLeft, swipeRight;
|
||||
$.fn.swipe = function (params) {
|
||||
swipeLeft = params.swipeLeft.bind(this);
|
||||
swipeRight = params.swipeRight.bind(this);
|
||||
};
|
||||
|
||||
var form = createView({
|
||||
View: FormView,
|
||||
model: 'partner',
|
||||
data: this.data,
|
||||
arch: '<form string="Partners">' +
|
||||
'<sheet>' +
|
||||
'<field name="display_name"/>' +
|
||||
'</sheet>' +
|
||||
'</form>',
|
||||
viewOptions: {
|
||||
ids: [1, 2],
|
||||
index: 0,
|
||||
},
|
||||
res_id: 1,
|
||||
mockRPC: function (route, args) {
|
||||
if (route === '/web/dataset/call_kw/partner/read') {
|
||||
assert.step(args.args[0][0]);
|
||||
}
|
||||
return this._super(route, args);
|
||||
},
|
||||
});
|
||||
|
||||
swipeLeft();
|
||||
assert.strictEqual(form.pager.$('.o_pager_value').text(), '2', 'pager value should be 2');
|
||||
|
||||
swipeRight();
|
||||
assert.strictEqual(form.pager.$('.o_pager_value').text(), '1', 'pager value should be 1');
|
||||
|
||||
assert.verifySteps([1, 2, 1]);
|
||||
|
||||
$.fn.swipe = oldSwipe;
|
||||
form.destroy();
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
@@ -626,7 +626,6 @@
|
||||
<script type="text/javascript" src="/web/static/tests/chrome/action_manager_mobile_tests.js"></script>
|
||||
<script type="text/javascript" src="/web/static/tests/views/calendar_mobile_tests.js"></script>
|
||||
<script type="text/javascript" src="/web/static/tests/views/kanban_mobile_tests.js"></script>
|
||||
<script type="text/javascript" src="/web/static/tests/views/form_mobile_tests.js"></script>
|
||||
<script type="text/javascript" src="/web/static/tests/views/mobile_control_panel_tests.js"></script>
|
||||
<script type="text/javascript" src="/web/static/tests/fields/basic_fields_mobile_tests.js"></script>
|
||||
<script type="text/javascript" src="/web/static/tests/fields/relational_fields_mobile_tests.js"></script>
|
||||
|
||||
Reference in New Issue
Block a user