mirror of
https://github.com/bitwarden/browser.git
synced 2025-01-08 19:18:02 +01:00
init view properties
This commit is contained in:
parent
62b074ae22
commit
b01709240e
@ -4,12 +4,12 @@ import { Attachment } from '../domain/attachment';
|
||||
import { SymmetricCryptoKey } from '../domain/symmetricCryptoKey';
|
||||
|
||||
export class AttachmentView implements View {
|
||||
id: string;
|
||||
url: string;
|
||||
size: number;
|
||||
sizeName: string;
|
||||
fileName: string;
|
||||
key: SymmetricCryptoKey;
|
||||
id: string = null;
|
||||
url: string = null;
|
||||
size: number = null;
|
||||
sizeName: string = null;
|
||||
fileName: string = null;
|
||||
key: SymmetricCryptoKey = null;
|
||||
|
||||
constructor(a?: Attachment) {
|
||||
if (!a) {
|
||||
|
@ -3,15 +3,15 @@ import { View } from './view';
|
||||
import { Card } from '../domain/card';
|
||||
|
||||
export class CardView implements View {
|
||||
cardholderName: string;
|
||||
cardholderName: string = null;
|
||||
expMonth: string = null;
|
||||
expYear: string;
|
||||
code: string;
|
||||
expYear: string = null;
|
||||
code: string = null;
|
||||
|
||||
// tslint:disable
|
||||
private _brand: string = null;
|
||||
private _number: string;
|
||||
private _subTitle: string;
|
||||
private _number: string = null;
|
||||
private _subTitle: string = null;
|
||||
// tslint:enable
|
||||
|
||||
constructor(c?: Card) {
|
||||
|
@ -12,25 +12,25 @@ import { SecureNoteView } from './secureNoteView';
|
||||
import { View } from './view';
|
||||
|
||||
export class CipherView implements View {
|
||||
id: string;
|
||||
organizationId: string;
|
||||
folderId: string;
|
||||
name: string;
|
||||
notes: string;
|
||||
type: CipherType;
|
||||
id: string = null;
|
||||
organizationId: string = null;
|
||||
folderId: string = null;
|
||||
name: string = null;
|
||||
notes: string = null;
|
||||
type: CipherType = null;
|
||||
favorite = false;
|
||||
organizationUseTotp = false;
|
||||
edit = false;
|
||||
localData: any;
|
||||
login: LoginView;
|
||||
identity: IdentityView;
|
||||
card: CardView;
|
||||
secureNote: SecureNoteView;
|
||||
attachments: AttachmentView[];
|
||||
fields: FieldView[];
|
||||
passwordHistory: PasswordHistoryView[];
|
||||
collectionIds: string[];
|
||||
revisionDate: Date;
|
||||
login = new LoginView();
|
||||
identity = new IdentityView();
|
||||
card = new CardView();
|
||||
secureNote = new SecureNoteView();
|
||||
attachments: AttachmentView[] = null;
|
||||
fields: FieldView[] = null;
|
||||
passwordHistory: PasswordHistoryView[] = null;
|
||||
collectionIds: string[] = null;
|
||||
revisionDate: Date = null;
|
||||
|
||||
constructor(c?: Cipher) {
|
||||
if (!c) {
|
||||
@ -90,7 +90,7 @@ export class CipherView implements View {
|
||||
}
|
||||
|
||||
get passwordRevisionDisplayDate(): Date {
|
||||
if (this.login == null) {
|
||||
if (this.type !== CipherType.Login || this.login == null) {
|
||||
return null;
|
||||
} else if (this.login.password == null || this.login.password === '') {
|
||||
return null;
|
||||
|
@ -4,10 +4,10 @@ import { Collection } from '../domain/collection';
|
||||
import { ITreeNodeObject } from '../domain/treeNode';
|
||||
|
||||
export class CollectionView implements View, ITreeNodeObject {
|
||||
id: string;
|
||||
organizationId: string;
|
||||
name: string;
|
||||
readOnly: boolean;
|
||||
id: string = null;
|
||||
organizationId: string = null;
|
||||
name: string = null;
|
||||
readOnly: boolean = null;
|
||||
|
||||
constructor(c?: Collection) {
|
||||
if (!c) {
|
||||
|
@ -5,9 +5,9 @@ import { View } from './view';
|
||||
import { Field } from '../domain/field';
|
||||
|
||||
export class FieldView implements View {
|
||||
name: string;
|
||||
value: string;
|
||||
type: FieldType;
|
||||
name: string = null;
|
||||
value: string = null;
|
||||
type: FieldType = null;
|
||||
|
||||
constructor(f?: Field) {
|
||||
if (!f) {
|
||||
|
@ -5,8 +5,8 @@ import { ITreeNodeObject } from '../domain/treeNode';
|
||||
|
||||
export class FolderView implements View, ITreeNodeObject {
|
||||
id: string = null;
|
||||
name: string;
|
||||
revisionDate: Date;
|
||||
name: string = null;
|
||||
revisionDate: Date = null;
|
||||
|
||||
constructor(f?: Folder) {
|
||||
if (!f) {
|
||||
|
@ -6,26 +6,26 @@ import { Utils } from '../../misc/utils';
|
||||
|
||||
export class IdentityView implements View {
|
||||
title: string = null;
|
||||
middleName: string;
|
||||
address1: string;
|
||||
address2: string;
|
||||
address3: string;
|
||||
city: string;
|
||||
state: string;
|
||||
postalCode: string;
|
||||
country: string;
|
||||
company: string;
|
||||
email: string;
|
||||
phone: string;
|
||||
ssn: string;
|
||||
username: string;
|
||||
passportNumber: string;
|
||||
licenseNumber: string;
|
||||
middleName: string = null;
|
||||
address1: string = null;
|
||||
address2: string = null;
|
||||
address3: string = null;
|
||||
city: string = null;
|
||||
state: string = null;
|
||||
postalCode: string = null;
|
||||
country: string = null;
|
||||
company: string = null;
|
||||
email: string = null;
|
||||
phone: string = null;
|
||||
ssn: string = null;
|
||||
username: string = null;
|
||||
passportNumber: string = null;
|
||||
licenseNumber: string = null;
|
||||
|
||||
// tslint:disable
|
||||
private _firstName: string;
|
||||
private _lastName: string;
|
||||
private _subTitle: string;
|
||||
private _firstName: string = null;
|
||||
private _lastName: string = null;
|
||||
private _subTitle: string = null;
|
||||
// tslint:enable
|
||||
|
||||
constructor(i?: Identity) {
|
||||
|
@ -20,10 +20,10 @@ export class LoginUriView implements View {
|
||||
match: UriMatchType = null;
|
||||
|
||||
// tslint:disable
|
||||
private _uri: string;
|
||||
private _domain: string;
|
||||
private _hostname: string;
|
||||
private _canLaunch: boolean;
|
||||
private _uri: string = null;
|
||||
private _domain: string = null;
|
||||
private _hostname: string = null;
|
||||
private _canLaunch: boolean = null;
|
||||
// tslint:enable
|
||||
|
||||
constructor(u?: LoginUri) {
|
||||
|
@ -4,11 +4,11 @@ import { View } from './view';
|
||||
import { Login } from '../domain/login';
|
||||
|
||||
export class LoginView implements View {
|
||||
username: string;
|
||||
password: string;
|
||||
passwordRevisionDate?: Date;
|
||||
totp: string;
|
||||
uris: LoginUriView[];
|
||||
username: string = null;
|
||||
password: string = null;
|
||||
passwordRevisionDate?: Date = null;
|
||||
totp: string = null;
|
||||
uris: LoginUriView[] = null;
|
||||
|
||||
constructor(l?: Login) {
|
||||
if (!l) {
|
||||
|
@ -3,8 +3,8 @@ import { View } from './view';
|
||||
import { Password } from '../domain/password';
|
||||
|
||||
export class PasswordHistoryView implements View {
|
||||
password: string;
|
||||
lastUsedDate: Date;
|
||||
password: string = null;
|
||||
lastUsedDate: Date = null;
|
||||
|
||||
constructor(ph?: Password) {
|
||||
if (!ph) {
|
||||
|
@ -5,7 +5,7 @@ import { View } from './view';
|
||||
import { SecureNote } from '../domain/secureNote';
|
||||
|
||||
export class SecureNoteView implements View {
|
||||
type: SecureNoteType;
|
||||
type: SecureNoteType = null;
|
||||
|
||||
constructor(n?: SecureNote) {
|
||||
if (!n) {
|
||||
|
@ -10,6 +10,10 @@ import {
|
||||
|
||||
import { ImportResult } from '../models/domain/importResult';
|
||||
|
||||
import { CipherType } from '../enums/cipherType';
|
||||
|
||||
import { Utils } from '../misc/utils';
|
||||
|
||||
import { CipherRequest } from '../models/request/cipherRequest';
|
||||
import { CollectionRequest } from '../models/request/collectionRequest';
|
||||
import { FolderRequest } from '../models/request/folderRequest';
|
||||
@ -278,6 +282,6 @@ export class ImportService implements ImportServiceAbstraction {
|
||||
|
||||
private badData(c: CipherView) {
|
||||
return (c.name == null || c.name === '--') &&
|
||||
(c.login != null && (c.login.password == null || c.login.password === ''));
|
||||
(c.type === CipherType.Login && c.login != null && Utils.isNullOrWhitespace(c.login.password));
|
||||
}
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ export class SearchService implements SearchServiceAbstraction {
|
||||
});
|
||||
builder.field('notes');
|
||||
(builder as any).field('login.username', {
|
||||
extractor: (c: CipherView) => c.login != null ? c.login.username : null,
|
||||
extractor: (c: CipherView) => c.type === CipherType.Login && c.login != null ? c.login.username : null,
|
||||
});
|
||||
(builder as any).field('login.uris', { boost: 2, extractor: (c: CipherView) => this.uriExtractor(c) });
|
||||
(builder as any).field('fields', { extractor: (c: CipherView) => this.fieldExtractor(c, false) });
|
||||
@ -198,7 +198,7 @@ export class SearchService implements SearchServiceAbstraction {
|
||||
}
|
||||
|
||||
private uriExtractor(c: CipherView) {
|
||||
if (c.login == null || !c.login.hasUris) {
|
||||
if (c.type !== CipherType.Login || c.login == null || !c.login.hasUris) {
|
||||
return null;
|
||||
}
|
||||
const uris: string[] = [];
|
||||
|
Loading…
Reference in New Issue
Block a user