LP1831788 Add EgCoreModule for CommonWidgetsModule, etc.
authorBill Erickson <berickxx@gmail.com>
Wed, 31 Jul 2019 18:21:18 +0000 (14:21 -0400)
committerGalen Charlton <gmc@equinoxinitiative.org>
Thu, 1 Aug 2019 13:49:57 +0000 (09:49 -0400)
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 <berickxx@gmail.com>
Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
Signed-off-by: Jane Sandberg <sandbej@linnbenton.edu>
Open-ILS/src/eg2/src/app/common.module.ts
Open-ILS/src/eg2/src/app/core/core.module.ts [new file with mode: 0644]
Open-ILS/src/eg2/src/app/share/common-widgets.module.ts

index a4e4026..76394c3 100644 (file)
@@ -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 (file)
index 0000000..82052f5
--- /dev/null
@@ -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 {}
+
index 0f15c98..71c5d30 100644 (file)
@@ -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,