-
Notifications
You must be signed in to change notification settings - Fork 35
Description
Following #1404, and clarifying this comment
Users - without knowledge of the underlying KindOfQuantity, knowledge of EC and/or access to WIMSE - would have to guess which KindOfQuantity is the right one to update the formatting of the property they want in property grid. Exposing a new ContextMenuItem that lets users customize that specific property's formatting would be extremely valuable and ease usage of formatting customization.
Implementation
From a technical perspective, The ContextMenuItem, onClick could open a Dialog that shows just the QuantityFormatPanel coming from @iTwin/quantity-formatting-react. This slightly differs from the Dialog implementation in test-viewer's status bar by omitting the FormatSelector
component from the Dialog. The props of the QuantityFormatPanel
should be easy to create. The formatDefinition can be retrieved by doing IModelApp.formatsProvider.getFormat(PropertyRecord.property.kindOfQuantityName)
. Only fields that use KoQ to format a value should have the context menuItem show, otherwise, we don't add it to the context menu.
On 'save', the modal closes, and the MenuItem would add the updated format back to the current active FormatsProvider. The Menuitem can use the property's Koq value, or, having retrieving the previous FormatDefinition
to edit from IModelApp.FormatsProvider
, can use the FormatDefinition
's name
property as the unique identifier for the format (as they should all be the schema item's full name).
Concerns
IModelApp.formatsProvider
is not of type MutableFormatsProvider
, so you can't directly use that interface's addFormat
method.
If a FormatManager
is made available to property-grid, then property-grid can use it to customize the FormatDefinition
of a field, and use that field's KoQ and the edited format and add them back to the currently active formatsProvider via the FormatManager
. Example of such interaction
- Question would be how would property grid want that passed in...
Prerequisites:
- FormatManager API is moved to @itwin/quantity-formatting-react