-
Notifications
You must be signed in to change notification settings - Fork 24.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This module didn't worked on mobile: user cannot select the products or see their cart. This commit reworks the LunchKanbanWidget template and introduces a dedicated template for mobile. This template introduces a button at the bottom of the screen to toggle the "cart" widget on mobile (hiding it by default). It tries to make the best use of the existing Bootstrap classes allowing to have a more responsive layout and reducing the custom CSS required by this module (both in desktop and in mobile). This commit adds a decent JS tests-suite (mobile & desktop) to this module as the existing one left substential parts of the UI untested (opening wizard when clicking on a kanban record, cart's lines content, clear cart button, widget structure and content based on the state...). Those tests are also less based on DOM nodes order/tag names and use instead dedicated classnames. It also modifies the LunchKanbanRecord click handling to had a dedicated event handler instead of overriding the default _onGlobalClick() and make it more testable. Finally this commit also remove unused code. Task ID: 1945032 closes #31428 Signed-off-by: Adrien Dieudonné (adr) <adr@odoo.com>
- Loading branch information
Showing
14 changed files
with
1,335 additions
and
429 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
odoo.define('lunch.LunchKanbanMobile', function (require) { | ||
"use strict"; | ||
|
||
var config = require('web.config'); | ||
var LunchKanbanWidget = require('lunch.LunchKanbanWidget'); | ||
var LunchKanbanController = require('lunch.LunchKanbanController'); | ||
|
||
if (!config.device.isMobile) { | ||
return; | ||
} | ||
|
||
LunchKanbanWidget.include({ | ||
template: "LunchKanbanWidgetMobile", | ||
|
||
/** | ||
* Override to set the toggle state allowing initially open it. | ||
* | ||
* @override | ||
*/ | ||
init: function (parent, params) { | ||
this._super.apply(this, arguments); | ||
this.keepOpen = params.keepOpen || undefined; | ||
}, | ||
}); | ||
|
||
LunchKanbanController.include({ | ||
/** | ||
* @override | ||
*/ | ||
init: function () { | ||
this._super.apply(this, arguments); | ||
this.openWidget = false; | ||
}, | ||
|
||
//-------------------------------------------------------------------------- | ||
// Private | ||
//-------------------------------------------------------------------------- | ||
|
||
/** | ||
* Override to add the widget's toggle state to its data. | ||
* | ||
* @override | ||
* @private | ||
*/ | ||
_renderLunchKanbanWidget: function () { | ||
this.widgetData.keepOpen = this.openWidget; | ||
this.openWidget = false; | ||
return this._super.apply(this, arguments); | ||
}, | ||
|
||
//-------------------------------------------------------------------------- | ||
// Handlers | ||
//-------------------------------------------------------------------------- | ||
|
||
/** | ||
* @override | ||
* @private | ||
*/ | ||
_onAddProduct: function () { | ||
this.openWidget = true; | ||
this._super.apply(this, arguments); | ||
}, | ||
|
||
/** | ||
* @override | ||
* @private | ||
*/ | ||
_onRemoveProduct: function () { | ||
this.openWidget = true; | ||
this._super.apply(this, arguments); | ||
}, | ||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,36 @@ | ||
odoo.define('lunch.LunchKanbanRecord', function (require) { | ||
"use strict"; | ||
"use strict"; | ||
|
||
/** | ||
* This file defines the KanbanRecord for the Lunch Kanban view. | ||
*/ | ||
/** | ||
* This file defines the KanbanRecord for the Lunch Kanban view. | ||
*/ | ||
|
||
var KanbanRecord = require('web.KanbanRecord'); | ||
var KanbanRecord = require('web.KanbanRecord'); | ||
|
||
var LunchKanbanRecord = KanbanRecord.extend({ | ||
_onGlobalClick: function (ev) { | ||
ev.preventDefault(); | ||
// ignore clicks on oe_kanban_action elements | ||
if (!$(ev.target).hasClass('oe_kanban_action')) { | ||
this.trigger_up('open_wizard', {productId: this.recordData.product_id}); | ||
} | ||
}, | ||
}); | ||
var LunchKanbanRecord = KanbanRecord.extend({ | ||
events: _.extend({}, KanbanRecord.prototype.events, { | ||
'click': '_onSelectRecord', | ||
}), | ||
|
||
return LunchKanbanRecord; | ||
//-------------------------------------------------------------------------- | ||
// Handlers | ||
//-------------------------------------------------------------------------- | ||
|
||
}); | ||
/** | ||
* Open the add product wizard | ||
* | ||
* @private | ||
* @param {MouseEvent} ev Click event | ||
*/ | ||
_onSelectRecord: function (ev) { | ||
ev.preventDefault(); | ||
// ignore clicks on oe_kanban_action elements | ||
if (!$(ev.target).hasClass('oe_kanban_action')) { | ||
this.trigger_up('open_wizard', {productId: this.recordData.product_id}); | ||
} | ||
}, | ||
}); | ||
|
||
return LunchKanbanRecord; | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.