Skip to content
Snippets Groups Projects

[IMP] :sparkles: Controls of 0 or less or more than 100 percent are removed. It is...

Merged Álvaro García requested to merge feacture/selfconsumption_distribution_table_wizard into dev
3 files
+ 46
37
Compare changes
  • Side-by-side
  • Inline
Files
3
/** @odoo-module **/
import {Component, useState} from "@odoo/owl";
import {registry} from "@web/core/registry";
import { Component, useState } from "@odoo/owl";
import { registry } from "@web/core/registry";
class ProgressBarWidget extends Component {
setup() {
// Obtener valores desde this.props
const {record} = this.props;
const { record } = this.props;
// Configurar el estado inicial usando hooks de OWL
this.state = useState({
@@ -16,17 +16,21 @@ class ProgressBarWidget extends Component {
});
// Calcular el porcentaje basado en los valores actuales
this.state.percentage = Math.min(
(this.state.current_quantity / this.state.max_quantity) * 100,
100
);
this.state.percentage = (this.state.current_quantity / this.state.max_quantity) * 100;
}
get progressStyle() {
let background_color = '#7C7BAD';
if (this.state.percentage > 100) {
background_color = '#a10000';
} else if (this.state.percentage == 100) {
background_color = '#00a12a';
}
let width = this.state.percentage > 100 ? 100 : this.state.percentage;
return `
width: ${this.state.percentage}%;
width: ${width}%;
height: 100%;
background-color: #7C7BAD;
background-color: ${background_color};
`;
}
Loading