LP#1831781: add eg-help-popover Angular component
authorCesar Velez <cesar.velez@equinoxinitiative.org>
Wed, 6 Mar 2019 23:06:57 +0000 (18:06 -0500)
committerJane Sandberg <sandbej@linnbenton.edu>
Fri, 28 Jun 2019 15:27:28 +0000 (08:27 -0700)
Usage:

<eg-help-popover helpLink="https://youtu.be/dQw4w9WgXcQ"
 helptext="Helpful msg. Optional link."></eg-help-popover>

Additional placement attributes accepted. Basically wraps
ng-bootstrap's
https://ng-bootstrap.github.io/#/components/popover/examples#basic

To test
-------
[1] Go to the Angular sandbox page (/eg2/en-US/staff/sandbox) and
    verify functioning of the popovers, which display question marks.

Sponsored-by: MassLNC
Sponsored-by: Georgia Public Library Service
Sponsored-by: Indiana State Library
Sponsored-by: CW MARS
Sponsored-by: King County Library System
Signed-off-by: Cesar Velez <cesar.velez@equinoxinitiative.org>
Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Signed-off-by: Jane Sandberg <sandbej@linnbenton.edu>
Open-ILS/src/eg2/src/app/share/eg-help-popover/eg-help-popover.component.css [new file with mode: 0644]
Open-ILS/src/eg2/src/app/share/eg-help-popover/eg-help-popover.component.html [new file with mode: 0644]
Open-ILS/src/eg2/src/app/share/eg-help-popover/eg-help-popover.component.spec.ts [new file with mode: 0644]
Open-ILS/src/eg2/src/app/share/eg-help-popover/eg-help-popover.component.ts [new file with mode: 0644]
Open-ILS/src/eg2/src/app/staff/common.module.ts
Open-ILS/src/eg2/src/app/staff/sandbox/sandbox.component.html

diff --git a/Open-ILS/src/eg2/src/app/share/eg-help-popover/eg-help-popover.component.css b/Open-ILS/src/eg2/src/app/share/eg-help-popover/eg-help-popover.component.css
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/Open-ILS/src/eg2/src/app/share/eg-help-popover/eg-help-popover.component.html b/Open-ILS/src/eg2/src/app/share/eg-help-popover/eg-help-popover.component.html
new file mode 100644 (file)
index 0000000..7891eaa
--- /dev/null
@@ -0,0 +1,7 @@
+<span class="material-icons" placement="{{placement}}" *ngIf="helpLink.length < 1; else withUrl" ngbPopover="{{helpText}}" triggers="keyup.enter click" tabindex="0">live_help</span>
+<ng-template #withUrl>
+  <ng-template #popContent>
+    <a target="_blank" href="{{helpLink}}">{{helpText}}</a>
+  </ng-template>
+  <span class="material-icons" [ngbPopover]="popContent" placement="{{placement}}" triggers="keyup.enter click" tabindex="0">live_help</span>
+</ng-template>
diff --git a/Open-ILS/src/eg2/src/app/share/eg-help-popover/eg-help-popover.component.spec.ts b/Open-ILS/src/eg2/src/app/share/eg-help-popover/eg-help-popover.component.spec.ts
new file mode 100644 (file)
index 0000000..3dfeecb
--- /dev/null
@@ -0,0 +1,26 @@
+import { async, ComponentFixture, TestBed } from '@angular/core/testing';
+import { NgbPopoverModule } from '@ng-bootstrap/ng-bootstrap';
+import { EgHelpPopoverComponent } from './eg-help-popover.component';
+
+describe('EgHelpPopoverComponent', () => {
+  let component: EgHelpPopoverComponent;
+  let fixture: ComponentFixture<EgHelpPopoverComponent>;
+
+  beforeEach(async(() => {
+    TestBed.configureTestingModule({
+      declarations: [ EgHelpPopoverComponent ],
+      imports: [NgbPopoverModule.forRoot()]
+    })
+    .compileComponents();
+  }));
+
+  beforeEach(() => {
+    fixture = TestBed.createComponent(EgHelpPopoverComponent);
+    component = fixture.componentInstance;
+    fixture.detectChanges();
+  });
+
+  it('should create', () => {
+    expect(component).toBeTruthy();
+  });
+});
diff --git a/Open-ILS/src/eg2/src/app/share/eg-help-popover/eg-help-popover.component.ts b/Open-ILS/src/eg2/src/app/share/eg-help-popover/eg-help-popover.component.ts
new file mode 100644 (file)
index 0000000..77d8fd6
--- /dev/null
@@ -0,0 +1,25 @@
+import { Component, OnInit, Input } from '@angular/core';
+import {NgbPopover} from '@ng-bootstrap/ng-bootstrap';
+
+@Component({
+  selector: 'eg-help-popover',
+  templateUrl: './eg-help-popover.component.html',
+  styleUrls: ['./eg-help-popover.component.css']
+})
+export class EgHelpPopoverComponent implements OnInit {
+
+  @Input()
+  helpText = '';
+
+  @Input()
+  helpLink = '';
+
+  @Input()
+  placement = '';
+
+  constructor() { }
+
+  ngOnInit() {
+  }
+
+}
index 9c822a2..5575b70 100644 (file)
@@ -21,6 +21,7 @@ import {BucketDialogComponent} from '@eg/staff/share/buckets/bucket-dialog.compo
 import {BibSummaryComponent} from '@eg/staff/share/bib-summary/bib-summary.component';
 import {TranslateComponent} from '@eg/staff/share/translate/translate.component';
 import {AdminPageComponent} from '@eg/staff/share/admin-page/admin-page.component';
