From bb8b2321b16cded0ed6abc2143503776854b64c9 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Wed, 31 Jul 2019 14:21:18 -0400 Subject: [PATCH] LP1831788 Add EgCoreModule for CommonWidgetsModule, etc. Collect core objects into their own module so they may be imported without requiring task-specific modules to import EgCommonModule, which provides a lot more than most sub-modules need. In the case of CommonWidgetsModule, it required access to the FormatPipe, which is a core object, originally exported from EgCommonModule. However, EgCommonModule was overkill for CommonWidgetsModule and importing it would likely have created other dependency problems. Signed-off-by: Bill Erickson Signed-off-by: Galen Charlton Signed-off-by: Jane Sandberg --- Open-ILS/src/eg2/src/app/common.module.ts | 17 +++++------ Open-ILS/src/eg2/src/app/core/core.module.ts | 29 +++++++++++++++++++ .../src/app/share/common-widgets.module.ts | 5 +++- 3 files changed, 40 insertions(+), 11 deletions(-) create mode 100644 Open-ILS/src/eg2/src/app/core/core.module.ts diff --git a/Open-ILS/src/eg2/src/app/common.module.ts b/Open-ILS/src/eg2/src/app/common.module.ts index a4e402680d..76394c3924 100644 --- a/Open-ILS/src/eg2/src/app/common.module.ts +++ b/Open-ILS/src/eg2/src/app/common.module.ts @@ -1,11 +1,12 @@ /** * Modules, services, and components used by all apps. */ -import {CommonModule, DatePipe, CurrencyPipe} from '@angular/common'; +import {CommonModule} from '@angular/common'; import {NgModule, ModuleWithProviders} from '@angular/core'; import {RouterModule} from '@angular/router'; import {FormsModule} from '@angular/forms'; import {NgbModule} from '@ng-bootstrap/ng-bootstrap'; +import {EgCoreModule} from '@eg/core/core.module'; /* Note core services are injected into 'root'. @@ -13,7 +14,6 @@ They do not have to be added to the providers list. */ // consider moving these to core... -import {FormatService, FormatValuePipe} from '@eg/core/format.service'; import {HatchService} from '@eg/share/print/hatch.service'; import {PrintService} from '@eg/share/print/print.service'; @@ -36,20 +36,21 @@ import {BoolDisplayComponent} from '@eg/share/util/bool.component'; PromptDialogComponent, ProgressInlineComponent, ProgressDialogComponent, - BoolDisplayComponent, - FormatValuePipe + BoolDisplayComponent ], imports: [ CommonModule, FormsModule, RouterModule, - NgbModule + NgbModule, + EgCoreModule ], exports: [ CommonModule, RouterModule, NgbModule, FormsModule, + EgCoreModule, PrintComponent, DialogComponent, AlertDialogComponent, @@ -58,7 +59,6 @@ import {BoolDisplayComponent} from '@eg/share/util/bool.component'; ProgressInlineComponent, ProgressDialogComponent, BoolDisplayComponent, - FormatValuePipe ] }) @@ -69,11 +69,8 @@ export class EgCommonModule { return { ngModule: EgCommonModule, providers: [ - DatePipe, - CurrencyPipe, HatchService, - PrintService, - FormatService + PrintService ] }; } diff --git a/Open-ILS/src/eg2/src/app/core/core.module.ts b/Open-ILS/src/eg2/src/app/core/core.module.ts new file mode 100644 index 0000000000..82052f591d --- /dev/null +++ b/Open-ILS/src/eg2/src/app/core/core.module.ts @@ -0,0 +1,29 @@ +/** + * Core objects. + * Note that core services are generally defined with + * @Injectable({providedIn: 'root'}) so they are globally available + * and do not require entry in our 'providers' array. + */ +import {NgModule} from '@angular/core'; +import {CommonModule, DatePipe, CurrencyPipe} from '@angular/common'; +import {FormatService, FormatValuePipe} from './format.service'; + +@NgModule({ + declarations: [ + FormatValuePipe + ], + imports: [ + CommonModule + ], + exports: [ + CommonModule, + FormatValuePipe + ], + providers: [ + DatePipe, + CurrencyPipe + ] +}) + +export class EgCoreModule {} + diff --git a/Open-ILS/src/eg2/src/app/share/common-widgets.module.ts b/Open-ILS/src/eg2/src/app/share/common-widgets.module.ts index 0f15c98b67..71c5d3023c 100644 --- a/Open-ILS/src/eg2/src/app/share/common-widgets.module.ts +++ b/Open-ILS/src/eg2/src/app/share/common-widgets.module.ts @@ -7,6 +7,7 @@ import {NgModule, ModuleWithProviders} from '@angular/core'; import {CommonModule} from '@angular/common'; import {FormsModule} from '@angular/forms'; import {NgbModule} from '@ng-bootstrap/ng-bootstrap'; +import {EgCoreModule} from '@eg/core/core.module'; import {ComboboxComponent} from '@eg/share/combobox/combobox.component'; import {ComboboxEntryComponent} from '@eg/share/combobox/combobox-entry.component'; import {DateSelectComponent} from '@eg/share/date-select/date-select.component'; @@ -22,12 +23,14 @@ import {OrgSelectComponent} from '@eg/share/org-select/org-select.component'; imports: [ CommonModule, FormsModule, - NgbModule + NgbModule, + EgCoreModule ], exports: [ CommonModule, FormsModule, NgbModule, + EgCoreModule, ComboboxComponent, ComboboxEntryComponent, DateSelectComponent, -- 2.43.2