diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 007f067644..061908bfa3 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -14,6 +14,7 @@ import { AddEditComponent } from './vault/add-edit.component'; import { AppComponent } from './app.component'; import { AttachmentsComponent } from './vault/attachments.component'; import { BlurClickDirective } from './directives/blur-click.directive'; +import { BoxRowDirective } from './directives/box-row.directive'; import { CiphersComponent } from './vault/ciphers.component'; import { FallbackSrcDirective } from './directives/fallback-src.directive'; import { GroupingsComponent } from './vault/groupings.component'; @@ -46,6 +47,7 @@ import { ViewComponent } from './vault/view.component'; AppComponent, AttachmentsComponent, BlurClickDirective, + BoxRowDirective, CiphersComponent, FallbackSrcDirective, GroupingsComponent, diff --git a/src/app/directives/box-row.directive.ts b/src/app/directives/box-row.directive.ts new file mode 100644 index 0000000000..8a74a90483 --- /dev/null +++ b/src/app/directives/box-row.directive.ts @@ -0,0 +1,49 @@ +import { + Directive, + ElementRef, + HostListener, + OnInit, +} from '@angular/core'; + +@Directive({ + selector: '[appBoxRow]', +}) +export class BoxRowDirective implements OnInit { + el: HTMLElement = null; + formEls: NodeListOf; + + constructor(private elRef: ElementRef) { + this.el = elRef.nativeElement; + } + + ngOnInit(): void { + this.formEls = this.el.querySelectorAll('input:not([type="hidden"]), select, textarea'); + this.formEls.forEach((formEl) => { + formEl.addEventListener('focus', (event: Event) => { + this.el.classList.add('active'); + }, false); + + formEl.addEventListener('blur', (event: Event) => { + this.el.classList.remove('active'); + }, false); + }); + } + + @HostListener('click', ['$event']) onClick(event: Event) { + if (event.target !== this.el) { + return; + } + + if (this.formEls.length > 0) { + const formEl = (this.formEls[0] as HTMLElement); + if (formEl.tagName.toLowerCase() === 'input') { + const inputEl = (formEl as HTMLInputElement); + if (inputEl.type != null && inputEl.type.toLowerCase() === 'checkbox') { + inputEl.checked = !inputEl.checked; + return; + } + } + formEl.focus(); + } + } +} diff --git a/src/app/vault/add-edit.component.html b/src/app/vault/add-edit.component.html index f11d84d582..4be66b855c 100644 --- a/src/app/vault/add-edit.component.html +++ b/src/app/vault/add-edit.component.html @@ -5,28 +5,28 @@ {{'itemInformation' | i18n}}
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
@@ -171,18 +171,18 @@
-
+
-
+
-
+
@@ -198,8 +198,8 @@
-
- +
+
@@ -209,7 +209,8 @@
-
+
{{'newCustomField' | i18n}} diff --git a/src/app/vault/password-generator.component.html b/src/app/vault/password-generator.component.html index d02bc40701..27764763b1 100644 --- a/src/app/vault/password-generator.component.html +++ b/src/app/vault/password-generator.component.html @@ -20,27 +20,27 @@ Options
-
+
{{options.length}}
-
+
-
+
-
+
-
+
@@ -49,17 +49,17 @@
-
+
-
+
-
+