summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/fields/basic_fields.js
diff options
context:
space:
mode:
authorOdoo's Mergebot <xmo+roboto@odoo.com>2020-01-08 10:49:01 +0100
committerGitHub <noreply@github.com>2020-01-08 10:49:01 +0100
commit5d1837d25088f4355eb2422d3c924151697ba0ed (patch)
tree2b7d8b581a3abcf53b9eb709d8ead4811b54d73f /addons/web/static/src/js/fields/basic_fields.js
parentd6706850502cb3f6d2505afd566e48e99fa4e88e (diff)
parenta321963d192a049671864404bfaee5a0ccf9b4e8 (diff)
[MERGE] event (_*): replace state by stages and improve event management flow
PURPOSE Improve event management by replacing static states by dynamic global stages. It gives more flexibility and allows event users to customize their flow according to their business requirements. SPECIFICATIONS From stage to state =============== event: replace state by kanban stage (website_)event: adapt to state removal by correctly computing availability based on available seats. event_sale: adapt to state removal by correctly computing availability based on tickets sale_available field (based on number and dates) event: add a cron that clean the event pipeline. The cron will move every ended events in the next "ended stage". We inherit from `ir.autovacuum` so the method `power_on` is called one time per day. Color picker widget =============== Move the widget ``color_picker`` from "planning" to web to use it in event application. Improve views =========== Kanban view - add a field ``sales_total_price`` which contains the total sum of all sale order lines (care about the currency) - this field is used in ``event_sale`` - display the number of expected and confirmed - when clicking on these buttons, redirect to the tree view with the correct filter - display this new field in the kanban view - display the location instead of the country in the kanban view Form view - Change the order of the buttons in the header of the event form view - Preview Badge > Contact Attendee > Contact Speaker - Add a note field on the model `event.event` Search - Remove the default filter "Upcoming/Running" Track improvement =============== 1. the color of a track is now based on the color of the stage 2. the default date of a track is the ``date_begin`` of its event LINKS Task #2088538 PR odoo/odoo#39486 Enterprise PR odoo/enterprise#6460 Related: odoo/enterprise#6460 Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
Diffstat (limited to 'addons/web/static/src/js/fields/basic_fields.js')
-rw-r--r--addons/web/static/src/js/fields/basic_fields.js95
1 files changed, 95 insertions, 0 deletions
diff --git a/addons/web/static/src/js/fields/basic_fields.js b/addons/web/static/src/js/fields/basic_fields.js
index 350dc5f5674..37e61c8fd5b 100644
--- a/addons/web/static/src/js/fields/basic_fields.js
+++ b/addons/web/static/src/js/fields/basic_fields.js
@@ -3347,6 +3347,100 @@ var FieldColor = AbstractField.extend({
},
});
+var FieldColorPicker = FieldInteger.extend({
+ /**
+ * Prepares the rendering, since we are based on an input but not using it
+ * setting tagName after parent init force the widget to not render an input
+ *
+ * @override
+ */
+ init: function () {
+ this._super.apply(this, arguments);
+ this.tagName = 'div';
+ },
+ /**
+ * Render the widget when it is edited.
+ *
+ * @override
+ */
+ _renderEdit: function () {
+ this.$el.html(qweb.render('ColorPicker'));
+ this._setupColorPicker();
+ this._highlightSelectedColor();
+ },
+ /**
+ * Render the widget when it is NOT edited.
+ *
+ * @override
+ */
+ _renderReadonly: function () {
+ this.$el.html(qweb.render('ColorPickerReadonly', {active_color: this.value,}));
+ this.$el.on('click', 'a', function(ev){ ev.preventDefault(); });
+ },
+ /**
+ * Render the kanban colors inside first ul element.
+ * This is the same template as in KanbanRecord.
+ *
+ * <a> elements click are bound to _onColorChanged
+ *
+ */
+ _setupColorPicker: function () {
+ var $colorpicker = this.$('ul');
+ if (!$colorpicker.length) {
+ return;
+ }
+ $colorpicker.html(qweb.render('KanbanColorPicker'));
+ $colorpicker.on('click', 'a', this._onColorChanged.bind(this));
+ },
+ /**
+ * Returns the widget value.
+ * Since NumericField is based on an input, but we don't use it,
+ * we override this function to use the internal value of the widget.
+ *
+ *
+ * @override
+ * @returns {string}
+ */
+ _getValue: function (){
+ return this.value;
+ },
+ /**
+ * Listener in edit mode for click on a color.
+ * The actual color can be found in the data-color
+ * attribute of the target element.
+ *
+ * We re-render the widget after the update because
+ * the selected color has changed and it should
+ * be reflected in the ui.
+ *
+ * @param ev
+ */
+ _onColorChanged: function(ev) {
+ ev.preventDefault();
+ var color = null;
+ if(ev.currentTarget && ev.currentTarget.dataset && ev.currentTarget.dataset.color){
+ color = ev.currentTarget.dataset.color;
+ }
+ if(color){
+ this.value = color;
+ this._onChange();
+ this._renderEdit();
+ }
+ },
+ /**
+ * Helper to modify the active color's style
+ * while in edit mode.
+ *
+ */
+ _highlightSelectedColor: function(){
+ try{
+ $(this.$('li')[parseInt(this.value)]).css('border', '2px solid teal');
+ } catch(err) {
+
+ }
+ },
+});
+
return {
TranslatableFieldMixin: TranslatableFieldMixin,
DebouncedField: DebouncedField,
@@ -3392,6 +3486,7 @@ return {
JournalDashboardGraph: JournalDashboardGraph,
AceEditor: AceEditor,
FieldColor: FieldColor,
+ FieldColorPicker: FieldColorPicker,
};
});