New field creates fields widget field (#18022)
## Context
Introducing "NewFieldDefaultConfiguration" to FIELDS widget
configurations
```typescript
{
isVisible: boolean;
viewFieldGroupId: string | null;
}
```
This configuration will define where a new field should be added (which
section) and its default visibility inside FIELDS widget views.
The new field position should always be at the end (meaning the last
position for the view fields OR the last position of a viewFieldGroup)
See "New fields" on this screenshot
<img width="401" height="724" alt="Layout V1"
src="https://github.com/user-attachments/assets/4969bcaa-f244-4504-8947-778a02c24c47"
/>
This commit is contained in:
+1
@@ -43,6 +43,7 @@ export class CreatePageLayoutWidgetActionHandlerService extends WorkspaceMigrati
|
||||
universalConfiguration: action.flatEntity.universalConfiguration,
|
||||
flatFieldMetadataMaps: allFlatEntityMaps.flatFieldMetadataMaps,
|
||||
flatViewMaps: allFlatEntityMaps.flatViewMaps,
|
||||
flatViewFieldGroupMaps: allFlatEntityMaps.flatViewFieldGroupMaps,
|
||||
});
|
||||
|
||||
const emptyUniversalForeignKeyAggregators =
|
||||
|
||||
+2
@@ -51,6 +51,8 @@ export class UpdatePageLayoutWidgetActionHandlerService extends WorkspaceMigrati
|
||||
universalConfiguration,
|
||||
flatFieldMetadataMaps: allFlatEntityMaps.flatFieldMetadataMaps,
|
||||
flatViewMaps: allFlatEntityMaps.flatViewMaps,
|
||||
flatViewFieldGroupMaps:
|
||||
allFlatEntityMaps.flatViewFieldGroupMaps,
|
||||
}),
|
||||
};
|
||||
|
||||
|
||||
+51
-14
@@ -42,10 +42,12 @@ export const fromUniversalConfigurationToFlatPageLayoutWidgetConfiguration = ({
|
||||
universalConfiguration,
|
||||
flatFieldMetadataMaps,
|
||||
flatViewMaps,
|
||||
flatViewFieldGroupMaps,
|
||||
}: {
|
||||
universalConfiguration: FlatPageLayoutWidget['universalConfiguration'];
|
||||
flatFieldMetadataMaps: MetadataFlatEntityMaps<'fieldMetadata'>;
|
||||
flatViewMaps: MetadataFlatEntityMaps<'view'>;
|
||||
flatViewFieldGroupMaps: MetadataFlatEntityMaps<'viewFieldGroup'>;
|
||||
}): FlatPageLayoutWidget['configuration'] => {
|
||||
switch (universalConfiguration.configurationType) {
|
||||
case WidgetConfigurationType.AGGREGATE_CHART: {
|
||||
@@ -198,26 +200,61 @@ export const fromUniversalConfigurationToFlatPageLayoutWidgetConfiguration = ({
|
||||
}
|
||||
|
||||
case WidgetConfigurationType.FIELDS: {
|
||||
const { viewId: viewUniversalIdentifier, ...rest } =
|
||||
universalConfiguration;
|
||||
const {
|
||||
viewId: viewUniversalIdentifier,
|
||||
newFieldDefaultConfiguration: universalNewFieldDefaultConfiguration,
|
||||
...rest
|
||||
} = universalConfiguration;
|
||||
|
||||
if (!isDefined(viewUniversalIdentifier)) {
|
||||
return { ...rest, viewId: null };
|
||||
let viewId: string | null = null;
|
||||
|
||||
if (isDefined(viewUniversalIdentifier)) {
|
||||
const flatView = findFlatEntityByUniversalIdentifier({
|
||||
flatEntityMaps: flatViewMaps,
|
||||
universalIdentifier: viewUniversalIdentifier,
|
||||
});
|
||||
|
||||
if (!isDefined(flatView)) {
|
||||
throw new FlatEntityMapsException(
|
||||
`View not found for universal identifier: ${viewUniversalIdentifier}`,
|
||||
FlatEntityMapsExceptionCode.ENTITY_NOT_FOUND,
|
||||
);
|
||||
}
|
||||
|
||||
viewId = flatView.id;
|
||||
}
|
||||
|
||||
const flatView = findFlatEntityByUniversalIdentifier({
|
||||
flatEntityMaps: flatViewMaps,
|
||||
universalIdentifier: viewUniversalIdentifier,
|
||||
});
|
||||
let newFieldDefaultConfiguration:
|
||||
| { isVisible: boolean; viewFieldGroupId: string | null }
|
||||
| null
|
||||
| undefined = universalNewFieldDefaultConfiguration;
|
||||
|
||||
if (!isDefined(flatView)) {
|
||||
throw new FlatEntityMapsException(
|
||||
`View not found for universal identifier: ${viewUniversalIdentifier}`,
|
||||
FlatEntityMapsExceptionCode.ENTITY_NOT_FOUND,
|
||||
);
|
||||
if (
|
||||
isDefined(universalNewFieldDefaultConfiguration) &&
|
||||
isDefined(universalNewFieldDefaultConfiguration.viewFieldGroupId)
|
||||
) {
|
||||
const viewFieldGroupUniversalIdentifier =
|
||||
universalNewFieldDefaultConfiguration.viewFieldGroupId;
|
||||
|
||||
const flatViewFieldGroup = findFlatEntityByUniversalIdentifier({
|
||||
flatEntityMaps: flatViewFieldGroupMaps,
|
||||
universalIdentifier: viewFieldGroupUniversalIdentifier,
|
||||
});
|
||||
|
||||
if (!isDefined(flatViewFieldGroup)) {
|
||||
throw new FlatEntityMapsException(
|
||||
`View field group not found for universal identifier: ${viewFieldGroupUniversalIdentifier}`,
|
||||
FlatEntityMapsExceptionCode.ENTITY_NOT_FOUND,
|
||||
);
|
||||
}
|
||||
|
||||
newFieldDefaultConfiguration = {
|
||||
isVisible: universalNewFieldDefaultConfiguration.isVisible,
|
||||
viewFieldGroupId: flatViewFieldGroup.id,
|
||||
};
|
||||
}
|
||||
|
||||
return { ...rest, viewId: flatView.id };
|
||||
return { ...rest, viewId, newFieldDefaultConfiguration };
|
||||
}
|
||||
|
||||
case WidgetConfigurationType.VIEW:
|
||||
|
||||
Reference in New Issue
Block a user