From 63ac79fb7b7341b64677d07c0e49201b272f9629 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Thu, 5 Apr 2018 23:49:04 -0400 Subject: [PATCH] vault add/edit --- src/_locales/en/messages.json | 9 + src/popup2/app-routing.module.ts | 3 + src/popup2/app.module.ts | 2 + src/popup2/vault/add-edit.component.html | 303 ++++++++++++++++++++++ src/popup2/vault/add-edit.component.ts | 58 +++++ src/popup2/vault/ciphers.component.html | 6 +- src/popup2/vault/ciphers.component.ts | 12 +- src/popup2/vault/groupings.component.html | 6 +- src/popup2/vault/groupings.component.ts | 8 + src/popup2/vault/view.component.html | 8 +- 10 files changed, 405 insertions(+), 10 deletions(-) create mode 100644 src/popup2/vault/add-edit.component.html create mode 100644 src/popup2/vault/add-edit.component.ts diff --git a/src/_locales/en/messages.json b/src/_locales/en/messages.json index 014136506e..0eb1041a73 100644 --- a/src/_locales/en/messages.json +++ b/src/_locales/en/messages.json @@ -467,6 +467,15 @@ "uri": { "message": "URI" }, + "uriPosition": { + "message": "URI $POSITION$", + "placeholders": { + "position": { + "content": "$1", + "example": "2" + } + } + }, "newUri": { "message": "New URI" }, diff --git a/src/popup2/app-routing.module.ts b/src/popup2/app-routing.module.ts index 548d3a7302..26f791468d 100644 --- a/src/popup2/app-routing.module.ts +++ b/src/popup2/app-routing.module.ts @@ -15,6 +15,7 @@ import { RegisterComponent } from './accounts/register.component'; import { TwoFactorOptionsComponent } from './accounts/two-factor-options.component'; import { TwoFactorComponent } from './accounts/two-factor.component'; import { TabsComponent } from './tabs.component'; +import { AddEditComponent } from './vault/add-edit.component'; import { CiphersComponent } from './vault/ciphers.component'; import { CurrentTabComponent } from './vault/current-tab.component'; import { GroupingsComponent } from './vault/groupings.component'; @@ -33,6 +34,8 @@ const routes: Routes = [ { path: 'environment', component: EnvironmentComponent }, { path: 'ciphers', component: CiphersComponent }, { path: 'view-cipher', component: ViewComponent }, + { path: 'add-cipher', component: AddEditComponent }, + { path: 'edit-cipher', component: AddEditComponent }, { path: 'tabs', component: TabsComponent, children: [ diff --git a/src/popup2/app.module.ts b/src/popup2/app.module.ts index ac7132f3f0..b9a7b821c0 100644 --- a/src/popup2/app.module.ts +++ b/src/popup2/app.module.ts @@ -24,6 +24,7 @@ import { RegisterComponent } from './accounts/register.component'; import { TwoFactorOptionsComponent } from './accounts/two-factor-options.component'; import { TwoFactorComponent } from './accounts/two-factor.component'; import { TabsComponent } from './tabs.component'; +import { AddEditComponent } from './vault/add-edit.component'; import { CiphersComponent } from './vault/ciphers.component'; import { CurrentTabComponent } from './vault/current-tab.component'; import { GroupingsComponent } from './vault/groupings.component'; @@ -62,6 +63,7 @@ import { IconComponent } from 'jslib/angular/components/icon.component'; ], declarations: [ ActionButtonsComponent, + AddEditComponent, ApiActionDirective, AppComponent, AutofocusDirective, diff --git a/src/popup2/vault/add-edit.component.html b/src/popup2/vault/add-edit.component.html new file mode 100644 index 0000000000..ba859d26f3 --- /dev/null +++ b/src/popup2/vault/add-edit.component.html @@ -0,0 +1,303 @@ +
+
+
+ +
+
+ {{title}} +
+
+ +
+
+ +
+
+ {{'itemInformation' | i18n}} +
+
+
+ + +
+
+ + +
+ +
+
+ + +
+
+
+ + +
+
+ + + + + + + +
+
+
+ + +
+
+ +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+
+
+
+ +
+ + + +
+ + + + +
+
+ + + +
+
+
+ + {{'newUri' | i18n}} + +
+
+
+
+
+ + +
+
+ + +
+ +
{{'attachments' | i18n}}
+ +
+
+
+
+
+ +
+
+
+ +
+
+
+
+
+ {{'customFields' | i18n}} +
+
+ +
+ + + + + +
+ + + +
+ +
+ + + +
+
+
+
+ + {{'newCustomField' | i18n}} + + + +
+
+
+
+
diff --git a/src/popup2/vault/add-edit.component.ts b/src/popup2/vault/add-edit.component.ts new file mode 100644 index 0000000000..7c96c33015 --- /dev/null +++ b/src/popup2/vault/add-edit.component.ts @@ -0,0 +1,58 @@ +import * as template from './add-edit.component.html'; + +import { Location } from '@angular/common'; +import { + Component, + OnInit, +} from '@angular/core'; +import { + ActivatedRoute, + Router, +} from '@angular/router'; + +import { ToasterService } from 'angular2-toaster'; +import { Angulartics2 } from 'angulartics2'; + +import { AuditService } from 'jslib/abstractions/audit.service'; +import { CipherService } from 'jslib/abstractions/cipher.service'; +import { FolderService } from 'jslib/abstractions/folder.service'; +import { I18nService } from 'jslib/abstractions/i18n.service'; +import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service'; + +import { AddEditComponent as BaseAddEditComponent } from 'jslib/angular/components/add-edit.component'; + +@Component({ + selector: 'app-vault-add-edit', + template: template, +}) +export class AddEditComponent extends BaseAddEditComponent implements OnInit { + constructor(cipherService: CipherService, folderService: FolderService, + i18nService: I18nService, platformUtilsService: PlatformUtilsService, + analytics: Angulartics2, toasterService: ToasterService, + auditService: AuditService, private route: ActivatedRoute, + private router: Router, private location: Location) { + super(cipherService, folderService, i18nService, platformUtilsService, analytics, + toasterService, auditService); + } + + ngOnInit() { + this.route.queryParams.subscribe(async (params) => { + if (params.cipherId) { + this.cipherId = params.cipherId; + } + this.editMode = !params.cipherId; + await this.load(); + }); + } + + async submit() { + if (await super.submit()) { + this.location.back(); + } + } + + cancel() { + super.cancel(); + this.location.back(); + } +} diff --git a/src/popup2/vault/ciphers.component.html b/src/popup2/vault/ciphers.component.html index 691e5dcea4..df589f5868 100644 --- a/src/popup2/vault/ciphers.component.html +++ b/src/popup2/vault/ciphers.component.html @@ -1,15 +1,15 @@
{{searchPlaceholder || ('searchVault' | i18n)}}
-
diff --git a/src/popup2/vault/ciphers.component.ts b/src/popup2/vault/ciphers.component.ts index 7705165d78..c3a991e5c8 100644 --- a/src/popup2/vault/ciphers.component.ts +++ b/src/popup2/vault/ciphers.component.ts @@ -1,5 +1,6 @@ import * as template from './ciphers.component.html'; +import { Location } from '@angular/common'; import { Component, OnInit, @@ -21,7 +22,7 @@ import { CiphersComponent as BaseCiphersComponent } from 'jslib/angular/componen }) export class CiphersComponent extends BaseCiphersComponent implements OnInit { constructor(cipherService: CipherService, private route: ActivatedRoute, - private router: Router) { + private router: Router, private location: Location) { super(cipherService); } @@ -44,4 +45,13 @@ export class CiphersComponent extends BaseCiphersComponent implements OnInit { super.selectCipher(cipher); this.router.navigate(['/view-cipher'], { queryParams: { cipherId: cipher.id } }); } + + addCipher() { + super.addCipher(); + this.router.navigate(['/add-cipher']); + } + + back() { + this.location.back(); + } } diff --git a/src/popup2/vault/groupings.component.html b/src/popup2/vault/groupings.component.html index ff9f248ed4..784257a5be 100644 --- a/src/popup2/vault/groupings.component.html +++ b/src/popup2/vault/groupings.component.html @@ -20,7 +20,8 @@ {{favoriteCiphers.length}}
- +
@@ -105,7 +106,8 @@
{{noFolderCiphers.length}}
- +
diff --git a/src/popup2/vault/groupings.component.ts b/src/popup2/vault/groupings.component.ts index 4d3b00a569..aab5c9e04f 100644 --- a/src/popup2/vault/groupings.component.ts +++ b/src/popup2/vault/groupings.component.ts @@ -110,4 +110,12 @@ export class GroupingsComponent extends BaseGroupingsComponent implements OnInit super.selectCollection(collection); this.router.navigate(['/ciphers'], { queryParams: { collectionId: collection.id } }); } + + selectCipher(cipher: CipherView) { + this.router.navigate(['/view-cipher'], { queryParams: { cipherId: cipher.id } }); + } + + addCipher() { + this.router.navigate(['/add-cipher']); + } } diff --git a/src/popup2/vault/view.component.html b/src/popup2/vault/view.component.html index 79e1c22020..6450e2b73d 100644 --- a/src/popup2/vault/view.component.html +++ b/src/popup2/vault/view.component.html @@ -1,12 +1,12 @@
- +
- {{'viewItem' | i18n}} + {{'viewItem' | i18n}}
- +
@@ -183,7 +183,7 @@ *ngIf="u.canLaunch" (click)="launch(u)"> -