跳转至

Add value formatting(添加值格式化)

Value formatting refers to applying a special formatter to the value of a property, transforming the raw value to a more readable version. In the image below, the left-hand side (Before) shows the weight and value columns without any formatting. The right-hand side (After) has a unit (“kg”) applied to the weight column and the value column is displayed in a more compact form with a currency sign (“$100K”). These are both examples of numeric formatting. The Ontology also supports date and time formatting, as well as user ID formatting, resource RID formatting, and artifact GID formatting.

Value formatting example

Supported value formatting

Type Description
Numeric formatting Add currencies/units/prefixes, various types of notations (compact, scientific), and percentages. See the numeric formatting section for more details.
Date and time formatting Render timestamps and dates in a specific format as well as in a specific timezone.
Foundry ID formatting Display a Foundry ID as a user's first and last name or group name.
Resource RID formatting Display a Foundry resource ID (RID) as an icon and resource name, with a clickable link that routes to that resource.
Artifact GID formatting Display an artifact global ID (GID) as an icon and artifact name, with a clickable link that routes to that artifact.

Add value formatting

In the property editor:

  1. Select the property to which you want to add value formatting.
  2. On the right hand side panel of the properties pane, you will see a type of formatting depending on the base type of the property (value formatting, numeric formatting, date and time formatting, etc.). Toggle on the formatting.

Value formatting toggle

  1. Additional formatting options are available for numeric formatting and date and time formatting, as described below:
  2. Numeric formatting options
  3. Date and time formatting options
  4. As you select the available formatting options, you will see a preview for how values of the property will be rendered with the new formatting applied.

Numeric formatting options

Numeric formatting options

Name Description Usage
Numeric formatting On/Off toggle. Toggle this to remove/add numeric formatting.
Base type Contains various types of formatting available (Currency, Unit, Percentage, Prefix/Suffix, Fixed Values) as well as examples and descriptions of each type. If Capacity in Pounds has an associated unit, select "Unit" from this dropdown.
Use grouping Adds locale-aware comma separator. Toggle this on to go from 123456 to 123,456.
Notation Contains Compact/Scientific and Engineer notations. Choose compact to approximate values, like 123K.
Preview result View and test numeric formatting. Add any number in the input that is similar to what you'd expect to see in your property's values for a preview of the formatting.

Date and time formatting options

Date and time formatting options

Name Description Example
Date Only the date (no time) Wed, Jul 22, 2020
Date and time (long) Both the date and time, in long form Wed, July 22, 2020, 1:00:00 PM
Date and time (short) Both the date and time, in short form Jul 22, 2020, 1:00 PM
ISO instant Both the date and time (ISO 8601 format) 2020-07-22T13:00:00.000Z
Relative to now The date relative to right now 8 minutes ago
Time Only the time (no date) 1:00 pm

:::callout{theme="neutral"} When formatting Relative to now, applications will only format in relative terms up to 24 hours ago. After this, it will render in Date and time (short) form with the day of the week: Wed, Jul 22, 2020, 1:00 PM. :::

Relative to now

Time zones

If you are formatting a timestamp, you can specify which timezone to render the timestamp, either as a static timezone that you input, or as the application user's current timezone. When entering a static timezone, you can search for a timezone by inputting the UTC offset or the locale name.

User ID formatting

Value formatting can be applied to strings that are Foundry/Multipass user IDs or group IDs and convert them to display the user's first and last name or the group name by selecting the Multipass username option. This value formatting option is typically used when you have created an Action that edits a property and stores a user ID or group ID in one of the property fields. In the backing data, this information will be stored as the user's Foundry user ID or group ID, and the value formatting can be applied to render the user's name or the group instead of the ID.

FAQ

Will this work with existing type classes?

Value formatting takes precedence over existing type classes in the UI. If you have both configured, value formatting will be displayed. You can however, use value formatting on one property and type classes on another.

Will this work with editable properties in Object Views?

Value formatting is supported for properties configured for inline edits. Properties with the legacy hubble:editable type class will disable value formatting.


中文翻译

添加值格式化

值格式化(Value formatting)是指对属性值应用特殊格式化器,将原始值转换为更易读的版本。下图中,左侧(之前)展示了未应用任何格式化的 weightvalue 列。右侧(之后)的 weight 列应用了单位("kg"),而 value 列则以更紧凑的形式显示,并带有货币符号("$100K")。这些都是数值格式化的示例。本体(Ontology)还支持日期和时间格式化,以及用户 ID 格式化、资源 RID 格式化和工件 GID 格式化。

