make npm run export-strings happier
authorGalen Charlton <gmc@equinoxinitiative.org>
Thu, 17 Sep 2020 16:16:01 +0000 (12:16 -0400)
committerGalen Charlton <gmc@equinoxinitiative.org>
Thu, 17 Sep 2020 16:16:01 +0000 (12:16 -0400)
The UrlMatcher function used by the provider interface needs
to spelled slighly differently to avoid the AOT compiler
used by "npm run export-strings" from failing with the following error:

ERROR in Error during template compile of 'AcqProviderRoutingModule'
  Function expressions are not supported in decorators in 'ɵ0'
    'ɵ0' contains the error at app/staff/acq/provider/routing.module.ts(7,14)
      Consider changing the function expression into an exported function

Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
Open-ILS/src/eg2/src/app/staff/acq/provider/routing.module.ts

index 32f6785..3344d33 100644 (file)
@@ -1,37 +1,39 @@
 import {NgModule} from '@angular/core';
-import {RouterModule, Routes, UrlMatchResult} from '@angular/router';
+import {RouterModule, Routes, UrlSegment, UrlMatchResult} from '@angular/router';
 import {AcqProviderComponent} from './acq-provider.component';
 import {ProviderResolver, CanLeaveAcqProviderGuard} from './resolver.service';
 
+export function providerRouteMatcher(segments: UrlSegment[]) {
+    // using a custom matcher so that we
+    // don't force a component re-initialization
+    // when navigating from the search form to a
+    // provider record
+    if (segments.length === 0) {
+        return {
+            consumed: segments,
+            posParams: {}
+        };
+    } else if (segments.length === 1) {
+        return {
+            consumed: segments,
+            posParams: {
+                id: segments[0],
+            }
+        };
+    } else if (segments.length > 1) {
+        return {
+            consumed: segments,
+            posParams: {
+                id: segments[0],
+                tab: segments[1],
+            }
+        };
+    }
+    return <UrlMatchResult>(null as any);
+}
+
 const routes: Routes = [
-  { matcher: (segments) => {
-        // using a custom matcher so that we
-        // don't force a component re-initialization
-        // when navigating from the search form to a
-        // provider record
-        if (segments.length === 0) {
-            return {
-                consumed: segments,
-                posParams: {}
-            };
-        } else if (segments.length === 1) {
-            return {
-                consumed: segments,
-                posParams: {
-                    id: segments[0],
-                }
-            };
-        } else if (segments.length > 1) {
-            return {
-                consumed: segments,
-                posParams: {
-                    id: segments[0],
-                    tab: segments[1],
-                }
-            };
-        }
-        return <UrlMatchResult>(null as any);
-    },
+  { matcher: providerRouteMatcher,
     component: AcqProviderComponent,
     resolve: { providerResolver : ProviderResolver },
     canDeactivate: [CanLeaveAcqProviderGuard],