summaryrefslogtreecommitdiff
path: root/addons/timer/static/src/js/timer_toggle_button.js
diff options
context:
space:
mode:
authorThibault Francois <tfr@openerp.com>2020-06-11 13:32:58 +0200
committerjbm-odoo <jbm@odoo.com>2020-06-15 15:51:20 +0200
commit7f83e0286e04ae79ec0eabe602d391f28a13a4fb (patch)
tree4a0052ea0a662afb8a0e21d309d1a061cbf96d24 /addons/timer/static/src/js/timer_toggle_button.js
parentd6a23144d5c5b85c2a02097bcbb3e006a9c2c52a (diff)
[FIX] timer, hr_timesheet: Fix _compute_display_timer_buttons
mixin method should not return in the middle of the loop Use the value updated on the record instead super() is called with self at every iteration which is not very efficient and can be wrong Solution call super for each specific record and only when needed write is not a good practice in compute method X-original-commit: 7e19ed98d18305370b5c14edd3d310cfea5df714
Diffstat (limited to 'addons/timer/static/src/js/timer_toggle_button.js')
-rw-r--r--addons/timer/static/src/js/timer_toggle_button.js79
1 files changed, 0 insertions, 79 deletions
diff --git a/addons/timer/static/src/js/timer_toggle_button.js b/addons/timer/static/src/js/timer_toggle_button.js
deleted file mode 100644
index d189d996502..00000000000
--- a/addons/timer/static/src/js/timer_toggle_button.js
+++ /dev/null
@@ -1,79 +0,0 @@
-odoo.define('timer.timer_toggle_button', function (require) {
-"use strict";
-
-const fieldRegistry = require('web.field_registry');
-const { FieldToggleBoolean } = require("web.basic_fields");
-const { _lt } = require('web.core');
-
-/**
- * The TimerToggleButton is used to display correctly the button
- * to start or stop a timer for a timesheet in kanban, list and grid
- * views.
- */
-const TimerToggleButton = FieldToggleBoolean.extend({
- /**
- * @override
- * @private
- */
- _render: function () {
- // When the is_timer_running field is false, then the button is used to start the timer
- const title = this.value ? _lt('Stop') : _lt('Play');
- const name = this.value ? 'action_timer_stop' : 'action_timer_start';
- const label = this.value ? _lt('Stop') : _lt('Start');
-
- this.$('i')
- .addClass('fa')
- .toggleClass('fa-stop-circle o-timer-stop-button', this.value)
- .toggleClass('fa-play-circle o-timer-play-button', !this.value)
- .attr('title', title);
-
- this.$el.addClass('o-timer-button');
- this.$el.attr('title', title);
- this.$el.attr('name', name);
- this.$el.attr('aria-label', label);
- this.$el.attr('aria-pressed', this.value);
- this.$el.attr('type', 'button');
- this.$el.attr('role', 'button');
- },
- /**
- * Toggle the button
- *
- * When the user click on this button,
- * - the action "action_timer_start" is called
- * into the account.analytic.line model,
- * if the value of is_timer_running field is set on false.
- * - the action "action_timer_stop" is called
- * into the account.analytic.line model,
- * if the value of is_timer_running field is set on true.
- * Then we change the value of the is_timer_running.
- * @override
- * @private
- * @param {MouseEvent} event
- */
- _onToggleButton: async function (event) {
- const context = this.record.getContext();
- event.stopPropagation();
- const result = await this._rpc({
- model: this.model,
- method: this._getActionButton(),
- context: context,
- args: [this.res_id]
- });
-
- this.trigger_up('timer_changed', {
- id: this.res_id,
- is_timer_running: !this.value
- });
-
- this._setValue(!this.value);
- },
- _getActionButton: function () {
- return this.value ? 'action_timer_stop' : 'action_timer_start';
- }
-});
-
-fieldRegistry.add('timer_toggle_button', TimerToggleButton);
-
-return TimerToggleButton;
-
-});