diff --git a/projects/valtimo/components/src/lib/components/value-path-selector/value-path-selector.component.ts b/projects/valtimo/components/src/lib/components/value-path-selector/value-path-selector.component.ts index 7e6ebcad0..40a7db4b1 100644 --- a/projects/valtimo/components/src/lib/components/value-path-selector/value-path-selector.component.ts +++ b/projects/valtimo/components/src/lib/components/value-path-selector/value-path-selector.component.ts @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - +import {CommonModule} from '@angular/common'; import { Component, EventEmitter, @@ -25,8 +25,23 @@ import { OnInit, Output, } from '@angular/core'; -import {CommonModule} from '@angular/common'; -import {ValuePathSelectorService} from '../../services'; +import { + AbstractControl, + ControlValueAccessor, + FormBuilder, + FormControl, + NG_VALUE_ACCESSOR, + ReactiveFormsModule, +} from '@angular/forms'; +import {TranslateModule} from '@ngx-translate/core'; +import {DocumentService} from '@valtimo/document'; +import { + DropdownModule, + InputModule, + ListItem, + LoadingModule, + ToggleModule, +} from 'carbon-components-angular'; import { BehaviorSubject, combineLatest, @@ -39,30 +54,16 @@ import { switchMap, tap, } from 'rxjs'; +import {distinctUntilChanged} from 'rxjs/operators'; import { + ValueCollectionPath, ValuePathSelectorInputMode, ValuePathSelectorNotation, ValuePathSelectorPrefix, -} from '../../models/value-path-selector.model'; -import { - DropdownModule, - InputModule, - ListItem, - LoadingModule, - ToggleModule, -} from 'carbon-components-angular'; -import { - AbstractControl, - ControlValueAccessor, - FormBuilder, - FormControl, - NG_VALUE_ACCESSOR, - ReactiveFormsModule, -} from '@angular/forms'; + ValueResolverOptionType, +} from '../../models'; +import {ValuePathSelectorService} from '../../services'; import {InputLabelModule} from '../input-label/input-label.module'; -import {TranslateModule} from '@ngx-translate/core'; -import {DocumentService} from '@valtimo/document'; -import {distinctUntilChanged} from 'rxjs/operators'; @Component({ selector: 'valtimo-value-path-selector', @@ -154,12 +155,26 @@ export class ValuePathSelectorComponent implements OnInit, OnDestroy, ControlVal if (!value) return; this._prefixesSubject$.next(value); } + private readonly _valueType$ = new BehaviorSubject( + ValueResolverOptionType.FIELD + ); + @Input() public set valueType(value: ValueResolverOptionType) { + this._valueType$.next(value); + } @Input() public label = ''; @Input() public tooltip = ''; @Input() public required = false; @Input() public showDocumentDefinitionSelector = false; @Input() public notation: ValuePathSelectorNotation = 'dots'; + private readonly _selectedCollectionPath$ = new BehaviorSubject(null); + @Input() public set selectedCollectionPath(value: ValueCollectionPath | null) { + this._selectedCollectionPath$.next(value); + + if (!value) return; + this._inputMode$.next(ValuePathSelectorInputMode.DROPDOWN); + } + @Input() public set defaultValue(value: string) { if (!value) return; this.selectedPath.setValue(value); @@ -167,6 +182,8 @@ export class ValuePathSelectorComponent implements OnInit, OnDestroy, ControlVal this._inputMode$.next(ValuePathSelectorInputMode.MANUAL); } @Output() valueChangeEvent: EventEmitter = new EventEmitter(); + @Output() collectionPathSelected: EventEmitter = + new EventEmitter(); private readonly _documentDefinitionNameSubject$ = new BehaviorSubject(''); private get _documentDefinitionName$(): Observable { @@ -194,32 +211,63 @@ export class ValuePathSelectorComponent implements OnInit, OnDestroy, ControlVal this._documentDefinitionName$, this._prefixes$, this._version$, + this._valueType$, + this._selectedCollectionPath$, ]).pipe( tap(() => this.loadingValuePathItems$.next(true)), - switchMap(([documentDefinitionName, prefixes, version]) => - typeof version === 'number' - ? this.valuePathSelectorService.getResolvableKeysPerPrefix( - prefixes, - documentDefinitionName, - version + switchMap(([documentDefinitionName, prefixes, version, valueType, selectedCollection]) => + !selectedCollection + ? typeof version === 'number' + ? this.valuePathSelectorService.getResolvableKeysPerPrefix( + prefixes, + documentDefinitionName, + valueType, + version + ) + : this.valuePathSelectorService.getResolvableKeysPerPrefix( + prefixes, + documentDefinitionName, + valueType + ) + : of( + this.valuePathSelectorService.getCollectionPathCacheResult( + selectedCollection.prefix, + documentDefinitionName, + version ?? 'latest', + selectedCollection.unformattedPath + ) ) - : this.valuePathSelectorService.getResolvableKeysPerPrefix(prefixes, documentDefinitionName) ), - map(result => - result.map(path => this.getFormattedPath(path)).sort((a, b) => a.localeCompare(b)) + map((results: string[]) => + results + .map(result => this.getFormattedPath(result)) + .sort((a, b) => a.content.localeCompare(b.content)) ), - tap(options => (this._cachedOptions = options)), + tap(options => (this._cachedOptions = options.map(option => option.content))), switchMap(options => combineLatest([of(options), this._selectedPath$, this.inputModeIsDropdown$]) ), tap(([options, selectedPath, inputModeIsDropdown]) => { - if (!options.includes(selectedPath) && !!selectedPath && inputModeIsDropdown) + if ( + !options.map(option => option.content).includes(selectedPath) && + !!selectedPath && + inputModeIsDropdown + ) this._inputMode$.next(ValuePathSelectorInputMode.MANUAL); }), map(([options, selectedPath]) => - options.map(option => ({content: option, selected: option === selectedPath})) + options.map(option => ({ + content: option.content, + selected: option.content === selectedPath, + prefix: option.prefix, + unformattedPath: option.unformattedPath, + })) ), - tap(() => this.loadingValuePathItems$.next(false)) + tap((options: ListItem[]) => { + const option = options.find((option: ListItem) => option.selected); + if (!!option) this.onPathSelected({item: option}); + this.loadingValuePathItems$.next(false); + }) ); public readonly loadingDocumentDefinitionItems$ = new BehaviorSubject(true); @@ -290,9 +338,14 @@ export class ValuePathSelectorComponent implements OnInit, OnDestroy, ControlVal } } - public onPathSelected(event: {item: {content: string}}): void { + public onPathSelected(event: {item: ValueCollectionPath | {content: string}}): void { const selectedPath = event?.item?.content; + + if (this.collectionPathSelected.observed) + this.collectionPathSelected.emit(!!selectedPath ? event.item : null); + if (!selectedPath) return; + this.selectedPath.setValue(selectedPath); } @@ -315,10 +368,18 @@ export class ValuePathSelectorComponent implements OnInit, OnDestroy, ControlVal ); } - private getFormattedPath(unformattedPath: string): string { + private getFormattedPath(unformattedPath: string): ValueCollectionPath { const splitPathPrefix = unformattedPath.split(':'); const prefix = splitPathPrefix[0]; const remainingPath = splitPathPrefix[1]; + + if (!remainingPath) + return { + prefix, + unformattedPath, + content: unformattedPath, + }; + const requiredNotation = this.notation; const pathNotation: ValuePathSelectorNotation = remainingPath.includes('/') ? 'slashes' @@ -333,6 +394,10 @@ export class ValuePathSelectorComponent implements OnInit, OnDestroy, ControlVal '' ); - return `${prefix}:${requiredNotation === 'dots' ? formattedPath.substring(1) : formattedPath}`; + return { + prefix, + unformattedPath, + content: `${prefix}:${requiredNotation === 'dots' ? formattedPath.substring(1) : formattedPath}`, + }; } } diff --git a/projects/valtimo/components/src/lib/models/value-path-selector.model.ts b/projects/valtimo/components/src/lib/models/value-path-selector.model.ts index 1d5cfeca6..b9d9dabbd 100644 --- a/projects/valtimo/components/src/lib/models/value-path-selector.model.ts +++ b/projects/valtimo/components/src/lib/models/value-path-selector.model.ts @@ -24,8 +24,37 @@ interface ValuePathSelectorCache { }; } +interface ValuePathCollectionCache { + [documentDefinitionName: string]: { + [version: string | number]: { + [prefix: string]: ValueCollectionCacheEntry; + }; + }; +} + +interface ValueCollectionCacheEntry { + [collectionPath: string]: string[]; +} + +interface ValueCollectionPath { + content: string; + prefix: string; + unformattedPath: string; +} + type DocumentDefinitionItemsCache = ListItem[]; +interface ValueResolverOption { + prefixes: ValuePathSelectorPrefix[]; + type: ValueResolverOptionType; +} + +interface ValueResolverResult { + path: string; + type: ValueResolverOptionType; + children?: ValueResolverResult[]; +} + enum ValuePathSelectorPrefix { DOC = 'doc', CASE = 'case', @@ -35,6 +64,11 @@ enum ValuePathSelectorPrefix { ZAAK = 'zaak', } +enum ValueResolverOptionType { + FIELD = 'FIELD', + COLLECTION = 'COLLECTION', +} + enum ValuePathSelectorInputMode { DROPDOWN, MANUAL, @@ -45,10 +79,16 @@ type ValuePathSelectorNotation = 'dots' | 'slashes'; type ValuePathVersionArgument = number | 'latest'; export { + DocumentDefinitionItemsCache, + ValueCollectionCacheEntry, + ValueCollectionPath, + ValuePathCollectionCache, ValuePathSelectorCache, - ValuePathSelectorPrefix, ValuePathSelectorInputMode, - ValuePathVersionArgument, - DocumentDefinitionItemsCache, ValuePathSelectorNotation, + ValuePathSelectorPrefix, + ValuePathVersionArgument, + ValueResolverOption, + ValueResolverOptionType, + ValueResolverResult, }; diff --git a/projects/valtimo/components/src/lib/services/value-path-selector.service.ts b/projects/valtimo/components/src/lib/services/value-path-selector.service.ts index dce150046..8b272fc2d 100644 --- a/projects/valtimo/components/src/lib/services/value-path-selector.service.ts +++ b/projects/valtimo/components/src/lib/services/value-path-selector.service.ts @@ -29,7 +29,16 @@ import { switchMap, take, } from 'rxjs'; -import {ValuePathSelectorCache, ValuePathSelectorPrefix, ValuePathVersionArgument} from '../models'; +import { + ValueCollectionCacheEntry, + ValuePathCollectionCache, + ValuePathSelectorCache, + ValuePathSelectorPrefix, + ValuePathVersionArgument, + ValueResolverOption, + ValueResolverOptionType, + ValueResolverResult, +} from '../models'; import {deepmerge} from 'deepmerge-ts'; import {DocumentDefinitions} from '@valtimo/document'; import {isEqual} from 'lodash'; @@ -40,6 +49,7 @@ import {tap} from 'rxjs/operators'; }) export class ValuePathSelectorService extends BaseApiService implements OnDestroy { private _cache: ValuePathSelectorCache = {}; + private _collectionCache: ValuePathCollectionCache = {}; private _documentDefinitionCache$ = new BehaviorSubject(null); private readonly _subscriptions = new Subscription(); @@ -55,6 +65,7 @@ export class ValuePathSelectorService extends BaseApiService implements OnDestro public getResolvableKeysPerPrefix( prefixes: ValuePathSelectorPrefix[], documentDefinitionName: string, + type: ValueResolverOptionType = ValueResolverOptionType.FIELD, version: ValuePathVersionArgument = 'latest' ): Observable { return of(version).pipe( @@ -66,26 +77,46 @@ export class ValuePathSelectorService extends BaseApiService implements OnDestro .map(prefix => this.getResultFromCache(prefix, documentDefinitionName, version)) .reduce((acc, curr) => [...acc, ...curr], []); const prefixesWithoutCache = prefixes.filter(prefix => !prefixesWithCache.includes(prefix)); + const reqBody: ValueResolverOption = { + prefixes, + type, + }; const httpCall = typeof version !== 'number' ? this.httpClient .post< - string[] - >(this.getApiUrl(`/management/v1/value-resolver/document-definition/${documentDefinitionName}/keys`), prefixesWithoutCache) + ValueResolverResult[] + >(this.getApiUrl(`/management/v2/value-resolver/document-definition/${documentDefinitionName}/keys`), reqBody) .pipe(catchError(() => of([]))) : this.httpClient .post< - string[] - >(this.getApiUrl(`/management/v1/value-resolver/document-definition/${documentDefinitionName}/version/${version}/keys`), prefixesWithoutCache) + ValueResolverResult[] + >(this.getApiUrl(`/management/v2/value-resolver/document-definition/${documentDefinitionName}/version/${version}/keys`), reqBody) .pipe(catchError(() => of([]))); return combineLatest([ - prefixesWithoutCache.length > 0 ? httpCall : of([]), + prefixesWithoutCache.length > 0 + ? httpCall.pipe( + map((results: ValueResolverResult[]) => { + if (type === ValueResolverOptionType.COLLECTION) + this.cacheCollectionFieldPaths( + results, + prefixes, + documentDefinitionName, + version + ); + + return type === ValueResolverOptionType.FIELD + ? results.map((result: ValueResolverResult) => result.path) + : results.reduce((acc, curr) => [...acc, ...this.getCollectionPaths(curr)], []); + }) + ) + : of([]), of(resultsFromCache), ]); }), - tap(([result, resultsFromCache]) => { - const combinedResults = [...result, ...resultsFromCache]; + tap(([results, resultsFromCache]) => { + const combinedResults = [...results, ...resultsFromCache]; prefixes.forEach(prefix => { const prefixResults = combinedResults.filter(valuePath => valuePath.includes(prefix)); this.cacheResult(prefix, documentDefinitionName, version, prefixResults); @@ -109,6 +140,17 @@ export class ValuePathSelectorService extends BaseApiService implements OnDestro return this._documentDefinitionCache$.asObservable(); } + public getCollectionPathCacheResult( + prefix: string, + documentDefinitionName: string, + version: ValuePathVersionArgument = 'latest', + collectionKey: string + ): string[] { + return ( + this._collectionCache[documentDefinitionName]?.[version]?.[prefix]?.[collectionKey] || [] + ); + } + private openClearCacheSubscription(): void { this._subscriptions.add( interval(60 * 1000).subscribe(() => { @@ -144,4 +186,91 @@ export class ValuePathSelectorService extends BaseApiService implements OnDestro this._cache = deepmerge(this._cache, resultCacheObject); } } + + private getCollectionPaths(result: ValueResolverResult): string[] { + if (result.type === ValueResolverOptionType.FIELD) return []; + + if ( + !result.children.some( + (child: ValueResolverResult) => child.type === ValueResolverOptionType.COLLECTION + ) + ) + return [result.path]; + + return result.children.reduce( + (acc, curr) => [ + ...acc, + ...this.getCollectionPaths(curr).map(childPath => `${result.path}${childPath}`), + ], + [] + ); + } + + private getCollectionCacheResult( + prefix: string, + documentDefinitionName: string, + version: ValuePathVersionArgument = 'latest' + ): ValueCollectionCacheEntry | null { + return this._collectionCache[documentDefinitionName]?.[version]?.[prefix] || null; + } + + private cacheCollectionFieldPaths( + results: ValueResolverResult[], + prefixes, + documentDefinitionName, + version + ): void { + const prefixesWithResult = prefixes.filter((prefix: string) => + results.some((result: ValueResolverResult) => result.path.includes(prefix)) + ); + + const resultCacheObject: ValuePathCollectionCache = { + [documentDefinitionName]: { + [version]: { + ...prefixesWithResult.reduce( + (acc, curr) => ({ + ...acc, + [curr]: { + ...results + .filter((result: ValueResolverResult) => result.path.includes(curr)) + .reduce((acc, curr) => ({...acc, ...this.getChildrenField(curr)}), {}), + }, + }), + {} + ), + }, + }, + }; + + if ( + prefixesWithResult.some( + prefix => !this.getCollectionCacheResult(prefix, documentDefinitionName, version) + ) + ) + this._collectionCache = deepmerge(this._collectionCache, resultCacheObject); + } + + private getChildrenField( + result: ValueResolverResult, + parentPath = '' + ): ValueCollectionCacheEntry { + const collectionChildren = result.children?.filter( + (child: ValueResolverResult) => child.type === ValueResolverOptionType.COLLECTION + ); + + if (!collectionChildren || collectionChildren.length === 0) + return { + [`${parentPath}${result.path}`]: result.children.map( + (child: ValueResolverResult) => child.path + ), + }; + + return collectionChildren.reduce( + (collectionEntries, collectionChild) => ({ + ...collectionEntries, + ...this.getChildrenField(collectionChild, result.path), + }), + {} + ); + } } diff --git a/projects/valtimo/dossier-management/src/lib/components/dossier-management-widget-configurators/collection/dossier-management-widget-collection.component.html b/projects/valtimo/dossier-management/src/lib/components/dossier-management-widget-configurators/collection/dossier-management-widget-collection.component.html index 0947ce1eb..ab4bf3afe 100644 --- a/projects/valtimo/dossier-management/src/lib/components/dossier-management-widget-configurators/collection/dossier-management-widget-collection.component.html +++ b/projects/valtimo/dossier-management/src/lib/components/dossier-management-widget-configurators/collection/dossier-management-widget-collection.component.html @@ -48,20 +48,23 @@ /> - +
- - + name="cardCollection" + [attr.data-carbon-theme]="obs.theme" + [documentDefinitionName]="documentDefinitionName$ | async" + [prefixes]="[ValuePathSelectorPrefix.DOC, ValuePathSelectorPrefix.CASE]" + [valueType]="ValueResolverOptionType.COLLECTION" + (collectionPathSelected)="onCollectionPathSelected($event)" + > +
@@ -70,20 +73,21 @@
- +
- - + name="cardTitle" + [attr.data-carbon-theme]="obs.theme" + [documentDefinitionName]="documentDefinitionName$ | async" + [prefixes]="[ValuePathSelectorPrefix.DOC, ValuePathSelectorPrefix.CASE]" + [selectedCollectionPath]="selectedCollectionPath$ | async" + > +
diff --git a/projects/valtimo/dossier-management/src/lib/components/dossier-management-widget-configurators/collection/dossier-management-widget-collection.component.scss b/projects/valtimo/dossier-management/src/lib/components/dossier-management-widget-configurators/collection/dossier-management-widget-collection.component.scss index 7b9af4180..a0ad2e2bf 100644 --- a/projects/valtimo/dossier-management/src/lib/components/dossier-management-widget-configurators/collection/dossier-management-widget-collection.component.scss +++ b/projects/valtimo/dossier-management/src/lib/components/dossier-management-widget-configurators/collection/dossier-management-widget-collection.component.scss @@ -20,8 +20,10 @@ gap: 24px; &__form { - display: flex; + display: grid; gap: 16px; + grid-template-columns: repeat(3, 1fr); + align-items: flex-end; } &__subtitle { @@ -30,6 +32,11 @@ line-height: 22px; } + &__path-selector { + display: flex; + flex-direction: column; + } + &__card { flex-direction: column; display: flex; diff --git a/projects/valtimo/dossier-management/src/lib/components/dossier-management-widget-configurators/collection/dossier-management-widget-collection.component.ts b/projects/valtimo/dossier-management/src/lib/components/dossier-management-widget-configurators/collection/dossier-management-widget-collection.component.ts index 04f2f702d..a21caf11c 100644 --- a/projects/valtimo/dossier-management/src/lib/components/dossier-management-widget-configurators/collection/dossier-management-widget-collection.component.ts +++ b/projects/valtimo/dossier-management/src/lib/components/dossier-management-widget-configurators/collection/dossier-management-widget-collection.component.ts @@ -40,6 +40,10 @@ import { CdsThemeService, CurrentCarbonTheme, InputLabelModule, + ValueCollectionPath, + ValuePathSelectorComponent, + ValuePathSelectorPrefix, + ValueResolverOptionType, } from '@valtimo/components'; import { CaseWidgetCurrencyDisplayType, @@ -59,11 +63,12 @@ import { InputModule, ListItem, } from 'carbon-components-angular'; -import {debounceTime, map, Observable, Subscription} from 'rxjs'; +import {BehaviorSubject, debounceTime, map, Observable, Subscription} from 'rxjs'; import {WidgetContentComponent} from '../../../models'; import {WidgetFieldsService, WidgetWizardService} from '../../../services'; import {DossierManagementWidgetFieldsColumnComponent} from '../fields/column/dossier-management-widget-fields-column.component'; +import {ActivatedRoute, ParamMap} from '@angular/router'; @Component({ templateUrl: './dossier-management-widget-collection.component.html', @@ -81,6 +86,7 @@ import {DossierManagementWidgetFieldsColumnComponent} from '../fields/column/dos ButtonModule, IconModule, InputLabelModule, + ValuePathSelectorComponent, ], }) export class DossierManagementWidgetCollectionComponent @@ -128,10 +134,17 @@ export class DossierManagementWidgetCollectionComponent ) ); + public readonly selectedCollectionPath$ = new BehaviorSubject(null); public readonly CaseWidgetDisplayTypeKey = CaseWidgetDisplayTypeKey; public readonly content = this.widgetWizardService .widgetContent as WritableSignal; public readonly displayTypeItems: ListItem[] = this.widgetFieldsService.displayTypeItems; + public readonly ValuePathSelectorPrefix = ValuePathSelectorPrefix; + public readonly ValueResolverOptionType = ValueResolverOptionType; + + public readonly documentDefinitionName$: Observable = this.route.paramMap.pipe( + map((paramMap: ParamMap) => paramMap.get('name') ?? '') + ); public WIDTH_ITEMS: ListItem[] = [ { @@ -152,6 +165,7 @@ export class DossierManagementWidgetCollectionComponent constructor( private readonly cdsThemeService: CdsThemeService, private readonly fb: FormBuilder, + private readonly route: ActivatedRoute, private readonly translateService: TranslateService, private readonly widgetWizardService: WidgetWizardService, private readonly widgetFieldsService: WidgetFieldsService @@ -232,6 +246,10 @@ export class DossierManagementWidgetCollectionComponent ); } + public onCollectionPathSelected(collectionPath: ValueCollectionPath): void { + this.selectedCollectionPath$.next(collectionPath); + } + private initForm(): void { if (!this.widgetWizardService.widgetContent()) return; diff --git a/projects/valtimo/dossier-management/src/lib/components/dossier-management-widget-configurators/fields/column/dossier-management-widget-fields-column.component.html b/projects/valtimo/dossier-management/src/lib/components/dossier-management-widget-configurators/fields/column/dossier-management-widget-fields-column.component.html index 9a75a1b12..c9c6d0c2c 100644 --- a/projects/valtimo/dossier-management/src/lib/components/dossier-management-widget-configurators/fields/column/dossier-management-widget-fields-column.component.html +++ b/projects/valtimo/dossier-management/src/lib/components/dossier-management-widget-configurators/fields/column/dossier-management-widget-fields-column.component.html @@ -54,24 +54,6 @@ />
- - - - - - - + + @if (!documentDefinitionName) { + + + + + + + } @else { +
+ + + + +
+ }
@@ -309,7 +328,7 @@ ; + @Input() public selectedCollectionPath?: ValueCollectionPath | null; @Output() public columnUpdateEvent = new EventEmitter<{ data: FieldsCaseWidgetValue[]; @@ -106,6 +115,7 @@ export class DossierManagementWidgetFieldsColumnComponent implements OnInit, OnD } public displayTypeItems: ListItem[] = this.widgetFieldsService.displayTypeItems; + public readonly ValuePathSelectorPrefix = ValuePathSelectorPrefix; public getDisplayItemsSelected(row: AbstractControl): ListItem[] { return this.widgetFieldsService.getDisplayItemsSelected(row); @@ -115,6 +125,9 @@ export class DossierManagementWidgetFieldsColumnComponent implements OnInit, OnD public readonly widgetType: Signal = computed( () => this.widgetWizardService.selectedWidget()?.type ?? CaseWidgetType.FIELDS ); + public readonly isFieldWidget: Signal = computed( + () => this.widgetType() === CaseWidgetType.FIELDS + ); public readonly inputTheme$: Observable = this.cdsThemeService.currentTheme$; diff --git a/projects/valtimo/dossier-management/src/lib/components/dossier-management-widget-configurators/fields/dossier-management-widget-fields.component.html b/projects/valtimo/dossier-management/src/lib/components/dossier-management-widget-configurators/fields/dossier-management-widget-fields.component.html index 39a278a51..0eb2b9c0d 100644 --- a/projects/valtimo/dossier-management/src/lib/components/dossier-management-widget-configurators/fields/dossier-management-widget-fields.component.html +++ b/projects/valtimo/dossier-management/src/lib/components/dossier-management-widget-configurators/fields/dossier-management-widget-fields.component.html @@ -46,8 +46,8 @@ > diff --git a/projects/valtimo/dossier-management/src/lib/components/dossier-management-widget-configurators/fields/dossier-management-widget-fields.component.ts b/projects/valtimo/dossier-management/src/lib/components/dossier-management-widget-configurators/fields/dossier-management-widget-fields.component.ts index 2689e7ac3..6fa7cfde0 100644 --- a/projects/valtimo/dossier-management/src/lib/components/dossier-management-widget-configurators/fields/dossier-management-widget-fields.component.ts +++ b/projects/valtimo/dossier-management/src/lib/components/dossier-management-widget-configurators/fields/dossier-management-widget-fields.component.ts @@ -38,10 +38,11 @@ import { } from '@valtimo/components'; import {FieldsCaseWidgetValue, WidgetFieldsContent} from '@valtimo/dossier'; import {ButtonModule, IconModule, InputModule, Tab, TabsModule} from 'carbon-components-angular'; -import {debounceTime, map, Subscription} from 'rxjs'; +import {debounceTime, map, Observable, Subscription, tap} from 'rxjs'; import {WidgetContentComponent} from '../../../models'; import {WidgetWizardService} from '../../../services'; import {DossierManagementWidgetFieldsColumnComponent} from './column/dossier-management-widget-fields-column.component'; +import {ActivatedRoute, ParamMap} from '@angular/router'; @Component({ templateUrl: './dossier-management-widget-fields.component.html', @@ -90,6 +91,9 @@ export class DossierManagementWidgetFieldsComponent ) ); public readonly activeTab = signal(0); + public readonly documentDefinitionName$: Observable = this.route.paramMap.pipe( + map((paramMap: ParamMap) => paramMap.get('name') ?? '') + ); private readonly _subscriptions = new Subscription(); private readonly _contentValid = signal(false); @@ -97,6 +101,7 @@ export class DossierManagementWidgetFieldsComponent constructor( private readonly cdsThemeService: CdsThemeService, private readonly fb: FormBuilder, + private readonly route: ActivatedRoute, private readonly widgetWizardService: WidgetWizardService ) {} diff --git a/projects/valtimo/dossier-management/src/lib/components/dossier-management-widget-configurators/table/dossier-management-widget-table.component.html b/projects/valtimo/dossier-management/src/lib/components/dossier-management-widget-configurators/table/dossier-management-widget-table.component.html index 11c200810..484b9d066 100644 --- a/projects/valtimo/dossier-management/src/lib/components/dossier-management-widget-configurators/table/dossier-management-widget-table.component.html +++ b/projects/valtimo/dossier-management/src/lib/components/dossier-management-widget-configurators/table/dossier-management-widget-table.component.html @@ -49,20 +49,22 @@ /> - +
- - + [attr.data-carbon-theme]="obs.theme" + [documentDefinitionName]="documentDefinitionName$ | async" + [prefixes]="[ValuePathSelectorPrefix.DOC, ValuePathSelectorPrefix.CASE]" + [valueType]="ValueResolverOptionType.COLLECTION" + (collectionPathSelected)="onCollectionPathSelected($event)" + > +
@@ -72,6 +74,8 @@ diff --git a/projects/valtimo/dossier-management/src/lib/components/dossier-management-widget-configurators/table/dossier-management-widget-table.component.scss b/projects/valtimo/dossier-management/src/lib/components/dossier-management-widget-configurators/table/dossier-management-widget-table.component.scss index a35b5ee30..b23e08cf4 100644 --- a/projects/valtimo/dossier-management/src/lib/components/dossier-management-widget-configurators/table/dossier-management-widget-table.component.scss +++ b/projects/valtimo/dossier-management/src/lib/components/dossier-management-widget-configurators/table/dossier-management-widget-table.component.scss @@ -19,12 +19,10 @@ gap: 24px; &__form { - display: flex; + display: grid; gap: 16px; - - // > * { - // width: 100%; - // } + grid-template-columns: repeat(3, 1fr); + align-items: flex-end; } &__subtitle { @@ -38,4 +36,9 @@ flex-direction: column; gap: 8px; } + + &__path-selector { + display: flex; + flex-direction: column; + } } diff --git a/projects/valtimo/dossier-management/src/lib/components/dossier-management-widget-configurators/table/dossier-management-widget-table.component.ts b/projects/valtimo/dossier-management/src/lib/components/dossier-management-widget-configurators/table/dossier-management-widget-table.component.ts index e280a73a4..b1fc21eaa 100644 --- a/projects/valtimo/dossier-management/src/lib/components/dossier-management-widget-configurators/table/dossier-management-widget-table.component.ts +++ b/projects/valtimo/dossier-management/src/lib/components/dossier-management-widget-configurators/table/dossier-management-widget-table.component.ts @@ -34,13 +34,18 @@ import { CdsThemeService, CurrentCarbonTheme, InputLabelModule, + ValueCollectionPath, + ValuePathSelectorComponent, + ValuePathSelectorPrefix, + ValueResolverOptionType, } from '@valtimo/components'; import {FieldsCaseWidgetValue, WidgetContentProperties, WidgetTableContent} from '@valtimo/dossier'; import {ButtonModule, InputModule, ToggleModule} from 'carbon-components-angular'; -import {debounceTime, map, Observable, Subscription} from 'rxjs'; +import {BehaviorSubject, debounceTime, map, Observable, Subscription} from 'rxjs'; import {WidgetContentComponent} from '../../../models'; import {WidgetWizardService} from '../../../services'; import {DossierManagementWidgetFieldsColumnComponent} from '../fields/column/dossier-management-widget-fields-column.component'; +import {ActivatedRoute, ParamMap} from '@angular/router'; @Component({ templateUrl: './dossier-management-widget-table.component.html', @@ -57,6 +62,7 @@ import {DossierManagementWidgetFieldsColumnComponent} from '../fields/column/dos ToggleModule, ButtonModule, InputLabelModule, + ValuePathSelectorComponent, ], }) export class DossierManagementWidgetTableComponent @@ -79,12 +85,17 @@ export class DossierManagementWidgetTableComponent Validators.required ), }); + public readonly ValuePathSelectorPrefix = ValuePathSelectorPrefix; + public readonly ValueResolverOptionType = ValueResolverOptionType; public readonly theme$: Observable = this.cdsThemeService.currentTheme$.pipe( map((currentTheme: CurrentCarbonTheme) => currentTheme === CurrentCarbonTheme.G10 ? CARBON_THEME.WHITE : CARBON_THEME.G90 ) ); + public readonly documentDefinitionName$: Observable = this.route.paramMap.pipe( + map((paramMap: ParamMap) => paramMap.get('name') ?? '') + ); public readonly content = this.widgetWizardService .widgetContent as WritableSignal; @@ -92,12 +103,15 @@ export class DossierManagementWidgetTableComponent () => (this.widgetWizardService.widgetContent() as WidgetTableContent)?.firstColumnAsTitle || false ); + public readonly selectedCollectionPath$ = new BehaviorSubject(null); + private readonly _contentValid = signal(this.widgetWizardService.editMode()); private readonly _subscriptions = new Subscription(); constructor( private readonly cdsThemeService: CdsThemeService, private readonly fb: FormBuilder, + private readonly route: ActivatedRoute, private readonly widgetWizardService: WidgetWizardService ) {} @@ -143,4 +157,8 @@ export class DossierManagementWidgetTableComponent ({...content, firstColumnAsTitle}) as WidgetTableContent ); } + + public onCollectionPathSelected(collectionPath: ValueCollectionPath): void { + this.selectedCollectionPath$.next(collectionPath); + } }