mirror of
https://github.com/bitwarden/browser
synced 2025-12-17 16:53:34 +00:00
apply collection and folder views
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
import { CollectionData } from '../data/collectionData';
|
||||
|
||||
import { CollectionView } from '../view/collectionView';
|
||||
|
||||
import { CipherString } from './cipherString';
|
||||
import Domain from './domain';
|
||||
|
||||
@@ -21,13 +23,8 @@ export class Collection extends Domain {
|
||||
}, alreadyEncrypted, ['id', 'organizationId']);
|
||||
}
|
||||
|
||||
decrypt(): Promise<any> {
|
||||
const model = {
|
||||
id: this.id,
|
||||
organizationId: this.organizationId,
|
||||
};
|
||||
|
||||
return this.decryptObj(model, {
|
||||
decrypt(): Promise<CollectionView> {
|
||||
return this.decryptObj(new CollectionView(this), {
|
||||
name: null,
|
||||
}, this.organizationId);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import { FolderData } from '../data/folderData';
|
||||
|
||||
import { FolderView } from '../view/folderView';
|
||||
|
||||
import { CipherString } from './cipherString';
|
||||
import Domain from './domain';
|
||||
|
||||
@@ -19,12 +21,8 @@ export class Folder extends Domain {
|
||||
}, alreadyEncrypted, ['id']);
|
||||
}
|
||||
|
||||
decrypt(): Promise<any> {
|
||||
const model = {
|
||||
id: this.id,
|
||||
};
|
||||
|
||||
return this.decryptObj(model, {
|
||||
decrypt(): Promise<FolderView> {
|
||||
return this.decryptObj(new FolderView(this), {
|
||||
name: null,
|
||||
}, null);
|
||||
}
|
||||
|
||||
18
src/models/view/collectionView.ts
Normal file
18
src/models/view/collectionView.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { View } from './view';
|
||||
|
||||
import { Collection } from '../domain/collection';
|
||||
|
||||
export class CollectionView implements View {
|
||||
id: string;
|
||||
organizationId: string;
|
||||
name: string;
|
||||
|
||||
constructor(c?: Collection) {
|
||||
if (!c) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.id = c.id;
|
||||
this.organizationId = c.organizationId;
|
||||
}
|
||||
}
|
||||
16
src/models/view/folderView.ts
Normal file
16
src/models/view/folderView.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { View } from './view';
|
||||
|
||||
import { Folder } from '../domain/folder';
|
||||
|
||||
export class FolderView implements View {
|
||||
id: string;
|
||||
name: string;
|
||||
|
||||
constructor(f?: Folder) {
|
||||
if (!f) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.id = f.id;
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,11 @@ import { SecureNote } from '../domain/secureNote';
|
||||
export class SecureNoteView implements View {
|
||||
type: SecureNoteType;
|
||||
|
||||
constructor(n: SecureNote) {
|
||||
constructor(n?: SecureNote) {
|
||||
if (!n) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.type = n.type;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user