Class DraftInfoSupport
java.lang.Object
io.jmix.uirecoveryflowui.view.draft.DraftInfoSupport
Turns
ViewDraft rows into the DraftInfo entries the drafts list view renders.
A draft stores only the view identifier and the identifier of the edited instance, so everything a card shows - the view title, the record name and the address to link to - is resolved here. Every lookup degrades instead of failing: a view that is no longer registered yields no address, and a record that cannot be loaded yields no name.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected CurrentAuthenticationprotected DataManagerprotected static final Stringprotected IdSerializationprotected static final Stringprotected Messagesprotected MetadataToolsprotected RouteSupportprotected ViewRegistryprotected ViewSupport -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncreateInfo(ViewDraft draft) Builds the entry for a single draft.createInfos(Collection<ViewDraft> drafts) Builds an entry for each of the given drafts, keeping their order.protected StringformatSavedDate(@Nullable OffsetDateTime createdDate) protected @Nullable StringgetRecordName(@Nullable String entityId) Loads the drafted record to name it.protected com.vaadin.flow.router.RouteConfigurationprotected com.vaadin.flow.router.RouteParametersgetRouteParameters(@Nullable String entityId) Route parameters that address the drafted instance, built the same way navigating to a detail view builds them, so that the link opens exactly the view the draft was captured from.protected @Nullable Stringprotected StringgetViewTitle(String viewId, @Nullable ViewInfo viewInfo) protected @Nullable Id<?> parseEntityId(String entityId)
-
Field Details
-
MESSAGE_GROUP
-
ENTITY_ID_ROUTE_PARAM
- See Also:
-
viewRegistry
-
viewSupport
-
idSerialization
-
dataManager
-
metadataTools
-
routeSupport
-
messages
-
currentAuthentication
-
-
Constructor Details
-
DraftInfoSupport
public DraftInfoSupport()
-
-
Method Details
-
createInfos
Builds an entry for each of the given drafts, keeping their order.- Parameters:
drafts- drafts to describe- Returns:
- one entry per draft
-
createInfo
Builds the entry for a single draft.- Parameters:
draft- draft to describe- Returns:
- the entry
-
getViewTitle
- Parameters:
viewId- identifier of the view the draft belongs toviewInfo- registration of that view, ornullif it is not registered any more- Returns:
- the localized view title, falling back to the identifier when the view is gone or declares no title
-
getRecordName
Loads the drafted record to name it. A draft not tied to an instance, and the marker of an instance that was never persisted, have no record to load.- Parameters:
entityId- identifier of the drafted instance, ornull- Returns:
- the instance name, or
nullif there is nothing to name or it cannot be loaded
-
getUrl
- Parameters:
viewInfo- registration of the view the draft belongs toentityId- identifier of the drafted instance, ornull- Returns:
- the address of that view, or
nullif it cannot be built
-
getRouteParameters
Route parameters that address the drafted instance, built the same way navigating to a detail view builds them, so that the link opens exactly the view the draft was captured from.- Parameters:
entityId- identifier of the drafted instance, ornull- Returns:
- the route parameters, empty for a draft not tied to an instance
-
parseEntityId
- Parameters:
entityId- identifier of the drafted instance- Returns:
- the parsed identifier, or
nullif it cannot be parsed
-
formatSavedDate
- Parameters:
createdDate- the moment the draft was saved- Returns:
- that moment in the current user's time zone and locale
-
getRouteConfiguration
protected com.vaadin.flow.router.RouteConfiguration getRouteConfiguration()
-