@smallpearl/ngx-helper 0.33.17 → 0.33.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/entities/src/paged-loader.d.ts +1 -0
- package/fesm2022/smallpearl-ngx-helper-entities.mjs +22 -10
- package/fesm2022/smallpearl-ngx-helper-entities.mjs.map +1 -1
- package/fesm2022/smallpearl-ngx-helper-mat-entity-list.mjs +22 -14
- package/fesm2022/smallpearl-ngx-helper-mat-entity-list.mjs.map +1 -1
- package/fesm2022/smallpearl-ngx-helper-sideload.mjs +12 -7
- package/fesm2022/smallpearl-ngx-helper-sideload.mjs.map +1 -1
- package/package.json +9 -9
- package/sideload/src/sideload.d.ts +3 -2
|
@@ -206,6 +206,7 @@ export declare abstract class SPPagedEntityLoader<TEntity extends {
|
|
|
206
206
|
setEntities(entities: TEntity[]): void;
|
|
207
207
|
getEntities(): TEntity[];
|
|
208
208
|
getEntity(id: TEntity[IdKey]): TEntity | undefined;
|
|
209
|
+
protected addAddlContextTokens(context: HttpContext): void;
|
|
209
210
|
protected doActualLoad(lr: LoadRequest): Observable<any>;
|
|
210
211
|
private existsInCache;
|
|
211
212
|
private getCacheKey;
|
|
@@ -212,20 +212,27 @@ class SPPagedEntityLoader {
|
|
|
212
212
|
_capitalizedEntityName = computed(() => capitalize(this.entityName()));
|
|
213
213
|
_httpReqContext = computed(() => {
|
|
214
214
|
let reqContext = this.httpReqContext();
|
|
215
|
-
if (reqContext instanceof HttpContext) {
|
|
216
|
-
return reqContext;
|
|
217
|
-
}
|
|
218
|
-
// Likely to be array of `(HttpContextToken, value)` pairs.
|
|
219
215
|
const context = new HttpContext();
|
|
220
|
-
if (reqContext
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
context.set(
|
|
216
|
+
if (reqContext instanceof HttpContext) {
|
|
217
|
+
// Copy existing context values
|
|
218
|
+
for (const key of reqContext.keys()) {
|
|
219
|
+
context.set(key, reqContext.get(key));
|
|
224
220
|
}
|
|
225
|
-
|
|
226
|
-
|
|
221
|
+
}
|
|
222
|
+
else {
|
|
223
|
+
// Likely to be array of `(HttpContextToken, value)` pairs.
|
|
224
|
+
if (reqContext && Array.isArray(reqContext)) {
|
|
225
|
+
if (reqContext.length == 2 && !Array.isArray(reqContext[0])) {
|
|
226
|
+
// one dimensional array of a key, value pair.
|
|
227
|
+
context.set(reqContext[0], reqContext[1]);
|
|
228
|
+
}
|
|
229
|
+
else {
|
|
230
|
+
reqContext.forEach(([k, v]) => context.set(k, v));
|
|
231
|
+
}
|
|
227
232
|
}
|
|
228
233
|
}
|
|
234
|
+
// Give subclasses a chance to add their own context tokens.
|
|
235
|
+
this.addAddlContextTokens(context);
|
|
229
236
|
return context;
|
|
230
237
|
});
|
|
231
238
|
entityListConfig = inject(SP_MAT_ENTITY_LIST_CONFIG, {
|
|
@@ -405,6 +412,11 @@ class SPPagedEntityLoader {
|
|
|
405
412
|
getEntity(id) {
|
|
406
413
|
return this.store.query(getEntity(id));
|
|
407
414
|
}
|
|
415
|
+
addAddlContextTokens(context) {
|
|
416
|
+
// Add any additional context tokens required for this request.
|
|
417
|
+
// Note that context is a mutable object. Subclasses can override
|
|
418
|
+
// this method to add their own context tokens.
|
|
419
|
+
}
|
|
408
420
|
// Does the actual loading of entities from the remote or the loader
|
|
409
421
|
// function. Once loaded, the entities are stored in the internal store and
|
|
410
422
|
// pagination properties are updated.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"smallpearl-ngx-helper-entities.mjs","sources":["../../../../projects/smallpearl/ngx-helper/entities/src/paged-loader.ts","../../../../projects/smallpearl/ngx-helper/entities/smallpearl-ngx-helper-entities.ts"],"sourcesContent":["import {\n HttpClient,\n HttpContext,\n HttpContextToken,\n HttpParams,\n} from '@angular/common/http';\nimport { computed, Directive, inject, input } from '@angular/core';\nimport { createStore, select, setProps, withProps } from '@ngneat/elf';\nimport { getAllEntities, getEntitiesCount, getEntity, upsertEntities, withEntities } from '@ngneat/elf-entities';\nimport { getPaginationData, setPage, skipWhilePageExists, updatePaginationData, withPagination } from '@ngneat/elf-pagination';\nimport { SP_MAT_ENTITY_LIST_CONFIG, SPMatEntityListPaginator, SPPageParams } from '@smallpearl/ngx-helper/mat-entity-list';\nimport { capitalize } from 'lodash';\nimport { plural } from 'pluralize';\nimport {\n distinctUntilChanged,\n filter,\n finalize,\n Observable,\n of,\n Subject,\n Subscription,\n switchMap,\n tap\n} from 'rxjs';\n\n/**\n * A type representing an entity loader function that takes page number,\n * page size, and an optional search value and returns an Observable of\n * the response. This is similar the http.get() method of HttpClient but\n * with pagination parameters. The return value is deliberately kept generic\n * (Observable<any>) to allow flexibility in the response type. This reponse\n * will be parsed by the provided paginator's parseRequestResponse() method.\n * So as long as the function return type and paginator are compatible,\n * any response type can be handled.\n *\n * Ideally the response should contain the total number of entities available\n * at the remote and the array of entities for the requested page.\n */\nexport type SPEntityLoaderFn = (\n page: number,\n pageSize: number,\n searchValue: string | undefined\n) => Observable<any>;\n\n/**\n * Represents a request to load entities from the remote. This is used to\n * compare two requests to determine if they are equal. This is useful to\n * prevent duplicate requests being sent to the remote.\n */\nclass LoadRequest {\n constructor(\n public endpoint: string | SPEntityLoaderFn,\n public pageNumber: number,\n public searchStr: string | undefined,\n public force = false\n ) {}\n\n // Returns true if two LoadRequest objects are equal and this object's\n // 'force' is not set to true.\n isEqualToAndNotForced(prev: LoadRequest): boolean {\n // console.log(\n // `isEqualToAndNotForced - ${this.endpoint}, ${this.params.toString()} ${\n // this.force\n // }, other: ${prev.endpoint}, ${prev.params.toString()}, ${prev.force}`\n // );\n return this.force\n ? false\n : (typeof this.endpoint === 'function' ||\n this.endpoint.localeCompare(prev.endpoint as string) === 0) &&\n this.pageNumber === prev.pageNumber &&\n this.searchStr === prev.searchStr;\n }\n}\n\ntype StateProps = {\n allEntitiesLoaded: boolean;\n loading: boolean;\n loaded: boolean\n};\n\nconst DEFAULT_STATE_PROPS: StateProps = {\n allEntitiesLoaded: false,\n loading: false,\n loaded: false\n}\n\n// Default paginator implementation. This can handle dynamic-rest and DRF\n// native pagination schemes. It also has a fallback to handle response conists\n// of an array of entities.\nclass DefaultPaginator implements SPMatEntityListPaginator {\n getRequestPageParams(\n endpoint: string,\n page: number,\n pageSize: number\n ): SPPageParams {\n return {\n page: page + 1,\n pageSize,\n };\n }\n\n parseRequestResponse<\n TEntity extends { [P in IdKey]: PropertyKey },\n IdKey extends string = 'id'\n >(\n entityName: string,\n entityNamePlural: string,\n endpoint: string,\n params: SPPageParams,\n resp: any\n ) {\n if (Array.isArray(resp)) {\n return {\n total: resp.length,\n entities: resp,\n };\n }\n\n if (typeof resp === 'object') {\n const keys = Object.keys(resp);\n // Handle dynamic-rest sideloaded response\n // Rudimentary sideloaded response support. This should work for most\n // of the sideloaded responses where the main entities are stored\n // under the plural entity name key and resp['meta'] object contains\n // the total count.\n if (\n keys.includes(entityNamePlural) &&\n Array.isArray(resp[entityNamePlural])\n ) {\n let total = resp[entityNamePlural].length;\n if (\n keys.includes('meta') &&\n typeof resp['meta'] === 'object' &&\n typeof resp['meta']['total'] === 'number'\n ) {\n total = resp['meta']['total'];\n }\n return {\n total,\n entities: resp[entityNamePlural],\n };\n }\n\n // Handle django-rest-framework style response\n if (keys.includes('results') && Array.isArray(resp['results'])) {\n let total = resp['results'].length;\n if (keys.includes('count') && typeof resp['count'] === 'number') {\n total = resp['count'];\n }\n return {\n total,\n entities: resp['results'],\n };\n }\n\n // Finally, look for \"items\" key\n if (keys.includes('items') && Array.isArray(resp['items'])) {\n return {\n total: resp['items'].length,\n entities: resp['items'],\n };\n }\n }\n\n return {\n total: 0,\n entities: [],\n };\n }\n}\n\n/**\n * An abstract class that you can use wherever you would like to load entities\n * from a remote endpoint in a paged manner. Entities can be loaded in one of\n * two ways:\n *\n * 1. By providing an entityLoaderFn that takes an endpoint and HttpParams\n * and returns a Observable of entities.\n * 2. Or by providing a URL and using the default loader that uses HttpClient\n * to load entities.\n * This class uses RxJS to manage the loading of entities and provides\n * signals to track the loading state, entity count, page index, page size,\n * and whether more entities are available to load.\n *\n * How to use this class:\n *\n * 1. Dervice your component from SPPagedEntityLoader.\n * 2. After your component is initialized, call the startLoader() method to\n * get the component going. This sets up the necessary subscriptions to\n * listen for load requests. Load requests are triggered by calling the\n * loadPage() or loadNextPage() methods.\n * 3. If your component supports infinite scrolling, call loadMoreEntities()\n * method to load the next page of entities when it detects a scroll event.\n * 4. If you component needs to load a specific page (via a pagination control),\n * call the loadPage(pageNumber) method to load the specified page.\n * 5. Entities are stored in an internal entities store which is an @ngneat/elf\n * store. You can subscribe to the store's query to get the list of entities.\n * 6. When your component is destroyed, call the stopLoader() method to clean up\n * internal subscriptions.\n *\n * The class is decorated with Angular's @Directive decorator so that we can\n * use signals for the input properties and dependency injection for HttpClient.\n * There are no abstract methods as such, but the class is meant to be extended\n * by your component to provide the necessary configuration via input properties.\n * This is why it is declared as abstract.\n */\n@Directive({\n selector: '**spPagedEntityLoader**',\n})\nexport abstract class SPPagedEntityLoader<\n TEntity extends { [P in IdKey]: PropertyKey },\n IdKey extends string = 'id'\n> {\n // We cache the entities that we fetch from remote here. Cache is indexed\n // by the endpoint. Each endpoint also keeps a refCount, which is incremented\n // for each instance of the component using the same endpoint. When this\n // refcount reaches 0, the endpoint is removed from the cache.\n //\n // This mechanism is to suppress multiple fetches from the remote from the\n // same endpoint as that can occur if a form has multiple instances of\n // this component with the same url.\n static _entitiesCache = new Map<string, { refCount: number; resp: any }>();\n // cache keys for this instance\n cacheKeys = new Set<string>();\n\n // Current search parameter value. This is used to load entities\n // matching the search string.\n searchParamValue: string | undefined;\n\n //** REQUIRED ATTRIBUTES **//\n /**\n * Entity name, that is used to form the \"New { item }\" menu item if\n * inlineNew=true. This is also used as the key of the object in GET response\n * if the reponse JSON is an object (sideloaded response), where the values\n * are stored indexed by the server model name. For eg:-\n *\n * {\n * 'customers': [\n * {...},\n * {...},\n * {...},\n * ]\n * }\n */\n entityName = input.required<string>();\n url = input.required<string | SPEntityLoaderFn>();\n\n //** OPTIONAL ATTRIBUTES **//\n // Number of entities to be loaded per page from the server. This will be\n // passed to PagedEntityLoader to load entities in pages. Defaults to 50.\n // Adjust this accordingly based on the average size of your entities to\n // optimize server round-trips and memory usage.\n pageSize = input<number>(50);\n\n // Paginator for the remote entity list. This is used to determine the\n // pagination parameters for the API request. If not specified, the global\n // paginator specified in SPMatEntityListConfig will be used. If that too is\n // not specified, a default paginator will be used. Default paginator can\n // handle DRF native PageNumberPagination and dynamic-rest style pagination.\n paginator = input<SPMatEntityListPaginator>();\n\n // Search parameter name to be used in the HTTP request.\n // Defaults to 'search'. That is when a search string is specified and\n // the entire entity list has not been fetched, a fresh HTTP request is made\n // to the remote server with `?<searchParamName>=<search string>` parameter.\n searchParamName = input<string>('search');\n\n // Entity idKey, if idKey is different from the default 'id'.\n idKey = input<string>('id');\n\n // Plural entity name, used when grouping options. If not specified, it is\n // derived by pluralizing the entityName.\n pluralEntityName = input<string | undefined>(undefined); // defaults to pluralized entityName\n\n httpReqContext = input<\n [[HttpContextToken<any>, any]] | [HttpContextToken<any>, any] | HttpContext | undefined\n >(undefined); // defaults to empty context\n\n // Parameters to be added to the HTTP request to retrieve data from\n // remote. This won't be used if `loadFromRemoteFn` is specified.\n httpParams = input<HttpParams | undefined>(undefined); // defaults to empty params\n\n // Mechanism to default pageSize to last entities length.\n protected loadRequest$ = new Subject<LoadRequest>();\n protected sub$: Subscription | undefined;\n protected _pageSize = computed<number>(() =>\n this.pageSize() ? this.pageSize() : 50\n );\n\n protected _pluralEntityName = computed<string>(() => {\n const pluralEntityName = this.pluralEntityName();\n return pluralEntityName ? pluralEntityName : plural(this.entityName());\n });\n\n protected _capitalizedEntityName = computed<string>(() =>\n capitalize(this.entityName())\n );\n\n protected _httpReqContext = computed(() => {\n let reqContext = this.httpReqContext();\n if (reqContext instanceof HttpContext) {\n return reqContext;\n }\n\n // Likely to be array of `(HttpContextToken, value)` pairs.\n const context = new HttpContext();\n if (reqContext && Array.isArray(reqContext)) {\n if (reqContext.length == 2 && !Array.isArray(reqContext[0])) {\n // one dimensional array of a key, value pair.\n context.set(reqContext[0], reqContext[1]);\n } else {\n reqContext.forEach(([k, v]) => context.set(k, v));\n }\n }\n return context;\n });\n\n entityListConfig = inject(SP_MAT_ENTITY_LIST_CONFIG, {\n optional: true,\n });\n protected _paginator = computed<SPMatEntityListPaginator>(() => {\n const paginator = this.paginator();\n const entityListConfigPaginator = this.entityListConfig\n ? (this.entityListConfig.paginator as SPMatEntityListPaginator)\n : undefined;\n return paginator\n ? paginator\n : entityListConfigPaginator\n ? entityListConfigPaginator\n : new DefaultPaginator();\n });\n\n // We create it here so that store member variable will have the correct\n // type. Unfortunately elf doesn't have a simple generic type that we can\n // use to declare the type of the store and then initialize it later.\n // We will recreate it in the constructor to have the correct idKey.\n protected store = createStore(\n { name: Math.random().toString(36).slice(2) },\n withEntities<TEntity, IdKey>({ idKey: 'id' as IdKey }),\n withProps<StateProps>(DEFAULT_STATE_PROPS),\n withPagination({\n initialPage: 0,\n })\n );\n\n protected http = inject(HttpClient);\n\n constructor() {}\n\n /**\n * Starts listening for load requests and processes them. Call this from your\n * component's ngOnInit() or ngAfterViewInit() method.\n */\n startLoader() {\n // Recreate store with the correct idKey. We have to do this after\n // the idKey is available from the constructor argument.\n const entities = this.store.query(getAllEntities());\n this.store = createStore(\n { name: Math.random().toString(36).slice(2) },\n withEntities<TEntity, IdKey>({\n initialValue: entities,\n idKey: this.idKey() as IdKey,\n }),\n withProps<StateProps>(DEFAULT_STATE_PROPS),\n withPagination({\n initialPage: 0,\n })\n );\n\n this.sub$ = this.loadRequest$\n .pipe(\n filter((lr) => lr.endpoint !== '' || lr.force === true),\n distinctUntilChanged((prev, current) =>\n current.isEqualToAndNotForced(prev)\n ),\n switchMap((lr: LoadRequest) => this.doActualLoad(lr))\n )\n .subscribe();\n }\n\n /**\n * Stops listening for load requests and cleans up subscriptions.\n */\n stopLoader() {\n if (this.sub$) {\n this.sub$.unsubscribe();\n this.sub$ = undefined;\n }\n // Remove references to this component's pages from the cache. If this\n // is the only component using those cached pages, they will be cleared\n // from the cache.\n this.removeFromCache();\n }\n\n hasStarted(): boolean {\n return this.sub$ !== undefined;\n }\n\n /**\n * Returns a boolean indicating whether all entities at the remote have been\n * loaded. All entities are considered loaded when there are no more entities\n * to load from the remote (that is all pages have been loaded without\n * a search filter).\n * @returns\n */\n allEntitiesLoaded(): boolean {\n return this.store.query((state) => state.allEntitiesLoaded);\n }\n\n /**\n * Returns the total number of entities at the remote as reported by the\n * server (or load fn) during each load.\n * @returns\n */\n totalEntitiesAtRemote(): number {\n return this.store.query(getPaginationData()).total;\n }\n\n /**\n * Returns number of entities currently stored in the internal store.\n * @returns\n */\n totalEntitiesCount(): number {\n return this.store.query(getEntitiesCount());\n }\n\n /**\n * Returns true if there are more entities to load from the remote.\n * This is computed based on the total entities count and the number of\n * entities loaded so far. For this method to work correctly, an initial\n * load must have been performed to get the total count from the remote.\n * @returns\n */\n hasMore(): boolean {\n const paginationData = this.store.query(getPaginationData());\n return (\n Object.keys(paginationData.pages).length * paginationData.perPage <\n paginationData.total\n );\n // return this.store.query((state) => state.hasMore);\n }\n\n /**\n * Returns true if a load operation is in progress. The load async operation\n * method turns the loading state to true when a load operation starts and\n * turns it to false when the operation completes.\n * @returns\n */\n loading(): boolean {\n return this.store.query((state) => state.loading);\n }\n\n /**\n * Returns the loading state as an Observable that emits when the state changes.\n * @returns\n */\n get loading$() {\n return this.store.pipe(\n select((state) => state.loading),\n distinctUntilChanged()\n );\n }\n\n /**\n * Boolean indicates whether the loader has completed at least one load\n * operation.\n */\n loaded(): boolean {\n return this.store.query((state) => state.loaded);\n }\n\n /**\n * Returns the endpoint URL if the loader was created with an endpoint.\n * If the loader was created with a loader function, an empty string is\n * returned.\n * @returns\n */\n endpoint(): string {\n return this.url() instanceof Function ? '' : (this.url() as string);\n }\n\n /**\n * Loads the specified page number of entities from the remote.\n * @param pageNumber\n */\n loadPage(pageNumber: number) {\n this.loadRequest$.next(\n new LoadRequest(this.url(), pageNumber, this.searchParamValue, false)\n );\n }\n\n /**\n * Returns the total number of pages available at the remote.\n * @returns\n */\n totalPages(): number {\n const paginationData = this.store.query(getPaginationData());\n return Math.ceil(paginationData.total / paginationData.perPage);\n }\n\n /**\n * Loads the next page of entities from the remote.\n *\n * @param searchParamValue Optional search parameter value. If specified\n * and is different from the current search parameter value, the internal\n * store is reset and entities are loaded from page 0 with the new search\n * parameter value. Otherwise, the next page of entities is loaded.\n */\n loadNextPage() {\n if (\n this.store.query(getPaginationData()).currentPage >= this.totalPages() &&\n this.loaded()\n ) {\n return;\n }\n\n const paginationData = this.store.query(getPaginationData());\n // console.log(`Loading page - forceRefresh: ${forceRefresh}, currentPage: ${paginationData.currentPage}...`);\n this.loadRequest$.next(\n new LoadRequest(\n this.url(),\n paginationData.currentPage,\n this.searchParamValue,\n false\n )\n );\n }\n\n // Sets the search parameter value to be used in subsequent loads.\n // If the search parameter value is different from the current value,\n // the internal store is reset to clear any previously loaded entities.\n setSearchParamValue(searchStr: string) {\n if (searchStr !== this.searchParamValue) {\n this.searchParamValue = searchStr;\n this.store.reset();\n }\n }\n\n setEntities(entities: TEntity[]) {\n this.store.update(upsertEntities(entities as any));\n }\n\n getEntities(): TEntity[] {\n return this.store.query(getAllEntities());\n }\n\n getEntity(id: TEntity[IdKey]): TEntity | undefined {\n return this.store.query(getEntity(id));\n }\n\n // Does the actual loading of entities from the remote or the loader\n // function. Once loaded, the entities are stored in the internal store and\n // pagination properties are updated.\n protected doActualLoad(lr: LoadRequest) {\n const loaderFn =\n typeof this.url() === 'function'\n ? (this.url() as SPEntityLoaderFn)\n : undefined;\n let obs: Observable<any>;\n let paramsObj: any = {};\n const pageSize = this._pageSize();\n if (loaderFn) {\n obs = (loaderFn as SPEntityLoaderFn)(\n lr.pageNumber,\n pageSize,\n lr.searchStr\n );\n paramsObj = {\n page: lr.pageNumber,\n pageSize,\n };\n if (lr.searchStr) {\n paramsObj[this.searchParamName()] = lr.searchStr || '';\n }\n } else {\n // Form the HttpParams which consists of pagination params and any\n // embedded params in the URL which doesn't conflict with the page\n // params.\n const urlParts = (this.url() as string).split('?');\n const pageParams = this._paginator().getRequestPageParams(\n urlParts[0],\n lr.pageNumber,\n pageSize\n );\n if (lr.searchStr) {\n pageParams[this.searchParamName()] = lr.searchStr || '';\n }\n let httpParams = new HttpParams({ fromObject: pageParams });\n if (this.httpParams()) {\n this.httpParams()!\n .keys()\n .forEach((key) => {\n const value = this.httpParams()!.getAll(key);\n (value || []).forEach((v) => {\n httpParams = httpParams.append(key, v);\n });\n });\n }\n if (urlParts.length > 1) {\n const embeddedParams = new HttpParams({ fromString: urlParts[1] });\n embeddedParams.keys().forEach((key) => {\n const value = embeddedParams.getAll(key);\n (value || []).forEach((v) => {\n if (!httpParams.has(key)) {\n httpParams = httpParams.append(key, v);\n }\n });\n });\n }\n const cacheKey = this.getCacheKey(urlParts[0], httpParams);\n if (this.existsInCache(cacheKey)) {\n obs = of(this.getFromCache(cacheKey));\n } else {\n obs = this.http\n .get<any>(urlParts[0], {\n context: this._httpReqContext(),\n params: httpParams,\n })\n .pipe(tap((resp) => this.addToCache(cacheKey, resp)));\n }\n\n // Convert HttpParams to JS object\n httpParams.keys().forEach((key) => {\n paramsObj[key] = httpParams.get(key);\n });\n }\n\n this.store.update(\n setProps((state) => ({\n ...state,\n loading: true,\n }))\n );\n return obs.pipe(\n // skipWhilePageExistsInCacheOrCache(cacheKey, resp),\n skipWhilePageExists(this.store, lr.pageNumber),\n tap((resp) => {\n let hasMore = false;\n\n let entities: TEntity[] = [];\n let total = 0;\n\n if (Array.isArray(resp)) {\n // If the response is an array, we assume it's the array of entities.\n // Obviously, in this case, there's no pagination and therefore\n // set the total number of entities to the length of the array.\n total = resp.length;\n entities = resp;\n } else {\n const result = this._paginator().parseRequestResponse(\n this.entityName(),\n this._pluralEntityName()!,\n this.endpoint(),\n paramsObj,\n resp\n );\n total = result.total;\n entities = result.entities as unknown as TEntity[];\n }\n\n this.store.update(\n upsertEntities(entities as any),\n setProps((state) => ({\n ...state,\n totalCount: total,\n })),\n updatePaginationData({\n total: total,\n perPage: this.pageSize(),\n lastPage: lr.pageNumber,\n currentPage: lr.pageNumber + 1,\n }),\n setPage(\n lr.pageNumber,\n entities.map((e) => (e as any)[this.idKey()])\n )\n );\n }),\n finalize(() => {\n this.store.update(\n setProps((state) => ({\n ...state,\n allEntitiesLoaded: !this.hasMore() && !this.searchParamValue,\n loading: false,\n loaded: true,\n }))\n );\n })\n );\n }\n\n private existsInCache(cacheKey: string): boolean {\n return SPPagedEntityLoader._entitiesCache.has(cacheKey);\n }\n\n private getCacheKey(url: string, params?: HttpParams): string {\n if (params) {\n return `${url}?${params.toString()}`;\n }\n return url;\n }\n\n private getFromCache(cacheKey: string): any {\n if (cacheKey && SPPagedEntityLoader._entitiesCache.has(cacheKey)) {\n return SPPagedEntityLoader._entitiesCache.get(cacheKey)?.resp;\n }\n return [];\n }\n\n addToCache(cacheKey: string, resp: any) {\n if (!SPPagedEntityLoader._entitiesCache.has(cacheKey)) {\n SPPagedEntityLoader._entitiesCache.set(cacheKey, {\n refCount: 0,\n resp,\n });\n }\n const cacheEntry = SPPagedEntityLoader._entitiesCache.get(cacheKey);\n cacheEntry!.refCount += 1;\n this.cacheKeys.add(cacheKey);\n }\n\n private removeFromCache() {\n for (const cacheKey of this.cacheKeys) {\n const cacheEntry = SPPagedEntityLoader._entitiesCache.get(cacheKey);\n if (cacheEntry) {\n cacheEntry!.refCount -= 1;\n if (cacheEntry.refCount <= 0) {\n SPPagedEntityLoader._entitiesCache.delete(cacheKey);\n }\n }\n }\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;;;AA4CA;;;;AAIG;AACH,MAAM,WAAW,CAAA;AAEN,IAAA,QAAA;AACA,IAAA,UAAA;AACA,IAAA,SAAA;AACA,IAAA,KAAA;AAJT,IAAA,WAAA,CACS,QAAmC,EACnC,UA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QAAQ,EAAE,yBAAyB;AACpC,iBAAA;;;AChND;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"smallpearl-ngx-helper-entities.mjs","sources":["../../../../projects/smallpearl/ngx-helper/entities/src/paged-loader.ts","../../../../projects/smallpearl/ngx-helper/entities/smallpearl-ngx-helper-entities.ts"],"sourcesContent":["import {\n HttpClient,\n HttpContext,\n HttpContextToken,\n HttpParams,\n} from '@angular/common/http';\nimport { computed, Directive, inject, input } from '@angular/core';\nimport { createStore, select, setProps, withProps } from '@ngneat/elf';\nimport { getAllEntities, getEntitiesCount, getEntity, upsertEntities, withEntities } from '@ngneat/elf-entities';\nimport { getPaginationData, setPage, skipWhilePageExists, updatePaginationData, withPagination } from '@ngneat/elf-pagination';\nimport { SP_MAT_ENTITY_LIST_CONFIG, SPMatEntityListPaginator, SPPageParams } from '@smallpearl/ngx-helper/mat-entity-list';\nimport { capitalize } from 'lodash';\nimport { plural } from 'pluralize';\nimport {\n distinctUntilChanged,\n filter,\n finalize,\n Observable,\n of,\n Subject,\n Subscription,\n switchMap,\n tap\n} from 'rxjs';\n\n/**\n * A type representing an entity loader function that takes page number,\n * page size, and an optional search value and returns an Observable of\n * the response. This is similar the http.get() method of HttpClient but\n * with pagination parameters. The return value is deliberately kept generic\n * (Observable<any>) to allow flexibility in the response type. This reponse\n * will be parsed by the provided paginator's parseRequestResponse() method.\n * So as long as the function return type and paginator are compatible,\n * any response type can be handled.\n *\n * Ideally the response should contain the total number of entities available\n * at the remote and the array of entities for the requested page.\n */\nexport type SPEntityLoaderFn = (\n page: number,\n pageSize: number,\n searchValue: string | undefined\n) => Observable<any>;\n\n/**\n * Represents a request to load entities from the remote. This is used to\n * compare two requests to determine if they are equal. This is useful to\n * prevent duplicate requests being sent to the remote.\n */\nclass LoadRequest {\n constructor(\n public endpoint: string | SPEntityLoaderFn,\n public pageNumber: number,\n public searchStr: string | undefined,\n public force = false\n ) {}\n\n // Returns true if two LoadRequest objects are equal and this object's\n // 'force' is not set to true.\n isEqualToAndNotForced(prev: LoadRequest): boolean {\n // console.log(\n // `isEqualToAndNotForced - ${this.endpoint}, ${this.params.toString()} ${\n // this.force\n // }, other: ${prev.endpoint}, ${prev.params.toString()}, ${prev.force}`\n // );\n return this.force\n ? false\n : (typeof this.endpoint === 'function' ||\n this.endpoint.localeCompare(prev.endpoint as string) === 0) &&\n this.pageNumber === prev.pageNumber &&\n this.searchStr === prev.searchStr;\n }\n}\n\ntype StateProps = {\n allEntitiesLoaded: boolean;\n loading: boolean;\n loaded: boolean\n};\n\nconst DEFAULT_STATE_PROPS: StateProps = {\n allEntitiesLoaded: false,\n loading: false,\n loaded: false\n}\n\n// Default paginator implementation. This can handle dynamic-rest and DRF\n// native pagination schemes. It also has a fallback to handle response conists\n// of an array of entities.\nclass DefaultPaginator implements SPMatEntityListPaginator {\n getRequestPageParams(\n endpoint: string,\n page: number,\n pageSize: number\n ): SPPageParams {\n return {\n page: page + 1,\n pageSize,\n };\n }\n\n parseRequestResponse<\n TEntity extends { [P in IdKey]: PropertyKey },\n IdKey extends string = 'id'\n >(\n entityName: string,\n entityNamePlural: string,\n endpoint: string,\n params: SPPageParams,\n resp: any\n ) {\n if (Array.isArray(resp)) {\n return {\n total: resp.length,\n entities: resp,\n };\n }\n\n if (typeof resp === 'object') {\n const keys = Object.keys(resp);\n // Handle dynamic-rest sideloaded response\n // Rudimentary sideloaded response support. This should work for most\n // of the sideloaded responses where the main entities are stored\n // under the plural entity name key and resp['meta'] object contains\n // the total count.\n if (\n keys.includes(entityNamePlural) &&\n Array.isArray(resp[entityNamePlural])\n ) {\n let total = resp[entityNamePlural].length;\n if (\n keys.includes('meta') &&\n typeof resp['meta'] === 'object' &&\n typeof resp['meta']['total'] === 'number'\n ) {\n total = resp['meta']['total'];\n }\n return {\n total,\n entities: resp[entityNamePlural],\n };\n }\n\n // Handle django-rest-framework style response\n if (keys.includes('results') && Array.isArray(resp['results'])) {\n let total = resp['results'].length;\n if (keys.includes('count') && typeof resp['count'] === 'number') {\n total = resp['count'];\n }\n return {\n total,\n entities: resp['results'],\n };\n }\n\n // Finally, look for \"items\" key\n if (keys.includes('items') && Array.isArray(resp['items'])) {\n return {\n total: resp['items'].length,\n entities: resp['items'],\n };\n }\n }\n\n return {\n total: 0,\n entities: [],\n };\n }\n}\n\n/**\n * An abstract class that you can use wherever you would like to load entities\n * from a remote endpoint in a paged manner. Entities can be loaded in one of\n * two ways:\n *\n * 1. By providing an entityLoaderFn that takes an endpoint and HttpParams\n * and returns a Observable of entities.\n * 2. Or by providing a URL and using the default loader that uses HttpClient\n * to load entities.\n * This class uses RxJS to manage the loading of entities and provides\n * signals to track the loading state, entity count, page index, page size,\n * and whether more entities are available to load.\n *\n * How to use this class:\n *\n * 1. Dervice your component from SPPagedEntityLoader.\n * 2. After your component is initialized, call the startLoader() method to\n * get the component going. This sets up the necessary subscriptions to\n * listen for load requests. Load requests are triggered by calling the\n * loadPage() or loadNextPage() methods.\n * 3. If your component supports infinite scrolling, call loadMoreEntities()\n * method to load the next page of entities when it detects a scroll event.\n * 4. If you component needs to load a specific page (via a pagination control),\n * call the loadPage(pageNumber) method to load the specified page.\n * 5. Entities are stored in an internal entities store which is an @ngneat/elf\n * store. You can subscribe to the store's query to get the list of entities.\n * 6. When your component is destroyed, call the stopLoader() method to clean up\n * internal subscriptions.\n *\n * The class is decorated with Angular's @Directive decorator so that we can\n * use signals for the input properties and dependency injection for HttpClient.\n * There are no abstract methods as such, but the class is meant to be extended\n * by your component to provide the necessary configuration via input properties.\n * This is why it is declared as abstract.\n */\n@Directive({\n selector: '**spPagedEntityLoader**',\n})\nexport abstract class SPPagedEntityLoader<\n TEntity extends { [P in IdKey]: PropertyKey },\n IdKey extends string = 'id'\n> {\n // We cache the entities that we fetch from remote here. Cache is indexed\n // by the endpoint. Each endpoint also keeps a refCount, which is incremented\n // for each instance of the component using the same endpoint. When this\n // refcount reaches 0, the endpoint is removed from the cache.\n //\n // This mechanism is to suppress multiple fetches from the remote from the\n // same endpoint as that can occur if a form has multiple instances of\n // this component with the same url.\n static _entitiesCache = new Map<string, { refCount: number; resp: any }>();\n // cache keys for this instance\n cacheKeys = new Set<string>();\n\n // Current search parameter value. This is used to load entities\n // matching the search string.\n searchParamValue: string | undefined;\n\n //** REQUIRED ATTRIBUTES **//\n /**\n * Entity name, that is used to form the \"New { item }\" menu item if\n * inlineNew=true. This is also used as the key of the object in GET response\n * if the reponse JSON is an object (sideloaded response), where the values\n * are stored indexed by the server model name. For eg:-\n *\n * {\n * 'customers': [\n * {...},\n * {...},\n * {...},\n * ]\n * }\n */\n entityName = input.required<string>();\n url = input.required<string | SPEntityLoaderFn>();\n\n //** OPTIONAL ATTRIBUTES **//\n // Number of entities to be loaded per page from the server. This will be\n // passed to PagedEntityLoader to load entities in pages. Defaults to 50.\n // Adjust this accordingly based on the average size of your entities to\n // optimize server round-trips and memory usage.\n pageSize = input<number>(50);\n\n // Paginator for the remote entity list. This is used to determine the\n // pagination parameters for the API request. If not specified, the global\n // paginator specified in SPMatEntityListConfig will be used. If that too is\n // not specified, a default paginator will be used. Default paginator can\n // handle DRF native PageNumberPagination and dynamic-rest style pagination.\n paginator = input<SPMatEntityListPaginator>();\n\n // Search parameter name to be used in the HTTP request.\n // Defaults to 'search'. That is when a search string is specified and\n // the entire entity list has not been fetched, a fresh HTTP request is made\n // to the remote server with `?<searchParamName>=<search string>` parameter.\n searchParamName = input<string>('search');\n\n // Entity idKey, if idKey is different from the default 'id'.\n idKey = input<string>('id');\n\n // Plural entity name, used when grouping options. If not specified, it is\n // derived by pluralizing the entityName.\n pluralEntityName = input<string | undefined>(undefined); // defaults to pluralized entityName\n\n httpReqContext = input<\n [[HttpContextToken<any>, any]] | [HttpContextToken<any>, any] | HttpContext | undefined\n >(undefined); // defaults to empty context\n\n // Parameters to be added to the HTTP request to retrieve data from\n // remote. This won't be used if `loadFromRemoteFn` is specified.\n httpParams = input<HttpParams | undefined>(undefined); // defaults to empty params\n\n // Mechanism to default pageSize to last entities length.\n protected loadRequest$ = new Subject<LoadRequest>();\n protected sub$: Subscription | undefined;\n protected _pageSize = computed<number>(() =>\n this.pageSize() ? this.pageSize() : 50\n );\n\n protected _pluralEntityName = computed<string>(() => {\n const pluralEntityName = this.pluralEntityName();\n return pluralEntityName ? pluralEntityName : plural(this.entityName());\n });\n\n protected _capitalizedEntityName = computed<string>(() =>\n capitalize(this.entityName())\n );\n\n protected _httpReqContext = computed(() => {\n let reqContext = this.httpReqContext();\n const context = new HttpContext();\n if (reqContext instanceof HttpContext) {\n // Copy existing context values\n for (const key of reqContext.keys()) {\n context.set(key, reqContext.get(key));\n }\n } else {\n // Likely to be array of `(HttpContextToken, value)` pairs.\n if (reqContext && Array.isArray(reqContext)) {\n if (reqContext.length == 2 && !Array.isArray(reqContext[0])) {\n // one dimensional array of a key, value pair.\n context.set(reqContext[0], reqContext[1]);\n } else {\n reqContext.forEach(([k, v]) => context.set(k, v));\n }\n }\n }\n\n // Give subclasses a chance to add their own context tokens.\n this.addAddlContextTokens(context);\n\n return context;\n });\n\n entityListConfig = inject(SP_MAT_ENTITY_LIST_CONFIG, {\n optional: true,\n });\n protected _paginator = computed<SPMatEntityListPaginator>(() => {\n const paginator = this.paginator();\n const entityListConfigPaginator = this.entityListConfig\n ? (this.entityListConfig.paginator as SPMatEntityListPaginator)\n : undefined;\n return paginator\n ? paginator\n : entityListConfigPaginator\n ? entityListConfigPaginator\n : new DefaultPaginator();\n });\n\n // We create it here so that store member variable will have the correct\n // type. Unfortunately elf doesn't have a simple generic type that we can\n // use to declare the type of the store and then initialize it later.\n // We will recreate it in the constructor to have the correct idKey.\n protected store = createStore(\n { name: Math.random().toString(36).slice(2) },\n withEntities<TEntity, IdKey>({ idKey: 'id' as IdKey }),\n withProps<StateProps>(DEFAULT_STATE_PROPS),\n withPagination({\n initialPage: 0,\n })\n );\n\n protected http = inject(HttpClient);\n\n constructor() {}\n\n /**\n * Starts listening for load requests and processes them. Call this from your\n * component's ngOnInit() or ngAfterViewInit() method.\n */\n startLoader() {\n // Recreate store with the correct idKey. We have to do this after\n // the idKey is available from the constructor argument.\n const entities = this.store.query(getAllEntities());\n this.store = createStore(\n { name: Math.random().toString(36).slice(2) },\n withEntities<TEntity, IdKey>({\n initialValue: entities,\n idKey: this.idKey() as IdKey,\n }),\n withProps<StateProps>(DEFAULT_STATE_PROPS),\n withPagination({\n initialPage: 0,\n })\n );\n\n this.sub$ = this.loadRequest$\n .pipe(\n filter((lr) => lr.endpoint !== '' || lr.force === true),\n distinctUntilChanged((prev, current) =>\n current.isEqualToAndNotForced(prev)\n ),\n switchMap((lr: LoadRequest) => this.doActualLoad(lr))\n )\n .subscribe();\n }\n\n /**\n * Stops listening for load requests and cleans up subscriptions.\n */\n stopLoader() {\n if (this.sub$) {\n this.sub$.unsubscribe();\n this.sub$ = undefined;\n }\n // Remove references to this component's pages from the cache. If this\n // is the only component using those cached pages, they will be cleared\n // from the cache.\n this.removeFromCache();\n }\n\n hasStarted(): boolean {\n return this.sub$ !== undefined;\n }\n\n /**\n * Returns a boolean indicating whether all entities at the remote have been\n * loaded. All entities are considered loaded when there are no more entities\n * to load from the remote (that is all pages have been loaded without\n * a search filter).\n * @returns\n */\n allEntitiesLoaded(): boolean {\n return this.store.query((state) => state.allEntitiesLoaded);\n }\n\n /**\n * Returns the total number of entities at the remote as reported by the\n * server (or load fn) during each load.\n * @returns\n */\n totalEntitiesAtRemote(): number {\n return this.store.query(getPaginationData()).total;\n }\n\n /**\n * Returns number of entities currently stored in the internal store.\n * @returns\n */\n totalEntitiesCount(): number {\n return this.store.query(getEntitiesCount());\n }\n\n /**\n * Returns true if there are more entities to load from the remote.\n * This is computed based on the total entities count and the number of\n * entities loaded so far. For this method to work correctly, an initial\n * load must have been performed to get the total count from the remote.\n * @returns\n */\n hasMore(): boolean {\n const paginationData = this.store.query(getPaginationData());\n return (\n Object.keys(paginationData.pages).length * paginationData.perPage <\n paginationData.total\n );\n // return this.store.query((state) => state.hasMore);\n }\n\n /**\n * Returns true if a load operation is in progress. The load async operation\n * method turns the loading state to true when a load operation starts and\n * turns it to false when the operation completes.\n * @returns\n */\n loading(): boolean {\n return this.store.query((state) => state.loading);\n }\n\n /**\n * Returns the loading state as an Observable that emits when the state changes.\n * @returns\n */\n get loading$() {\n return this.store.pipe(\n select((state) => state.loading),\n distinctUntilChanged()\n );\n }\n\n /**\n * Boolean indicates whether the loader has completed at least one load\n * operation.\n */\n loaded(): boolean {\n return this.store.query((state) => state.loaded);\n }\n\n /**\n * Returns the endpoint URL if the loader was created with an endpoint.\n * If the loader was created with a loader function, an empty string is\n * returned.\n * @returns\n */\n endpoint(): string {\n return this.url() instanceof Function ? '' : (this.url() as string);\n }\n\n /**\n * Loads the specified page number of entities from the remote.\n * @param pageNumber\n */\n loadPage(pageNumber: number) {\n this.loadRequest$.next(\n new LoadRequest(this.url(), pageNumber, this.searchParamValue, false)\n );\n }\n\n /**\n * Returns the total number of pages available at the remote.\n * @returns\n */\n totalPages(): number {\n const paginationData = this.store.query(getPaginationData());\n return Math.ceil(paginationData.total / paginationData.perPage);\n }\n\n /**\n * Loads the next page of entities from the remote.\n *\n * @param searchParamValue Optional search parameter value. If specified\n * and is different from the current search parameter value, the internal\n * store is reset and entities are loaded from page 0 with the new search\n * parameter value. Otherwise, the next page of entities is loaded.\n */\n loadNextPage() {\n if (\n this.store.query(getPaginationData()).currentPage >= this.totalPages() &&\n this.loaded()\n ) {\n return;\n }\n\n const paginationData = this.store.query(getPaginationData());\n // console.log(`Loading page - forceRefresh: ${forceRefresh}, currentPage: ${paginationData.currentPage}...`);\n this.loadRequest$.next(\n new LoadRequest(\n this.url(),\n paginationData.currentPage,\n this.searchParamValue,\n false\n )\n );\n }\n\n // Sets the search parameter value to be used in subsequent loads.\n // If the search parameter value is different from the current value,\n // the internal store is reset to clear any previously loaded entities.\n setSearchParamValue(searchStr: string) {\n if (searchStr !== this.searchParamValue) {\n this.searchParamValue = searchStr;\n this.store.reset();\n }\n }\n\n setEntities(entities: TEntity[]) {\n this.store.update(upsertEntities(entities as any));\n }\n\n getEntities(): TEntity[] {\n return this.store.query(getAllEntities());\n }\n\n getEntity(id: TEntity[IdKey]): TEntity | undefined {\n return this.store.query(getEntity(id));\n }\n\n protected addAddlContextTokens(context: HttpContext): void {\n // Add any additional context tokens required for this request.\n // Note that context is a mutable object. Subclasses can override\n // this method to add their own context tokens.\n }\n\n // Does the actual loading of entities from the remote or the loader\n // function. Once loaded, the entities are stored in the internal store and\n // pagination properties are updated.\n protected doActualLoad(lr: LoadRequest) {\n const loaderFn =\n typeof this.url() === 'function'\n ? (this.url() as SPEntityLoaderFn)\n : undefined;\n let obs: Observable<any>;\n let paramsObj: any = {};\n const pageSize = this._pageSize();\n if (loaderFn) {\n obs = (loaderFn as SPEntityLoaderFn)(\n lr.pageNumber,\n pageSize,\n lr.searchStr\n );\n paramsObj = {\n page: lr.pageNumber,\n pageSize,\n };\n if (lr.searchStr) {\n paramsObj[this.searchParamName()] = lr.searchStr || '';\n }\n } else {\n // Form the HttpParams which consists of pagination params and any\n // embedded params in the URL which doesn't conflict with the page\n // params.\n const urlParts = (this.url() as string).split('?');\n const pageParams = this._paginator().getRequestPageParams(\n urlParts[0],\n lr.pageNumber,\n pageSize\n );\n if (lr.searchStr) {\n pageParams[this.searchParamName()] = lr.searchStr || '';\n }\n let httpParams = new HttpParams({ fromObject: pageParams });\n if (this.httpParams()) {\n this.httpParams()!\n .keys()\n .forEach((key) => {\n const value = this.httpParams()!.getAll(key);\n (value || []).forEach((v) => {\n httpParams = httpParams.append(key, v);\n });\n });\n }\n if (urlParts.length > 1) {\n const embeddedParams = new HttpParams({ fromString: urlParts[1] });\n embeddedParams.keys().forEach((key) => {\n const value = embeddedParams.getAll(key);\n (value || []).forEach((v) => {\n if (!httpParams.has(key)) {\n httpParams = httpParams.append(key, v);\n }\n });\n });\n }\n const cacheKey = this.getCacheKey(urlParts[0], httpParams);\n if (this.existsInCache(cacheKey)) {\n obs = of(this.getFromCache(cacheKey));\n } else {\n obs = this.http\n .get<any>(urlParts[0], {\n context: this._httpReqContext(),\n params: httpParams,\n })\n .pipe(tap((resp) => this.addToCache(cacheKey, resp)));\n }\n\n // Convert HttpParams to JS object\n httpParams.keys().forEach((key) => {\n paramsObj[key] = httpParams.get(key);\n });\n }\n\n this.store.update(\n setProps((state) => ({\n ...state,\n loading: true,\n }))\n );\n return obs.pipe(\n // skipWhilePageExistsInCacheOrCache(cacheKey, resp),\n skipWhilePageExists(this.store, lr.pageNumber),\n tap((resp) => {\n let hasMore = false;\n\n let entities: TEntity[] = [];\n let total = 0;\n\n if (Array.isArray(resp)) {\n // If the response is an array, we assume it's the array of entities.\n // Obviously, in this case, there's no pagination and therefore\n // set the total number of entities to the length of the array.\n total = resp.length;\n entities = resp;\n } else {\n const result = this._paginator().parseRequestResponse(\n this.entityName(),\n this._pluralEntityName()!,\n this.endpoint(),\n paramsObj,\n resp\n );\n total = result.total;\n entities = result.entities as unknown as TEntity[];\n }\n\n this.store.update(\n upsertEntities(entities as any),\n setProps((state) => ({\n ...state,\n totalCount: total,\n })),\n updatePaginationData({\n total: total,\n perPage: this.pageSize(),\n lastPage: lr.pageNumber,\n currentPage: lr.pageNumber + 1,\n }),\n setPage(\n lr.pageNumber,\n entities.map((e) => (e as any)[this.idKey()])\n )\n );\n }),\n finalize(() => {\n this.store.update(\n setProps((state) => ({\n ...state,\n allEntitiesLoaded: !this.hasMore() && !this.searchParamValue,\n loading: false,\n loaded: true,\n }))\n );\n })\n );\n }\n\n private existsInCache(cacheKey: string): boolean {\n return SPPagedEntityLoader._entitiesCache.has(cacheKey);\n }\n\n private getCacheKey(url: string, params?: HttpParams): string {\n if (params) {\n return `${url}?${params.toString()}`;\n }\n return url;\n }\n\n private getFromCache(cacheKey: string): any {\n if (cacheKey && SPPagedEntityLoader._entitiesCache.has(cacheKey)) {\n return SPPagedEntityLoader._entitiesCache.get(cacheKey)?.resp;\n }\n return [];\n }\n\n addToCache(cacheKey: string, resp: any) {\n if (!SPPagedEntityLoader._entitiesCache.has(cacheKey)) {\n SPPagedEntityLoader._entitiesCache.set(cacheKey, {\n refCount: 0,\n resp,\n });\n }\n const cacheEntry = SPPagedEntityLoader._entitiesCache.get(cacheKey);\n cacheEntry!.refCount += 1;\n this.cacheKeys.add(cacheKey);\n }\n\n private removeFromCache() {\n for (const cacheKey of this.cacheKeys) {\n const cacheEntry = SPPagedEntityLoader._entitiesCache.get(cacheKey);\n if (cacheEntry) {\n cacheEntry!.refCount -= 1;\n if (cacheEntry.refCount <= 0) {\n SPPagedEntityLoader._entitiesCache.delete(cacheKey);\n }\n }\n }\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;;;AA4CA;;;;AAIG;AACH,MAAM,WAAW,CAAA;AAEN,IAAA,QAAA;AACA,IAAA,UAAA;AACA,IAAA,SAAA;AACA,IAAA,KAAA;AAJT,IAAA,WAAA,CACS,QAAmC,EACnC,UAAkB,EAClB,SAA6B,EAC7B,QAAQ,KAAK,EAAA;QAHb,IAAQ,CAAA,QAAA,GAAR,QAAQ;QACR,IAAU,CAAA,UAAA,GAAV,UAAU;QACV,IAAS,CAAA,SAAA,GAAT,SAAS;QACT,IAAK,CAAA,KAAA,GAAL,KAAK;;;;AAKd,IAAA,qBAAqB,CAAC,IAAiB,EAAA;;;;;;QAMrC,OAAO,IAAI,CAAC;AACV,cAAE;AACF,cAAE,CAAC,OAAO,IAAI,CAAC,QAAQ,KAAK,UAAU;gBAClC,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,IAAI,CAAC,QAAkB,CAAC,KAAK,CAAC;AAC1D,gBAAA,IAAI,CAAC,UAAU,KAAK,IAAI,CAAC,UAAU;AACnC,gBAAA,IAAI,CAAC,SAAS,KAAK,IAAI,CAAC,SAAS;;AAE1C;AAQD,MAAM,mBAAmB,GAAe;AACtC,IAAA,iBAAiB,EAAE,KAAK;AACxB,IAAA,OAAO,EAAE,KAAK;AACd,IAAA,MAAM,E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AA,EAAA,iBAAA,EAAA,QAAA,EAAA,IAAA,EAAA,UAAA,EAAA,KAAA,EAAA,iBAAA,EAAA,IAAA,EAAA,EAAA,KAAA,EAAA,EAAA,iBAAA,EAAA,OAAA,EAAA,UAAA,EAAA,OAAA,EAAA,QAAA,EAAA,IAAA,EAAA,UAAA,EAAA,KAAA,EAAA,iBAAA,EAAA,IAAA,EAAA,EAAA,gBAAA,EAAA,EAAA,iBAAA,EAAA,kBAAA,EAAA,UAAA,EAAA,kBAAA,EAAA,QAAA,EAAA,IAAA,EAAA,UAAA,EAAA,KAAA,EAAA,iBAAA,EAAA,IAAA,EAAA,EAAA,cAAA,EAAA,EAAA,iBAAA,EAAA,gBAAA,EAAA,UAAA,EAAA,gBAAA,EAAA,QAAA,EAAA,IAAA,EAAA,UAAA,EAAA,KAAA,EAAA,iBAAA,EAAA,IAAA,EAAA,EAAA,UAAA,EAAA,EAAA,iBAAA,EAAA,YAAA,EAAA,UAAA,EAAA,YAAA,EAAA,QAAA,EAAA,IAAA,EAAA,UAAA,EAAA,KAAA,EAAA,iBAAA,EAAA,IAAA,EAAA,EAAA,EAAA,QAAA,EAAA,EAAA,EAAA,CAAA;;2FAAnB,mBAAmB,EAAA,UAAA,EAAA,CAAA;kBAHxC,SAAS;AAAC,YAAA,IAAA,EAAA,CAAA;AACT,oBAAA,QAAQ,EAAE,yBAAyB;AACpC,iBAAA;;;AChND;;AAEG;;;;"}
|
|
@@ -215,24 +215,32 @@ class SPMatEntityListComponent {
|
|
|
215
215
|
: plural(this.entityName()));
|
|
216
216
|
_httpReqContext = computed(() => {
|
|
217
217
|
let reqContext = this.httpReqContext();
|
|
218
|
+
let context = new HttpContext();
|
|
218
219
|
if (reqContext instanceof HttpContext) {
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
if (reqContext && Array.isArray(reqContext)) {
|
|
223
|
-
if (reqContext.length == 2 && !Array.isArray(reqContext[0])) {
|
|
224
|
-
// one dimensional array of a key, value pair.
|
|
225
|
-
context.set(reqContext[0], reqContext[1]);
|
|
220
|
+
// Copy existing context values
|
|
221
|
+
for (const key of reqContext.keys()) {
|
|
222
|
+
context.set(key, reqContext.get(key));
|
|
226
223
|
}
|
|
227
|
-
|
|
228
|
-
|
|
224
|
+
}
|
|
225
|
+
else {
|
|
226
|
+
if (reqContext && Array.isArray(reqContext)) {
|
|
227
|
+
if (reqContext.length == 2 && !Array.isArray(reqContext[0])) {
|
|
228
|
+
// one dimensional array of a key, value pair.
|
|
229
|
+
context.set(reqContext[0], reqContext[1]);
|
|
230
|
+
}
|
|
231
|
+
else {
|
|
232
|
+
reqContext.forEach(([k, v]) => context.set(k, v));
|
|
233
|
+
}
|
|
229
234
|
}
|
|
230
235
|
}
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
+
// Add mandatory SP_MAT_ENTITY_LIST_HTTP_CONTEXT context token
|
|
237
|
+
if (!context.has(SP_MAT_ENTITY_LIST_HTTP_CONTEXT)) {
|
|
238
|
+
context.set(SP_MAT_ENTITY_LIST_HTTP_CONTEXT, {
|
|
239
|
+
entityName: this.entityName(),
|
|
240
|
+
entityNamePlural: this._entityNamePlural(),
|
|
241
|
+
endpoint: this.endpoint(),
|
|
242
|
+
});
|
|
243
|
+
}
|
|
236
244
|
return context;
|
|
237
245
|
});
|
|
238
246
|
deferViewInit = input(false);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"smallpearl-ngx-helper-mat-entity-list.mjs","sources":["../../../../projects/smallpearl/ngx-helper/mat-entity-list/src/mat-entity-list-types.ts","../../../../projects/smallpearl/ngx-helper/mat-entity-list/src/providers.ts","../../../../projects/smallpearl/ngx-helper/mat-entity-list/src/config.ts","../../../../projects/smallpearl/ngx-helper/mat-entity-list/src/mat-entity-list.component.ts","../../../../projects/smallpearl/ngx-helper/mat-entity-list/smallpearl-ngx-helper-mat-entity-list.ts"],"sourcesContent":["import { HttpContextToken } from \"@angular/common/http\";\nimport { Observable } from \"rxjs\";\n\nexport interface SPMatEntityListHttpContext {\n entityName: string;\n entityNamePlural: string;\n endpoint: string;\n}\n\nexport const SP_MAT_ENTITY_LIST_HTTP_CONTEXT =\n new HttpContextToken<SPMatEntityListHttpContext>(() => ({\n entityName: '',\n entityNamePlural: '',\n endpoint: '',\n }));\n\n/**\n * Pagination HTTP request params. Actually copied from Angular's HttpParams\n * declaration. The ReadonlyArray<string|number|boolean> is a bit of an\n * overkill for pagination params, but what the heck. When you copy-paste,\n * do it in full!\n */\nexport type SPPageParams = { [param: string]: string | number | boolean | ReadonlyArray<string | number | boolean>; }\n\n/**\n * An interface that the clients should provide, either via a global config\n * (see above), that handles parsing the GET response and returns the entities\n * stored therein. This class will allow the entity-list component to be\n * used across different pagination response types as long as the appropriate\n * SPMatEntityListPaginator class is provided to the component.\n */\nexport interface SPMatEntityListPaginator {\n /**\n * Return the HTTP request params for the given page index and page size as\n * an object. For example, for a REST API that supports 'skip' and 'top' params,\n * the implementation would be:\n *\n * ```typescript\n * getRequestPageParams(endpoint: string, pageIndex: number, pageSize: number): SPPageParams {\n * return {\n * skip: pageIndex * pageSize,\n * top: pageSize\n * };\n * }\n * ```\n * @param endpoint\n * @param pageIndex\n * @param pageSize\n * @returns\n */\n getRequestPageParams: (endpoint: string, pageIndex: number, pageSize: number) => SPPageParams;\n\n /**\n * Parse the HTTP response received from the GET request and return an object\n * containing the total number of entities available and the array of entities\n * for the current page. For example, for the pure DRF paginated response\n * like below:\n * ```json\n * {\n * \"count\": 102,\n * \"next\": \"http://api.example.org/entities/?page=3\",\n * \"previous\": \"http://api.example.org/entities/?page=1\",\n * \"results\": [\n * {\n * \"id\": 1,\n * \"name\": \"Entity 1\"\n * },\n * {\n * \"id\": 2,\n * \"name\": \"Entity 2\"\n * }\n * ]\n * }\n * ```\n * The implementation would be:\n * ```typescript\n * parseRequestResponse<TEntity extends { [P in IdKey]: PropertyKey }, IdKey extends string = 'id'>(\n * entityName: string,\n * entityNamePlural: string,\n * endpoint: string,\n * params: SPPageParams,\n * resp: any\n * ): { total: number; entities: TEntity[] } {\n * return {\n * total: resp.count,\n * entities: resp.results\n * };\n * }\n * ```\n * @param entityName\n * @param entityNamePlural\n * @param endpoint\n * @param params\n * @param resp\n * @returns\n */\n parseRequestResponse: <\n TEntity extends { [P in IdKey]: PropertyKey },\n IdKey extends string = 'id'\n >(\n entityName: string,\n entityNamePlural: string,\n endpoint: string,\n params: SPPageParams,\n resp: any\n ) => { total: number; entities: TEntity[] };\n}\n\n/**\n * 'entity' is really TEntity arg of SPMatEntityListComponent<TEntity>.\n * 'column' is the column name. This allows the same value function to support\n * multiple columns further enabing DRY.\n */\nexport type COLUMN_VALUE_FN = (entity: any, column: string) => string|number|Date|boolean;\n\n/**\n * Global config for SPMatEntityList component.\n */\nexport interface SPMatEntityListConfig {\n urlResolver?: (endpoint: string) => string;\n paginator?: SPMatEntityListPaginator;\n defaultPageSize?: number;\n pageSizes?: Array<number>;\n /**\n * Provide a method to return the labels for the columns. This is useful when\n * the columns are specified as the JSON object key names and the labels are\n * to be transformed into a uniform manner (uppercase) or when the labels\n * are to be dynamically localized. Note that the response can be an\n * Observable<string> if the label is to be fetched/changed asynchronously\n * (as that can happen in an app that supports dynamic changing of the UI\n * language).\n * @param entityName\n * @param columnName\n * @returns\n */\n columnLabelFn?: (entityName: string, columnName: string) => string | Observable<string>;\n}\n\n/**\n * Type for custom entities loader function, which if provided will be called\n * instead of HttpClient.get.\n */\nexport type SPMatEntityListEntityLoaderFn = (params: any) => Observable<any>;\n","import { InjectionToken } from '@angular/core';\nimport { SPMatEntityListConfig } from './mat-entity-list-types';\n\nexport const SP_MAT_ENTITY_LIST_CONFIG = new InjectionToken<SPMatEntityListConfig>(\n 'SPMatEntityListConfig'\n);\n","import { inject } from '@angular/core';\nimport { SPMatEntityListConfig } from './mat-entity-list-types';\nimport { SP_MAT_ENTITY_LIST_CONFIG } from './providers';\n\nexport const DefaultSPMatEntityListConfig: SPMatEntityListConfig = {\n urlResolver: (endpoint: string) => endpoint,\n paginator: undefined,\n defaultPageSize: 50,\n pageSizes: [10, 25, 50, 100],\n columnLabelFn: (entityName: string, columnName: string) => columnName,\n};\n\n/**\n * To be called from an object's constructor.\n */\nexport function getEntityListConfig(): SPMatEntityListConfig {\n const entityListConfig = inject(SP_MAT_ENTITY_LIST_CONFIG, {\n optional: true,\n });\n return {\n ...DefaultSPMatEntityListConfig,\n ...(entityListConfig ?? {}),\n };\n}\n","import { CommonModule } from '@angular/common';\nimport { HttpClient, HttpContext, HttpContextToken, HttpParams } from '@angular/common/http';\nimport {\n AfterViewInit,\n ChangeDetectionStrategy,\n Component,\n computed,\n ContentChildren,\n Directive,\n effect,\n ElementRef,\n EventEmitter,\n inject,\n Injector,\n input,\n OnDestroy,\n OnInit,\n Output,\n QueryList,\n runInInjectionContext,\n signal,\n viewChild,\n viewChildren\n} from '@angular/core';\nimport { MatButtonModule } from '@angular/material/button';\nimport { MatInputModule } from '@angular/material/input';\nimport { MatPaginatorModule, PageEvent } from '@angular/material/paginator';\nimport { MatProgressSpinnerModule } from '@angular/material/progress-spinner';\nimport { MatSort, MatSortModule } from '@angular/material/sort';\nimport {\n MatColumnDef,\n MatTable,\n MatTableDataSource,\n MatTableModule,\n} from '@angular/material/table';\nimport { DomSanitizer } from '@angular/platform-browser';\nimport { RouterModule } from '@angular/router';\nimport { createStore } from '@ngneat/elf';\nimport {\n addEntities,\n deleteEntities,\n getEntitiesCount,\n hasEntity,\n selectAllEntities,\n updateEntities,\n upsertEntities,\n withEntities,\n} from '@ngneat/elf-entities';\nimport {\n SP_ENTITY_FIELD_CONFIG,\n SPEntityField,\n SPEntityFieldSpec\n} from '@smallpearl/ngx-helper/entity-field';\nimport { InfiniteScrollDirective } from 'ngx-infinite-scroll';\nimport { plural } from 'pluralize';\nimport {\n distinctUntilChanged,\n filter,\n finalize,\n Observable,\n of,\n Subject,\n Subscription,\n switchMap,\n takeUntil,\n tap\n} from 'rxjs';\nimport { getEntityListConfig } from './config';\nimport {\n SP_MAT_ENTITY_LIST_HTTP_CONTEXT,\n SPMatEntityListEntityLoaderFn,\n SPMatEntityListPaginator\n} from './mat-entity-list-types';\n\n@Directive({\n selector: '[headerAlignment]',\n standalone: true\n})\nexport class HeaderAlignmentDirective implements AfterViewInit {\n\n headerAlignment = input<string>();\n\n constructor(private el: ElementRef) {\n // this.el.nativeElement.style.backgroundColor = 'yellow';\n }\n\n ngAfterViewInit(): void {\n if (this.headerAlignment()) {\n const sortHeader = this.el.nativeElement.querySelector('.mat-sort-header-container');\n if (sortHeader) {\n sortHeader.style.justifyContent = this.headerAlignment();\n } else {\n this.el.nativeElement.style.justifyContent = this.headerAlignment();\n }\n }\n }\n}\n\n/**\n * Represents a request to load entities from the remote. This is used to\n * compare two requests to determine if they are equal. This is useful to\n * prevent duplicate requests being sent to the remote.\n */\nclass LoadRequest {\n constructor(\n public endpoint: string,\n public params: HttpParams,\n public force = false\n ) {}\n\n // Returns true if two LoadRequest objects are equal and this object's\n // 'force' is not set to true.\n isEqualToAndNotForced(prev: LoadRequest): boolean {\n // console.log(\n // `isEqualToAndNotForced - ${this.endpoint}, ${this.params.toString()} ${\n // this.force\n // }, other: ${prev.endpoint}, ${prev.params.toString()}, ${prev.force}`\n // );\n return this.force\n ? false\n : this.endpoint.localeCompare(prev.endpoint) === 0 &&\n this.params.toString().localeCompare(prev.params.toString()) === 0;\n }\n}\n\n/**\n * A component to display a list of entities loaded from remote.\n */\n@Component({\n imports: [\n CommonModule,\n RouterModule,\n MatTableModule,\n MatSortModule,\n MatPaginatorModule,\n MatButtonModule,\n MatInputModule,\n MatProgressSpinnerModule,\n InfiniteScrollDirective,\n HeaderAlignmentDirective,\n ],\n selector: 'sp-mat-entity-list',\n template: `\n <div\n class=\"entities-list-wrapper\"\n infiniteScroll\n [infiniteScrollDistance]=\"infiniteScrollDistance()\"\n [infiniteScrollThrottle]=\"infiniteScrollThrottle()\"\n [infiniteScrollContainer]=\"infiniteScrollContainer()\"\n [scrollWindow]=\"infiniteScrollWindow()\"\n [infiniteScrollDisabled]=\"\n pagination() !== 'infinite' || !_paginator || !hasMore()\n \"\n (scrolled)=\"infiniteScrollLoadNextPage($event)\"\n >\n <div\n class=\"busy-overlay\"\n [ngClass]=\"{ show: pagination() === 'discrete' && loading() }\"\n >\n <ng-container *ngTemplateOutlet=\"busySpinner\"></ng-container>\n </div>\n <table mat-table [dataSource]=\"dataSource()\">\n <tr mat-header-row *matHeaderRowDef=\"_displayedColumns()\"></tr>\n <tr\n mat-row\n [class.active-row]=\"activeEntityId() === row[this.idKey()]\"\n *matRowDef=\"let row; columns: _displayedColumns()\"\n (click)=\"toggleActiveEntity(row)\"\n ></tr>\n </table>\n @if (pagination() == 'discrete' && _paginator) {\n <mat-paginator\n showFirstLastButtons\n [length]=\"entityCount()\"\n [pageSize]=\"_pageSize()\"\n [pageIndex]=\"pageIndex()\"\n [pageSizeOptions]=\"[]\"\n [hidePageSize]=\"true\"\n (page)=\"handlePageEvent($event)\"\n [disabled]=\"loading()\"\n aria-label=\"Select page\"\n ></mat-paginator>\n }\n <div\n class=\"infinite-scroll-loading\"\n [ngClass]=\"{ show: pagination() === 'infinite' && loading() }\"\n >\n <ng-container *ngTemplateOutlet=\"busySpinner\"></ng-container>\n </div>\n </div>\n <!-- We keep the column definitions outside the <table> so that they can\n be dynamically added to the MatTable. -->\n <span matSort=\"sorter()\">\n @for (column of __columns(); track $index) {\n <ng-container [matColumnDef]=\"column.spec.name\">\n @if (disableSort()) {\n <th\n [class]=\"column.class\"\n [headerAlignment]=\"column.options.alignment\"\n mat-header-cell\n *matHeaderCellDef\n >\n {{ getColumnLabel(column) | async }}\n </th>\n } @else {\n <th\n [class]=\"column.class\"\n [headerAlignment]=\"column.options.alignment\"\n mat-header-cell\n mat-sort-header\n *matHeaderCellDef\n >\n {{ getColumnLabel(column) | async }}\n </th>\n }\n <td\n [class]=\"column.class\"\n [style.text-align]=\"column.options.alignment\"\n mat-cell\n *matCellDef=\"let element\"\n [routerLink]=\"column.getRouterLink(element)\"\n >\n @if (column.hasRouterLink(element)) {\n <a [routerLink]=\"column.getRouterLink(element)\">\n <span [innerHTML]=\"column.value(element)\"></span>\n </a>\n } @else { @let val = column.value(element);\n <span [innerHTML]=\"isAsync(val) ? (val | async) : val\"></span>\n }\n </td>\n </ng-container>\n }\n </span>\n <ng-template #busySpinner>\n <div class=\"busy-spinner\">\n <mat-spinner mode=\"indeterminate\" diameter=\"28\"></mat-spinner>\n </div>\n </ng-template>\n `,\n styles: [\n `\n .entities-list-wrapper {\n position: relative;\n }\n .busy-overlay {\n display: none;\n height: 100%;\n width: 100%;\n position: absolute;\n top: 0px;\n left: 0px;\n z-index: 1000;\n opacity: 0.6;\n background-color: transparent;\n }\n .show {\n display: block;\n }\n .busy-spinner {\n width: 100%;\n height: 100%;\n display: flex;\n align-items: center;\n justify-content: center;\n }\n .infinite-scroll-loading {\n display: none;\n width: 100%;\n padding: 8px;\n }\n .active-row {\n font-weight: bold;\n }\n `,\n ],\n changeDetection: ChangeDetectionStrategy.OnPush,\n})\nexport class SPMatEntityListComponent<\n TEntity extends { [P in IdKey]: PropertyKey },\n IdKey extends string = 'id'\n> implements OnInit, OnDestroy, AfterViewInit\n{\n /* CLIENT PROVIDED PARAMETERS */\n entityName = input.required<string>();\n entityNamePlural = input<string>();\n\n /**\n * The endpoint from where the entities are to be retrieved\n */\n endpoint = input<string>('');\n /**\n * Custom entities loader function, which if provided will be called\n * instead of HttpClient.get.\n */\n entityLoaderFn = input<SPMatEntityListEntityLoaderFn | undefined>(undefined);\n /**\n * The columns of the entity to be displayed. This is an array of\n * SPEntityFieldSpec objects. If there's a one-to-one mapping between the\n * column's field name, its title & the rendered value, a string can be\n * specified instead. That is, the value of this property is a heterogeneous\n * array consisting of SPEntityFieldSpec<> objects and strings.\n */\n columns = input<Array<SPEntityFieldSpec<TEntity, IdKey> | string>>([]);\n\n /**\n * Names of columns that are displayed. This will default to all the columns\n * listed in columns.\n */\n displayedColumns = input<string[]>([]); // ['name', 'cell', 'gender'];\n\n /**\n * Number of entities per page. If this is not set and paginator is defined,\n * the number of entities int in the first request, will be taken as the\n * page size.\n */\n pageSize = input<number>(0);\n /**\n * Entity idKey, if idKey is different from the default 'id'.\n */\n idKey = input<string>('id');\n /**\n * Type of pagination -- continuous or discrete. 'infinite' pagination\n * uses an 'infiniteScroll' and 'discrete' pagination uses a mat-paginator\n * at the bottom to navigate between pages.\n */\n pagination = input<'infinite' | 'discrete' | 'none'>('discrete');\n /**\n * Component specific paginator. Only used if pagination != 'none'.\n */\n paginator = input<SPMatEntityListPaginator>();\n /**\n *\n */\n sorter = input<MatSort>();\n /**\n * Disable sorting of rows\n */\n disableSort = input<boolean>(false);\n /**\n * Wrappers for infiniteScroll properties, for customization by the client\n */\n infiniteScrollContainer = input<any>('');\n infiniteScrollDistance = input<number>(1);\n infiniteScrollThrottle = input<number>(400);\n infiniteScrollWindow = input<boolean>(false);\n /**\n * Custom context to be set for HttpClient requests. Value for this attribute\n * can be an array of HttpContextToken key, value pairs, or an instance of\n * HttpContext.\n *\n * In the client code specify this property by initializing a member variable\n * as:\n\n ```\n Component({\n ...\n template: `\n <sp-mat-entity-list\n [httpReqContext]=\"httpReqContext\"\n ></sp-mat-entity-list>\n `\n })\n export class YourComponent {\n httpReqContext: [HttpContextToken<any>, any] = [\n MY_CONTEXT_TOKEN, 'customers'\n ];\n // Or [httpReqContext]=\"httpReqContext2\" will work too.\n httpReqContext2: HttpContext = new HttpContext().set(\n MY_CONTEXT_TOKEN, 'customers'\n );\n }\n ```\n *\n * Of course if you want to pass multiple context properties, declare the type\n * as an array of array. That is, `[[HttpContextToken<any>, any]]` and\n * initialize it appropriately.\n */\n httpReqContext = input<\n [[HttpContextToken<any>, any]] | [HttpContextToken<any>, any] | HttpContext | undefined\n >();\n /* END CLIENT PROVIDED PARAMETERS */\n\n // *** INTERNAL *** //\n _entityNamePlural = computed(() =>\n this.entityNamePlural()\n ? this.entityNamePlural()\n : plural(this.entityName())\n );\n\n _httpReqContext = computed(() => {\n let reqContext = this.httpReqContext();\n if (reqContext instanceof HttpContext) {\n return reqContext;\n }\n const context = new HttpContext();\n if (reqContext && Array.isArray(reqContext)) {\n if (reqContext.length == 2 && !Array.isArray(reqContext[0])) {\n // one dimensional array of a key, value pair.\n context.set(reqContext[0], reqContext[1]);\n } else {\n reqContext.forEach(([k, v]) => context.set(k, v));\n }\n }\n context.set(SP_MAT_ENTITY_LIST_HTTP_CONTEXT, {\n entityName: this.entityName(),\n entityNamePlural: this._entityNamePlural(),\n endpoint: this.endpoint(),\n });\n return context;\n });\n deferViewInit = input<boolean>(false);\n firstLoadDone = false;\n allColumnNames = signal<string[]>([]);\n _displayedColumns = computed(() =>\n this.displayedColumns().length > 0\n ? this.displayedColumns().filter(\n (colName) =>\n this.allColumnNames().find((name) => name === colName) !== undefined\n )\n : this.allColumnNames()\n );\n dataSource = signal<MatTableDataSource<TEntity>>(\n new MatTableDataSource<TEntity>()\n );\n\n table = viewChild(MatTable);\n sort = viewChild(MatSort);\n // These are our own <ng-container matColumnDef></ng-container>\n // which we create for each column that we create by the declaration:\n // <ng-container *ngFor=\"let column of columns()\" [matColumnDef]=\"column.name\">\n viewColumnDefs = viewChildren(MatColumnDef);\n // These are the <ng-container matColumnDef></ng-container> placed\n // inside <sp-mat-entity-list></<sp-mat-entity-list> by the client to override\n // the default <ng-container matColumnDef> created by the component.\n @ContentChildren(MatColumnDef) clientColumnDefs!: QueryList<MatColumnDef>;\n\n contentColumnDefs: MatColumnDef[] = [];\n\n subs$ = new Subscription();\n destroy$ = new Subject<void>();\n\n // Pagination state\n entityCount = signal<number>(0);\n pageIndex = signal<number>(0);\n\n // Mechanism to default pageSize to last entities length.\n lastFetchedEntitiesCount = signal<number>(0);\n _pageSize = computed<number>(() =>\n this.pageSize()\n ? this.pageSize()\n : this.entityListConfig.defaultPageSize ?? this.lastFetchedEntitiesCount()\n );\n // Effective columns, derived from columns(), which can either be an array\n // of objects of array of strings.\n _columns = computed<SPEntityFieldSpec<TEntity, IdKey>[]>(() => {\n const columns = this.columns();\n let fields: SPEntityField<TEntity, IdKey>[] = [];\n let cols: SPEntityFieldSpec<TEntity, IdKey>[] = [];\n columns.forEach((colDef) => {\n // fields.push(new SPEntityField(colDef))\n if (typeof colDef === 'string') {\n cols.push({ name: String(colDef) });\n } else if (typeof colDef === 'object') {\n cols.push(colDef as SPEntityFieldSpec<TEntity, IdKey>);\n }\n });\n return cols;\n });\n\n __columns = computed<SPEntityField<TEntity, IdKey>[]>(() =>\n this.columns().map(\n (colDef) => new SPEntityField<TEntity, IdKey>(colDef, this.fieldConfig)\n )\n );\n\n // We isolate retrieving items from the remote and providing the items\n // to the component into two distinct operations. The retrieval operation\n // retrieves data asynchronously and then stores the data in a local store.\n // The UI would be 'listening' to a reactive callback that would be triggered\n // whenever items in the store changes. This is because store is an immutable\n // data structure and any changes (addition/deletion) to it would result in\n // the entire store being replaced with a copy with the changes applied.\n\n // Ideally we should declare this as\n // store!: Store<...>. But @ngneat/elf does not provide a generic type\n // for Store<...>, which can be composed from its type arguments. Instead it\n // uses type composition using its arguments to generate store's type\n // implicitly. So we use the same mechanism to enforce type safety in our\n // code. The code below results in a type declaration for store that is\n // dependent on the components generic arguments. (Making use of TypeScript's\n // type deduction system from variable assignment). Later on in the\n // constructor we reassign this.store with a new object that uses the\n // client provided idKey() value as the identifying key for each entity in\n // the sore.\n store = createStore(\n { name: Math.random().toString(36).slice(2) },\n withEntities<TEntity, IdKey>({ idKey: this.idKey() as IdKey })\n );\n // We'll initialize this in ngOnInit() when 'store' is initialized with the\n // correct TEntity store that can be safely indexed using IdKey.\n entities$!: Observable<TEntity[]>;\n // Effective paginator, coalescing local paginator and paginator from global\n // config.\n _paginator!: SPMatEntityListPaginator | undefined;\n // We will toggle this during every entity load.\n loading = signal<boolean>(false);\n // We will update this after every load and pagination() == 'infinite'\n hasMore = signal<boolean>(true);\n\n activeEntity = signal<TEntity | undefined>(undefined);\n activeEntityId = computed(() =>\n this.activeEntity() ? (this.activeEntity() as any)[this.idKey()] : undefined\n );\n _prevActiveEntity!: TEntity | undefined;\n _activeEntityChange = effect(() => {\n runInInjectionContext(this.injector, () => {\n const activeEntity = this.activeEntity();\n // Though we can raise the selectEntity event directly from effect handler,\n // that would prevent the event handler from being able to update any\n // signals from inside it. So we generate the event asyncronously.\n // Also, this effect handler will be invoked for the initial 'undefined'\n // during which we shouldn't emit the selectEntity event. Therefore we\n // keep another state variable to filter out this state.\n if (activeEntity || this._prevActiveEntity) {\n setTimeout(() => {\n this._prevActiveEntity = activeEntity;\n this.selectEntity.emit(activeEntity);\n // if (this._prevActiveEntity && !activeEntity) {\n // this.selectEntity.emit(activeEntity);\n // } else if (activeEntity) {\n // this.selectEntity.emit(activeEntity);\n // }\n });\n }\n });\n });\n @Output() selectEntity = new EventEmitter<TEntity | undefined>();\n\n fieldConfig = inject(SP_ENTITY_FIELD_CONFIG, { optional: true })!;\n entityListConfig = getEntityListConfig();\n\n /**\n * A signal that can be used to trigger loading of more entities from the\n * remote. This can be visualized as the event loop of the entity list\n * component.\n */\n loadRequest$ = new Subject<LoadRequest>();\n\n endpointChanged = effect(() => {\n runInInjectionContext(this.injector, () => {\n if (this.endpoint()) {\n // console.log(`endpointChanged - ${this.endpoint()}`);\n setTimeout(() => {\n this.refresh();\n });\n }\n });\n });\n\n constructor(\n protected http: HttpClient,\n private sanitizer: DomSanitizer,\n private injector: Injector\n ) {}\n\n ngOnInit() {\n // This is the reactive callback that listens for changes to table entities\n // which are reflected in the mat-table.\n this.store = createStore(\n { name: Math.random().toString(36).slice(2) },\n withEntities<TEntity, IdKey>({ idKey: this.idKey() as IdKey })\n );\n this.entities$ = this.store.pipe(selectAllEntities());\n this._paginator = this.paginator()\n ? this.paginator()\n : this.entityListConfig?.paginator;\n\n this.entities$\n .pipe(\n takeUntil(this.destroy$),\n tap((entities) => {\n // .data is a setter property, which ought to trigger the necessary\n // signals resulting in mat-table picking up the changes without\n // requiring us to call cdr.detectChanges() explicitly.\n this.dataSource().data = entities;\n })\n )\n .subscribe();\n\n this.loadRequest$\n .pipe(\n takeUntil(this.destroy$),\n filter((lr) => lr.endpoint !== '' || lr.force === true),\n distinctUntilChanged((prev, current) =>\n current.isEqualToAndNotForced(prev)\n ),\n switchMap((lr: LoadRequest) => this.doActualLoad(lr))\n )\n .subscribe();\n }\n\n ngOnDestroy(): void {\n this.destroy$.next();\n this.destroy$.complete();\n }\n\n ngAfterViewInit(): void {\n if (!this.deferViewInit()) {\n this.buildContentColumnDefs();\n this.buildColumns();\n this.setupSort();\n this.loadMoreEntities();\n }\n }\n\n /**\n * Clear all entities in store and reload them from endpoint as if\n * the entities are being loaded for the first time.\n */\n refresh(force = false) {\n this.pageIndex.set(0);\n this.loadMoreEntities(force);\n }\n\n addEntity(entity: TEntity) {\n const pagination = this.pagination();\n const count = this.store.query(getEntitiesCount());\n if (\n pagination === 'infinite' ||\n pagination === 'none' ||\n count < this._pageSize()\n ) {\n this.store.update(addEntities(entity));\n } else {\n // 'discrete' pagination, refresh the crud items from the beginning.\n // Let component client set the behavior using a property\n // this.pageIndex.set(0);\n // this.loadMoreEntities();\n }\n }\n\n /**\n * Update an entity with a modified version. Can be used by CRUD UPDATE\n * operation to update an entity in the local store that is used to as the\n * source of MatTableDataSource.\n * @param id\n * @param entity\n */\n updateEntity(id: TEntity[IdKey], entity: TEntity) {\n if (this.store.query(hasEntity(id))) {\n this.store.update(updateEntities(id, entity));\n }\n }\n\n /**\n * Clients can call this method when it has deleted and entity via a CRUD\n * operation. Depending on the pagination mode, MatEntityList implements\n * an appropriate behavior.\n *\n * If the pagination is 'infinite', the relevent entity is removed from our\n * entity list. View will be repained as data store has changed.\n *\n * If the pagination is 'discrete', the entity is removed from the page.\n * If this is the only entity in the page, the current pageNumber is\n * decremented by 1 if it's possible (if the current pageNumber > 1).\n * The page is reloaded from remote.\n */\n removeEntity(id: TEntity[IdKey]) {\n const paginator = this._paginator;\n if (paginator) {\n if (this.pagination() === 'infinite') {\n // This will cause store to mutate which will trigger this.entity$ to\n // emit which in turn will update our MatTableDataSource instance.\n this.store.update(deleteEntities(id));\n } else {\n // Logic\n this.store.update(deleteEntities(id));\n const count = this.store.query(getEntitiesCount());\n if (count == 0) {\n // No more entities in this page\n // Go back one page\n if (this.pageIndex() > 0) {\n this.pageIndex.set(this.pageIndex() - 1);\n }\n }\n // load the page again\n this.loadMoreEntities();\n }\n } else {\n // Just remove the entity that has been deleted.\n this.store.update(deleteEntities(id));\n }\n }\n\n /**\n * Build the contentColumnDefs array by enumerating all of client's projected\n * content with matColumnDef directive.\n */\n buildContentColumnDefs() {\n const clientColumnDefs = this.clientColumnDefs;\n if (clientColumnDefs) {\n this.contentColumnDefs = clientColumnDefs.toArray();\n }\n }\n\n /**\n * Build the effective columns by parsing our own <ng-container matColumnDef>\n * statements for each column in columns() property and client's\n * <ng-container matColumnDef> provided via content projection.\n */\n buildColumns() {\n const matTable = this.table();\n\n if (matTable) {\n const columnNames = new Set<string>();\n const columnDefs: MatColumnDef[] = [];\n\n this._columns().forEach((colDef) => {\n if (!columnNames.has(colDef.name)) {\n const matColDef = this.viewColumnDefs().find(\n (cd) => cd.name === colDef.name\n );\n const clientColDef = this.contentColumnDefs.find(\n (cd) => cd.name === colDef.name\n );\n const columnDef = clientColDef ? clientColDef : matColDef;\n if (columnDef) {\n columnDefs.push(columnDef);\n columnNames.add(colDef.name);\n }\n }\n });\n columnDefs.forEach((cd) => {\n matTable.addColumnDef(cd);\n });\n\n this.allColumnNames.set(Array.from(columnNames));\n // this.displayedColumns.set(Array.from(columnNames) as string[]);\n }\n }\n\n setupSort() {\n const matSort = this.sort();\n if (matSort) {\n this.dataSource().sort = matSort;\n }\n }\n\n infiniteScrollLoadNextPage(ev: any) {\n // console.log(`infiniteScrollLoadNextPage - ${JSON.stringify(ev)}`);\n if (this._paginator) {\n this.loadMoreEntities();\n }\n }\n\n loadMoreEntities(forceRefresh = false) {\n this.loadRequest$.next(this.createNextLoadRequest(forceRefresh));\n }\n\n /**\n * Creates a LoadRequest object for loading entities using the current state\n * of the component. Therefore, if the request is for next page of entities,\n * the LoadRequest object will have the updated page index. However, if\n * pagination has been reset (refer to refresh()), the LoadRequest object\n * will be for the first page of data. Note that when 'endpoint' value\n * changes, the component's pagination state is reset causing a refresh()\n * to be called, which in turn will create a new LoadRequest object for the\n * first page of data.\n * @returns LoadRequest object for the next load request.\n */\n private createNextLoadRequest(forceRefresh: boolean): LoadRequest {\n let pageParams = {};\n const parts = this.endpoint().split('?');\n const endpoint = parts[0];\n if (this._paginator) {\n pageParams = this._paginator.getRequestPageParams(\n endpoint,\n this.pageIndex(),\n this.pageSize()\n );\n }\n let httpParams = new HttpParams();\n for (const key in pageParams) {\n httpParams = httpParams.append(key, (pageParams as any)[key]);\n }\n if (parts.length > 1) {\n const embeddedParams = new HttpParams({ fromString: parts[1] });\n embeddedParams.keys().forEach((key) => {\n const value = embeddedParams.getAll(key);\n (value || []).forEach((v) => {\n httpParams = httpParams.append(key, v);\n });\n });\n }\n return new LoadRequest(\n endpoint,\n httpParams,\n forceRefresh || !!this.entityLoaderFn()\n );\n }\n\n /**\n * Does the actual load of entities from the remote or via calling the\n * entityLoaderFn. This method is the workhorse of the entity list\n * 'loader-loop'.\n * @param lr\n * @returns Observable that emits the response from the remote or from\n * entityLoaderFn().\n */\n private doActualLoad(lr: LoadRequest) {\n // console.log(`doActualLoad - endpoint: ${lr.endpoint}, params: ${lr.params.toString()}`);\n const loaderFn = this.entityLoaderFn();\n const params = lr.params;\n const obs =\n loaderFn !== undefined\n ? loaderFn({ params })\n : this.http.get<any>(this.getUrl(lr.endpoint), {\n context: this._httpReqContext(),\n params,\n });\n\n this.loading.set(true);\n return obs.pipe(\n tap((resp) => {\n // TODO: defer this to a pagination provider so that we can support\n // many types of pagination. DRF itself has different schemes. And\n // express may have yet another pagination protocol.\n this.firstLoadDone = true;\n if (this._paginator) {\n // Convert HttpParams to JS object\n const paramsObj: any = {};\n params.keys().forEach((key) => {\n paramsObj[key] = params.get(key);\n });\n const { entities, total } = this._paginator.parseRequestResponse(\n this.entityName(),\n this._entityNamePlural()!,\n this.endpoint(),\n paramsObj,\n resp\n );\n this.entityCount.set(total);\n this.lastFetchedEntitiesCount.set(entities.length);\n // this.pageIndex.set(this.pageIndex() + 1)\n // entities = this._paginator.getEntitiesFromResponse(entities);\n if (this.pagination() === 'discrete') {\n this.store.reset();\n } else if (this.pagination() === 'infinite') {\n const pageSize = this._pageSize();\n const entityCount = this.entityCount();\n if (pageSize > 0) {\n const pageCount =\n Math.floor(entityCount / pageSize) +\n (entityCount % pageSize ? 1 : 0);\n this.hasMore.set(this.pageIndex() === pageCount);\n } else {\n this.hasMore.set(false);\n }\n }\n // store the entities in the store\n // TODO: remove as any\n this.store.update(upsertEntities(entities as any));\n } else {\n this.store.update(\n upsertEntities(this.findArrayInResult(resp) as TEntity[])\n );\n }\n }),\n finalize(() => this.loading.set(false))\n );\n }\n\n private findArrayInResult(res: any): any[] | undefined {\n if (Array.isArray(res)) {\n return res;\n }\n for (const key in res) {\n if (Object.prototype.hasOwnProperty.call(res, key)) {\n const element = res[key];\n if (Array.isArray(element)) {\n return element;\n }\n }\n }\n return [];\n }\n\n handlePageEvent(e: PageEvent) {\n this.pageIndex.set(e.pageIndex);\n this.loadMoreEntities();\n }\n\n getUrl(endpoint: string) {\n return this.entityListConfig?.urlResolver\n ? this.entityListConfig?.urlResolver(endpoint)\n : endpoint;\n }\n\n toggleActiveEntity(entity: TEntity | undefined) {\n if (entity) {\n if (entity === this.activeEntity()) {\n this.activeEntity.set(undefined);\n } else {\n this.activeEntity.set(entity);\n }\n } else {\n this.activeEntity.set(undefined);\n }\n }\n\n getColumnLabel(field: SPEntityField<TEntity, IdKey>): Observable<string> {\n if (field._fieldSpec.label) {\n return field._fieldSpec.label instanceof Observable\n ? field._fieldSpec.label\n : of(field._fieldSpec.label);\n }\n if (this.entityListConfig && this.entityListConfig.columnLabelFn) {\n const label = this.entityListConfig.columnLabelFn(\n this.entityName(),\n field._fieldSpec.name\n );\n return label instanceof Observable ? label : of(label);\n }\n return of(field._fieldSpec.name);\n }\n\n isAsync(val: any) {\n return val instanceof Observable;\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AASa,MAAA,+BAA+B,GAC1C,IAAI,gBAAgB,CAA6B,OAAO;AACtD,IAAA,UAAU,EAAE,EAAE;AACd,IAAA,gBAAgB,EAAE,EAAE;AACpB,IAAA,QAAQ,EAAE,EAAE;AACb,CAAA,CAAC;;MCXS,yBAAyB,GAAG,IAAI,cAAc,CACzD,uBAAuB;;ACAlB,MAAM,4BAA4B,GAA0B;AACjE,IAAA,WAAW,EAAE,CAAC,QAAgB,KAAK,QAAQ;AAC3C,IAAA,SAAS,EAAE,SAAS;AACpB,IAAA,eAAe,EAAE,EAAE;IACnB,SAAS,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,CAAC;IAC5B,aAAa,EAAE,CAAC,UAAkB,EAAE,UAAkB,KAAK,UAAU;CACtE;AAED;;AAEG;SACa,mBAAmB,GAAA;AACjC,IAAA,MAAM,gBAAgB,GAAG,MAAM,CAAC,yBAAyB,EAAE;AACzD,QAAA,QAAQ,EAAE,IAAI;AACf,KAAA,CAAC;IACF,OAAO;AACL,QAAA,GAAG,4BAA4B;AAC/B,QAAA,IAAI,gBAAgB,IAAI,EAAE,CAAC;KAC5B;AACH;;MCuDa,wBAAwB,CAAA;AAIf,IAAA,EAAA;IAFpB,eAAe,GAAG,KAAK,EAAU;AAEjC,IAAA,WAAA,CAAoB,EAAc,EAAA;QAAd,IAAE,CAAA,EAAA,GAAF,EAAE;;;IAItB,eAAe,GAAA;AACb,QAAA,IAAI,IAAI,CAAC,eAAe,EAAE,EAAE;AAC1B,YAAA,MAAM,UAAU,GAAG,IAAI,CAAC,EAAE,CAAC,aAAa,CAAC,aAAa,CAA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A,CAAA,iBAAA,CAAA,EAAA,CAAA,EAAA,eAAA,EAAA,EAAA,CAAA,uBAAA,CAAA,MAAA,EAAA,CAAA;;2FAuMxB,wBAAwB,EAAA,UAAA,EAAA,CAAA;kBArJpC,SAAS;AACC,YAAA,IAAA,EAAA,CAAA,EAAA,OAAA,EAAA;wBACP,YAAY;wBACZ,YAAY;wBACZ,cAAc;wBACd,aAAa;wBACb,kBAAkB;wBAClB,eAAe;wBACf,cAAc;wBACd,wBAAwB;wBACxB,uBAAuB;wBACvB,wBAAwB;AACzB,qBAAA,EAAA,QAAA,EACS,oBAAoB,EACpB,QAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgGT,EAqCgB,eAAA,EAAA,uBAAuB,CAAC,MAAM,EAAA,MAAA,EAAA,CAAA,4XAAA,CAAA,EAAA;iIA+JhB,gBAAgB,EAAA,CAAA;sBAA9C,eAAe;uBAAC,YAAY;gBAsGnB,YAAY,EAAA,CAAA;sBAArB;;;ACxhBH;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"smallpearl-ngx-helper-mat-entity-list.mjs","sources":["../../../../projects/smallpearl/ngx-helper/mat-entity-list/src/mat-entity-list-types.ts","../../../../projects/smallpearl/ngx-helper/mat-entity-list/src/providers.ts","../../../../projects/smallpearl/ngx-helper/mat-entity-list/src/config.ts","../../../../projects/smallpearl/ngx-helper/mat-entity-list/src/mat-entity-list.component.ts","../../../../projects/smallpearl/ngx-helper/mat-entity-list/smallpearl-ngx-helper-mat-entity-list.ts"],"sourcesContent":["import { HttpContextToken } from \"@angular/common/http\";\nimport { Observable } from \"rxjs\";\n\nexport interface SPMatEntityListHttpContext {\n entityName: string;\n entityNamePlural: string;\n endpoint: string;\n}\n\nexport const SP_MAT_ENTITY_LIST_HTTP_CONTEXT =\n new HttpContextToken<SPMatEntityListHttpContext>(() => ({\n entityName: '',\n entityNamePlural: '',\n endpoint: '',\n }));\n\n/**\n * Pagination HTTP request params. Actually copied from Angular's HttpParams\n * declaration. The ReadonlyArray<string|number|boolean> is a bit of an\n * overkill for pagination params, but what the heck. When you copy-paste,\n * do it in full!\n */\nexport type SPPageParams = { [param: string]: string | number | boolean | ReadonlyArray<string | number | boolean>; }\n\n/**\n * An interface that the clients should provide, either via a global config\n * (see above), that handles parsing the GET response and returns the entities\n * stored therein. This class will allow the entity-list component to be\n * used across different pagination response types as long as the appropriate\n * SPMatEntityListPaginator class is provided to the component.\n */\nexport interface SPMatEntityListPaginator {\n /**\n * Return the HTTP request params for the given page index and page size as\n * an object. For example, for a REST API that supports 'skip' and 'top' params,\n * the implementation would be:\n *\n * ```typescript\n * getRequestPageParams(endpoint: string, pageIndex: number, pageSize: number): SPPageParams {\n * return {\n * skip: pageIndex * pageSize,\n * top: pageSize\n * };\n * }\n * ```\n * @param endpoint\n * @param pageIndex\n * @param pageSize\n * @returns\n */\n getRequestPageParams: (endpoint: string, pageIndex: number, pageSize: number) => SPPageParams;\n\n /**\n * Parse the HTTP response received from the GET request and return an object\n * containing the total number of entities available and the array of entities\n * for the current page. For example, for the pure DRF paginated response\n * like below:\n * ```json\n * {\n * \"count\": 102,\n * \"next\": \"http://api.example.org/entities/?page=3\",\n * \"previous\": \"http://api.example.org/entities/?page=1\",\n * \"results\": [\n * {\n * \"id\": 1,\n * \"name\": \"Entity 1\"\n * },\n * {\n * \"id\": 2,\n * \"name\": \"Entity 2\"\n * }\n * ]\n * }\n * ```\n * The implementation would be:\n * ```typescript\n * parseRequestResponse<TEntity extends { [P in IdKey]: PropertyKey }, IdKey extends string = 'id'>(\n * entityName: string,\n * entityNamePlural: string,\n * endpoint: string,\n * params: SPPageParams,\n * resp: any\n * ): { total: number; entities: TEntity[] } {\n * return {\n * total: resp.count,\n * entities: resp.results\n * };\n * }\n * ```\n * @param entityName\n * @param entityNamePlural\n * @param endpoint\n * @param params\n * @param resp\n * @returns\n */\n parseRequestResponse: <\n TEntity extends { [P in IdKey]: PropertyKey },\n IdKey extends string = 'id'\n >(\n entityName: string,\n entityNamePlural: string,\n endpoint: string,\n params: SPPageParams,\n resp: any\n ) => { total: number; entities: TEntity[] };\n}\n\n/**\n * 'entity' is really TEntity arg of SPMatEntityListComponent<TEntity>.\n * 'column' is the column name. This allows the same value function to support\n * multiple columns further enabing DRY.\n */\nexport type COLUMN_VALUE_FN = (entity: any, column: string) => string|number|Date|boolean;\n\n/**\n * Global config for SPMatEntityList component.\n */\nexport interface SPMatEntityListConfig {\n urlResolver?: (endpoint: string) => string;\n paginator?: SPMatEntityListPaginator;\n defaultPageSize?: number;\n pageSizes?: Array<number>;\n /**\n * Provide a method to return the labels for the columns. This is useful when\n * the columns are specified as the JSON object key names and the labels are\n * to be transformed into a uniform manner (uppercase) or when the labels\n * are to be dynamically localized. Note that the response can be an\n * Observable<string> if the label is to be fetched/changed asynchronously\n * (as that can happen in an app that supports dynamic changing of the UI\n * language).\n * @param entityName\n * @param columnName\n * @returns\n */\n columnLabelFn?: (entityName: string, columnName: string) => string | Observable<string>;\n}\n\n/**\n * Type for custom entities loader function, which if provided will be called\n * instead of HttpClient.get.\n */\nexport type SPMatEntityListEntityLoaderFn = (params: any) => Observable<any>;\n","import { InjectionToken } from '@angular/core';\nimport { SPMatEntityListConfig } from './mat-entity-list-types';\n\nexport const SP_MAT_ENTITY_LIST_CONFIG = new InjectionToken<SPMatEntityListConfig>(\n 'SPMatEntityListConfig'\n);\n","import { inject } from '@angular/core';\nimport { SPMatEntityListConfig } from './mat-entity-list-types';\nimport { SP_MAT_ENTITY_LIST_CONFIG } from './providers';\n\nexport const DefaultSPMatEntityListConfig: SPMatEntityListConfig = {\n urlResolver: (endpoint: string) => endpoint,\n paginator: undefined,\n defaultPageSize: 50,\n pageSizes: [10, 25, 50, 100],\n columnLabelFn: (entityName: string, columnName: string) => columnName,\n};\n\n/**\n * To be called from an object's constructor.\n */\nexport function getEntityListConfig(): SPMatEntityListConfig {\n const entityListConfig = inject(SP_MAT_ENTITY_LIST_CONFIG, {\n optional: true,\n });\n return {\n ...DefaultSPMatEntityListConfig,\n ...(entityListConfig ?? {}),\n };\n}\n","import { CommonModule } from '@angular/common';\nimport { HttpClient, HttpContext, HttpContextToken, HttpParams } from '@angular/common/http';\nimport {\n AfterViewInit,\n ChangeDetectionStrategy,\n Component,\n computed,\n ContentChildren,\n Directive,\n effect,\n ElementRef,\n EventEmitter,\n inject,\n Injector,\n input,\n OnDestroy,\n OnInit,\n Output,\n QueryList,\n runInInjectionContext,\n signal,\n viewChild,\n viewChildren\n} from '@angular/core';\nimport { MatButtonModule } from '@angular/material/button';\nimport { MatInputModule } from '@angular/material/input';\nimport { MatPaginatorModule, PageEvent } from '@angular/material/paginator';\nimport { MatProgressSpinnerModule } from '@angular/material/progress-spinner';\nimport { MatSort, MatSortModule } from '@angular/material/sort';\nimport {\n MatColumnDef,\n MatTable,\n MatTableDataSource,\n MatTableModule,\n} from '@angular/material/table';\nimport { DomSanitizer } from '@angular/platform-browser';\nimport { RouterModule } from '@angular/router';\nimport { createStore } from '@ngneat/elf';\nimport {\n addEntities,\n deleteEntities,\n getEntitiesCount,\n hasEntity,\n selectAllEntities,\n updateEntities,\n upsertEntities,\n withEntities,\n} from '@ngneat/elf-entities';\nimport {\n SP_ENTITY_FIELD_CONFIG,\n SPEntityField,\n SPEntityFieldSpec\n} from '@smallpearl/ngx-helper/entity-field';\nimport { InfiniteScrollDirective } from 'ngx-infinite-scroll';\nimport { plural } from 'pluralize';\nimport {\n distinctUntilChanged,\n filter,\n finalize,\n Observable,\n of,\n Subject,\n Subscription,\n switchMap,\n takeUntil,\n tap\n} from 'rxjs';\nimport { getEntityListConfig } from './config';\nimport {\n SP_MAT_ENTITY_LIST_HTTP_CONTEXT,\n SPMatEntityListEntityLoaderFn,\n SPMatEntityListPaginator\n} from './mat-entity-list-types';\n\n@Directive({\n selector: '[headerAlignment]',\n standalone: true\n})\nexport class HeaderAlignmentDirective implements AfterViewInit {\n\n headerAlignment = input<string>();\n\n constructor(private el: ElementRef) {\n // this.el.nativeElement.style.backgroundColor = 'yellow';\n }\n\n ngAfterViewInit(): void {\n if (this.headerAlignment()) {\n const sortHeader = this.el.nativeElement.querySelector('.mat-sort-header-container');\n if (sortHeader) {\n sortHeader.style.justifyContent = this.headerAlignment();\n } else {\n this.el.nativeElement.style.justifyContent = this.headerAlignment();\n }\n }\n }\n}\n\n/**\n * Represents a request to load entities from the remote. This is used to\n * compare two requests to determine if they are equal. This is useful to\n * prevent duplicate requests being sent to the remote.\n */\nclass LoadRequest {\n constructor(\n public endpoint: string,\n public params: HttpParams,\n public force = false\n ) {}\n\n // Returns true if two LoadRequest objects are equal and this object's\n // 'force' is not set to true.\n isEqualToAndNotForced(prev: LoadRequest): boolean {\n // console.log(\n // `isEqualToAndNotForced - ${this.endpoint}, ${this.params.toString()} ${\n // this.force\n // }, other: ${prev.endpoint}, ${prev.params.toString()}, ${prev.force}`\n // );\n return this.force\n ? false\n : this.endpoint.localeCompare(prev.endpoint) === 0 &&\n this.params.toString().localeCompare(prev.params.toString()) === 0;\n }\n}\n\n/**\n * A component to display a list of entities loaded from remote.\n */\n@Component({\n imports: [\n CommonModule,\n RouterModule,\n MatTableModule,\n MatSortModule,\n MatPaginatorModule,\n MatButtonModule,\n MatInputModule,\n MatProgressSpinnerModule,\n InfiniteScrollDirective,\n HeaderAlignmentDirective,\n ],\n selector: 'sp-mat-entity-list',\n template: `\n <div\n class=\"entities-list-wrapper\"\n infiniteScroll\n [infiniteScrollDistance]=\"infiniteScrollDistance()\"\n [infiniteScrollThrottle]=\"infiniteScrollThrottle()\"\n [infiniteScrollContainer]=\"infiniteScrollContainer()\"\n [scrollWindow]=\"infiniteScrollWindow()\"\n [infiniteScrollDisabled]=\"\n pagination() !== 'infinite' || !_paginator || !hasMore()\n \"\n (scrolled)=\"infiniteScrollLoadNextPage($event)\"\n >\n <div\n class=\"busy-overlay\"\n [ngClass]=\"{ show: pagination() === 'discrete' && loading() }\"\n >\n <ng-container *ngTemplateOutlet=\"busySpinner\"></ng-container>\n </div>\n <table mat-table [dataSource]=\"dataSource()\">\n <tr mat-header-row *matHeaderRowDef=\"_displayedColumns()\"></tr>\n <tr\n mat-row\n [class.active-row]=\"activeEntityId() === row[this.idKey()]\"\n *matRowDef=\"let row; columns: _displayedColumns()\"\n (click)=\"toggleActiveEntity(row)\"\n ></tr>\n </table>\n @if (pagination() == 'discrete' && _paginator) {\n <mat-paginator\n showFirstLastButtons\n [length]=\"entityCount()\"\n [pageSize]=\"_pageSize()\"\n [pageIndex]=\"pageIndex()\"\n [pageSizeOptions]=\"[]\"\n [hidePageSize]=\"true\"\n (page)=\"handlePageEvent($event)\"\n [disabled]=\"loading()\"\n aria-label=\"Select page\"\n ></mat-paginator>\n }\n <div\n class=\"infinite-scroll-loading\"\n [ngClass]=\"{ show: pagination() === 'infinite' && loading() }\"\n >\n <ng-container *ngTemplateOutlet=\"busySpinner\"></ng-container>\n </div>\n </div>\n <!-- We keep the column definitions outside the <table> so that they can\n be dynamically added to the MatTable. -->\n <span matSort=\"sorter()\">\n @for (column of __columns(); track $index) {\n <ng-container [matColumnDef]=\"column.spec.name\">\n @if (disableSort()) {\n <th\n [class]=\"column.class\"\n [headerAlignment]=\"column.options.alignment\"\n mat-header-cell\n *matHeaderCellDef\n >\n {{ getColumnLabel(column) | async }}\n </th>\n } @else {\n <th\n [class]=\"column.class\"\n [headerAlignment]=\"column.options.alignment\"\n mat-header-cell\n mat-sort-header\n *matHeaderCellDef\n >\n {{ getColumnLabel(column) | async }}\n </th>\n }\n <td\n [class]=\"column.class\"\n [style.text-align]=\"column.options.alignment\"\n mat-cell\n *matCellDef=\"let element\"\n [routerLink]=\"column.getRouterLink(element)\"\n >\n @if (column.hasRouterLink(element)) {\n <a [routerLink]=\"column.getRouterLink(element)\">\n <span [innerHTML]=\"column.value(element)\"></span>\n </a>\n } @else { @let val = column.value(element);\n <span [innerHTML]=\"isAsync(val) ? (val | async) : val\"></span>\n }\n </td>\n </ng-container>\n }\n </span>\n <ng-template #busySpinner>\n <div class=\"busy-spinner\">\n <mat-spinner mode=\"indeterminate\" diameter=\"28\"></mat-spinner>\n </div>\n </ng-template>\n `,\n styles: [\n `\n .entities-list-wrapper {\n position: relative;\n }\n .busy-overlay {\n display: none;\n height: 100%;\n width: 100%;\n position: absolute;\n top: 0px;\n left: 0px;\n z-index: 1000;\n opacity: 0.6;\n background-color: transparent;\n }\n .show {\n display: block;\n }\n .busy-spinner {\n width: 100%;\n height: 100%;\n display: flex;\n align-items: center;\n justify-content: center;\n }\n .infinite-scroll-loading {\n display: none;\n width: 100%;\n padding: 8px;\n }\n .active-row {\n font-weight: bold;\n }\n `,\n ],\n changeDetection: ChangeDetectionStrategy.OnPush,\n})\nexport class SPMatEntityListComponent<\n TEntity extends { [P in IdKey]: PropertyKey },\n IdKey extends string = 'id'\n> implements OnInit, OnDestroy, AfterViewInit\n{\n /* CLIENT PROVIDED PARAMETERS */\n entityName = input.required<string>();\n entityNamePlural = input<string>();\n\n /**\n * The endpoint from where the entities are to be retrieved\n */\n endpoint = input<string>('');\n /**\n * Custom entities loader function, which if provided will be called\n * instead of HttpClient.get.\n */\n entityLoaderFn = input<SPMatEntityListEntityLoaderFn | undefined>(undefined);\n /**\n * The columns of the entity to be displayed. This is an array of\n * SPEntityFieldSpec objects. If there's a one-to-one mapping between the\n * column's field name, its title & the rendered value, a string can be\n * specified instead. That is, the value of this property is a heterogeneous\n * array consisting of SPEntityFieldSpec<> objects and strings.\n */\n columns = input<Array<SPEntityFieldSpec<TEntity, IdKey> | string>>([]);\n\n /**\n * Names of columns that are displayed. This will default to all the columns\n * listed in columns.\n */\n displayedColumns = input<string[]>([]); // ['name', 'cell', 'gender'];\n\n /**\n * Number of entities per page. If this is not set and paginator is defined,\n * the number of entities int in the first request, will be taken as the\n * page size.\n */\n pageSize = input<number>(0);\n /**\n * Entity idKey, if idKey is different from the default 'id'.\n */\n idKey = input<string>('id');\n /**\n * Type of pagination -- continuous or discrete. 'infinite' pagination\n * uses an 'infiniteScroll' and 'discrete' pagination uses a mat-paginator\n * at the bottom to navigate between pages.\n */\n pagination = input<'infinite' | 'discrete' | 'none'>('discrete');\n /**\n * Component specific paginator. Only used if pagination != 'none'.\n */\n paginator = input<SPMatEntityListPaginator>();\n /**\n *\n */\n sorter = input<MatSort>();\n /**\n * Disable sorting of rows\n */\n disableSort = input<boolean>(false);\n /**\n * Wrappers for infiniteScroll properties, for customization by the client\n */\n infiniteScrollContainer = input<any>('');\n infiniteScrollDistance = input<number>(1);\n infiniteScrollThrottle = input<number>(400);\n infiniteScrollWindow = input<boolean>(false);\n /**\n * Custom context to be set for HttpClient requests. Value for this attribute\n * can be an array of HttpContextToken key, value pairs, or an instance of\n * HttpContext.\n *\n * In the client code specify this property by initializing a member variable\n * as:\n\n ```\n Component({\n ...\n template: `\n <sp-mat-entity-list\n [httpReqContext]=\"httpReqContext\"\n ></sp-mat-entity-list>\n `\n })\n export class YourComponent {\n httpReqContext: [HttpContextToken<any>, any] = [\n MY_CONTEXT_TOKEN, 'customers'\n ];\n // Or [httpReqContext]=\"httpReqContext2\" will work too.\n httpReqContext2: HttpContext = new HttpContext().set(\n MY_CONTEXT_TOKEN, 'customers'\n );\n }\n ```\n *\n * Of course if you want to pass multiple context properties, declare the type\n * as an array of array. That is, `[[HttpContextToken<any>, any]]` and\n * initialize it appropriately.\n */\n httpReqContext = input<\n [[HttpContextToken<any>, any]] | [HttpContextToken<any>, any] | HttpContext | undefined\n >();\n /* END CLIENT PROVIDED PARAMETERS */\n\n // *** INTERNAL *** //\n _entityNamePlural = computed(() =>\n this.entityNamePlural()\n ? this.entityNamePlural()\n : plural(this.entityName())\n );\n\n _httpReqContext = computed(() => {\n let reqContext = this.httpReqContext();\n let context = new HttpContext();\n if (reqContext instanceof HttpContext) {\n // Copy existing context values\n for (const key of reqContext.keys()) {\n context.set(key, reqContext.get(key));\n }\n } else {\n if (reqContext && Array.isArray(reqContext)) {\n if (reqContext.length == 2 && !Array.isArray(reqContext[0])) {\n // one dimensional array of a key, value pair.\n context.set(reqContext[0], reqContext[1]);\n } else {\n reqContext.forEach(([k, v]) => context.set(k, v));\n }\n }\n }\n\n // Add mandatory SP_MAT_ENTITY_LIST_HTTP_CONTEXT context token\n if (!context.has(SP_MAT_ENTITY_LIST_HTTP_CONTEXT)) {\n context.set(SP_MAT_ENTITY_LIST_HTTP_CONTEXT, {\n entityName: this.entityName(),\n entityNamePlural: this._entityNamePlural(),\n endpoint: this.endpoint(),\n });\n }\n return context;\n });\n deferViewInit = input<boolean>(false);\n firstLoadDone = false;\n allColumnNames = signal<string[]>([]);\n _displayedColumns = computed(() =>\n this.displayedColumns().length > 0\n ? this.displayedColumns().filter(\n (colName) =>\n this.allColumnNames().find((name) => name === colName) !== undefined\n )\n : this.allColumnNames()\n );\n dataSource = signal<MatTableDataSource<TEntity>>(\n new MatTableDataSource<TEntity>()\n );\n\n table = viewChild(MatTable);\n sort = viewChild(MatSort);\n // These are our own <ng-container matColumnDef></ng-container>\n // which we create for each column that we create by the declaration:\n // <ng-container *ngFor=\"let column of columns()\" [matColumnDef]=\"column.name\">\n viewColumnDefs = viewChildren(MatColumnDef);\n // These are the <ng-container matColumnDef></ng-container> placed\n // inside <sp-mat-entity-list></<sp-mat-entity-list> by the client to override\n // the default <ng-container matColumnDef> created by the component.\n @ContentChildren(MatColumnDef) clientColumnDefs!: QueryList<MatColumnDef>;\n\n contentColumnDefs: MatColumnDef[] = [];\n\n subs$ = new Subscription();\n destroy$ = new Subject<void>();\n\n // Pagination state\n entityCount = signal<number>(0);\n pageIndex = signal<number>(0);\n\n // Mechanism to default pageSize to last entities length.\n lastFetchedEntitiesCount = signal<number>(0);\n _pageSize = computed<number>(() =>\n this.pageSize()\n ? this.pageSize()\n : this.entityListConfig.defaultPageSize ?? this.lastFetchedEntitiesCount()\n );\n // Effective columns, derived from columns(), which can either be an array\n // of objects of array of strings.\n _columns = computed<SPEntityFieldSpec<TEntity, IdKey>[]>(() => {\n const columns = this.columns();\n let fields: SPEntityField<TEntity, IdKey>[] = [];\n let cols: SPEntityFieldSpec<TEntity, IdKey>[] = [];\n columns.forEach((colDef) => {\n // fields.push(new SPEntityField(colDef))\n if (typeof colDef === 'string') {\n cols.push({ name: String(colDef) });\n } else if (typeof colDef === 'object') {\n cols.push(colDef as SPEntityFieldSpec<TEntity, IdKey>);\n }\n });\n return cols;\n });\n\n __columns = computed<SPEntityField<TEntity, IdKey>[]>(() =>\n this.columns().map(\n (colDef) => new SPEntityField<TEntity, IdKey>(colDef, this.fieldConfig)\n )\n );\n\n // We isolate retrieving items from the remote and providing the items\n // to the component into two distinct operations. The retrieval operation\n // retrieves data asynchronously and then stores the data in a local store.\n // The UI would be 'listening' to a reactive callback that would be triggered\n // whenever items in the store changes. This is because store is an immutable\n // data structure and any changes (addition/deletion) to it would result in\n // the entire store being replaced with a copy with the changes applied.\n\n // Ideally we should declare this as\n // store!: Store<...>. But @ngneat/elf does not provide a generic type\n // for Store<...>, which can be composed from its type arguments. Instead it\n // uses type composition using its arguments to generate store's type\n // implicitly. So we use the same mechanism to enforce type safety in our\n // code. The code below results in a type declaration for store that is\n // dependent on the components generic arguments. (Making use of TypeScript's\n // type deduction system from variable assignment). Later on in the\n // constructor we reassign this.store with a new object that uses the\n // client provided idKey() value as the identifying key for each entity in\n // the sore.\n store = createStore(\n { name: Math.random().toString(36).slice(2) },\n withEntities<TEntity, IdKey>({ idKey: this.idKey() as IdKey })\n );\n // We'll initialize this in ngOnInit() when 'store' is initialized with the\n // correct TEntity store that can be safely indexed using IdKey.\n entities$!: Observable<TEntity[]>;\n // Effective paginator, coalescing local paginator and paginator from global\n // config.\n _paginator!: SPMatEntityListPaginator | undefined;\n // We will toggle this during every entity load.\n loading = signal<boolean>(false);\n // We will update this after every load and pagination() == 'infinite'\n hasMore = signal<boolean>(true);\n\n activeEntity = signal<TEntity | undefined>(undefined);\n activeEntityId = computed(() =>\n this.activeEntity() ? (this.activeEntity() as any)[this.idKey()] : undefined\n );\n _prevActiveEntity!: TEntity | undefined;\n _activeEntityChange = effect(() => {\n runInInjectionContext(this.injector, () => {\n const activeEntity = this.activeEntity();\n // Though we can raise the selectEntity event directly from effect handler,\n // that would prevent the event handler from being able to update any\n // signals from inside it. So we generate the event asyncronously.\n // Also, this effect handler will be invoked for the initial 'undefined'\n // during which we shouldn't emit the selectEntity event. Therefore we\n // keep another state variable to filter out this state.\n if (activeEntity || this._prevActiveEntity) {\n setTimeout(() => {\n this._prevActiveEntity = activeEntity;\n this.selectEntity.emit(activeEntity);\n // if (this._prevActiveEntity && !activeEntity) {\n // this.selectEntity.emit(activeEntity);\n // } else if (activeEntity) {\n // this.selectEntity.emit(activeEntity);\n // }\n });\n }\n });\n });\n @Output() selectEntity = new EventEmitter<TEntity | undefined>();\n\n fieldConfig = inject(SP_ENTITY_FIELD_CONFIG, { optional: true })!;\n entityListConfig = getEntityListConfig();\n\n /**\n * A signal that can be used to trigger loading of more entities from the\n * remote. This can be visualized as the event loop of the entity list\n * component.\n */\n loadRequest$ = new Subject<LoadRequest>();\n\n endpointChanged = effect(() => {\n runInInjectionContext(this.injector, () => {\n if (this.endpoint()) {\n // console.log(`endpointChanged - ${this.endpoint()}`);\n setTimeout(() => {\n this.refresh();\n });\n }\n });\n });\n\n constructor(\n protected http: HttpClient,\n private sanitizer: DomSanitizer,\n private injector: Injector\n ) {}\n\n ngOnInit() {\n // This is the reactive callback that listens for changes to table entities\n // which are reflected in the mat-table.\n this.store = createStore(\n { name: Math.random().toString(36).slice(2) },\n withEntities<TEntity, IdKey>({ idKey: this.idKey() as IdKey })\n );\n this.entities$ = this.store.pipe(selectAllEntities());\n this._paginator = this.paginator()\n ? this.paginator()\n : this.entityListConfig?.paginator;\n\n this.entities$\n .pipe(\n takeUntil(this.destroy$),\n tap((entities) => {\n // .data is a setter property, which ought to trigger the necessary\n // signals resulting in mat-table picking up the changes without\n // requiring us to call cdr.detectChanges() explicitly.\n this.dataSource().data = entities;\n })\n )\n .subscribe();\n\n this.loadRequest$\n .pipe(\n takeUntil(this.destroy$),\n filter((lr) => lr.endpoint !== '' || lr.force === true),\n distinctUntilChanged((prev, current) =>\n current.isEqualToAndNotForced(prev)\n ),\n switchMap((lr: LoadRequest) => this.doActualLoad(lr))\n )\n .subscribe();\n }\n\n ngOnDestroy(): void {\n this.destroy$.next();\n this.destroy$.complete();\n }\n\n ngAfterViewInit(): void {\n if (!this.deferViewInit()) {\n this.buildContentColumnDefs();\n this.buildColumns();\n this.setupSort();\n this.loadMoreEntities();\n }\n }\n\n /**\n * Clear all entities in store and reload them from endpoint as if\n * the entities are being loaded for the first time.\n */\n refresh(force = false) {\n this.pageIndex.set(0);\n this.loadMoreEntities(force);\n }\n\n addEntity(entity: TEntity) {\n const pagination = this.pagination();\n const count = this.store.query(getEntitiesCount());\n if (\n pagination === 'infinite' ||\n pagination === 'none' ||\n count < this._pageSize()\n ) {\n this.store.update(addEntities(entity));\n } else {\n // 'discrete' pagination, refresh the crud items from the beginning.\n // Let component client set the behavior using a property\n // this.pageIndex.set(0);\n // this.loadMoreEntities();\n }\n }\n\n /**\n * Update an entity with a modified version. Can be used by CRUD UPDATE\n * operation to update an entity in the local store that is used to as the\n * source of MatTableDataSource.\n * @param id\n * @param entity\n */\n updateEntity(id: TEntity[IdKey], entity: TEntity) {\n if (this.store.query(hasEntity(id))) {\n this.store.update(updateEntities(id, entity));\n }\n }\n\n /**\n * Clients can call this method when it has deleted and entity via a CRUD\n * operation. Depending on the pagination mode, MatEntityList implements\n * an appropriate behavior.\n *\n * If the pagination is 'infinite', the relevent entity is removed from our\n * entity list. View will be repained as data store has changed.\n *\n * If the pagination is 'discrete', the entity is removed from the page.\n * If this is the only entity in the page, the current pageNumber is\n * decremented by 1 if it's possible (if the current pageNumber > 1).\n * The page is reloaded from remote.\n */\n removeEntity(id: TEntity[IdKey]) {\n const paginator = this._paginator;\n if (paginator) {\n if (this.pagination() === 'infinite') {\n // This will cause store to mutate which will trigger this.entity$ to\n // emit which in turn will update our MatTableDataSource instance.\n this.store.update(deleteEntities(id));\n } else {\n // Logic\n this.store.update(deleteEntities(id));\n const count = this.store.query(getEntitiesCount());\n if (count == 0) {\n // No more entities in this page\n // Go back one page\n if (this.pageIndex() > 0) {\n this.pageIndex.set(this.pageIndex() - 1);\n }\n }\n // load the page again\n this.loadMoreEntities();\n }\n } else {\n // Just remove the entity that has been deleted.\n this.store.update(deleteEntities(id));\n }\n }\n\n /**\n * Build the contentColumnDefs array by enumerating all of client's projected\n * content with matColumnDef directive.\n */\n buildContentColumnDefs() {\n const clientColumnDefs = this.clientColumnDefs;\n if (clientColumnDefs) {\n this.contentColumnDefs = clientColumnDefs.toArray();\n }\n }\n\n /**\n * Build the effective columns by parsing our own <ng-container matColumnDef>\n * statements for each column in columns() property and client's\n * <ng-container matColumnDef> provided via content projection.\n */\n buildColumns() {\n const matTable = this.table();\n\n if (matTable) {\n const columnNames = new Set<string>();\n const columnDefs: MatColumnDef[] = [];\n\n this._columns().forEach((colDef) => {\n if (!columnNames.has(colDef.name)) {\n const matColDef = this.viewColumnDefs().find(\n (cd) => cd.name === colDef.name\n );\n const clientColDef = this.contentColumnDefs.find(\n (cd) => cd.name === colDef.name\n );\n const columnDef = clientColDef ? clientColDef : matColDef;\n if (columnDef) {\n columnDefs.push(columnDef);\n columnNames.add(colDef.name);\n }\n }\n });\n columnDefs.forEach((cd) => {\n matTable.addColumnDef(cd);\n });\n\n this.allColumnNames.set(Array.from(columnNames));\n // this.displayedColumns.set(Array.from(columnNames) as string[]);\n }\n }\n\n setupSort() {\n const matSort = this.sort();\n if (matSort) {\n this.dataSource().sort = matSort;\n }\n }\n\n infiniteScrollLoadNextPage(ev: any) {\n // console.log(`infiniteScrollLoadNextPage - ${JSON.stringify(ev)}`);\n if (this._paginator) {\n this.loadMoreEntities();\n }\n }\n\n loadMoreEntities(forceRefresh = false) {\n this.loadRequest$.next(this.createNextLoadRequest(forceRefresh));\n }\n\n /**\n * Creates a LoadRequest object for loading entities using the current state\n * of the component. Therefore, if the request is for next page of entities,\n * the LoadRequest object will have the updated page index. However, if\n * pagination has been reset (refer to refresh()), the LoadRequest object\n * will be for the first page of data. Note that when 'endpoint' value\n * changes, the component's pagination state is reset causing a refresh()\n * to be called, which in turn will create a new LoadRequest object for the\n * first page of data.\n * @returns LoadRequest object for the next load request.\n */\n private createNextLoadRequest(forceRefresh: boolean): LoadRequest {\n let pageParams = {};\n const parts = this.endpoint().split('?');\n const endpoint = parts[0];\n if (this._paginator) {\n pageParams = this._paginator.getRequestPageParams(\n endpoint,\n this.pageIndex(),\n this.pageSize()\n );\n }\n let httpParams = new HttpParams();\n for (const key in pageParams) {\n httpParams = httpParams.append(key, (pageParams as any)[key]);\n }\n if (parts.length > 1) {\n const embeddedParams = new HttpParams({ fromString: parts[1] });\n embeddedParams.keys().forEach((key) => {\n const value = embeddedParams.getAll(key);\n (value || []).forEach((v) => {\n httpParams = httpParams.append(key, v);\n });\n });\n }\n return new LoadRequest(\n endpoint,\n httpParams,\n forceRefresh || !!this.entityLoaderFn()\n );\n }\n\n /**\n * Does the actual load of entities from the remote or via calling the\n * entityLoaderFn. This method is the workhorse of the entity list\n * 'loader-loop'.\n * @param lr\n * @returns Observable that emits the response from the remote or from\n * entityLoaderFn().\n */\n private doActualLoad(lr: LoadRequest) {\n // console.log(`doActualLoad - endpoint: ${lr.endpoint}, params: ${lr.params.toString()}`);\n const loaderFn = this.entityLoaderFn();\n const params = lr.params;\n const obs =\n loaderFn !== undefined\n ? loaderFn({ params })\n : this.http.get<any>(this.getUrl(lr.endpoint), {\n context: this._httpReqContext(),\n params,\n });\n\n this.loading.set(true);\n return obs.pipe(\n tap((resp) => {\n // TODO: defer this to a pagination provider so that we can support\n // many types of pagination. DRF itself has different schemes. And\n // express may have yet another pagination protocol.\n this.firstLoadDone = true;\n if (this._paginator) {\n // Convert HttpParams to JS object\n const paramsObj: any = {};\n params.keys().forEach((key) => {\n paramsObj[key] = params.get(key);\n });\n const { entities, total } = this._paginator.parseRequestResponse(\n this.entityName(),\n this._entityNamePlural()!,\n this.endpoint(),\n paramsObj,\n resp\n );\n this.entityCount.set(total);\n this.lastFetchedEntitiesCount.set(entities.length);\n // this.pageIndex.set(this.pageIndex() + 1)\n // entities = this._paginator.getEntitiesFromResponse(entities);\n if (this.pagination() === 'discrete') {\n this.store.reset();\n } else if (this.pagination() === 'infinite') {\n const pageSize = this._pageSize();\n const entityCount = this.entityCount();\n if (pageSize > 0) {\n const pageCount =\n Math.floor(entityCount / pageSize) +\n (entityCount % pageSize ? 1 : 0);\n this.hasMore.set(this.pageIndex() === pageCount);\n } else {\n this.hasMore.set(false);\n }\n }\n // store the entities in the store\n // TODO: remove as any\n this.store.update(upsertEntities(entities as any));\n } else {\n this.store.update(\n upsertEntities(this.findArrayInResult(resp) as TEntity[])\n );\n }\n }),\n finalize(() => this.loading.set(false))\n );\n }\n\n private findArrayInResult(res: any): any[] | undefined {\n if (Array.isArray(res)) {\n return res;\n }\n for (const key in res) {\n if (Object.prototype.hasOwnProperty.call(res, key)) {\n const element = res[key];\n if (Array.isArray(element)) {\n return element;\n }\n }\n }\n return [];\n }\n\n handlePageEvent(e: PageEvent) {\n this.pageIndex.set(e.pageIndex);\n this.loadMoreEntities();\n }\n\n getUrl(endpoint: string) {\n return this.entityListConfig?.urlResolver\n ? this.entityListConfig?.urlResolver(endpoint)\n : endpoint;\n }\n\n toggleActiveEntity(entity: TEntity | undefined) {\n if (entity) {\n if (entity === this.activeEntity()) {\n this.activeEntity.set(undefined);\n } else {\n this.activeEntity.set(entity);\n }\n } else {\n this.activeEntity.set(undefined);\n }\n }\n\n getColumnLabel(field: SPEntityField<TEntity, IdKey>): Observable<string> {\n if (field._fieldSpec.label) {\n return field._fieldSpec.label instanceof Observable\n ? field._fieldSpec.label\n : of(field._fieldSpec.label);\n }\n if (this.entityListConfig && this.entityListConfig.columnLabelFn) {\n const label = this.entityListConfig.columnLabelFn(\n this.entityName(),\n field._fieldSpec.name\n );\n return label instanceof Observable ? label : of(label);\n }\n return of(field._fieldSpec.name);\n }\n\n isAsync(val: any) {\n return val instanceof Observable;\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AASa,MAAA,+BAA+B,GAC1C,IAAI,gBAAgB,CAA6B,OAAO;AACtD,IAAA,UAAU,EAAE,EAAE;AACd,IAAA,gBAAgB,EAAE,EAAE;AACpB,IAAA,QAAQ,EAAE,EAAE;AACb,CAAA,CAAC;;MCXS,yBAAyB,GAAG,IAAI,cAAc,CACzD,uBAAuB;;ACAlB,MAAM,4BAA4B,GAA0B;AACjE,IAAA,WAAW,EAAE,CAAC,QAAgB,KAAK,QAAQ;AAC3C,IAAA,SAAS,EAAE,SAAS;AACpB,IAAA,eAAe,EAAE,EAAE;IACnB,SAAS,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,CAAC;IAC5B,aAAa,EAAE,CAAC,UAAkB,EAAE,UAAkB,KAAK,UAAU;CACtE;AAED;;AAEG;SACa,mBAAmB,GAAA;AACjC,IAAA,MAAM,gBAAgB,GAAG,MAAM,CAAC,yBAAyB,EAAE;AACzD,QAAA,QAAQ,EAAE,IAAI;AACf,KAAA,CAAC;IACF,OAAO;AACL,QAAA,GAAG,4BAA4B;AAC/B,QAAA,IAAI,gBAAgB,IAAI,EAAE,CAAC;KAC5B;AACH;;MCuDa,wBAAwB,CAAA;AAIf,IAAA,EAAA;IAFpB,eAAe,GAAG,KAAK,EAAU;AAEjC,IAAA,WAAA,CAAoB,EAAc,EAAA;QAAd,IAAE,CAAA,EAAA,GAAF,EAAE;;;IAItB,eAAe,GAAA;AACb,QAAA,IAAI,IAAI,CAAC,eAAe,EAAE,EAAE;AAC1B,YAAA,MAAM,UAAU,GAAG,IAAI,CAAC,EAAE,CAAC,aAAa,CAAC,aAAa,CAAC,4BAA4B,CAAC;YACpF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AA,UAAA,EAAA,aAAA,CAAA,EAAA,QAAA,EAAA,CAAA,oBAAA,CAAA,EAAA,EAAA,EAAA,IAAA,EAAA,WAAA,EAAA,IAAA,EAAA,uBAAuB,0WA5Dd,wBAAwB,EAAA,QAAA,EAAA,mBAAA,EAAA,MAAA,EAAA,CAAA,iBAAA,CAAA,EAAA,CAAA,EAAA,eAAA,EAAA,EAAA,CAAA,uBAAA,CAAA,MAAA,EAAA,CAAA;;2FAuMxB,wBAAwB,EAAA,UAAA,EAAA,CAAA;kBArJpC,SAAS;AACC,YAAA,IAAA,EAAA,CAAA,EAAA,OAAA,EAAA;wBACP,YAAY;wBACZ,YAAY;wBACZ,cAAc;wBACd,aAAa;wBACb,kBAAkB;wBAClB,eAAe;wBACf,cAAc;wBACd,wBAAwB;wBACxB,uBAAuB;wBACvB,wBAAwB;AACzB,qBAAA,EAAA,QAAA,EACS,oBAAoB,EACpB,QAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgGT,EAqCgB,eAAA,EAAA,uBAAuB,CAAC,MAAM,EAAA,MAAA,EAAA,CAAA,4XAAA,CAAA,EAAA;iIAuKhB,gBAAgB,EAAA,CAAA;sBAA9C,eAAe;uBAAC,YAAY;gBAsGnB,YAAY,EAAA,CAAA;sBAArB;;;AChiBH;;AAEG;;;;"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { singular, plural } from 'pluralize';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* A function merge sideloaded content into the main object thereby returning
|
|
4
|
+
* A function to merge sideloaded content into the main object thereby returning
|
|
5
5
|
* a composite object.
|
|
6
|
+
*
|
|
6
7
|
* @param resp - the JSON response object, typically received from remote for
|
|
7
8
|
* an HTTP request.
|
|
8
9
|
* @param targetObjKey - the key name of the target object into which the
|
|
@@ -14,20 +15,18 @@ import { singular, plural } from 'pluralize';
|
|
|
14
15
|
* element the sideload data element's key. This is useful when the the
|
|
15
16
|
* target objet's property name that is to be merged with sideload data do not
|
|
16
17
|
* match.
|
|
17
|
-
* @returns
|
|
18
|
+
* @returns Object with sideloaded data merged into the target object.
|
|
18
19
|
*/
|
|
19
20
|
function sideloadToComposite(resp, targetObjKey, idKey = 'id', mergeStrategy = 'append', appendObjSuffix = 'Detail', sideloadDataMap) {
|
|
20
21
|
if (typeof resp !== 'object' && !Array.isArray(resp)) {
|
|
21
22
|
return;
|
|
22
23
|
}
|
|
23
|
-
const
|
|
24
|
+
const targetObjKeySingular = singular(targetObjKey);
|
|
25
|
+
const targetObjKeyPlural = plural(targetObjKey);
|
|
24
26
|
const targetObjResponse = resp[targetObjKey];
|
|
25
27
|
if (!targetObjResponse) {
|
|
26
28
|
return;
|
|
27
29
|
}
|
|
28
|
-
// all sideload keys, except the targetObjKey
|
|
29
|
-
allRespKeys.splice(allRespKeys.findIndex((k) => k === targetObjKey), 1);
|
|
30
|
-
const allRespKeysSingular = allRespKeys.map(k => singular(k));
|
|
31
30
|
// Normalize single target object into an array to simplify handling
|
|
32
31
|
let entities = Array.isArray(targetObjResponse)
|
|
33
32
|
? targetObjResponse
|
|
@@ -101,7 +100,13 @@ function sideloadToComposite(resp, targetObjKey, idKey = 'id', mergeStrategy = '
|
|
|
101
100
|
*/
|
|
102
101
|
const mergeSideloadIntoObject = (obj, mergeStrategy, appendObjSuffix = 'Detail') => {
|
|
103
102
|
for (const key in obj) {
|
|
104
|
-
if (
|
|
103
|
+
if (
|
|
104
|
+
// This check is needed to avoid infinite recursion, if one of the inner
|
|
105
|
+
// objects has a key matching the targetObjKey's singular or plural form.
|
|
106
|
+
key === targetObjKeySingular ||
|
|
107
|
+
key === targetObjKeyPlural ||
|
|
108
|
+
!Object.prototype.hasOwnProperty.call(obj, key) ||
|
|
109
|
+
KEYS_TO_SKIP.has(key)) {
|
|
105
110
|
continue;
|
|
106
111
|
}
|
|
107
112
|
const value = obj[key];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"smallpearl-ngx-helper-sideload.mjs","sources":["../../../../projects/smallpearl/ngx-helper/sideload/src/sideload.ts","../../../../projects/smallpearl/ngx-helper/sideload/smallpearl-ngx-helper-sideload.ts"],"sourcesContent":["import { plural, singular } from 'pluralize';\n\n/**\n * A function merge sideloaded content into the main object thereby returning\n * a composite object.\n * @param resp - the JSON response object, typically received from remote for\n * an HTTP request.\n * @param targetObjKey - the key name of the target object into which the\n * sideloaded data are to be merged.\n * @param idKey - idKey. Function assumes that all the objects use the same\n * key name as the unique object identifier.\n * @param sideloadDataMap: An array of [string, string], where the first\n * element specifies the property name of the target object and the second\n * element the sideload data element's key. This is useful when the the\n * target objet's property name that is to be merged with sideload data do not\n * match.\n * @returns\n */\nexport function sideloadToComposite(\n resp: any,\n targetObjKey: string,\n idKey: string = 'id',\n mergeStrategy: 'inplace' | 'append' = 'append',\n appendObjSuffix: string = 'Detail',\n sideloadDataMap?: Array<[string, string, string?]>\n) {\n if (typeof resp !== 'object' && !Array.isArray(resp)) {\n return;\n }\n\n const allRespKeys = Object.keys(resp);\n const targetObjResponse = resp[targetObjKey];\n if (!targetObjResponse) {\n return;\n }\n\n // all sideload keys, except the targetObjKey\n allRespKeys.splice(\n allRespKeys.findIndex((k) => k === targetObjKey),\n 1\n );\n const allRespKeysSingular = allRespKeys.map(k => singular(k));\n\n // Normalize single target object into an array to simplify handling\n let entities: Array<any> = Array.isArray(targetObjResponse)\n ? targetObjResponse\n : [targetObjResponse];\n\n // standard keys that'll never be merged with sideloaded content\n const KEYS_TO_SKIP = new Set([\n 'id',\n 'number',\n 'date',\n 'time',\n 'timestamp',\n 'modified',\n 'created',\n 'createdAt',\n 'updatedAt',\n 'updated',\n 'description',\n 'notes',\n 'desc',\n 'description',\n 'name',\n 'firstName',\n 'lastName',\n 'fullName',\n 'email',\n 'telephone',\n 'phone',\n 'mobile',\n 'address',\n 'title',\n 'content',\n ]);\n if (idKey) {\n KEYS_TO_SKIP.add(idKey);\n }\n const getSideloadPluralKey = (key: string) => {\n if (sideloadDataMap) {\n const entry = sideloadDataMap.find(([objKey]) => objKey === key);\n if (entry?.[1]) return entry[1];\n }\n // Prefer actual response keys to avoid pluralization mismatches\n if (resp.hasOwnProperty(key)) return key;\n const pluralKey = plural(key);\n if (resp.hasOwnProperty(pluralKey)) return pluralKey;\n return pluralKey;\n };\n const getSideloadDataKey = (key: string): string => {\n if (sideloadDataMap) {\n const entry = sideloadDataMap.find(([objKey]) => objKey === key);\n // Prefer explicit sideload data key if provided, else fallback to idKey\n if (entry) {\n return entry[2] ?? idKey;\n }\n }\n return idKey;\n };\n const isEntityKeyType = (value: string) =>\n typeof value === 'string' || typeof value === 'number';\n\n /**\n * Given an object, enumerates all keys of the object and for any key with\n * a matching sideload value, merges that into the 'obj', either by\n * replacing the matching key's value or by appending it as a new property.\n * If the value of a property is an object, recurses with the object as\n * first argument.\n * @param obj\n * @param mergeStrategy\n * @param appendObjSuffix\n * @returns\n */\n const mergeSideloadIntoObject = (\n obj: any,\n mergeStrategy: 'inplace' | 'append',\n appendObjSuffix: string = 'Detail'\n ) => {\n for (const key in obj) {\n if (!Object.prototype.hasOwnProperty.call(obj, key) || KEYS_TO_SKIP.has(key)) {\n continue;\n }\n const value = obj[key];\n\n // Helper to get sideload data array for a key\n const getSideloadArray = (keyPlural: string) => {\n const data = resp[keyPlural];\n if (Array.isArray(data)) return data;\n if (data != null) return [data];\n return [];\n };\n\n if (Array.isArray(value) && value.length > 0) {\n if (isEntityKeyType(value[0])) {\n // Array of ids: merge sideloaded objects\n const keyPlural = getSideloadPluralKey(key);\n const sideloadId = getSideloadDataKey(key);\n const sideloadData = getSideloadArray(keyPlural);\n const matchingSideloadObjs = sideloadData.filter((so: any) =>\n value.includes(so?.[sideloadId])\n );\n if (matchingSideloadObjs.length > 0) {\n const targetKey =\n mergeStrategy === 'inplace'\n ? key\n : `${singular(key)}${appendObjSuffix}s`;\n obj[targetKey] = mergeSideloadIntoObjects(\n matchingSideloadObjs,\n mergeStrategy,\n appendObjSuffix\n );\n }\n } else {\n // Array of objects: recurse\n value.forEach((item: any) => {\n if (typeof item === 'object' && item !== null) {\n mergeSideloadIntoObject(item, mergeStrategy, appendObjSuffix);\n }\n });\n }\n } else if (typeof value === 'object' && value !== null && !Array.isArray(value)) {\n // Nested object: recurse\n mergeSideloadIntoObject(value, mergeStrategy, appendObjSuffix);\n } else if (isEntityKeyType(value)) {\n const keyPlural = getSideloadPluralKey(key);\n const sideloadId = getSideloadDataKey(key);\n const sideloadData = getSideloadArray(keyPlural);\n // The second check avoids duplicate merging of sideload data\n if (sideloadData.length > 0 && !Object.prototype.hasOwnProperty.call(obj, keyPlural)) {\n const matchingSideloadObj = sideloadData.find(\n (so: any) => so?.[sideloadId] === value\n );\n\n // Merge any FKs in the inner object with their sideloaded data\n const compositeSideloadObj = mergeSideloadIntoObject(\n matchingSideloadObj || {},\n mergeStrategy,\n appendObjSuffix\n );\n if (compositeSideloadObj) {\n const targetKey =\n mergeStrategy === 'inplace'\n ? key\n : `${singular(key)}${appendObjSuffix}`;\n obj[targetKey] = { ...compositeSideloadObj };\n }\n // if (matchingSideloadObj) {\n // const targetKey =\n // mergeStrategy === 'inplace'\n // ? key\n // : `${singular(key)}${appendObjSuffix}`;\n // obj[targetKey] = { ...matchingSideloadObj };\n // }\n }\n }\n }\n return obj;\n };\n\n const mergeSideloadIntoObjects = (objs: Array<any>, mergeStrategy: 'inplace' | 'append', appendObjSuffix: string) => {\n return objs.map((obj) => {\n return mergeSideloadIntoObject(obj, mergeStrategy, appendObjSuffix);\n });\n };\n\n mergeSideloadIntoObjects(entities, mergeStrategy, appendObjSuffix);\n return resp[targetObjKey];\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;AAEA;;;;;;;;;;;;;;;AAeG;SACa,mBAAmB,CACjC,IAAS,EACT,YAAoB,EACpB,KAAA,GAAgB,IAAI,EACp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AAe,CAAC;AAClE,IAAA,OAAO,IAAI,CAAC,YAAY,CAAC;AAC3B;;AChNA;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"smallpearl-ngx-helper-sideload.mjs","sources":["../../../../projects/smallpearl/ngx-helper/sideload/src/sideload.ts","../../../../projects/smallpearl/ngx-helper/sideload/smallpearl-ngx-helper-sideload.ts"],"sourcesContent":["import { plural, singular } from 'pluralize';\n\n/**\n * A function to merge sideloaded content into the main object thereby returning\n * a composite object.\n *\n * @param resp - the JSON response object, typically received from remote for\n * an HTTP request.\n * @param targetObjKey - the key name of the target object into which the\n * sideloaded data are to be merged.\n * @param idKey - idKey. Function assumes that all the objects use the same\n * key name as the unique object identifier.\n * @param sideloadDataMap: An array of [string, string], where the first\n * element specifies the property name of the target object and the second\n * element the sideload data element's key. This is useful when the the\n * target objet's property name that is to be merged with sideload data do not\n * match.\n * @returns Object with sideloaded data merged into the target object.\n */\nexport function sideloadToComposite(\n resp: any,\n targetObjKey: string,\n idKey: string = 'id',\n mergeStrategy: 'inplace' | 'append' = 'append',\n appendObjSuffix: string = 'Detail',\n sideloadDataMap?: Array<[string, string, string?]>\n) {\n if (typeof resp !== 'object' && !Array.isArray(resp)) {\n return;\n }\n\n const targetObjKeySingular = singular(targetObjKey);\n const targetObjKeyPlural = plural(targetObjKey);\n\n const targetObjResponse = resp[targetObjKey];\n if (!targetObjResponse) {\n return;\n }\n\n // Normalize single target object into an array to simplify handling\n let entities: Array<any> = Array.isArray(targetObjResponse)\n ? targetObjResponse\n : [targetObjResponse];\n\n // standard keys that'll never be merged with sideloaded content\n const KEYS_TO_SKIP = new Set([\n 'id',\n 'number',\n 'date',\n 'time',\n 'timestamp',\n 'modified',\n 'created',\n 'createdAt',\n 'updatedAt',\n 'updated',\n 'description',\n 'notes',\n 'desc',\n 'description',\n 'name',\n 'firstName',\n 'lastName',\n 'fullName',\n 'email',\n 'telephone',\n 'phone',\n 'mobile',\n 'address',\n 'title',\n 'content',\n ]);\n if (idKey) {\n KEYS_TO_SKIP.add(idKey);\n }\n const getSideloadPluralKey = (key: string) => {\n if (sideloadDataMap) {\n const entry = sideloadDataMap.find(([objKey]) => objKey === key);\n if (entry?.[1]) return entry[1];\n }\n // Prefer actual response keys to avoid pluralization mismatches\n if (resp.hasOwnProperty(key)) return key;\n const pluralKey = plural(key);\n if (resp.hasOwnProperty(pluralKey)) return pluralKey;\n return pluralKey;\n };\n const getSideloadDataKey = (key: string): string => {\n if (sideloadDataMap) {\n const entry = sideloadDataMap.find(([objKey]) => objKey === key);\n // Prefer explicit sideload data key if provided, else fallback to idKey\n if (entry) {\n return entry[2] ?? idKey;\n }\n }\n return idKey;\n };\n const isEntityKeyType = (value: string) =>\n typeof value === 'string' || typeof value === 'number';\n\n /**\n * Given an object, enumerates all keys of the object and for any key with\n * a matching sideload value, merges that into the 'obj', either by\n * replacing the matching key's value or by appending it as a new property.\n * If the value of a property is an object, recurses with the object as\n * first argument.\n * @param obj\n * @param mergeStrategy\n * @param appendObjSuffix\n * @returns\n */\n const mergeSideloadIntoObject = (\n obj: any,\n mergeStrategy: 'inplace' | 'append',\n appendObjSuffix: string = 'Detail'\n ) => {\n for (const key in obj) {\n if (\n // This check is needed to avoid infinite recursion, if one of the inner\n // objects has a key matching the targetObjKey's singular or plural form.\n key === targetObjKeySingular ||\n key === targetObjKeyPlural ||\n !Object.prototype.hasOwnProperty.call(obj, key) ||\n KEYS_TO_SKIP.has(key)\n ) {\n continue;\n }\n const value = obj[key];\n\n // Helper to get sideload data array for a key\n const getSideloadArray = (keyPlural: string) => {\n const data = resp[keyPlural];\n if (Array.isArray(data)) return data;\n if (data != null) return [data];\n return [];\n };\n\n if (Array.isArray(value) && value.length > 0) {\n if (isEntityKeyType(value[0])) {\n // Array of ids: merge sideloaded objects\n const keyPlural = getSideloadPluralKey(key);\n const sideloadId = getSideloadDataKey(key);\n const sideloadData = getSideloadArray(keyPlural);\n const matchingSideloadObjs = sideloadData.filter((so: any) =>\n value.includes(so?.[sideloadId])\n );\n if (matchingSideloadObjs.length > 0) {\n const targetKey =\n mergeStrategy === 'inplace'\n ? key\n : `${singular(key)}${appendObjSuffix}s`;\n obj[targetKey] = mergeSideloadIntoObjects(\n matchingSideloadObjs,\n mergeStrategy,\n appendObjSuffix\n );\n }\n } else {\n // Array of objects: recurse\n value.forEach((item: any) => {\n if (typeof item === 'object' && item !== null) {\n mergeSideloadIntoObject(item, mergeStrategy, appendObjSuffix);\n }\n });\n }\n } else if (typeof value === 'object' && value !== null && !Array.isArray(value)) {\n // Nested object: recurse\n mergeSideloadIntoObject(value, mergeStrategy, appendObjSuffix);\n } else if (isEntityKeyType(value)) {\n const keyPlural = getSideloadPluralKey(key);\n const sideloadId = getSideloadDataKey(key);\n const sideloadData = getSideloadArray(keyPlural);\n // The second check avoids duplicate merging of sideload data\n if (sideloadData.length > 0 && !Object.prototype.hasOwnProperty.call(obj, keyPlural)) {\n const matchingSideloadObj = sideloadData.find(\n (so: any) => so?.[sideloadId] === value\n );\n\n // Merge any FKs in the inner object with their sideloaded data\n const compositeSideloadObj = mergeSideloadIntoObject(\n matchingSideloadObj || {},\n mergeStrategy,\n appendObjSuffix\n );\n if (compositeSideloadObj) {\n const targetKey =\n mergeStrategy === 'inplace'\n ? key\n : `${singular(key)}${appendObjSuffix}`;\n obj[targetKey] = { ...compositeSideloadObj };\n }\n // if (matchingSideloadObj) {\n // const targetKey =\n // mergeStrategy === 'inplace'\n // ? key\n // : `${singular(key)}${appendObjSuffix}`;\n // obj[targetKey] = { ...matchingSideloadObj };\n // }\n }\n }\n }\n return obj;\n };\n\n const mergeSideloadIntoObjects = (objs: Array<any>, mergeStrategy: 'inplace' | 'append', appendObjSuffix: string) => {\n return objs.map((obj) => {\n return mergeSideloadIntoObject(obj, mergeStrategy, appendObjSuffix);\n });\n };\n\n mergeSideloadIntoObjects(entities, mergeStrategy, appendObjSuffix);\n return resp[targetObjKey];\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],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AAC,QAAQ,EAAE,aAAa,EAAE,eAAe,CAAC;AAClE,IAAA,OAAO,IAAI,CAAC,YAAY,CAAC;AAC3B;;ACnNA;;AAEG;;;;"}
|
package/package.json
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
"path": "src/assets/i18n/"
|
|
7
7
|
}
|
|
8
8
|
],
|
|
9
|
-
"version": "0.33.
|
|
9
|
+
"version": "0.33.21",
|
|
10
10
|
"peerDependencies": {
|
|
11
11
|
"@angular/common": "^19.1.0",
|
|
12
12
|
"@angular/core": "^19.1.0",
|
|
@@ -48,6 +48,14 @@
|
|
|
48
48
|
"types": "./entities/index.d.ts",
|
|
49
49
|
"default": "./fesm2022/smallpearl-ngx-helper-entities.mjs"
|
|
50
50
|
},
|
|
51
|
+
"./locale": {
|
|
52
|
+
"types": "./locale/index.d.ts",
|
|
53
|
+
"default": "./fesm2022/smallpearl-ngx-helper-locale.mjs"
|
|
54
|
+
},
|
|
55
|
+
"./forms": {
|
|
56
|
+
"types": "./forms/index.d.ts",
|
|
57
|
+
"default": "./fesm2022/smallpearl-ngx-helper-forms.mjs"
|
|
58
|
+
},
|
|
51
59
|
"./hover-dropdown": {
|
|
52
60
|
"types": "./hover-dropdown/index.d.ts",
|
|
53
61
|
"default": "./fesm2022/smallpearl-ngx-helper-hover-dropdown.mjs"
|
|
@@ -56,14 +64,6 @@
|
|
|
56
64
|
"types": "./mat-busy-wheel/index.d.ts",
|
|
57
65
|
"default": "./fesm2022/smallpearl-ngx-helper-mat-busy-wheel.mjs"
|
|
58
66
|
},
|
|
59
|
-
"./forms": {
|
|
60
|
-
"types": "./forms/index.d.ts",
|
|
61
|
-
"default": "./fesm2022/smallpearl-ngx-helper-forms.mjs"
|
|
62
|
-
},
|
|
63
|
-
"./locale": {
|
|
64
|
-
"types": "./locale/index.d.ts",
|
|
65
|
-
"default": "./fesm2022/smallpearl-ngx-helper-locale.mjs"
|
|
66
|
-
},
|
|
67
67
|
"./entity-field": {
|
|
68
68
|
"types": "./entity-field/index.d.ts",
|
|
69
69
|
"default": "./fesm2022/smallpearl-ngx-helper-entity-field.mjs"
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* A function merge sideloaded content into the main object thereby returning
|
|
2
|
+
* A function to merge sideloaded content into the main object thereby returning
|
|
3
3
|
* a composite object.
|
|
4
|
+
*
|
|
4
5
|
* @param resp - the JSON response object, typically received from remote for
|
|
5
6
|
* an HTTP request.
|
|
6
7
|
* @param targetObjKey - the key name of the target object into which the
|
|
@@ -12,6 +13,6 @@
|
|
|
12
13
|
* element the sideload data element's key. This is useful when the the
|
|
13
14
|
* target objet's property name that is to be merged with sideload data do not
|
|
14
15
|
* match.
|
|
15
|
-
* @returns
|
|
16
|
+
* @returns Object with sideloaded data merged into the target object.
|
|
16
17
|
*/
|
|
17
18
|
export declare function sideloadToComposite(resp: any, targetObjKey: string, idKey?: string, mergeStrategy?: 'inplace' | 'append', appendObjSuffix?: string, sideloadDataMap?: Array<[string, string, string?]>): any;
|