+import {EgHelpPopoverComponent} from '@eg/share/eg-help-popover/eg-help-popover.component';
 
 /**
  * Imports the EG common modules and adds modules common to all staff UI's.
@@ -43,7 +44,8 @@ import {AdminPageComponent} from '@eg/staff/share/admin-page/admin-page.componen
     BucketDialogComponent,
     BibSummaryComponent,
     TranslateComponent,
-    AdminPageComponent
+    AdminPageComponent,
+    EgHelpPopoverComponent
   ],
   imports: [
     EgCommonModule,
@@ -67,7 +69,8 @@ import {AdminPageComponent} from '@eg/staff/share/admin-page/admin-page.componen
     BucketDialogComponent,
     BibSummaryComponent,
     TranslateComponent,
-    AdminPageComponent
+    AdminPageComponent,
+    EgHelpPopoverComponent
   ]
 })
 
index aa21644..9087d04 100644 (file)
@@ -7,7 +7,7 @@
   prefix=":) {{dynamicTitleText}}"
   suffix="Sandbox">
 </eg-title>
-
+<eg-help-popover [placement]="'right'" helpText="This page is for random ng stuff!"></eg-help-popover>
 <div class="row flex pt-2">
   <div i18n> Modify Page Title: </div>
   <div class="col-lg-2">
@@ -47,6 +47,8 @@
 <div class="row mb-3">
   <div class="col-lg-3">
     <button class="btn btn-outline-danger" (click)="progress.increment()">Increment Inline</button>
+    <eg-help-popover [placement]="'bottom'" helpText="Exercise your clicking finger by clicking the button above.">
+    </eg-help-popover>
   </div>
   <div class="col-lg-3">
     <eg-progress-inline [max]="100" [value]="1" #progress></eg-progress-inline>
     <button class="btn btn-light" (click)="showProgress()">Test Progress Dialog</button>
   </div>
   <div class="col-lg-3">
+    <eg-help-popover helpLink="https://www.youtube.com/watch?v=dQw4w9WgXcQ" helpText="This popover is supposed to help or something...!"></eg-help-popover>
     <eg-combobox [allowFreeText]="true" 
       placeholder="Combobox with static data"
       [entries]="cbEntries"></eg-combobox>
   </div>
   <div class="col-lg-3">
+    <eg-help-popover helpText="You have to type to see any options in this dropdown."></eg-help-popover>
     <eg-combobox
       placeholder="Combobox with dynamic data"
       [asyncDataSource]="cbAsyncSource"></eg-combobox>
@@ -71,6 +75,7 @@
 </div>
 <div class="row mb-3">
   <div class="col-lg-4">
+   <eg-help-popover helpText="If you like Toast you must click below!" placement="'auto'"></eg-help-popover>
    <button class="btn btn-info" (click)="testToast()">Test Toast Message</button>
   </div>
   <div class="col-lg-2">