diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 007f0676..061908bf 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 00000000..8a74a904 --- /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 f11d84d5..4be66b85 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 d02bc407..27764763 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 @@
-
+
-
+
-
+