Skip to content

Commit

Permalink
refactor(Button): Reimposta sistema di coercion per le proprietà bool…
Browse files Browse the repository at this point in the history
…eane del bottone

ref #44
  • Loading branch information
Mario Traetta committed Jul 31, 2018
1 parent f1ef909 commit 73749f4
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions projects/design-angular-kit/src/lib/button/button.component.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Component, OnInit, Input } from '@angular/core';
import { Component, Input } from '@angular/core';
import { ThemeColor } from '../models/ThemeColor';
import { ButtonSize } from '../models/ButtonSize';
import { Util } from '../util/util';

let identifier = 0;

Expand All @@ -12,7 +13,7 @@ let identifier = 0;
templateUrl: './button.component.html',
styleUrls: ['./button.component.css']
})
export class ButtonComponent implements OnInit {
export class ButtonComponent {

id = `button-${identifier++}`;

Expand All @@ -21,7 +22,7 @@ export class ButtonComponent implements OnInit {
*/
@Input()
get disabled(): boolean { return this._disabled; }
set disabled(value: boolean) { this._disabled = value != null && `${value}` !== 'false'; }
set disabled(value: boolean) { this._disabled = Util.coerceBooleanProperty(value); }
private _disabled = false;

/**
Expand All @@ -31,15 +32,15 @@ export class ButtonComponent implements OnInit {
*/
@Input()
get outline(): boolean { return this._outline; }
set outline(value: boolean) { this._outline = value != null && `${value}` !== 'false'; }
set outline(value: boolean) { this._outline = Util.coerceBooleanProperty(value); }
private _outline = false;

/**
* Indica se il pulsante occupa tutta l'ampiezza a sua disposizione.
*/
@Input()
get block(): boolean { return this._block; }
set block(value: boolean) { this._block = value != null && `${value}` !== 'false'; }
set block(value: boolean) { this._block = Util.coerceBooleanProperty(value); }
private _block = false;

/**
Expand Down Expand Up @@ -116,9 +117,4 @@ export class ButtonComponent implements OnInit {
return cssClass;
}

constructor() { }

ngOnInit() {
}

}

0 comments on commit 73749f4

Please sign in to comment.