[open-ils-commits] [GIT] Evergreen ILS branch rel_3_3 updated. 45fb062fbd59ec2ef6c124dd5841040c3291dc2f
Evergreen Git
git at git.evergreen-ils.org
Thu Jun 20 13:54:45 EDT 2019
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Evergreen ILS".
The branch, rel_3_3 has been updated
via 45fb062fbd59ec2ef6c124dd5841040c3291dc2f (commit)
from bcb5523aac31c85f54eb3a812dbe1d9a45b7ebb5 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 45fb062fbd59ec2ef6c124dd5841040c3291dc2f
Author: Galen Charlton <gmc at equinoxinitiative.org>
Date: Mon Jun 17 10:46:14 2019 -0400
LP#1833080: have eg-bool recognize IDL bool string values
This patch updates eg-bool so that it can format both
true Boolean and IDL bool string values (i.e., 't' or 'f'). Prior
to this patch, IDL bool values would always be rendered as 'Yes'.
This patch relaxes the type restriction on the value setter
and getter; unfortunately, there's no way to overload the
setter or making it accept (say) boolean|string.A
This patch also supplies some unit sets.
To test
-------
[1] View an Angular grid that has Boolean fields. The Copy
Status server admin page is a good one.
[2] Note that the boolean values are all rendered as "Yes".
[3] Apply the patch and repeat step 1. This time, false
values should be displayed as "No".
[4] Verify that 'npm run test' for the Angular app passes.
Sponsored-by: PaILS
Signed-off-by: Galen Charlton <gmc at equinoxinitiative.org>
Signed-off-by: Bill Erickson <berickxx at gmail.com>
diff --git a/Open-ILS/src/eg2/src/app/share/util/bool.component.spec.ts b/Open-ILS/src/eg2/src/app/share/util/bool.component.spec.ts
new file mode 100644
index 0000000000..aeec506333
--- /dev/null
+++ b/Open-ILS/src/eg2/src/app/share/util/bool.component.spec.ts
@@ -0,0 +1,59 @@
+import { async, ComponentFixture, TestBed } from '@angular/core/testing';
+import { BoolDisplayComponent } from './bool.component';
+import { Component } from '@angular/core';
+import { ViewChild } from '@angular/core';
+
+describe('BoolDisplayComponent', () => {
+ @Component({
+ selector: `eg-host-component`,
+ template: `<eg-bool></eg-bool>`
+ })
+ class TestHostComponent {
+ @ViewChild(BoolDisplayComponent)
+ public boolDisplayComponent: BoolDisplayComponent;
+ }
+
+ let hostComponent: TestHostComponent;
+ let fixture: ComponentFixture<TestHostComponent>;
+
+ beforeEach(async(() => {
+ TestBed.configureTestingModule({
+ declarations: [ BoolDisplayComponent, TestHostComponent ],
+ })
+ .compileComponents();
+ }));
+
+ beforeEach(() => {
+ fixture = TestBed.createComponent(TestHostComponent);
+ hostComponent = fixture.componentInstance;
+ fixture.detectChanges();
+ });
+
+ it('recognizes Javascript true', async() => {
+ hostComponent.boolDisplayComponent.value = true;
+ fixture.detectChanges();
+ expect(fixture.nativeElement.querySelector('span').innerText).toEqual('Yes');
+ });
+ it('recognizes Javascript false', async() => {
+ hostComponent.boolDisplayComponent.value = false;
+ fixture.detectChanges();
+ expect(fixture.nativeElement.querySelector('span').innerText).toEqual('No');
+ });
+ it('recognizes string "t"', async() => {
+ hostComponent.boolDisplayComponent.value = 't';
+ fixture.detectChanges();
+ expect(fixture.nativeElement.querySelector('span').innerText).toEqual('Yes');
+ });
+ it('recognizes string "f"', async() => {
+ hostComponent.boolDisplayComponent.value = 'f';
+ fixture.detectChanges();
+ expect(fixture.nativeElement.querySelector('span').innerText).toEqual('No');
+ });
+ it('recognizes ternary nul', async() => {
+ hostComponent.boolDisplayComponent.value = null;
+ hostComponent.boolDisplayComponent.ternary = true;
+ fixture.detectChanges();
+ expect(fixture.nativeElement.querySelector('span').innerText).toEqual('Unset');
+ });
+
+});
diff --git a/Open-ILS/src/eg2/src/app/share/util/bool.component.ts b/Open-ILS/src/eg2/src/app/share/util/bool.component.ts
index 2c7ec971f0..a7363b330d 100644
--- a/Open-ILS/src/eg2/src/app/share/util/bool.component.ts
+++ b/Open-ILS/src/eg2/src/app/share/util/bool.component.ts
@@ -16,10 +16,20 @@ import {Component, Input} from '@angular/core';
export class BoolDisplayComponent {
_value: boolean;
- @Input() set value(v: boolean) {
- this._value = v;
+ @Input() set value(v: any) {
+ if (typeof v === 'string') {
+ if (v === 't') {
+ this._value = true;
+ } else if (v === 'f') {
+ this._value = false;
+ } else {
+ this._value = null;
+ }
+ } else {
+ this._value = v;
+ }
}
- get value(): boolean {
+ get value(): any {
return this._value;
}
-----------------------------------------------------------------------
Summary of changes:
.../eg2/src/app/share/util/bool.component.spec.ts | 59 ++++++++++++++++++++++
.../src/eg2/src/app/share/util/bool.component.ts | 16 ++++--
2 files changed, 72 insertions(+), 3 deletions(-)
create mode 100644 Open-ILS/src/eg2/src/app/share/util/bool.component.spec.ts
hooks/post-receive
--
Evergreen ILS
More information about the open-ils-commits
mailing list