mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-23 11:56:00 +01:00
subtitle properties
This commit is contained in:
parent
9fe0cfb2d8
commit
b4257b9ff3
@ -4,13 +4,48 @@ import { Card } from '../domain/card';
|
||||
|
||||
export class CardView implements View {
|
||||
cardholderName: string;
|
||||
brand: string;
|
||||
number: string;
|
||||
expMonth: string;
|
||||
expYear: string;
|
||||
code: string;
|
||||
|
||||
// tslint:disable
|
||||
private _brand: string;
|
||||
private _number: string;
|
||||
private _subTitle: string;
|
||||
// tslint:enable
|
||||
|
||||
constructor(c?: Card) {
|
||||
// ctor
|
||||
}
|
||||
|
||||
get brand(): string {
|
||||
return this._brand;
|
||||
}
|
||||
set brand(value: string) {
|
||||
this._brand = value;
|
||||
this._subTitle = null;
|
||||
}
|
||||
|
||||
get number(): string {
|
||||
return this._number;
|
||||
}
|
||||
set number(value: string) {
|
||||
this._number = value;
|
||||
this._subTitle = null;
|
||||
}
|
||||
|
||||
get subTitle(): string {
|
||||
if (this._subTitle == null) {
|
||||
this._subTitle = this.brand;
|
||||
if (this.number != null && this.number.length >= 4) {
|
||||
if (this._subTitle != null && this._subTitle !== '') {
|
||||
this._subTitle += ', ';
|
||||
} else {
|
||||
this._subTitle = '';
|
||||
}
|
||||
this._subTitle += ('*' + this.number.substr(this.number.length - 4));
|
||||
}
|
||||
}
|
||||
return this._subTitle;
|
||||
}
|
||||
}
|
||||
|
@ -27,9 +27,6 @@ export class CipherView implements View {
|
||||
fields: FieldView[];
|
||||
collectionIds: string[];
|
||||
|
||||
// tslint:disable-next-line
|
||||
private _subTitle: string;
|
||||
|
||||
constructor(c?: Cipher) {
|
||||
if (!c) {
|
||||
return;
|
||||
@ -45,40 +42,19 @@ export class CipherView implements View {
|
||||
}
|
||||
|
||||
get subTitle(): string {
|
||||
if (this._subTitle == null) {
|
||||
switch (this.type) {
|
||||
case CipherType.Login:
|
||||
this._subTitle = this.login.username;
|
||||
break;
|
||||
case CipherType.SecureNote:
|
||||
this._subTitle = null;
|
||||
break;
|
||||
case CipherType.Card:
|
||||
this._subTitle = this.card.brand;
|
||||
if (this.card.number != null && this.card.number.length >= 4) {
|
||||
if (this._subTitle !== '') {
|
||||
this._subTitle += ', ';
|
||||
}
|
||||
this._subTitle += ('*' + this.card.number.substr(this.card.number.length - 4));
|
||||
}
|
||||
break;
|
||||
case CipherType.Identity:
|
||||
this._subTitle = '';
|
||||
if (this.identity.firstName != null) {
|
||||
this._subTitle = this.identity.firstName;
|
||||
}
|
||||
if (this.identity.lastName != null) {
|
||||
if (this._subTitle !== '') {
|
||||
this._subTitle += ' ';
|
||||
}
|
||||
this._subTitle += this.identity.lastName;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
switch (this.type) {
|
||||
case CipherType.Login:
|
||||
return this.login.subTitle;
|
||||
case CipherType.SecureNote:
|
||||
return this.secureNote.subTitle;
|
||||
case CipherType.Card:
|
||||
return this.card.subTitle;
|
||||
case CipherType.Identity:
|
||||
return this.identity.subTitle;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return this._subTitle;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -4,9 +4,7 @@ import { Identity } from '../domain/identity';
|
||||
|
||||
export class IdentityView implements View {
|
||||
title: string;
|
||||
firstName: string;
|
||||
middleName: string;
|
||||
lastName: string;
|
||||
address1: string;
|
||||
address2: string;
|
||||
address3: string;
|
||||
@ -22,7 +20,46 @@ export class IdentityView implements View {
|
||||
passportNumber: string;
|
||||
licenseNumber: string;
|
||||
|
||||
// tslint:disable
|
||||
private _firstName: string;
|
||||
private _lastName: string;
|
||||
private _subTitle: string;
|
||||
// tslint:enable
|
||||
|
||||
constructor(i?: Identity) {
|
||||
// ctor
|
||||
}
|
||||
|
||||
get firstName(): string {
|
||||
return this._firstName;
|
||||
}
|
||||
set firstName(value: string) {
|
||||
this._firstName = value;
|
||||
this._subTitle = null;
|
||||
}
|
||||
|
||||
get lastName(): string {
|
||||
return this._lastName;
|
||||
}
|
||||
set lastName(value: string) {
|
||||
this._lastName = value;
|
||||
this._subTitle = null;
|
||||
}
|
||||
|
||||
get subTitle(): string {
|
||||
if (this._subTitle == null && (this.firstName != null || this.lastName != null)) {
|
||||
this._subTitle = '';
|
||||
if (this.firstName != null) {
|
||||
this._subTitle = this.firstName;
|
||||
}
|
||||
if (this.lastName != null) {
|
||||
if (this._subTitle !== '') {
|
||||
this._subTitle += ' ';
|
||||
}
|
||||
this._subTitle += this.lastName;
|
||||
}
|
||||
}
|
||||
|
||||
return this._subTitle;
|
||||
}
|
||||
}
|
||||
|
@ -5,19 +5,37 @@ import { Login } from '../domain/login';
|
||||
import { PlatformUtilsService } from '../../abstractions/platformUtils.service';
|
||||
|
||||
export class LoginView implements View {
|
||||
uri: string;
|
||||
username: string;
|
||||
password: string;
|
||||
maskedPassword: string;
|
||||
totp: string;
|
||||
|
||||
// tslint:disable-next-line
|
||||
// tslint:disable
|
||||
private _uri: string;
|
||||
private _username: string;
|
||||
private _password: string;
|
||||
private _domain: string;
|
||||
private _maskedPassword: string;
|
||||
// tslint:enable
|
||||
|
||||
constructor(l?: Login) {
|
||||
// ctor
|
||||
}
|
||||
|
||||
get uri(): string {
|
||||
return this._uri;
|
||||
}
|
||||
set uri(value: string) {
|
||||
this._uri = value;
|
||||
this._domain = null;
|
||||
}
|
||||
|
||||
get password(): string {
|
||||
return this._password;
|
||||
}
|
||||
set password(value: string) {
|
||||
this._password = value;
|
||||
this._maskedPassword = null;
|
||||
}
|
||||
|
||||
get domain(): string {
|
||||
if (this._domain == null && this.uri != null) {
|
||||
const containerService = (window as any).bitwardenContainerService;
|
||||
@ -31,4 +49,19 @@ export class LoginView implements View {
|
||||
|
||||
return this._domain;
|
||||
}
|
||||
|
||||
get maskedPassword(): string {
|
||||
if (this._maskedPassword == null && this.password != null) {
|
||||
this._maskedPassword = '';
|
||||
for (var i = 0; i < this.password.length; i++) {
|
||||
this._maskedPassword += '•';
|
||||
}
|
||||
}
|
||||
|
||||
return this._maskedPassword;
|
||||
}
|
||||
|
||||
get subTitle(): string {
|
||||
return this.username;
|
||||
}
|
||||
}
|
||||
|
@ -10,4 +10,8 @@ export class SecureNoteView implements View {
|
||||
constructor(n: SecureNote) {
|
||||
this.type = n.type;
|
||||
}
|
||||
|
||||
get subTitle(): string {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user