@lucca-front/ng 22.0.1-rc.2 → 22.0.1
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/fesm2022/lucca-front-ng-core-select-api.mjs +1 -0
- package/fesm2022/lucca-front-ng-core-select-api.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-core-select-establishment.mjs +32 -9
- package/fesm2022/lucca-front-ng-core-select-establishment.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-core-select-job-qualification.mjs +11 -0
- package/fesm2022/lucca-front-ng-core-select-job-qualification.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-forms-rich-text-input-formatters-plain-text.mjs +5 -2
- package/fesm2022/lucca-front-ng-forms-rich-text-input-formatters-plain-text.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-forms-rich-text-input.mjs +52 -20
- package/fesm2022/lucca-front-ng-forms-rich-text-input.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-multi-select.mjs +2 -2
- package/fesm2022/lucca-front-ng-multi-select.mjs.map +1 -1
- package/package.json +4 -4
- package/src/components/_listbox.scss +12 -6
- package/types/lucca-front-ng-core-select-api.d.ts +6 -0
- package/types/lucca-front-ng-core-select-establishment.d.ts +7 -0
- package/types/lucca-front-ng-core-select-job-qualification.d.ts +8 -0
- package/types/lucca-front-ng-forms-rich-text-input.d.ts +3 -2
|
@@ -43,6 +43,7 @@ class ALuCoreSelectApiDirective {
|
|
|
43
43
|
});
|
|
44
44
|
const dataSource = {
|
|
45
45
|
paramsChange: this.params$,
|
|
46
|
+
...(this.getGroupOptions ? { getGroupOptions: (group) => this.getGroupOptions(group) } : {}),
|
|
46
47
|
clueDebounceMs: this.debounceDuration,
|
|
47
48
|
getTotalCount: () => this.totalCount$,
|
|
48
49
|
reset: () => this.clearLastPageByClue(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lucca-front-ng-core-select-api.mjs","sources":["../../../packages/ng/core-select/api/api.directive.ts","../../../packages/ng/core-select/api/api-v3.directive.ts","../../../packages/ng/core-select/api/api-v4.directive.ts","../../../packages/ng/core-select/api/lucca-front-ng-core-select-api.ts"],"sourcesContent":["import { Directive, inject, OnDestroy, OnInit, Signal } from '@angular/core';\nimport { ALuSelectInputComponent, coreSelectDefaultOptionComparer, coreSelectDefaultOptionKey, LuOptionComparer, SelectDataSource } from '@lucca-front/ng/core-select';\nimport { BehaviorSubject, catchError, map, Observable, of, Subject, switchMap, take, takeUntil, tap } from 'rxjs';\n\nexport const LU_SELECT_MAGIC_PAGE_SIZE = 20;\nexport const MAGIC_DEBOUNCE_DURATION = 250;\n\n@Directive()\nexport abstract class ALuCoreSelectApiDirective<TOption, TParams = Record<string, string | number | boolean> | null> implements OnDestroy, OnInit {\n\tprotected readonly destroy$ = new Subject<void>();\n\tprotected pageSize = LU_SELECT_MAGIC_PAGE_SIZE;\n\tprotected debounceDuration = MAGIC_DEBOUNCE_DURATION;\n\n\tpublic select = inject<ALuSelectInputComponent<TOption, unknown>>(ALuSelectInputComponent);\n\n\t/**\n\t * Current clue — updated by clueChange$ subscription (keeps select in searchable mode)\n\t * and by direct getOptions calls from the select component.\n\t */\n\tprotected readonly currentClue$ = new BehaviorSubject<string>('');\n\n\t/**\n\t * Clue observable — no debounce (debounce is now handled by the select component).\n\t */\n\tprotected readonly clue$ = this.currentClue$.asObservable();\n\n\t/**\n\t * Create an object that will be used as params for the api call\n\t */\n\tprotected abstract params$: Observable<TParams>;\n\n\t/**\n\t * Optional synchronous view of {@link params$}. When a directive derives its params from signals,\n\t * it should expose them here so {@link buildParamsFromClue} can read the value that reflects the\n\t * clue we just set — reading `params$` (a `toObservable` replay) can otherwise hand back the\n\t * previous clue's params on the non-debounced empty-clue path, leaving searches stuck.\n\t */\n\tprotected readonly paramsSignal?: Signal<TParams>;\n\n\t/**\n\t * Compare two options to know if they are the same. For example, compare by id or by JSON\n\t */\n\tprotected optionComparer: LuOptionComparer<TOption> = (a, b) => this.optionKey(a) === this.optionKey(b);\n\n\t/**\n\t * Return a unique key to identify the option in for-of loops\n\t */\n\tprotected abstract optionKey: (option: TOption) => unknown;\n\n\t/**\n\t * Return the options for the given params and page\n\t */\n\tprotected abstract getOptions(params: TParams, page: number): Observable<TOption[]>;\n\n\t#lastClue?: string;\n\t#lastPage?: number;\n\n\tpublic ngOnInit(): void {\n\t\tif (this.select.optionComparer() === coreSelectDefaultOptionComparer) {\n\t\t\tthis.select.optionComparer.set(this.optionComparer);\n\t\t}\n\n\t\tif (this.select.optionKey() === coreSelectDefaultOptionKey) {\n\t\t\tthis.select.optionKey.set(this.optionKey);\n\t\t}\n\n\t\t// Subscribe to clueChange$ to (1) keep the select in searchable mode and (2) drive currentClue$\n\t\tthis.select.clueChange$.pipe(takeUntil(this.destroy$)).subscribe((clue) => {\n\t\t\tthis.currentClue$.next(clue);\n\t\t\tthis.clearLastPageByClue();\n\t\t});\n\n\t\tconst dataSource: SelectDataSource<TOption> = {\n\t\t\tparamsChange: this.params$,\n\t\t\tclueDebounceMs: this.debounceDuration,\n\t\t\tgetTotalCount: () => this.totalCount$,\n\t\t\treset: () => this.clearLastPageByClue(),\n\t\t\ttransformOptions: (options) => this.transformOptions(options),\n\t\t\tgetOptions: ({ clue, page }) => {\n\t\t\t\tconst lastPage = clue === this.#lastClue ? this.#lastPage : undefined;\n\t\t\t\tif (lastPage !== undefined && page > lastPage) {\n\t\t\t\t\treturn of([] as readonly TOption[]);\n\t\t\t\t}\n\t\t\t\treturn this.buildParamsFromClue(clue).pipe(\n\t\t\t\t\ttake(1),\n\t\t\t\t\tswitchMap((params) =>\n\t\t\t\t\t\tthis.getOptionsPage(params, page).pipe(\n\t\t\t\t\t\t\ttap(({ isLastPage }) => {\n\t\t\t\t\t\t\t\tif (isLastPage) {\n\t\t\t\t\t\t\t\t\tthis.#lastClue = clue;\n\t\t\t\t\t\t\t\t\tthis.#lastPage = page;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\tmap(({ items }) => items as readonly TOption[]),\n\t\t\t\t\t\t),\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t},\n\t\t};\n\n\t\tthis.select.dataSource.set(dataSource);\n\t}\n\n\t/**\n\t * Post-process the whole list of loaded options (all pages accumulated). Override it for\n\t * decorations that can't be computed page by page, eg. flagging homonyms across pages.\n\t */\n\tprotected transformOptions(options: readonly TOption[]): Observable<readonly TOption[]> {\n\t\treturn of(options);\n\t}\n\n\tprotected buildParamsFromClue(clue: string): Observable<TParams> {\n\t\tthis.currentClue$.next(clue);\n\t\t// Prefer the synchronous signal (always reflects the clue we just set); fall back to the\n\t\t// reactive observable for directives that still build their params from observables.\n\t\treturn this.paramsSignal ? of(this.paramsSignal()) : this.params$.pipe(take(1));\n\t}\n\n\tpublic abstract totalCount$: Observable<number>;\n\n\tprotected clearLastPageByClue() {\n\t\tthis.#lastClue = undefined;\n\t\tthis.#lastPage = undefined;\n\t}\n\n\tprotected getOptionsPage(params: TParams, page: number): Observable<{ items: TOption[]; isLastPage: boolean }> {\n\t\treturn this.getOptions(params, page).pipe(\n\t\t\tcatchError(() => of([] as TOption[])),\n\t\t\tmap((items) => ({ items, isLastPage: items.length < this.pageSize })),\n\t\t);\n\t}\n\n\tpublic ngOnDestroy(): void {\n\t\tthis.destroy$.next();\n\t\tthis.destroy$.complete();\n\t}\n}\n","import { HttpClient } from '@angular/common/http';\nimport { Directive, forwardRef, inject, input } from '@angular/core';\nimport { toObservable } from '@angular/core/rxjs-interop';\nimport { ILuApiCollectionResponse, ILuApiItem } from '@lucca-front/ng/api';\nimport { CORE_SELECT_API_TOTAL_COUNT_PROVIDER, CoreSelectApiTotalCountProvider } from '@lucca-front/ng/core-select';\nimport { combineLatest, debounceTime, map, Observable, switchMap, take } from 'rxjs';\nimport { ALuCoreSelectApiDirective } from './api.directive';\n\n@Directive({\n\t// The attribute is already prefixed with \"lu-simple-select\"\n\t// eslint-disable-next-line @angular-eslint/directive-selector\n\tselector: 'lu-simple-select[apiV3],lu-multi-select[apiV3]',\n\tproviders: [\n\t\t{\n\t\t\tprovide: CORE_SELECT_API_TOTAL_COUNT_PROVIDER,\n\t\t\tuseExisting: forwardRef(() => LuCoreSelectApiV3Directive),\n\t\t},\n\t],\n})\nexport class LuCoreSelectApiV3Directive<T extends ILuApiItem> extends ALuCoreSelectApiDirective<T> implements CoreSelectApiTotalCountProvider {\n\tprotected httpClient = inject(HttpClient);\n\n\treadonly apiV3 = input.required<string>();\n\n\treadonly fields = input('id,name');\n\n\treadonly orderBy = input<string | null>('name,asc');\n\n\treadonly filters = input<Record<string, string | number | boolean>>({});\n\n\tprotected readonly url$ = toObservable(this.apiV3);\n\tprotected readonly fields$ = toObservable(this.fields);\n\tprotected readonly orderBy$ = toObservable(this.orderBy);\n\tprotected readonly filters$ = toObservable(this.filters);\n\n\tprotected override params$ = combineLatest([this.fields$, this.filters$, this.orderBy$, this.clue$]).pipe(\n\t\tmap(([fields, filters, orderBy, clue]) => ({\n\t\t\t...filters,\n\t\t\t...(fields ? { fields } : {}),\n\t\t\t...(orderBy ? { orderBy } : {}),\n\t\t\t...(clue ? { name: `like,${clue}` } : {}),\n\t\t})),\n\t);\n\n\tpublic totalCount$ = combineLatest([this.url$, this.filters$]).pipe(\n\t\tdebounceTime(250),\n\t\tswitchMap(([url, params]) =>\n\t\t\tthis.httpClient.get<{ data: { count: number } }>(url, {\n\t\t\t\tparams: {\n\t\t\t\t\t...params,\n\t\t\t\t\tfields: 'collection.count',\n\t\t\t\t},\n\t\t\t}),\n\t\t),\n\t\tmap((res) => res.data?.count ?? 0),\n\t);\n\n\tprotected override getOptions(params: Record<string, string | number | boolean>, page: number): Observable<T[]> {\n\t\treturn this.url$.pipe(\n\t\t\ttake(1),\n\t\t\tswitchMap((url) =>\n\t\t\t\tthis.httpClient.get<ILuApiCollectionResponse<T>>(url, {\n\t\t\t\t\tparams: {\n\t\t\t\t\t\t...params,\n\t\t\t\t\t\tpaging: `${page * this.pageSize},${this.pageSize}`,\n\t\t\t\t\t},\n\t\t\t\t}),\n\t\t\t),\n\t\t\tmap((res) => res.data.items),\n\t\t);\n\t}\n\n\tprotected override optionKey = (option: T) => option.id;\n}\n","import { HttpClient } from '@angular/common/http';\nimport { computed, Directive, forwardRef, inject, input, model } from '@angular/core';\nimport { toObservable, toSignal } from '@angular/core/rxjs-interop';\nimport { ILuApiItem } from '@lucca-front/ng/api';\nimport { applySearchDelimiter, CORE_SELECT_API_TOTAL_COUNT_PROVIDER, CoreSelectApiTotalCountProvider } from '@lucca-front/ng/core-select';\nimport { debounceTime, map, Observable, switchMap } from 'rxjs';\nimport { ALuCoreSelectApiDirective } from './api.directive';\n\n@Directive({\n\t// The attribute is already prefixed with \"lu-simple-select\"\n\t// eslint-disable-next-line @angular-eslint/directive-selector\n\tselector: 'lu-simple-select[apiV4],lu-multi-select[apiV4]',\n\tproviders: [\n\t\t{\n\t\t\tprovide: CORE_SELECT_API_TOTAL_COUNT_PROVIDER,\n\t\t\tuseExisting: forwardRef(() => LuCoreSelectApiV4Directive),\n\t\t},\n\t],\n})\nexport class LuCoreSelectApiV4Directive<T extends ILuApiItem> extends ALuCoreSelectApiDirective<T> implements CoreSelectApiTotalCountProvider {\n\treadonly apiV4 = model.required<string>();\n\treadonly sort = input<string | null>('+name');\n\treadonly filters = input<Record<string, string | number | boolean>>({});\n\treadonly searchDelimiter = input<string>(' ');\n\n\tprotected httpClient = inject(HttpClient);\n\n\tprotected readonly clue = toSignal(this.clue$);\n\n\tprotected override readonly paramsSignal = computed<Record<string, string | number | boolean>>(() => {\n\t\tconst sort = this.sort();\n\t\tconst clue = this.clue();\n\t\tconst searchDelimiter = this.searchDelimiter();\n\t\treturn {\n\t\t\t...this.filters(),\n\t\t\t...(sort ? { sort } : {}),\n\t\t\t...(clue ? { search: applySearchDelimiter(clue, searchDelimiter) } : {}),\n\t\t};\n\t});\n\tprotected override readonly params$: Observable<Record<string, string | number | boolean>> = toObservable(this.paramsSignal);\n\n\tpublic readonly totalCount$ = toObservable(computed(() => ({ url: this.apiV4(), filters: this.filters() }))).pipe(\n\t\tdebounceTime(250),\n\t\tswitchMap(({ url, filters }) =>\n\t\t\tthis.httpClient.get<{ count: number }>(url, {\n\t\t\t\tparams: {\n\t\t\t\t\t...filters,\n\t\t\t\t\t['fields.root']: 'count',\n\t\t\t\t},\n\t\t\t}),\n\t\t),\n\t\tmap((res) => res?.count ?? 0),\n\t);\n\n\tprotected override getOptions(params: Record<string, string | number | boolean>, page: number): Observable<T[]> {\n\t\treturn this.httpClient\n\t\t\t.get<T[] | { items: T[] }>(this.apiV4(), {\n\t\t\t\tparams: {\n\t\t\t\t\t...params,\n\t\t\t\t\tpage: page + 1,\n\t\t\t\t\tlimit: this.pageSize,\n\t\t\t\t},\n\t\t\t})\n\t\t\t.pipe(map((res) => (Array.isArray(res) ? res : res?.items) ?? []));\n\t}\n\n\tprotected override optionKey = (option: T) => option.id;\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;AAIO,MAAM,yBAAyB,GAAG;AAClC,MAAM,uBAAuB,GAAG,GAAG;MAGpB,yBAAyB,CAAA;AAD/C,IAAA,WAAA,GAAA;AAEoB,QAAA,IAAA,CAAA,QAAQ,GAAG,IAAI,OAAO,EAAQ;QACvC,IAAA,CAAA,QAAQ,GAAG,yBAAyB;QACpC,IAAA,CAAA,gBAAgB,GAAG,uBAAuB;AAE7C,QAAA,IAAA,CAAA,MAAM,GAAG,MAAM,CAA4C,uBAAuB,CAAC;AAE1F;;;AAGG;AACgB,QAAA,IAAA,CAAA,YAAY,GAAG,IAAI,eAAe,CAAS,EAAE,CAAC;AAEjE;;AAEG;AACgB,QAAA,IAAA,CAAA,KAAK,GAAG,IAAI,CAAC,YAAY,CAAC,YAAY,EAAE;AAe3D;;AAEG;QACO,IAAA,CAAA,cAAc,GAA8B,CAAC,CAAC,EAAE,CAAC,KAAK,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,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oBAAA,SAAS,EAAE;AACV,wBAAA;AACC,4BAAA,OAAO,EAAE,oCAAoC;AAC7C,4BAAA,WAAW,EAAE,UAAU,CAAC,gCAAgC,CAAC;AACzD,yBAAA;AACD,qBAAA;AACD,iBAAA;;;AClBD;;AAEG;;"}
|
|
1
|
+
{"version":3,"file":"lucca-front-ng-core-select-api.mjs","sources":["../../../packages/ng/core-select/api/api.directive.ts","../../../packages/ng/core-select/api/api-v3.directive.ts","../../../packages/ng/core-select/api/api-v4.directive.ts","../../../packages/ng/core-select/api/lucca-front-ng-core-select-api.ts"],"sourcesContent":["import { Directive, inject, OnDestroy, OnInit, Signal } from '@angular/core';\nimport { ALuSelectInputComponent, coreSelectDefaultOptionComparer, coreSelectDefaultOptionKey, LuOptionComparer, SelectDataSource } from '@lucca-front/ng/core-select';\nimport { BehaviorSubject, catchError, map, Observable, of, Subject, switchMap, take, takeUntil, tap } from 'rxjs';\n\nexport const LU_SELECT_MAGIC_PAGE_SIZE = 20;\nexport const MAGIC_DEBOUNCE_DURATION = 250;\n\n@Directive()\nexport abstract class ALuCoreSelectApiDirective<TOption, TParams = Record<string, string | number | boolean> | null> implements OnDestroy, OnInit {\n\tprotected readonly destroy$ = new Subject<void>();\n\tprotected pageSize = LU_SELECT_MAGIC_PAGE_SIZE;\n\tprotected debounceDuration = MAGIC_DEBOUNCE_DURATION;\n\n\tpublic select = inject<ALuSelectInputComponent<TOption, unknown>>(ALuSelectInputComponent);\n\n\t/**\n\t * Current clue — updated by clueChange$ subscription (keeps select in searchable mode)\n\t * and by direct getOptions calls from the select component.\n\t */\n\tprotected readonly currentClue$ = new BehaviorSubject<string>('');\n\n\t/**\n\t * Clue observable — no debounce (debounce is now handled by the select component).\n\t */\n\tprotected readonly clue$ = this.currentClue$.asObservable();\n\n\t/**\n\t * Create an object that will be used as params for the api call\n\t */\n\tprotected abstract params$: Observable<TParams>;\n\n\t/**\n\t * Optional synchronous view of {@link params$}. When a directive derives its params from signals,\n\t * it should expose them here so {@link buildParamsFromClue} can read the value that reflects the\n\t * clue we just set — reading `params$` (a `toObservable` replay) can otherwise hand back the\n\t * previous clue's params on the non-debounced empty-clue path, leaving searches stuck.\n\t */\n\tprotected readonly paramsSignal?: Signal<TParams>;\n\n\t/**\n\t * Compare two options to know if they are the same. For example, compare by id or by JSON\n\t */\n\tprotected optionComparer: LuOptionComparer<TOption> = (a, b) => this.optionKey(a) === this.optionKey(b);\n\n\t/**\n\t * Return a unique key to identify the option in for-of loops\n\t */\n\tprotected abstract optionKey: (option: TOption) => unknown;\n\n\t/**\n\t * Return the options for the given params and page\n\t */\n\tprotected abstract getOptions(params: TParams, page: number): Observable<TOption[]>;\n\n\t/**\n\t * Return every option of a group, ignoring pagination, so the group \"select all\" acts on the whole\n\t * group and not only on the pages already loaded. Override it in directives that set a grouping;\n\t * left undefined, the panel keeps its default behaviour and toggles the rendered options only.\n\t */\n\tprotected getGroupOptions?: (group: unknown) => Observable<TOption[]>;\n\n\t#lastClue?: string;\n\t#lastPage?: number;\n\n\tpublic ngOnInit(): void {\n\t\tif (this.select.optionComparer() === coreSelectDefaultOptionComparer) {\n\t\t\tthis.select.optionComparer.set(this.optionComparer);\n\t\t}\n\n\t\tif (this.select.optionKey() === coreSelectDefaultOptionKey) {\n\t\t\tthis.select.optionKey.set(this.optionKey);\n\t\t}\n\n\t\t// Subscribe to clueChange$ to (1) keep the select in searchable mode and (2) drive currentClue$\n\t\tthis.select.clueChange$.pipe(takeUntil(this.destroy$)).subscribe((clue) => {\n\t\t\tthis.currentClue$.next(clue);\n\t\t\tthis.clearLastPageByClue();\n\t\t});\n\n\t\tconst dataSource: SelectDataSource<TOption, unknown> = {\n\t\t\tparamsChange: this.params$,\n\t\t\t...(this.getGroupOptions ? { getGroupOptions: (group: unknown) => this.getGroupOptions!(group) } : {}),\n\t\t\tclueDebounceMs: this.debounceDuration,\n\t\t\tgetTotalCount: () => this.totalCount$,\n\t\t\treset: () => this.clearLastPageByClue(),\n\t\t\ttransformOptions: (options) => this.transformOptions(options),\n\t\t\tgetOptions: ({ clue, page }) => {\n\t\t\t\tconst lastPage = clue === this.#lastClue ? this.#lastPage : undefined;\n\t\t\t\tif (lastPage !== undefined && page > lastPage) {\n\t\t\t\t\treturn of([] as readonly TOption[]);\n\t\t\t\t}\n\t\t\t\treturn this.buildParamsFromClue(clue).pipe(\n\t\t\t\t\ttake(1),\n\t\t\t\t\tswitchMap((params) =>\n\t\t\t\t\t\tthis.getOptionsPage(params, page).pipe(\n\t\t\t\t\t\t\ttap(({ isLastPage }) => {\n\t\t\t\t\t\t\t\tif (isLastPage) {\n\t\t\t\t\t\t\t\t\tthis.#lastClue = clue;\n\t\t\t\t\t\t\t\t\tthis.#lastPage = page;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\tmap(({ items }) => items as readonly TOption[]),\n\t\t\t\t\t\t),\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t},\n\t\t};\n\n\t\tthis.select.dataSource.set(dataSource);\n\t}\n\n\t/**\n\t * Post-process the whole list of loaded options (all pages accumulated). Override it for\n\t * decorations that can't be computed page by page, eg. flagging homonyms across pages.\n\t */\n\tprotected transformOptions(options: readonly TOption[]): Observable<readonly TOption[]> {\n\t\treturn of(options);\n\t}\n\n\tprotected buildParamsFromClue(clue: string): Observable<TParams> {\n\t\tthis.currentClue$.next(clue);\n\t\t// Prefer the synchronous signal (always reflects the clue we just set); fall back to the\n\t\t// reactive observable for directives that still build their params from observables.\n\t\treturn this.paramsSignal ? of(this.paramsSignal()) : this.params$.pipe(take(1));\n\t}\n\n\tpublic abstract totalCount$: Observable<number>;\n\n\tprotected clearLastPageByClue() {\n\t\tthis.#lastClue = undefined;\n\t\tthis.#lastPage = undefined;\n\t}\n\n\tprotected getOptionsPage(params: TParams, page: number): Observable<{ items: TOption[]; isLastPage: boolean }> {\n\t\treturn this.getOptions(params, page).pipe(\n\t\t\tcatchError(() => of([] as TOption[])),\n\t\t\tmap((items) => ({ items, isLastPage: items.length < this.pageSize })),\n\t\t);\n\t}\n\n\tpublic ngOnDestroy(): void {\n\t\tthis.destroy$.next();\n\t\tthis.destroy$.complete();\n\t}\n}\n","import { HttpClient } from '@angular/common/http';\nimport { Directive, forwardRef, inject, input } from '@angular/core';\nimport { toObservable } from '@angular/core/rxjs-interop';\nimport { ILuApiCollectionResponse, ILuApiItem } from '@lucca-front/ng/api';\nimport { CORE_SELECT_API_TOTAL_COUNT_PROVIDER, CoreSelectApiTotalCountProvider } from '@lucca-front/ng/core-select';\nimport { combineLatest, debounceTime, map, Observable, switchMap, take } from 'rxjs';\nimport { ALuCoreSelectApiDirective } from './api.directive';\n\n@Directive({\n\t// The attribute is already prefixed with \"lu-simple-select\"\n\t// eslint-disable-next-line @angular-eslint/directive-selector\n\tselector: 'lu-simple-select[apiV3],lu-multi-select[apiV3]',\n\tproviders: [\n\t\t{\n\t\t\tprovide: CORE_SELECT_API_TOTAL_COUNT_PROVIDER,\n\t\t\tuseExisting: forwardRef(() => LuCoreSelectApiV3Directive),\n\t\t},\n\t],\n})\nexport class LuCoreSelectApiV3Directive<T extends ILuApiItem> extends ALuCoreSelectApiDirective<T> implements CoreSelectApiTotalCountProvider {\n\tprotected httpClient = inject(HttpClient);\n\n\treadonly apiV3 = input.required<string>();\n\n\treadonly fields = input('id,name');\n\n\treadonly orderBy = input<string | null>('name,asc');\n\n\treadonly filters = input<Record<string, string | number | boolean>>({});\n\n\tprotected readonly url$ = toObservable(this.apiV3);\n\tprotected readonly fields$ = toObservable(this.fields);\n\tprotected readonly orderBy$ = toObservable(this.orderBy);\n\tprotected readonly filters$ = toObservable(this.filters);\n\n\tprotected override params$ = combineLatest([this.fields$, this.filters$, this.orderBy$, this.clue$]).pipe(\n\t\tmap(([fields, filters, orderBy, clue]) => ({\n\t\t\t...filters,\n\t\t\t...(fields ? { fields } : {}),\n\t\t\t...(orderBy ? { orderBy } : {}),\n\t\t\t...(clue ? { name: `like,${clue}` } : {}),\n\t\t})),\n\t);\n\n\tpublic totalCount$ = combineLatest([this.url$, this.filters$]).pipe(\n\t\tdebounceTime(250),\n\t\tswitchMap(([url, params]) =>\n\t\t\tthis.httpClient.get<{ data: { count: number } }>(url, {\n\t\t\t\tparams: {\n\t\t\t\t\t...params,\n\t\t\t\t\tfields: 'collection.count',\n\t\t\t\t},\n\t\t\t}),\n\t\t),\n\t\tmap((res) => res.data?.count ?? 0),\n\t);\n\n\tprotected override getOptions(params: Record<string, string | number | boolean>, page: number): Observable<T[]> {\n\t\treturn this.url$.pipe(\n\t\t\ttake(1),\n\t\t\tswitchMap((url) =>\n\t\t\t\tthis.httpClient.get<ILuApiCollectionResponse<T>>(url, {\n\t\t\t\t\tparams: {\n\t\t\t\t\t\t...params,\n\t\t\t\t\t\tpaging: `${page * this.pageSize},${this.pageSize}`,\n\t\t\t\t\t},\n\t\t\t\t}),\n\t\t\t),\n\t\t\tmap((res) => res.data.items),\n\t\t);\n\t}\n\n\tprotected override optionKey = (option: T) => option.id;\n}\n","import { HttpClient } from '@angular/common/http';\nimport { computed, Directive, forwardRef, inject, input, model } from '@angular/core';\nimport { toObservable, toSignal } from '@angular/core/rxjs-interop';\nimport { ILuApiItem } from '@lucca-front/ng/api';\nimport { applySearchDelimiter, CORE_SELECT_API_TOTAL_COUNT_PROVIDER, CoreSelectApiTotalCountProvider } from '@lucca-front/ng/core-select';\nimport { debounceTime, map, Observable, switchMap } from 'rxjs';\nimport { ALuCoreSelectApiDirective } from './api.directive';\n\n@Directive({\n\t// The attribute is already prefixed with \"lu-simple-select\"\n\t// eslint-disable-next-line @angular-eslint/directive-selector\n\tselector: 'lu-simple-select[apiV4],lu-multi-select[apiV4]',\n\tproviders: [\n\t\t{\n\t\t\tprovide: CORE_SELECT_API_TOTAL_COUNT_PROVIDER,\n\t\t\tuseExisting: forwardRef(() => LuCoreSelectApiV4Directive),\n\t\t},\n\t],\n})\nexport class LuCoreSelectApiV4Directive<T extends ILuApiItem> extends ALuCoreSelectApiDirective<T> implements CoreSelectApiTotalCountProvider {\n\treadonly apiV4 = model.required<string>();\n\treadonly sort = input<string | null>('+name');\n\treadonly filters = input<Record<string, string | number | boolean>>({});\n\treadonly searchDelimiter = input<string>(' ');\n\n\tprotected httpClient = inject(HttpClient);\n\n\tprotected readonly clue = toSignal(this.clue$);\n\n\tprotected override readonly paramsSignal = computed<Record<string, string | number | boolean>>(() => {\n\t\tconst sort = this.sort();\n\t\tconst clue = this.clue();\n\t\tconst searchDelimiter = this.searchDelimiter();\n\t\treturn {\n\t\t\t...this.filters(),\n\t\t\t...(sort ? { sort } : {}),\n\t\t\t...(clue ? { search: applySearchDelimiter(clue, searchDelimiter) } : {}),\n\t\t};\n\t});\n\tprotected override readonly params$: Observable<Record<string, string | number | boolean>> = toObservable(this.paramsSignal);\n\n\tpublic readonly totalCount$ = toObservable(computed(() => ({ url: this.apiV4(), filters: this.filters() }))).pipe(\n\t\tdebounceTime(250),\n\t\tswitchMap(({ url, filters }) =>\n\t\t\tthis.httpClient.get<{ count: number }>(url, {\n\t\t\t\tparams: {\n\t\t\t\t\t...filters,\n\t\t\t\t\t['fields.root']: 'count',\n\t\t\t\t},\n\t\t\t}),\n\t\t),\n\t\tmap((res) => res?.count ?? 0),\n\t);\n\n\tprotected override getOptions(params: Record<string, string | number | boolean>, page: number): Observable<T[]> {\n\t\treturn this.httpClient\n\t\t\t.get<T[] | { items: T[] }>(this.apiV4(), {\n\t\t\t\tparams: {\n\t\t\t\t\t...params,\n\t\t\t\t\tpage: page + 1,\n\t\t\t\t\tlimit: this.pageSize,\n\t\t\t\t},\n\t\t\t})\n\t\t\t.pipe(map((res) => (Array.isArray(res) ? res : res?.items) ?? []));\n\t}\n\n\tprotected override optionKey = (option: T) => option.id;\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;AAIO,MAAM,yBAAyB,GAAG;AAClC,MAAM,uBAAuB,GAAG,GAAG;MAGpB,yBAAyB,CAAA;AAD/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EAAA,SAAA,EAAA,QAAA,EAAA,IAAA,EAAA,UAAA,EAAA,KAAA,EAAA,iBAAA,EAAA,IAAA,EAAA,EAAA,eAAA,EAAA,EAAA,iBAAA,EAAA,iBAAA,EAAA,UAAA,EAAA,iBAAA,EAAA,QAAA,EAAA,IAAA,EAAA,UAAA,EAAA,KAAA,EAAA,iBAAA,EAAA,IAAA,EAAA,EAAA,EAAA,OAAA,EAAA,EAAA,KAAA,EAAA,aAAA,EAAA,EAAA,SAAA,EAP3B;AACV,YAAA;AACC,gBAAA,OAAO,EAAE,oCAAoC;AAC7C,gBAAA,WAAW,EAAE,UAAU,CAAC,MAAM,0BAA0B,CAAC;AACzD,aAAA;AACD,SAAA,EAAA,eAAA,EAAA,IAAA,EAAA,QAAA,EAAA,EAAA,EAAA,CAAA,CAAA;;2FAEW,0BAA0B,EAAA,UAAA,EAAA,CAAA;kBAXtC,SAAS;AAAC,YAAA,IAAA,EAAA,CAAA;;;AAGV,oBAAA,QAAQ,EAAE,gDAAgD;AAC1D,oBAAA,SAAS,EAAE;AACV,wBAAA;AACC,4BAAA,OAAO,EAAE,oCAAoC;AAC7C,4BAAA,WAAW,EAAE,UAAU,CAAC,gCAAgC,CAAC;AACzD,yBAAA;AACD,qBAAA;AACD,iBAAA;;;AClBD;;AAEG;;"}
|
|
@@ -59,22 +59,39 @@ class LuCoreSelectEstablishmentsDirective extends ALuCoreSelectApiDirective {
|
|
|
59
59
|
this.searchDelimiter = input(' ', /* @ts-ignore */
|
|
60
60
|
...(ngDevMode ? [{ debugName: "searchDelimiter" }] : /* istanbul ignore next */ []));
|
|
61
61
|
this.clue = toSignal(this.clue$);
|
|
62
|
-
|
|
62
|
+
/**
|
|
63
|
+
* Params shared by every call: the restrictions that define which establishments are selectable,
|
|
64
|
+
* without the clue-dependent search and sort.
|
|
65
|
+
*/
|
|
66
|
+
this.#restrictionParams = computed(() => {
|
|
63
67
|
const operationIds = this.operationIds();
|
|
64
68
|
const uniqueOperationIds = this.uniqueOperationIds();
|
|
65
69
|
const appInstanceId = this.appInstanceId();
|
|
70
|
+
return {
|
|
71
|
+
...this.filters(),
|
|
72
|
+
...(operationIds ? { operations: operationIds.join(',') } : {}),
|
|
73
|
+
...(uniqueOperationIds ? { uniqueOperations: uniqueOperationIds.join(',') } : {}),
|
|
74
|
+
...(appInstanceId ? { appInstanceId } : {}),
|
|
75
|
+
};
|
|
76
|
+
}, /* @ts-ignore */
|
|
77
|
+
...(ngDevMode ? [{ debugName: "#restrictionParams" }] : /* istanbul ignore next */ []));
|
|
78
|
+
/**
|
|
79
|
+
* Establishments are grouped by legal unit, but the panel only knows the options of the pages it
|
|
80
|
+
* already loaded: a legal unit spanning several pages would be partially selected. Fetch the whole
|
|
81
|
+
* legal unit instead, page by page, so "select all" covers the options that are not rendered yet.
|
|
82
|
+
* Groups are only displayed when the clue is empty, hence the clue-less params.
|
|
83
|
+
*/
|
|
84
|
+
this.getGroupOptions = (legalUnitId) => this.#getLegalUnitOptions(legalUnitId, 0);
|
|
85
|
+
this.paramsSignal = computed(() => {
|
|
66
86
|
const clue = this.clue();
|
|
67
87
|
const searchDelimiter = this.searchDelimiter();
|
|
68
88
|
return {
|
|
69
|
-
...this
|
|
89
|
+
...this.#restrictionParams(),
|
|
70
90
|
...(clue
|
|
71
91
|
? // When the clue is not empty, sort establishments by name
|
|
72
92
|
{ search: applySearchDelimiter(clue, searchDelimiter), sort: 'name' }
|
|
73
93
|
: // When the clue is empty, establishments are grouped by legal unit, so sort them by legal unit name and then by name
|
|
74
94
|
{ sort: 'legalunit.name,name' }),
|
|
75
|
-
...(operationIds ? { operations: operationIds.join(',') } : {}),
|
|
76
|
-
...(uniqueOperationIds ? { uniqueOperations: uniqueOperationIds.join(',') } : {}),
|
|
77
|
-
...(appInstanceId ? { appInstanceId } : {}),
|
|
78
95
|
};
|
|
79
96
|
}, /* @ts-ignore */
|
|
80
97
|
...(ngDevMode ? [{ debugName: "paramsSignal" }] : /* istanbul ignore next */ []));
|
|
@@ -101,17 +118,23 @@ class LuCoreSelectEstablishmentsDirective extends ALuCoreSelectApiDirective {
|
|
|
101
118
|
});
|
|
102
119
|
});
|
|
103
120
|
}
|
|
121
|
+
/**
|
|
122
|
+
* Params shared by every call: the restrictions that define which establishments are selectable,
|
|
123
|
+
* without the clue-dependent search and sort.
|
|
124
|
+
*/
|
|
125
|
+
#restrictionParams;
|
|
104
126
|
buildParamsFromClue(clue) {
|
|
105
127
|
// Use the clue parameter directly instead of reading from the async signal
|
|
106
128
|
// to avoid stale params when selection triggers an immediate clue reset
|
|
107
129
|
return of({
|
|
108
|
-
...this
|
|
130
|
+
...this.#restrictionParams(),
|
|
109
131
|
...(clue ? { search: applySearchDelimiter(clue, this.searchDelimiter()), sort: 'name' } : { sort: 'legalunit.name,name' }),
|
|
110
|
-
...(this.operationIds() ? { operations: this.operationIds().join(',') } : {}),
|
|
111
|
-
...(this.uniqueOperationIds() ? { uniqueOperations: this.uniqueOperationIds().join(',') } : {}),
|
|
112
|
-
...(this.appInstanceId() ? { appInstanceId: this.appInstanceId() } : {}),
|
|
113
132
|
});
|
|
114
133
|
}
|
|
134
|
+
#getLegalUnitOptions(legalUnitId, page) {
|
|
135
|
+
const params = { ...this.#restrictionParams(), legalUnitId, sort: 'name' };
|
|
136
|
+
return this.getOptions(params, page).pipe(switchMap((options) => (options.length < this.pageSize ? of(options) : this.#getLegalUnitOptions(legalUnitId, page + 1).pipe(map((nextOptions) => [...options, ...nextOptions])))));
|
|
137
|
+
}
|
|
115
138
|
getOptions(params, page) {
|
|
116
139
|
const options$ = this.httpClient
|
|
117
140
|
.get(this.url(), {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lucca-front-ng-core-select-establishment.mjs","sources":["../../../packages/ng/core-select/establishment/establishment-grouping.service.ts","../../../packages/ng/core-select/establishment/establishment-grouping.component.ts","../../../packages/ng/core-select/establishment/establishments.directive.ts","../../../packages/ng/core-select/establishment/lucca-front-ng-core-select-establishment.ts"],"sourcesContent":["import { HttpClient, HttpParams } from '@angular/common/http';\nimport { Injectable, inject } from '@angular/core';\nimport { combineLatest, map, shareReplay } from 'rxjs';\n\n@Injectable({ providedIn: 'root' })\nexport class EstablishmentGroupingService {\n\tprotected http = inject(HttpClient);\n\tprotected establishmentsUrl = '/organization/structure/api/establishments';\n\tprotected legalUnitsUrl = '/organization/structure/api/legal-units';\n\n\tprotected countParams: HttpParams = new HttpParams().set('fields.root', 'count').set('limit', 0);\n\tprotected readonly establishmentsCount$ = this.http.get<{ count: number }>(this.establishmentsUrl, { params: this.countParams }).pipe(map((res) => res.count));\n\tprotected readonly legalUnitsCount$ = this.http.get<{ count: number }>(this.legalUnitsUrl, { params: this.countParams }).pipe(map((res) => res.count));\n\n\tpublic readonly useGrouping$ = combineLatest([this.legalUnitsCount$, this.establishmentsCount$]).pipe(\n\t\tmap(([luCount, establishmentCount]) => luCount > 1 && establishmentCount > 1),\n\t\tshareReplay(),\n\t);\n}\n","import { ChangeDetectionStrategy, Component, inject } from '@angular/core';\nimport { PORTAL_CONTEXT } from '@lucca-front/ng/core';\nimport { LuOptionGroupByContext } from '@lucca-front/ng/core-select';\nimport { LuCoreSelectEstablishment } from './models';\n\n@Component({\n\tselector: 'lu-establishment-grouping',\n\ttemplate: `{{ group.options[0].legalUnit.name }}`,\n\tchangeDetection: ChangeDetectionStrategy.OnPush,\n})\nexport class LuEstablishmentGroupingComponent {\n\tgroup = inject<LuOptionGroupByContext<LuCoreSelectEstablishment, number>>(PORTAL_CONTEXT).$implicit;\n}\n","import { HttpClient } from '@angular/common/http';\nimport { DestroyRef, Directive, OnInit, computed, forwardRef, inject, input } from '@angular/core';\nimport { takeUntilDestroyed, toObservable, toSignal } from '@angular/core/rxjs-interop';\nimport { luNullableNumberAttribute } from '@lucca-front/ng/core';\nimport { CORE_SELECT_API_TOTAL_COUNT_PROVIDER, CoreSelectApiTotalCountProvider, applySearchDelimiter } from '@lucca-front/ng/core-select';\nimport { ALuCoreSelectApiDirective } from '@lucca-front/ng/core-select/api';\nimport { Observable, debounceTime, filter, map, of, switchMap } from 'rxjs';\nimport { LuEstablishmentGroupingComponent } from './establishment-grouping.component';\nimport { EstablishmentGroupingService } from './establishment-grouping.service';\nimport { LuCoreSelectEstablishment } from './models';\n\n@Directive({\n\t// The attribute is already prefixed with \"lu-simple-select\" / \"lu-multi-select\"\n\t// eslint-disable-next-line @angular-eslint/directive-selector\n\tselector: 'lu-simple-select[establishments],lu-multi-select[establishments]',\n\texportAs: 'luEstablishments',\n\tproviders: [\n\t\t{\n\t\t\tprovide: CORE_SELECT_API_TOTAL_COUNT_PROVIDER,\n\t\t\tuseExisting: forwardRef(() => LuCoreSelectEstablishmentsDirective),\n\t\t},\n\t],\n})\nexport class LuCoreSelectEstablishmentsDirective<T extends LuCoreSelectEstablishment = LuCoreSelectEstablishment>\n\textends ALuCoreSelectApiDirective<T>\n\timplements OnInit, CoreSelectApiTotalCountProvider\n{\n\t#groupingService = inject(EstablishmentGroupingService);\n\t#destroyRef = inject(DestroyRef);\n\n\tprotected httpClient = inject(HttpClient);\n\n\treadonly url = input<string>('/organization/structure/api/establishments');\n\treadonly filters = input<Record<string, string | number | boolean> | null>(null);\n\treadonly operationIds = input<readonly number[] | null>(null);\n\treadonly uniqueOperationIds = input<readonly number[] | null>(null);\n\treadonly appInstanceId = input(null, { transform: luNullableNumberAttribute });\n\treadonly searchDelimiter = input<string>(' ');\n\n\tprotected readonly clue = toSignal(this.clue$);\n\n\tpublic override ngOnInit(): void {\n\t\tsuper.ngOnInit();\n\t\tthis.initGrouping();\n\t}\n\n\tprotected initGrouping() {\n\t\tthis.#groupingService.useGrouping$.pipe(filter(Boolean), takeUntilDestroyed(this.#destroyRef)).subscribe(() => {\n\t\t\tthis.select.groupingSignal.set({\n\t\t\t\tselector: (option) => option.legalUnitId,\n\t\t\t\tcontent: LuEstablishmentGroupingComponent,\n\t\t\t});\n\t\t});\n\t}\n\n\tprotected override buildParamsFromClue(clue: string): Observable<Record<string, string | number | boolean>> {\n\t\t// Use the clue parameter directly instead of reading from the async signal\n\t\t// to avoid stale params when selection triggers an immediate clue reset\n\t\treturn of({\n\t\t\t...this.filters(),\n\t\t\t...(clue ? { search: applySearchDelimiter(clue, this.searchDelimiter()), sort: 'name' } : { sort: 'legalunit.name,name' }),\n\t\t\t...(this.operationIds() ? { operations: this.operationIds()!.join(',') } : {}),\n\t\t\t...(this.uniqueOperationIds() ? { uniqueOperations: this.uniqueOperationIds()!.join(',') } : {}),\n\t\t\t...(this.appInstanceId() ? { appInstanceId: this.appInstanceId() } : {}),\n\t\t});\n\t}\n\n\tprotected override getOptions(params: Record<string, string | number | boolean> | null, page: number): Observable<T[]> {\n\t\tconst options$ = this.httpClient\n\t\t\t.get<T[] | { items: T[] }>(this.url(), {\n\t\t\t\tparams: {\n\t\t\t\t\t...params,\n\t\t\t\t\tpage: page + 1,\n\t\t\t\t\tlimit: this.pageSize,\n\t\t\t\t},\n\t\t\t})\n\t\t\t.pipe(map((res) => (Array.isArray(res) ? res : res?.items) ?? []));\n\n\t\treturn this.#groupingService.useGrouping$.pipe(switchMap(() => options$));\n\t}\n\n\tprotected override readonly paramsSignal = computed<Record<string, string | number | boolean>>(() => {\n\t\tconst operationIds = this.operationIds();\n\t\tconst uniqueOperationIds = this.uniqueOperationIds();\n\t\tconst appInstanceId = this.appInstanceId();\n\t\tconst clue = this.clue();\n\t\tconst searchDelimiter = this.searchDelimiter();\n\t\treturn {\n\t\t\t...this.filters(),\n\t\t\t...(clue\n\t\t\t\t? // When the clue is not empty, sort establishments by name\n\t\t\t\t\t{ search: applySearchDelimiter(clue, searchDelimiter), sort: 'name' }\n\t\t\t\t: // When the clue is empty, establishments are grouped by legal unit, so sort them by legal unit name and then by name\n\t\t\t\t\t{ sort: 'legalunit.name,name' }),\n\t\t\t...(operationIds ? { operations: operationIds.join(',') } : {}),\n\t\t\t...(uniqueOperationIds ? { uniqueOperations: uniqueOperationIds.join(',') } : {}),\n\t\t\t...(appInstanceId ? { appInstanceId } : {}),\n\t\t};\n\t});\n\tprotected override readonly params$: Observable<Record<string, string | number | boolean>> = toObservable(this.paramsSignal);\n\n\tpublic readonly totalCount$ = toObservable(computed(() => ({ url: this.url(), filters: this.filters() }))).pipe(\n\t\tdebounceTime(250),\n\t\tswitchMap(({ url, filters }) =>\n\t\t\tthis.httpClient.get<{ count: number }>(url, {\n\t\t\t\tparams: {\n\t\t\t\t\t...filters,\n\t\t\t\t\t['fields.root']: 'count',\n\t\t\t\t},\n\t\t\t}),\n\t\t),\n\t\tmap((res) => res?.count ?? 0),\n\t);\n\n\tprotected override optionKey = (option: T) => option.id;\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;;;MAKa,4BAA4B,CAAA;AADzC,IAAA,WAAA,GAAA;AAEW,QAAA,IAAA,CAAA,IAAI,GAAG,MAAM,CAAC,UAAU,CAAC;QACzB,IAAA,CAAA,iBAAiB,GAAG,4CAA4C;QAChE,IAAA,CAAA,aAAa,GAAG,yCAAyC;AAEzD,QAAA,IAAA,CAAA,WAAW,GAAe,IAAI,UAAU,EAAE,CAAC,GAAG,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;AAC7E,QAAA,IAAA,CAAA,oBAAoB,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAoB,IAAI,CAAC,iBAAiB,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,KAAK,GAAG,CAAC,KAAK,CAAC,CAAC;AAC3I,QAAA,IAAA,CAAA,gBAAgB,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAoB,IAAI,CAAC,aAAa,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,KAAK,GAAG,CAAC,KAAK,CA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AAA,EAAA,EAAA,kBAAA,EAAA,EAAA,iBAAA,EAAA,oBAAA,EAAA,UAAA,EAAA,oBAAA,EAAA,QAAA,EAAA,IAAA,EAAA,UAAA,EAAA,KAAA,EAAA,iBAAA,EAAA,IAAA,EAAA,EAAA,aAAA,EAAA,EAAA,iBAAA,EAAA,eAAA,EAAA,UAAA,EAAA,eAAA,EAAA,QAAA,EAAA,IAAA,EAAA,UAAA,EAAA,KAAA,EAAA,iBAAA,EAAA,IAAA,EAAA,EAAA,eAAA,EAAA,EAAA,iBAAA,EAAA,iBAAA,EAAA,UAAA,EAAA,iBAAA,EAAA,QAAA,EAAA,IAAA,EAAA,UAAA,EAAA,KAAA,EAAA,iBAAA,EAAA,IAAA,EAAA,EAAA,EAAA,SAAA,EAPpC;AACV,YAAA;AACC,gBAAA,OAAO,EAAE,oCAAoC;AAC7C,gBAAA,WAAW,EAAE,UAAU,CAAC,MAAM,mCAAmC,CAAC;AAClE,aAAA;AACD,SAAA,EAAA,QAAA,EAAA,CAAA,kBAAA,CAAA,EAAA,eAAA,EAAA,IAAA,EAAA,QAAA,EAAA,EAAA,EAAA,CAAA,CAAA;;2FAEW,mCAAmC,EAAA,UAAA,EAAA,CAAA;kBAZ/C,SAAS;AAAC,YAAA,IAAA,EAAA,CAAA;;;AAGV,oBAAA,QAAQ,EAAE,kEAAkE;AAC5E,oBAAA,QAAQ,EAAE,kBAAkB;AAC5B,oBAAA,SAAS,EAAE;AACV,wBAAA;AACC,4BAAA,OAAO,EAAE,oCAAoC;AAC7C,4BAAA,WAAW,EAAE,UAAU,CAAC,yCAAyC,CAAC;AAClE,yBAAA;AACD,qBAAA;AACD,iBAAA;;;ACtBD;;AAEG;;"}
|
|
1
|
+
{"version":3,"file":"lucca-front-ng-core-select-establishment.mjs","sources":["../../../packages/ng/core-select/establishment/establishment-grouping.service.ts","../../../packages/ng/core-select/establishment/establishment-grouping.component.ts","../../../packages/ng/core-select/establishment/establishments.directive.ts","../../../packages/ng/core-select/establishment/lucca-front-ng-core-select-establishment.ts"],"sourcesContent":["import { HttpClient, HttpParams } from '@angular/common/http';\nimport { Injectable, inject } from '@angular/core';\nimport { combineLatest, map, shareReplay } from 'rxjs';\n\n@Injectable({ providedIn: 'root' })\nexport class EstablishmentGroupingService {\n\tprotected http = inject(HttpClient);\n\tprotected establishmentsUrl = '/organization/structure/api/establishments';\n\tprotected legalUnitsUrl = '/organization/structure/api/legal-units';\n\n\tprotected countParams: HttpParams = new HttpParams().set('fields.root', 'count').set('limit', 0);\n\tprotected readonly establishmentsCount$ = this.http.get<{ count: number }>(this.establishmentsUrl, { params: this.countParams }).pipe(map((res) => res.count));\n\tprotected readonly legalUnitsCount$ = this.http.get<{ count: number }>(this.legalUnitsUrl, { params: this.countParams }).pipe(map((res) => res.count));\n\n\tpublic readonly useGrouping$ = combineLatest([this.legalUnitsCount$, this.establishmentsCount$]).pipe(\n\t\tmap(([luCount, establishmentCount]) => luCount > 1 && establishmentCount > 1),\n\t\tshareReplay(),\n\t);\n}\n","import { ChangeDetectionStrategy, Component, inject } from '@angular/core';\nimport { PORTAL_CONTEXT } from '@lucca-front/ng/core';\nimport { LuOptionGroupByContext } from '@lucca-front/ng/core-select';\nimport { LuCoreSelectEstablishment } from './models';\n\n@Component({\n\tselector: 'lu-establishment-grouping',\n\ttemplate: `{{ group.options[0].legalUnit.name }}`,\n\tchangeDetection: ChangeDetectionStrategy.OnPush,\n})\nexport class LuEstablishmentGroupingComponent {\n\tgroup = inject<LuOptionGroupByContext<LuCoreSelectEstablishment, number>>(PORTAL_CONTEXT).$implicit;\n}\n","import { HttpClient } from '@angular/common/http';\nimport { DestroyRef, Directive, OnInit, computed, forwardRef, inject, input } from '@angular/core';\nimport { takeUntilDestroyed, toObservable, toSignal } from '@angular/core/rxjs-interop';\nimport { luNullableNumberAttribute } from '@lucca-front/ng/core';\nimport { CORE_SELECT_API_TOTAL_COUNT_PROVIDER, CoreSelectApiTotalCountProvider, applySearchDelimiter } from '@lucca-front/ng/core-select';\nimport { ALuCoreSelectApiDirective } from '@lucca-front/ng/core-select/api';\nimport { Observable, debounceTime, filter, map, of, switchMap } from 'rxjs';\nimport { LuEstablishmentGroupingComponent } from './establishment-grouping.component';\nimport { EstablishmentGroupingService } from './establishment-grouping.service';\nimport { LuCoreSelectEstablishment } from './models';\n\n@Directive({\n\t// The attribute is already prefixed with \"lu-simple-select\" / \"lu-multi-select\"\n\t// eslint-disable-next-line @angular-eslint/directive-selector\n\tselector: 'lu-simple-select[establishments],lu-multi-select[establishments]',\n\texportAs: 'luEstablishments',\n\tproviders: [\n\t\t{\n\t\t\tprovide: CORE_SELECT_API_TOTAL_COUNT_PROVIDER,\n\t\t\tuseExisting: forwardRef(() => LuCoreSelectEstablishmentsDirective),\n\t\t},\n\t],\n})\nexport class LuCoreSelectEstablishmentsDirective<T extends LuCoreSelectEstablishment = LuCoreSelectEstablishment>\n\textends ALuCoreSelectApiDirective<T>\n\timplements OnInit, CoreSelectApiTotalCountProvider\n{\n\t#groupingService = inject(EstablishmentGroupingService);\n\t#destroyRef = inject(DestroyRef);\n\n\tprotected httpClient = inject(HttpClient);\n\n\treadonly url = input<string>('/organization/structure/api/establishments');\n\treadonly filters = input<Record<string, string | number | boolean> | null>(null);\n\treadonly operationIds = input<readonly number[] | null>(null);\n\treadonly uniqueOperationIds = input<readonly number[] | null>(null);\n\treadonly appInstanceId = input(null, { transform: luNullableNumberAttribute });\n\treadonly searchDelimiter = input<string>(' ');\n\n\tprotected readonly clue = toSignal(this.clue$);\n\n\tpublic override ngOnInit(): void {\n\t\tsuper.ngOnInit();\n\t\tthis.initGrouping();\n\t}\n\n\tprotected initGrouping() {\n\t\tthis.#groupingService.useGrouping$.pipe(filter(Boolean), takeUntilDestroyed(this.#destroyRef)).subscribe(() => {\n\t\t\tthis.select.groupingSignal.set({\n\t\t\t\tselector: (option) => option.legalUnitId,\n\t\t\t\tcontent: LuEstablishmentGroupingComponent,\n\t\t\t});\n\t\t});\n\t}\n\n\t/**\n\t * Params shared by every call: the restrictions that define which establishments are selectable,\n\t * without the clue-dependent search and sort.\n\t */\n\treadonly #restrictionParams = computed<Record<string, string | number | boolean>>(() => {\n\t\tconst operationIds = this.operationIds();\n\t\tconst uniqueOperationIds = this.uniqueOperationIds();\n\t\tconst appInstanceId = this.appInstanceId();\n\t\treturn {\n\t\t\t...this.filters(),\n\t\t\t...(operationIds ? { operations: operationIds.join(',') } : {}),\n\t\t\t...(uniqueOperationIds ? { uniqueOperations: uniqueOperationIds.join(',') } : {}),\n\t\t\t...(appInstanceId ? { appInstanceId } : {}),\n\t\t};\n\t});\n\n\tprotected override buildParamsFromClue(clue: string): Observable<Record<string, string | number | boolean>> {\n\t\t// Use the clue parameter directly instead of reading from the async signal\n\t\t// to avoid stale params when selection triggers an immediate clue reset\n\t\treturn of({\n\t\t\t...this.#restrictionParams(),\n\t\t\t...(clue ? { search: applySearchDelimiter(clue, this.searchDelimiter()), sort: 'name' } : { sort: 'legalunit.name,name' }),\n\t\t});\n\t}\n\n\t/**\n\t * Establishments are grouped by legal unit, but the panel only knows the options of the pages it\n\t * already loaded: a legal unit spanning several pages would be partially selected. Fetch the whole\n\t * legal unit instead, page by page, so \"select all\" covers the options that are not rendered yet.\n\t * Groups are only displayed when the clue is empty, hence the clue-less params.\n\t */\n\tprotected override getGroupOptions = (legalUnitId: unknown): Observable<T[]> => this.#getLegalUnitOptions(legalUnitId as number, 0);\n\n\t#getLegalUnitOptions(legalUnitId: number, page: number): Observable<T[]> {\n\t\tconst params = { ...this.#restrictionParams(), legalUnitId, sort: 'name' };\n\t\treturn this.getOptions(params, page).pipe(\n\t\t\tswitchMap((options) => (options.length < this.pageSize ? of(options) : this.#getLegalUnitOptions(legalUnitId, page + 1).pipe(map((nextOptions) => [...options, ...nextOptions])))),\n\t\t);\n\t}\n\n\tprotected override getOptions(params: Record<string, string | number | boolean> | null, page: number): Observable<T[]> {\n\t\tconst options$ = this.httpClient\n\t\t\t.get<T[] | { items: T[] }>(this.url(), {\n\t\t\t\tparams: {\n\t\t\t\t\t...params,\n\t\t\t\t\tpage: page + 1,\n\t\t\t\t\tlimit: this.pageSize,\n\t\t\t\t},\n\t\t\t})\n\t\t\t.pipe(map((res) => (Array.isArray(res) ? res : res?.items) ?? []));\n\n\t\treturn this.#groupingService.useGrouping$.pipe(switchMap(() => options$));\n\t}\n\n\tprotected override readonly paramsSignal = computed<Record<string, string | number | boolean>>(() => {\n\t\tconst clue = this.clue();\n\t\tconst searchDelimiter = this.searchDelimiter();\n\t\treturn {\n\t\t\t...this.#restrictionParams(),\n\t\t\t...(clue\n\t\t\t\t? // When the clue is not empty, sort establishments by name\n\t\t\t\t\t{ search: applySearchDelimiter(clue, searchDelimiter), sort: 'name' }\n\t\t\t\t: // When the clue is empty, establishments are grouped by legal unit, so sort them by legal unit name and then by name\n\t\t\t\t\t{ sort: 'legalunit.name,name' }),\n\t\t};\n\t});\n\tprotected override readonly params$: Observable<Record<string, string | number | boolean>> = toObservable(this.paramsSignal);\n\n\tpublic readonly totalCount$ = toObservable(computed(() => ({ url: this.url(), filters: this.filters() }))).pipe(\n\t\tdebounceTime(250),\n\t\tswitchMap(({ url, filters }) =>\n\t\t\tthis.httpClient.get<{ count: number }>(url, {\n\t\t\t\tparams: {\n\t\t\t\t\t...filters,\n\t\t\t\t\t['fields.root']: 'count',\n\t\t\t\t},\n\t\t\t}),\n\t\t),\n\t\tmap((res) => res?.count ?? 0),\n\t);\n\n\tprotected override optionKey = (option: T) => option.id;\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;;;MAKa,4BAA4B,CAAA;AADzC,IAAA,WAAA,GAAA;AAEW,QAAA,IAAA,CAAA,IAAI,GAAG,MAAM,CAAC,UAAU,CAAC;QACzB,IAAA,CAAA,iBAAiB,GAAG,4CAA4C;QAChE,IAAA,CAAA,aAAa,GAAG,yCAAyC;AAEzD,QAAA,IAAA,CAAA,WAAW,GAAe,IAAI,UAAU,EAAE,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A,IAAA,EAAA,UAAA,EAAA,KAAA,EAAA,iBAAA,EAAA,IAAA,EAAA,EAAA,eAAA,EAAA,EAAA,iBAAA,EAAA,iBAAA,EAAA,UAAA,EAAA,iBAAA,EAAA,QAAA,EAAA,IAAA,EAAA,UAAA,EAAA,KAAA,EAAA,iBAAA,EAAA,IAAA,EAAA,EAAA,EAAA,SAAA,EAPpC;AACV,YAAA;AACC,gBAAA,OAAO,EAAE,oCAAoC;AAC7C,gBAAA,WAAW,EAAE,UAAU,CAAC,MAAM,mCAAmC,CAAC;AAClE,aAAA;AACD,SAAA,EAAA,QAAA,EAAA,CAAA,kBAAA,CAAA,EAAA,eAAA,EAAA,IAAA,EAAA,QAAA,EAAA,EAAA,EAAA,CAAA,CAAA;;2FAEW,mCAAmC,EAAA,UAAA,EAAA,CAAA;kBAZ/C,SAAS;AAAC,YAAA,IAAA,EAAA,CAAA;;;AAGV,oBAAA,QAAQ,EAAE,kEAAkE;AAC5E,oBAAA,QAAQ,EAAE,kBAAkB;AAC5B,oBAAA,SAAS,EAAE;AACV,wBAAA;AACC,4BAAA,OAAO,EAAE,oCAAoC;AAC7C,4BAAA,WAAW,EAAE,UAAU,CAAC,yCAAyC,CAAC;AAClE,yBAAA;AACD,qBAAA;AACD,iBAAA;;;ACtBD;;AAEG;;"}
|
|
@@ -34,6 +34,13 @@ class LuCoreSelectJobQualificationsDirective extends ALuCoreSelectApiDirective {
|
|
|
34
34
|
this.searchDelimiter = input(' ', /* @ts-ignore */
|
|
35
35
|
...(ngDevMode ? [{ debugName: "searchDelimiter" }] : /* istanbul ignore next */ []));
|
|
36
36
|
this.clue = toSignal(this.clue$);
|
|
37
|
+
/**
|
|
38
|
+
* Job qualifications are grouped by job, but the panel only knows the options of the pages it
|
|
39
|
+
* already loaded: a job spanning several pages would be partially selected. Fetch the whole job
|
|
40
|
+
* instead, page by page, so "select all" covers the options that are not rendered yet. Groups are
|
|
41
|
+
* only displayed when the clue is empty, hence the clue-less params.
|
|
42
|
+
*/
|
|
43
|
+
this.getGroupOptions = (jobId) => this.#getJobOptions(jobId, 0);
|
|
37
44
|
this.paramsSignal = computed(() => {
|
|
38
45
|
const filters = this.filters();
|
|
39
46
|
const clue = this.clue();
|
|
@@ -69,6 +76,10 @@ class LuCoreSelectJobQualificationsDirective extends ALuCoreSelectApiDirective {
|
|
|
69
76
|
...(clue ? { search: applySearchDelimiter(clue, this.searchDelimiter()), sort: 'name' } : { sort: 'job.name,level.position' }),
|
|
70
77
|
});
|
|
71
78
|
}
|
|
79
|
+
#getJobOptions(jobId, page) {
|
|
80
|
+
const params = { ...this.filters(), 'job.id': jobId, sort: 'level.position' };
|
|
81
|
+
return this.getOptions(params, page).pipe(switchMap((options) => (options.length < this.pageSize ? of(options) : this.#getJobOptions(jobId, page + 1).pipe(map((nextOptions) => [...options, ...nextOptions])))));
|
|
82
|
+
}
|
|
72
83
|
getOptions(params, page) {
|
|
73
84
|
return this.httpClient
|
|
74
85
|
.get(this.url(), {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lucca-front-ng-core-select-job-qualification.mjs","sources":["../../../packages/ng/core-select/job-qualification/job-qualification-grouping.component.ts","../../../packages/ng/core-select/job-qualification/job-qualifications.directive.ts","../../../packages/ng/core-select/job-qualification/lucca-front-ng-core-select-job-qualification.ts"],"sourcesContent":["import { ChangeDetectionStrategy, Component, inject } from '@angular/core';\nimport { PORTAL_CONTEXT } from '@lucca-front/ng/core';\nimport { LuOptionGroupByContext } from '@lucca-front/ng/core-select';\nimport { LuCoreSelectJobQualification } from './models';\n\n@Component({\n\tselector: 'lu-job-qualification-grouping',\n\ttemplate: `{{ group.options[0].job.name }}`,\n\tchangeDetection: ChangeDetectionStrategy.OnPush,\n})\nexport class LuJobQualificationGroupingComponent {\n\tgroup = inject<LuOptionGroupByContext<LuCoreSelectJobQualification, number>>(PORTAL_CONTEXT).$implicit;\n}\n","import { HttpClient } from '@angular/common/http';\nimport { Directive, OnInit, computed, forwardRef, inject, input } from '@angular/core';\nimport { toObservable, toSignal } from '@angular/core/rxjs-interop';\nimport { CORE_SELECT_API_TOTAL_COUNT_PROVIDER, CoreSelectApiTotalCountProvider, applySearchDelimiter } from '@lucca-front/ng/core-select';\nimport { ALuCoreSelectApiDirective } from '@lucca-front/ng/core-select/api';\nimport { Observable, debounceTime, map, of, switchMap } from 'rxjs';\nimport { LuJobQualificationGroupingComponent } from './job-qualification-grouping.component';\nimport { LuCoreSelectJobQualification } from './models';\n\n@Directive({\n\t// The attribute is already prefixed with \"lu-simple-select\" / \"lu-multi-select\"\n\t// eslint-disable-next-line @angular-eslint/directive-selector\n\tselector: 'lu-simple-select[jobQualifications],lu-multi-select[jobQualifications]',\n\texportAs: 'jobQualifications',\n\tproviders: [\n\t\t{\n\t\t\tprovide: CORE_SELECT_API_TOTAL_COUNT_PROVIDER,\n\t\t\tuseExisting: forwardRef(() => LuCoreSelectJobQualificationsDirective),\n\t\t},\n\t],\n})\nexport class LuCoreSelectJobQualificationsDirective<T extends LuCoreSelectJobQualification = LuCoreSelectJobQualification>\n\textends ALuCoreSelectApiDirective<T>\n\timplements OnInit, CoreSelectApiTotalCountProvider\n{\n\tprotected httpClient = inject(HttpClient);\n\n\treadonly url = input<string>('/organization/structure/api/job-qualifications');\n\treadonly filters = input<Record<string, string | number | boolean> | null>(null);\n\treadonly searchDelimiter = input<string>(' ');\n\n\tprotected readonly clue = toSignal(this.clue$);\n\n\tpublic constructor() {\n\t\tsuper();\n\n\t\tthis.select.groupingSignal.set({\n\t\t\tselector: (option) => option.job.id,\n\t\t\tcontent: LuJobQualificationGroupingComponent,\n\t\t});\n\t}\n\n\tprotected override buildParamsFromClue(clue: string): Observable<Record<string, string | number | boolean>> {\n\t\t// Use the clue parameter directly instead of reading from the async signal\n\t\t// to avoid stale params when selection triggers an immediate clue reset\n\t\treturn of({\n\t\t\t...this.filters(),\n\t\t\t...(clue ? { search: applySearchDelimiter(clue, this.searchDelimiter()), sort: 'name' } : { sort: 'job.name,level.position' }),\n\t\t});\n\t}\n\n\tprotected override getOptions(params: Record<string, string | number | boolean> | null, page: number): Observable<T[]> {\n\t\treturn this.httpClient\n\t\t\t.get<T[] | { items: T[] }>(this.url(), {\n\t\t\t\tparams: {\n\t\t\t\t\t...params,\n\t\t\t\t\tpage: page + 1,\n\t\t\t\t\tlimit: this.pageSize,\n\t\t\t\t},\n\t\t\t})\n\t\t\t.pipe(map((res) => (Array.isArray(res) ? res : res?.items) ?? []));\n\t}\n\n\tprotected override readonly paramsSignal = computed<Record<string, string | number | boolean>>(() => {\n\t\tconst filters = this.filters();\n\t\tconst clue = this.clue();\n\t\treturn {\n\t\t\t...filters,\n\t\t\t...(clue\n\t\t\t\t? {\n\t\t\t\t\t\tsearch: applySearchDelimiter(clue, this.searchDelimiter()),\n\t\t\t\t\t\tsort: 'name',\n\t\t\t\t\t}\n\t\t\t\t: { sort: 'job.name,level.position' }),\n\t\t};\n\t});\n\tprotected override readonly params$: Observable<Record<string, string | number | boolean>> = toObservable(this.paramsSignal);\n\n\tpublic readonly totalCount$ = toObservable(computed(() => ({ url: this.url(), filters: this.filters() }))).pipe(\n\t\tdebounceTime(250),\n\t\tswitchMap(({ url, filters }) =>\n\t\t\tthis.httpClient.get<{ count: number }>(url, {\n\t\t\t\tparams: {\n\t\t\t\t\t...filters,\n\t\t\t\t\t['fields.root']: 'count',\n\t\t\t\t},\n\t\t\t}),\n\t\t),\n\t\tmap((res) => res?.count ?? 0),\n\t);\n\n\tprotected override optionKey = (option: T) => option.id;\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;;;MAUa,mCAAmC,CAAA;AALhD,IAAA,WAAA,GAAA;AAMC,QAAA,IAAA,CAAA,KAAK,GAAG,MAAM,CAA+D,cAAc,CAAC,CAAC,SAAS;AACtG,IAAA;8GAFY,mCAAmC,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,SAAA,EA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ACC,gBAAA,OAAO,EAAE,oCAAoC;AAC7C,gBAAA,WAAW,EAAE,UAAU,CAAC,MAAM,sCAAsC,CAAC;AACrE,aAAA;AACD,SAAA,EAAA,QAAA,EAAA,CAAA,mBAAA,CAAA,EAAA,eAAA,EAAA,IAAA,EAAA,QAAA,EAAA,EAAA,EAAA,CAAA,CAAA;;2FAEW,sCAAsC,EAAA,UAAA,EAAA,CAAA;kBAZlD,SAAS;AAAC,YAAA,IAAA,EAAA,CAAA;;;AAGV,oBAAA,QAAQ,EAAE,wEAAwE;AAClF,oBAAA,QAAQ,EAAE,mBAAmB;AAC7B,oBAAA,SAAS,EAAE;AACV,wBAAA;AACC,4BAAA,OAAO,EAAE,oCAAoC;AAC7C,4BAAA,WAAW,EAAE,UAAU,CAAC,4CAA4C,CAAC;AACrE,yBAAA;AACD,qBAAA;AACD,iBAAA;;;ACpBD;;AAEG;;"}
|
|
1
|
+
{"version":3,"file":"lucca-front-ng-core-select-job-qualification.mjs","sources":["../../../packages/ng/core-select/job-qualification/job-qualification-grouping.component.ts","../../../packages/ng/core-select/job-qualification/job-qualifications.directive.ts","../../../packages/ng/core-select/job-qualification/lucca-front-ng-core-select-job-qualification.ts"],"sourcesContent":["import { ChangeDetectionStrategy, Component, inject } from '@angular/core';\nimport { PORTAL_CONTEXT } from '@lucca-front/ng/core';\nimport { LuOptionGroupByContext } from '@lucca-front/ng/core-select';\nimport { LuCoreSelectJobQualification } from './models';\n\n@Component({\n\tselector: 'lu-job-qualification-grouping',\n\ttemplate: `{{ group.options[0].job.name }}`,\n\tchangeDetection: ChangeDetectionStrategy.OnPush,\n})\nexport class LuJobQualificationGroupingComponent {\n\tgroup = inject<LuOptionGroupByContext<LuCoreSelectJobQualification, number>>(PORTAL_CONTEXT).$implicit;\n}\n","import { HttpClient } from '@angular/common/http';\nimport { Directive, OnInit, computed, forwardRef, inject, input } from '@angular/core';\nimport { toObservable, toSignal } from '@angular/core/rxjs-interop';\nimport { CORE_SELECT_API_TOTAL_COUNT_PROVIDER, CoreSelectApiTotalCountProvider, applySearchDelimiter } from '@lucca-front/ng/core-select';\nimport { ALuCoreSelectApiDirective } from '@lucca-front/ng/core-select/api';\nimport { Observable, debounceTime, map, of, switchMap } from 'rxjs';\nimport { LuJobQualificationGroupingComponent } from './job-qualification-grouping.component';\nimport { LuCoreSelectJobQualification } from './models';\n\n@Directive({\n\t// The attribute is already prefixed with \"lu-simple-select\" / \"lu-multi-select\"\n\t// eslint-disable-next-line @angular-eslint/directive-selector\n\tselector: 'lu-simple-select[jobQualifications],lu-multi-select[jobQualifications]',\n\texportAs: 'jobQualifications',\n\tproviders: [\n\t\t{\n\t\t\tprovide: CORE_SELECT_API_TOTAL_COUNT_PROVIDER,\n\t\t\tuseExisting: forwardRef(() => LuCoreSelectJobQualificationsDirective),\n\t\t},\n\t],\n})\nexport class LuCoreSelectJobQualificationsDirective<T extends LuCoreSelectJobQualification = LuCoreSelectJobQualification>\n\textends ALuCoreSelectApiDirective<T>\n\timplements OnInit, CoreSelectApiTotalCountProvider\n{\n\tprotected httpClient = inject(HttpClient);\n\n\treadonly url = input<string>('/organization/structure/api/job-qualifications');\n\treadonly filters = input<Record<string, string | number | boolean> | null>(null);\n\treadonly searchDelimiter = input<string>(' ');\n\n\tprotected readonly clue = toSignal(this.clue$);\n\n\tpublic constructor() {\n\t\tsuper();\n\n\t\tthis.select.groupingSignal.set({\n\t\t\tselector: (option) => option.job.id,\n\t\t\tcontent: LuJobQualificationGroupingComponent,\n\t\t});\n\t}\n\n\tprotected override buildParamsFromClue(clue: string): Observable<Record<string, string | number | boolean>> {\n\t\t// Use the clue parameter directly instead of reading from the async signal\n\t\t// to avoid stale params when selection triggers an immediate clue reset\n\t\treturn of({\n\t\t\t...this.filters(),\n\t\t\t...(clue ? { search: applySearchDelimiter(clue, this.searchDelimiter()), sort: 'name' } : { sort: 'job.name,level.position' }),\n\t\t});\n\t}\n\n\t/**\n\t * Job qualifications are grouped by job, but the panel only knows the options of the pages it\n\t * already loaded: a job spanning several pages would be partially selected. Fetch the whole job\n\t * instead, page by page, so \"select all\" covers the options that are not rendered yet. Groups are\n\t * only displayed when the clue is empty, hence the clue-less params.\n\t */\n\tprotected override getGroupOptions = (jobId: unknown): Observable<T[]> => this.#getJobOptions(jobId as number, 0);\n\n\t#getJobOptions(jobId: number, page: number): Observable<T[]> {\n\t\tconst params = { ...this.filters(), 'job.id': jobId, sort: 'level.position' };\n\t\treturn this.getOptions(params, page).pipe(\n\t\t\tswitchMap((options) => (options.length < this.pageSize ? of(options) : this.#getJobOptions(jobId, page + 1).pipe(map((nextOptions) => [...options, ...nextOptions])))),\n\t\t);\n\t}\n\n\tprotected override getOptions(params: Record<string, string | number | boolean> | null, page: number): Observable<T[]> {\n\t\treturn this.httpClient\n\t\t\t.get<T[] | { items: T[] }>(this.url(), {\n\t\t\t\tparams: {\n\t\t\t\t\t...params,\n\t\t\t\t\tpage: page + 1,\n\t\t\t\t\tlimit: this.pageSize,\n\t\t\t\t},\n\t\t\t})\n\t\t\t.pipe(map((res) => (Array.isArray(res) ? res : res?.items) ?? []));\n\t}\n\n\tprotected override readonly paramsSignal = computed<Record<string, string | number | boolean>>(() => {\n\t\tconst filters = this.filters();\n\t\tconst clue = this.clue();\n\t\treturn {\n\t\t\t...filters,\n\t\t\t...(clue\n\t\t\t\t? {\n\t\t\t\t\t\tsearch: applySearchDelimiter(clue, this.searchDelimiter()),\n\t\t\t\t\t\tsort: 'name',\n\t\t\t\t\t}\n\t\t\t\t: { sort: 'job.name,level.position' }),\n\t\t};\n\t});\n\tprotected override readonly params$: Observable<Record<string, string | number | boolean>> = toObservable(this.paramsSignal);\n\n\tpublic readonly totalCount$ = toObservable(computed(() => ({ url: this.url(), filters: this.filters() }))).pipe(\n\t\tdebounceTime(250),\n\t\tswitchMap(({ url, filters }) =>\n\t\t\tthis.httpClient.get<{ count: number }>(url, {\n\t\t\t\tparams: {\n\t\t\t\t\t...filters,\n\t\t\t\t\t['fields.root']: 'count',\n\t\t\t\t},\n\t\t\t}),\n\t\t),\n\t\tmap((res) => res?.count ?? 0),\n\t);\n\n\tprotected override optionKey = (option: T) => option.id;\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;;;MAUa,mCAAmC,CAAA;AALhD,IAAA,WAAA,GAAA;AAMC,QAAA,IAAA,CAAA,KAAK,GAAG,MAAM,CAA+D,cAAc,CAAC,CAAC,SAAS;AACtG,IAAA;8GAFY,mCAAmC,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,SAAA,EAAA,CAAA,CAAA;AAAnC,IAAA,SAAA,IAAA,CAAA,IAAA,GAAA,EAAA,CAAA,oBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,IAAA,EAAA,mCAAmC,yFAHrC,CAAA,+BAAA,CAAiC,EAAA,QAAA,EAAA,IAAA,EAAA,eAAA,EAAA,EAAA,CAAA,uBAAA,CAAA,MAAA,EAAA,CAAA,CAAA;;2FAG/B,mCAAmC,EAAA,UAAA,EAAA,CAAA;kBAL/C,SAAS;AAAC,YAAA,IAAA,EAAA,CAAA;AACV,oBAAA,QAAQ,EAAE,+BAA+B;AACzC,oBAAA,QAAQ,EAAE,CAAA,+BAAA,CAAiC;oBAC3C,eAAe,EAAE,uBAAuB,CAAC,MAAM;AAC/C,iBAAA;;;ACYK,MAAO,sCACZ,SAAQ,yBAA4B,CAAA;AAWpC,IAAA,WAAA,GAAA;AACC,QAAA,KAAK,EAAE;AATE,QAAA,IAAA,CAAA,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC;QAEhC,IAAA,CAAA,GAAG,GAAG,KAAK,CAAS,gDAAgD;gFAAC;QACrE,IAAA,CAAA,OAAO,GAAG,KAAK,CAAmD,IAAI;oFAAC;QACvE,IAAA,CAAA,eAAe,GAAG,KAAK,CAAS,GAAG;4FAAC;AAE1B,QAAA,IAAA,CAA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AAA,QAAA,EAAA,EAAA,EAAA,CAAA,CAAA;;2FAEW,sCAAsC,EAAA,UAAA,EAAA,CAAA;kBAZlD,SAAS;AAAC,YAAA,IAAA,EAAA,CAAA;;;AAGV,oBAAA,QAAQ,EAAE,wEAAwE;AAClF,oBAAA,QAAQ,EAAE,mBAAmB;AAC7B,oBAAA,SAAS,EAAE;AACV,wBAAA;AACC,4BAAA,OAAO,EAAE,oCAAoC;AAC7C,4BAAA,WAAW,EAAE,UAAU,CAAC,4CAA4C,CAAC;AACrE,yBAAA;AACD,qBAAA;AACD,iBAAA;;;ACpBD;;AAEG;;"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { registerPlainText } from '@lexical/plain-text';
|
|
2
2
|
import { $rootTextContent } from '@lexical/text';
|
|
3
|
+
import { mergeRegister } from '@lexical/utils';
|
|
3
4
|
import { $createTagNode, RichTextFormatter, RICH_TEXT_FORMATTER } from '@lucca-front/ng/forms/rich-text-input';
|
|
4
|
-
import { $getRoot, $createParagraphNode, $createTextNode } from 'lexical';
|
|
5
|
+
import { TextNode, $getRoot, $createParagraphNode, $createTextNode } from 'lexical';
|
|
5
6
|
import * as i0 from '@angular/core';
|
|
6
7
|
import { Directive } from '@angular/core';
|
|
7
8
|
|
|
@@ -28,7 +29,9 @@ class PlainTextFormatter extends RichTextFormatter {
|
|
|
28
29
|
}
|
|
29
30
|
}
|
|
30
31
|
registerTextPlugin(editor) {
|
|
31
|
-
return registerPlainText(editor)
|
|
32
|
+
return mergeRegister(registerPlainText(editor),
|
|
33
|
+
// Pasted content is inserted as raw text: apply the transformers whenever a text node changes
|
|
34
|
+
editor.registerNodeTransform(TextNode, (textNode) => this.#applyTransformers(textNode)));
|
|
32
35
|
}
|
|
33
36
|
parse(editor, text) {
|
|
34
37
|
editor.update(() => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lucca-front-ng-forms-rich-text-input-formatters-plain-text.mjs","sources":["../../../packages/ng/forms/rich-text-input/formatters/plain-text/transformers/tag.transformers.ts","../../../packages/ng/forms/rich-text-input/formatters/plain-text/plain-text-formatter.ts","../../../packages/ng/forms/rich-text-input/formatters/plain-text/plain-text-formatter.directive.ts","../../../packages/ng/forms/rich-text-input/formatters/plain-text/lucca-front-ng-forms-rich-text-input-formatters-plain-text.ts"],"sourcesContent":["import { $createTagNode } from '@lucca-front/ng/forms/rich-text-input';\nimport { PlainTextTransformer } from './plain-text-transformer';\n\n/**\n * Transformer for tag nodes\n * It will match the following pattern `{{Tag}}` and create a TagNode (using `replace` function).\n *\n */\nexport const PLAINTEXT_TAGS: PlainTextTransformer = {\n\tregExp: /{{(\\w+)}}/,\n\treplace: (textNode, match) => {\n\t\tif (match[1]) {\n\t\t\ttextNode.replace($createTagNode(match[1].trim()));\n\t\t}\n\t},\n};\n","import { Provider } from '@angular/core';\nimport { registerPlainText } from '@lexical/plain-text';\nimport { $rootTextContent } from '@lexical/text';\nimport { RICH_TEXT_FORMATTER, RichTextFormatter } from '@lucca-front/ng/forms/rich-text-input';\nimport { $createParagraphNode, $createTextNode, $getRoot, LexicalEditor, TextNode } from 'lexical';\nimport { PLAINTEXT_TAGS, PlainTextTransformer } from './transformers';\n\nexport class PlainTextFormatter extends RichTextFormatter {\n\t#transformers: PlainTextTransformer[] = [PLAINTEXT_TAGS];\n\n\tconstructor(transformers?: PlainTextTransformer[]) {\n\t\tsuper();\n\t\tif (transformers) {\n\t\t\tthis.#transformers = transformers;\n\t\t}\n\t}\n\n\toverride registerTextPlugin(editor: LexicalEditor) {\n\t\treturn
|
|
1
|
+
{"version":3,"file":"lucca-front-ng-forms-rich-text-input-formatters-plain-text.mjs","sources":["../../../packages/ng/forms/rich-text-input/formatters/plain-text/transformers/tag.transformers.ts","../../../packages/ng/forms/rich-text-input/formatters/plain-text/plain-text-formatter.ts","../../../packages/ng/forms/rich-text-input/formatters/plain-text/plain-text-formatter.directive.ts","../../../packages/ng/forms/rich-text-input/formatters/plain-text/lucca-front-ng-forms-rich-text-input-formatters-plain-text.ts"],"sourcesContent":["import { $createTagNode } from '@lucca-front/ng/forms/rich-text-input';\nimport { PlainTextTransformer } from './plain-text-transformer';\n\n/**\n * Transformer for tag nodes\n * It will match the following pattern `{{Tag}}` and create a TagNode (using `replace` function).\n *\n */\nexport const PLAINTEXT_TAGS: PlainTextTransformer = {\n\tregExp: /{{(\\w+)}}/,\n\treplace: (textNode, match) => {\n\t\tif (match[1]) {\n\t\t\ttextNode.replace($createTagNode(match[1].trim()));\n\t\t}\n\t},\n};\n","import { Provider } from '@angular/core';\nimport { registerPlainText } from '@lexical/plain-text';\nimport { $rootTextContent } from '@lexical/text';\nimport { mergeRegister } from '@lexical/utils';\nimport { RICH_TEXT_FORMATTER, RichTextFormatter } from '@lucca-front/ng/forms/rich-text-input';\nimport { $createParagraphNode, $createTextNode, $getRoot, LexicalEditor, TextNode } from 'lexical';\nimport { PLAINTEXT_TAGS, PlainTextTransformer } from './transformers';\n\nexport class PlainTextFormatter extends RichTextFormatter {\n\t#transformers: PlainTextTransformer[] = [PLAINTEXT_TAGS];\n\n\tconstructor(transformers?: PlainTextTransformer[]) {\n\t\tsuper();\n\t\tif (transformers) {\n\t\t\tthis.#transformers = transformers;\n\t\t}\n\t}\n\n\toverride registerTextPlugin(editor: LexicalEditor) {\n\t\treturn mergeRegister(\n\t\t\tregisterPlainText(editor),\n\t\t\t// Pasted content is inserted as raw text: apply the transformers whenever a text node changes\n\t\t\teditor.registerNodeTransform(TextNode, (textNode) => this.#applyTransformers(textNode)),\n\t\t);\n\t}\n\n\toverride parse(editor: LexicalEditor, text?: string | null): void {\n\t\teditor.update(() => {\n\t\t\tconst rootNode = $getRoot();\n\t\t\trootNode.clear();\n\t\t\tif (text) {\n\t\t\t\tconst paragraphNode = $createParagraphNode();\n\t\t\t\tconst textNode = $createTextNode(text);\n\t\t\t\tparagraphNode.append(textNode);\n\t\t\t\trootNode.append(paragraphNode);\n\t\t\t\tthis.#applyTransformers(textNode);\n\t\t\t}\n\t\t});\n\t}\n\n\toverride format(editor: LexicalEditor): string {\n\t\tlet result = '';\n\t\teditor.getEditorState().read(() => (result = $rootTextContent()));\n\t\treturn result;\n\t}\n\n\t#applyTransformers(textNode: TextNode): void {\n\t\tfor (const t of this.#transformers) {\n\t\t\tconst match = textNode.getTextContent().match(t.regExp);\n\n\t\t\tif (!match) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst startIndex = match.index || 0;\n\t\t\tconst endIndex = startIndex + match[0].length;\n\n\t\t\tlet transformedNode: TextNode | undefined = undefined;\n\t\t\tlet nodeAfter: TextNode | undefined = undefined;\n\t\t\tlet nodeBefore: TextNode | undefined = undefined;\n\n\t\t\tif (startIndex === 0) {\n\t\t\t\t[transformedNode, nodeAfter] = textNode.splitText(endIndex);\n\t\t\t} else {\n\t\t\t\t[nodeBefore, transformedNode, nodeAfter] = textNode.splitText(startIndex, endIndex);\n\t\t\t}\n\t\t\tif (transformedNode) {\n\t\t\t\tt.replace(transformedNode, match);\n\t\t\t}\n\t\t\tif (nodeAfter) {\n\t\t\t\tthis.#applyTransformers(nodeAfter);\n\t\t\t}\n\t\t\tif (nodeBefore) {\n\t\t\t\tthis.#applyTransformers(nodeBefore);\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t}\n}\n\nexport function provideLuRichTextPlainTextFormatter(transformers?: PlainTextTransformer[]): Provider {\n\treturn {\n\t\tprovide: RICH_TEXT_FORMATTER,\n\t\tuseFactory: () => new PlainTextFormatter(transformers),\n\t};\n}\n","import { Directive } from '@angular/core';\nimport { provideLuRichTextPlainTextFormatter } from './plain-text-formatter';\n\n@Directive({\n\tselector: 'lu-rich-text-input[luWithPlainTextTagsFormatter]',\n\tproviders: [provideLuRichTextPlainTextFormatter()],\n})\nexport class PlainTextFormatterWithTagsDirective {}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;;AAGA;;;;AAIG;AACI,MAAM,cAAc,GAAyB;AACnD,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,MAAM,IAAI,kBAAkB,CAAC,YAAY,CAAC;KACtD;AACF;;MC9Ea,mCAAmC,CAAA;8GAAnC,mCAAmC,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,SAAA,EAAA,CAAA,CAAA;AAAnC,IAAA,SAAA,IAAA,CAAA,IAAA,GAAA,EAAA,CAAA,oBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,IAAA,EAAA,mCAAmC,EAAA,YAAA,EAAA,IAAA,EAAA,QAAA,EAAA,kDAAA,EAAA,SAAA,EAFpC,CAAC,mCAAmC,EAAE,CAAC,EAAA,QAAA,EAAA,EAAA,EAAA,CAAA,CAAA;;2FAEtC,mCAAmC,EAAA,UAAA,EAAA,CAAA;kBAJ/C,SAAS;AAAC,YAAA,IAAA,EAAA,CAAA;AACV,oBAAA,QAAQ,EAAE,kDAAkD;AAC5D,oBAAA,SAAS,EAAE,CAAC,mCAAmC,EAAE,CAAC;AAClD,iBAAA;;;ACND;;AAEG;;"}
|
|
@@ -12,7 +12,7 @@ import { registerHistory, createEmptyHistoryState } from '@lexical/history';
|
|
|
12
12
|
import { $isRootTextContentEmpty, $canShowPlaceholderCurry } from '@lexical/text';
|
|
13
13
|
import { mergeRegister, $getNearestNodeOfType } from '@lexical/utils';
|
|
14
14
|
import { FormFieldComponent, InputDirective, ɵPresentationDisplayDefaultDirective as _PresentationDisplayDefaultDirective } from '@lucca-front/ng/form-field';
|
|
15
|
-
import { createEditor, SKIP_DOM_SELECTION_TAG, $getRoot, $createTextNode, createCommand, $getSelection, $isRangeSelection, $isTextNode, $createParagraphNode, COMMAND_PRIORITY_NORMAL, SELECTION_CHANGE_COMMAND, INSERT_PARAGRAPH_COMMAND, KEY_ENTER_COMMAND, DecoratorNode,
|
|
15
|
+
import { createEditor, SKIP_DOM_SELECTION_TAG, $getRoot, $createTextNode, createCommand, $getSelection, $isRangeSelection, $isTextNode, $createParagraphNode, COMMAND_PRIORITY_NORMAL, SELECTION_CHANGE_COMMAND, INSERT_PARAGRAPH_COMMAND, KEY_ENTER_COMMAND, DecoratorNode, $getNodeByKey, TextNode, FORMAT_TEXT_COMMAND } from 'lexical';
|
|
16
16
|
import { $isAtNodeEnd, $setBlocksType } from '@lexical/selection';
|
|
17
17
|
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
18
18
|
import { LuOptionDirective, LuOptionGroupDirective } from '@lucca-front/ng/core-select';
|
|
@@ -1222,12 +1222,44 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.4", ngImpor
|
|
|
1222
1222
|
], imports: [ListFormatComponent], template: "<lu-rich-text-plugin-list format=\"bullet\" [tooltip]=\"intl().listsBulletLabel\" icon=\"formatBulletedList\" />\n<lu-rich-text-plugin-list format=\"number\" [tooltip]=\"intl().listsNumberedLabel\" icon=\"formatNumberedList\" />\n" }]
|
|
1223
1223
|
}], propDecorators: { pluginComponents: [{ type: i0.ViewChildren, args: [i0.forwardRef(() => RICH_TEXT_PLUGIN_COMPONENT), { isSignal: true }] }], intl: [{ type: i0.Input, args: [{ isSignal: true, alias: "intl", required: false }] }] } });
|
|
1224
1224
|
|
|
1225
|
+
// Chip components per editor and node key. Not stored on the nodes: Lexical clones them and reuses old instances on undo/redo.
|
|
1226
|
+
const tagChips = new WeakMap();
|
|
1227
|
+
function getTagChips(editor) {
|
|
1228
|
+
let chips = tagChips.get(editor);
|
|
1229
|
+
if (!chips) {
|
|
1230
|
+
chips = new Map();
|
|
1231
|
+
tagChips.set(editor, chips);
|
|
1232
|
+
}
|
|
1233
|
+
return chips;
|
|
1234
|
+
}
|
|
1235
|
+
/** Destroy the chip components of a tag node that are no longer in the editor DOM. */
|
|
1236
|
+
function destroyStaleTagChips(editor, nodeKey) {
|
|
1237
|
+
const chips = getTagChips(editor);
|
|
1238
|
+
const refs = chips.get(nodeKey);
|
|
1239
|
+
if (!refs) {
|
|
1240
|
+
return;
|
|
1241
|
+
}
|
|
1242
|
+
const currentElement = editor.getElementByKey(nodeKey);
|
|
1243
|
+
refs.forEach((ref) => {
|
|
1244
|
+
if (ref.location.nativeElement !== currentElement) {
|
|
1245
|
+
ref.destroy();
|
|
1246
|
+
refs.delete(ref);
|
|
1247
|
+
}
|
|
1248
|
+
});
|
|
1249
|
+
if (refs.size === 0) {
|
|
1250
|
+
chips.delete(nodeKey);
|
|
1251
|
+
}
|
|
1252
|
+
}
|
|
1253
|
+
/** Destroy stale chip components once Lexical has reconciled the DOM. */
|
|
1254
|
+
function registerTagChipsCleanup(editor) {
|
|
1255
|
+
return editor.registerMutationListener(TagNode, (mutations) => {
|
|
1256
|
+
mutations.forEach((_mutation, nodeKey) => destroyStaleTagChips(editor, nodeKey));
|
|
1257
|
+
});
|
|
1258
|
+
}
|
|
1225
1259
|
class TagNode extends DecoratorNode {
|
|
1226
1260
|
#tagKey;
|
|
1227
1261
|
#tagDescription;
|
|
1228
1262
|
#disabled;
|
|
1229
|
-
// Store the component reference on the node instance
|
|
1230
|
-
#componentRef;
|
|
1231
1263
|
#viewContainerRef;
|
|
1232
1264
|
setViewContainerRef(vcr) {
|
|
1233
1265
|
const self = this.getWritable();
|
|
@@ -1283,29 +1315,32 @@ class TagNode extends DecoratorNode {
|
|
|
1283
1315
|
createDOM(_config, editor) {
|
|
1284
1316
|
if (this.#viewContainerRef) {
|
|
1285
1317
|
if (!editor.isEditable()) {
|
|
1286
|
-
this.#componentRef?.destroy();
|
|
1287
1318
|
const span = document.createElement('span');
|
|
1288
1319
|
span.textContent = this.#tagDescription ?? this.#tagKey;
|
|
1289
1320
|
return span;
|
|
1290
1321
|
}
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1322
|
+
// Always create a new component, stale ones are destroyed by `registerTagChipsCleanup`
|
|
1323
|
+
const componentRef = this.#viewContainerRef.createComponent(ChipComponent);
|
|
1324
|
+
const chips = getTagChips(editor);
|
|
1325
|
+
const nodeKey = this.getKey();
|
|
1326
|
+
if (!chips.has(nodeKey)) {
|
|
1327
|
+
chips.set(nodeKey, new Set());
|
|
1294
1328
|
}
|
|
1329
|
+
chips.get(nodeKey)?.add(componentRef);
|
|
1295
1330
|
// Set inputs on the component instance
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1331
|
+
componentRef.setInput('unkillable', false);
|
|
1332
|
+
componentRef.setInput('palette', 'product');
|
|
1333
|
+
componentRef.setInput('disabled', this.#disabled);
|
|
1299
1334
|
// Get the component's DOM element
|
|
1300
|
-
const componentElement =
|
|
1335
|
+
const componentElement = componentRef.location.nativeElement;
|
|
1301
1336
|
const textNode = document.createTextNode(this.#tagDescription ?? this.#tagKey);
|
|
1302
1337
|
componentElement.insertBefore(textNode, componentElement.firstChild);
|
|
1303
1338
|
componentElement.classList.add('mod-S');
|
|
1304
1339
|
componentElement.classList.add('richTextField-content-chip');
|
|
1305
1340
|
// Add click handler ONLY to the delete button, not the whole chip
|
|
1306
|
-
|
|
1341
|
+
componentRef.instance.kill.subscribe(() => {
|
|
1307
1342
|
editor.update(() => {
|
|
1308
|
-
|
|
1343
|
+
$getNodeByKey(nodeKey)?.remove();
|
|
1309
1344
|
});
|
|
1310
1345
|
});
|
|
1311
1346
|
// Return the component's DOM element
|
|
@@ -1318,10 +1353,6 @@ class TagNode extends DecoratorNode {
|
|
|
1318
1353
|
updateDOM(prevNode, _dom, _config) {
|
|
1319
1354
|
return this.#tagDescription !== prevNode.#tagDescription || this.#tagKey !== prevNode.#tagKey || this.#disabled !== prevNode.#disabled || this.#viewContainerRef !== prevNode.#viewContainerRef;
|
|
1320
1355
|
}
|
|
1321
|
-
remove(preserveEmptyParent) {
|
|
1322
|
-
super.remove(preserveEmptyParent);
|
|
1323
|
-
this.#componentRef?.destroy();
|
|
1324
|
-
}
|
|
1325
1356
|
exportDOM() {
|
|
1326
1357
|
const element = document.createTextNode(this.getTextContent());
|
|
1327
1358
|
return { element };
|
|
@@ -1466,8 +1497,9 @@ class RichTextPluginTagComponent {
|
|
|
1466
1497
|
}
|
|
1467
1498
|
setEditorInstance(editor) {
|
|
1468
1499
|
this.editor = editor;
|
|
1500
|
+
this.#registeredCommands = mergeRegister(registerTagChipsCleanup(this.editor),
|
|
1469
1501
|
// listen for new partial tag nodes (coming from formatters)
|
|
1470
|
-
this
|
|
1502
|
+
this.editor.registerMutationListener(TagNode, (mutations) => {
|
|
1471
1503
|
const newNodes = new Set(this.#tagNodeKeys());
|
|
1472
1504
|
this.editor?.read(() => {
|
|
1473
1505
|
mutations.forEach((m, k) => {
|
|
@@ -1482,7 +1514,7 @@ class RichTextPluginTagComponent {
|
|
|
1482
1514
|
this.#tagNodeKeys.set(newNodes);
|
|
1483
1515
|
}
|
|
1484
1516
|
});
|
|
1485
|
-
}, { skipInitialization: true });
|
|
1517
|
+
}, { skipInitialization: true }));
|
|
1486
1518
|
}
|
|
1487
1519
|
getLexicalNodes() {
|
|
1488
1520
|
return [TagNode];
|
|
@@ -1678,5 +1710,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.4", ngImpor
|
|
|
1678
1710
|
* Generated bundle index. Do not edit.
|
|
1679
1711
|
*/
|
|
1680
1712
|
|
|
1681
|
-
export { $createTagNode, $isTagNode, ClearFormatComponent, HeadingsComponent, INITIAL_UPDATE_TAG, LinkComponent, ListStyleToolbarComponent, RICH_TEXT_FORMATTER, RICH_TEXT_PLUGIN_COMPONENT, RichTextFormatter, RichTextInputComponent, RichTextInputToolbarComponent, RichTextPluginTagComponent, TagNode, TextStyleComponent, TextStyleToolbarComponent };
|
|
1713
|
+
export { $createTagNode, $isTagNode, ClearFormatComponent, HeadingsComponent, INITIAL_UPDATE_TAG, LinkComponent, ListStyleToolbarComponent, RICH_TEXT_FORMATTER, RICH_TEXT_PLUGIN_COMPONENT, RichTextFormatter, RichTextInputComponent, RichTextInputToolbarComponent, RichTextPluginTagComponent, TagNode, TextStyleComponent, TextStyleToolbarComponent, registerTagChipsCleanup };
|
|
1682
1714
|
//# sourceMappingURL=lucca-front-ng-forms-rich-text-input.mjs.map
|