值格式化示例

支持的值格式化类型

类型 描述
数值格式化(Numeric formatting) 添加货币/单位/前缀、各种类型的记数法(紧凑型、科学型)和百分比。详见数值格式化部分
日期和时间格式化(Date and time formatting) 以特定格式和特定时区渲染时间戳和日期。
Foundry ID 格式化(Foundry ID formatting) 将 Foundry ID 显示为用户的姓名或组名。
资源 RID 格式化(Resource RID formatting) 将 Foundry 资源 ID(RID)显示为图标和资源名称,并带有可点击的链接,可跳转到该资源。
工件 GID 格式化(Artifact GID formatting) 将工件全局 ID(GID)显示为图标和工件名称,并带有可点击的链接,可跳转到该工件。

添加值格式化

在属性编辑器中:

  1. 选择要添加值格式化的属性。
  2. 在属性面板的右侧面板中,您将看到基于属性基础类型的格式化类型(值格式化、数值格式化、日期和时间格式化等)。开启格式化开关。

值格式化开关

  1. 数值格式化和日期时间格式化提供额外的格式化选项,如下所述:
  2. 数值格式化选项
  3. 日期和时间格式化选项
  4. 在选择可用格式化选项时,您将看到应用新格式化后属性值渲染效果的预览。

数值格式化选项

数值格式化选项

名称 描述 用法
数值格式化(Numeric formatting) 开/关切换。 切换此选项以移除/添加数值格式化。
基础类型(Base type) 包含各种可用的格式化类型(货币、单位、百分比、前缀/后缀、固定值)以及每种类型的示例和描述。 如果 Capacity in Pounds 有关联单位,请从下拉菜单中选择"单位"。
使用分组(Use grouping) 添加符合区域设置的逗号分隔符。 开启此选项可将 123456 显示为 123,456。
记数法(Notation) 包含紧凑型/科学型和工程型记数法。 选择紧凑型以近似显示值,如 123K。
预览结果(Preview result) 查看和测试数值格式化。 在输入框中输入与属性值类似的任意数字,以预览格式化效果。

日期和时间格式化选项

日期和时间格式化选项

名称 描述 示例
日期(Date) 仅日期(不含时间) Wed, Jul 22, 2020
日期和时间(长格式)(Date and time (long)) 日期和时间,长格式 Wed, July 22, 2020, 1:00:00 PM
日期和时间(短格式)(Date and time (short)) 日期和时间,短格式 Jul 22, 2020, 1:00 PM
ISO 即时(ISO instant) 日期和时间(ISO 8601 格式) 2020-07-22T13:00:00.000Z
相对当前时间(Relative to now) 相对于当前时间的日期 8 minutes ago
时间(Time) 仅时间(不含日期) 1:00 pm

:::callout{theme="neutral"} 当格式化为相对当前时间时,应用程序仅对 24 小时以内的时间使用相对格式。超过此时间后,将以日期和时间(短格式) 形式显示,并包含星期几:Wed, Jul 22, 2020, 1:00 PM。 :::

相对当前时间

时区

如果您正在格式化时间戳,可以指定渲染时间戳的时区,可以是您输入的静态时区,也可以是应用程序用户的当前时区。输入静态时区时,您可以通过输入 UTC 偏移量或区域名称来搜索时区。

用户 ID 格式化

值格式化可以应用于 Foundry/Multipass 用户 ID 或组 ID 的字符串,通过选择 Multipass 用户名(Multipass username)选项,将其转换为显示用户的姓名或组名。此值格式化选项通常用于当您创建了一个操作来编辑属性并将用户 ID 或组 ID 存储在某个属性字段中时。在后端数据中,此信息将存储为用户的 Foundry 用户 ID 或组 ID,而值格式化可用于渲染用户名或组名,而不是 ID。

常见问题

这能与现有的类型类(type classes)一起使用吗?

在 UI 中,值格式化优先于现有的类型类。如果两者都配置了,将显示值格式化。但是,您可以在一个属性上使用值格式化,在另一个属性上使用类型类。

这能用于对象视图(Object Views)中的可编辑属性吗?

值格式化支持配置为内联编辑的属性。具有旧版 hubble:editable 类型类的属性将禁用值格式化。