import '@material/web/textfield/outlined-text-field.js' import '@material/web/textfield/filled-text-field.js' import '@material/web/checkbox/checkbox.js' import { css, html, LitElement } from 'lit' import { customElement, property } from 'lit/decorators.js' import { i18next, localize } from '@operato/i18n' @customElement('kpi-view') export class KpiView extends localize(i18next)(LitElement) { static styles = [ css` :host { display: flex; flex-direction: column; gap: var(--spacing-medium); padding: var(--spacing-medium); } .form-group { display: flex; flex-direction: column; gap: var(--spacing-small); } .form-row { display: flex; gap: var(--spacing-medium); align-items: center; } .form-row > * { flex: 1; } label { font-weight: 500; color: var(--md-sys-color-on-surface); margin-bottom: var(--spacing-small); } md-outlined-text-field, md-filled-text-field, md-outlined-select { width: 100%; } .checkbox-group { display: flex; align-items: center; gap: var(--spacing-small); } .section-title { font-size: 1.1rem; font-weight: 600; color: var(--md-sys-color-primary); margin-top: var(--spacing-large); margin-bottom: var(--spacing-medium); border-bottom: 1px solid var(--md-sys-color-outline-variant); padding-bottom: var(--spacing-small); } textarea { background-color: var(--input-field-background, var(--md-sys-color-surface-container-highest)); color: var(--input-field-color, var(--md-sys-color-on-surface)); width: 100%; min-height: 100px; padding: var(--spacing-small); border: 1px solid var(--md-sys-color-outline); border-radius: var(--md-sys-shape-corner-small); font-family: monospace; resize: vertical; } ` ] @property({ type: Object }) kpi: any = {} render() { return html`
${i18next.t('label.basic_information')}
this.updateProperty('name', e.target.value)} required >
this.updateProperty('description', e.target.value)} type="textarea" rows="3" >
this.updateProperty('weight', parseFloat(e.target.value) || 1)} min="0" step="0.1" >
this.updateProperty('active', e.target.checked)} >
this.updateProperty('isLeaf', e.target.checked)} >
${i18next.t('label.formula_calculation')}
Schedule
this.updateProperty('schedule', e.target.value)} placeholder="${i18next.t('placeholder.cron_schedule')}" >
this.updateProperty('timezone', e.target.value)} placeholder="${i18next.t('placeholder.timezone')}" >
` } updateProperty(property: string, value: any) { this.kpi = { ...this.kpi, [property]: value } this.dispatchEvent(new CustomEvent('property-change', { detail: this.kpi, bubbles: true, composed: true })) this.requestUpdate() } }