From e373e603bf350309e3aa47171a42f8ec9f90f941 Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Fri, 15 Feb 2019 08:02:29 +0100 Subject: [PATCH] checkbox component noew emits change event --- front/core/components/check/check.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/front/core/components/check/check.js b/front/core/components/check/check.js index 8b8434da19..decc2ab8ca 100644 --- a/front/core/components/check/check.js +++ b/front/core/components/check/check.js @@ -1,8 +1,10 @@ import ngModule from '../../module'; +import Component from '../../lib/component'; import './style.scss'; -export default class Controller { - constructor($attrs) { +export default class Controller extends Component { + constructor($element, $scope, $attrs) { + super($element, $scope); this.hasInfo = Boolean($attrs.info); this.info = $attrs.info || null; } @@ -13,6 +15,10 @@ export default class Controller { value = false; this._field = value; + + if (this._checkValue !== undefined && this._checkValue !== null) + this.emit('change', {value: this.field}); + this._checkValue = value; } @@ -32,7 +38,7 @@ export default class Controller { } checkIntermediate() { - if ((this.intermediate || (this._field === false && this.tripleState)) && !this.isIntermediate) { + if ((this.intermediate || (!this._field && this.tripleState)) && !this.isIntermediate) { this.isIntermediate = true; return; } @@ -40,7 +46,7 @@ export default class Controller { this.isIntermediate = false; } } -Controller.$inject = ['$attrs']; +Controller.$inject = ['$element', '$scope', '$attrs']; ngModule.component('vnCheck', { template: require('./check.html'),