salix/front/core/components/label-value/label-value.js

54 lines
1.2 KiB
JavaScript

import ngModule from '../../module';
import './style.scss';
export default class Controller {
constructor($element, $translate, $attrs) {
this.element = $element[0];
this._ = $translate;
this.hasInfo = Boolean($attrs.info);
this.info = $attrs.info || null;
}
set label(value) {
let label = this.element.querySelector('vn-label');
label.textContent = this._.instant(value);
this._label = value;
}
get label() {
return this._label;
}
set value(value) {
let span = this.element.querySelector('span');
span.title = value;
span.textContent = value ? value : '-';
this._value = value;
}
get value() {
return this._value;
}
get title() {
return this._title;
}
set title(value) {
let span = this.element.querySelector('span');
span.title = value;
this._title = value;
}
}
Controller.$inject = ['$element', '$translate', '$attrs'];
ngModule.component('vnLabelValue', {
controller: Controller,
template: require('./label-value.html'),
bindings: {
title: '@?',
label: '@',
value: '@'
}
});