2018-01-24 17:33:15 +01:00
|
|
|
import { FieldType } from '../../enums/fieldType';
|
|
|
|
|
|
|
|
import { View } from './view';
|
|
|
|
|
|
|
|
import { Field } from '../domain/field';
|
|
|
|
|
|
|
|
export class FieldView implements View {
|
|
|
|
name: string;
|
|
|
|
type: FieldType;
|
|
|
|
|
2018-01-25 20:26:09 +01:00
|
|
|
// tslint:disable
|
|
|
|
private _value: string;
|
|
|
|
private _maskedValue: string;
|
|
|
|
// tslint:enable
|
|
|
|
|
2018-01-24 17:33:15 +01:00
|
|
|
constructor(f: Field) {
|
|
|
|
this.type = f.type;
|
|
|
|
}
|
2018-01-25 20:26:09 +01:00
|
|
|
|
|
|
|
get value(): string {
|
|
|
|
return this._value;
|
|
|
|
}
|
|
|
|
set value(value: string) {
|
|
|
|
this._value = value;
|
|
|
|
this._maskedValue = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
get maskedValue(): string {
|
|
|
|
if (this._maskedValue == null && this.value != null) {
|
|
|
|
this._maskedValue = '';
|
|
|
|
for (let i = 0; i < this.value.length; i++) {
|
|
|
|
this._maskedValue += '•';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return this._maskedValue;
|
|
|
|
}
|
2018-01-24 17:33:15 +01:00
|
|
|
}
|