2018-04-17 10:19:40 +00:00
|
|
|
import ngModule from '../../module';
|
2018-04-17 12:49:55 +00:00
|
|
|
import './style.scss';
|
2018-04-17 10:19:40 +00:00
|
|
|
|
2018-06-21 06:46:30 +00:00
|
|
|
export default class Controller {
|
2019-01-29 07:53:29 +00:00
|
|
|
constructor($element, $translate, $attrs) {
|
2018-06-29 07:46:14 +00:00
|
|
|
this.element = $element[0];
|
|
|
|
this._ = $translate;
|
2019-01-29 07:53:29 +00:00
|
|
|
this.hasInfo = Boolean($attrs.info);
|
|
|
|
this.info = $attrs.info || null;
|
2018-06-21 06:46:30 +00:00
|
|
|
}
|
2018-06-29 07:46:14 +00:00
|
|
|
set label(value) {
|
|
|
|
let label = this.element.querySelector('vn-label');
|
2019-01-20 15:47:04 +00:00
|
|
|
label.textContent = this._.instant(value);
|
2018-06-29 07:46:14 +00:00
|
|
|
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;
|
2018-06-21 06:46:30 +00:00
|
|
|
}
|
|
|
|
}
|
2019-01-29 07:53:29 +00:00
|
|
|
Controller.$inject = ['$element', '$translate', '$attrs'];
|
2018-06-21 06:46:30 +00:00
|
|
|
|
2018-04-17 10:19:40 +00:00
|
|
|
ngModule.component('vnLabelValue', {
|
2018-06-21 06:46:30 +00:00
|
|
|
controller: Controller,
|
2018-06-29 07:46:14 +00:00
|
|
|
template: require('./label-value.html'),
|
2018-04-17 10:19:40 +00:00
|
|
|
bindings: {
|
|
|
|
label: '@',
|
2018-06-29 07:46:14 +00:00
|
|
|
value: '@'
|
2018-04-17 10:19:40 +00:00
|
|
|
}
|
|
|
|
});
|