How to use the @bentley/imodeljs-frontend.PropertyRecord function in @bentley/imodeljs-frontend

To help you get started, we’ve selected a few @bentley/imodeljs-frontend examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github imodeljs / imodeljs / test-apps / ui-test-app / src / frontend / appui / contentviews / TableExampleContent.tsx View on Github external
const createLoremPropertyRecord = (column: ColumnDescription) => {
  const lorem = new LoremIpsum();
  const value = lorem.generateWords(5);

  const v: PropertyValue = {
    valueFormat: PropertyValueFormat.Primitive,
    value,
    displayValue: value,
  };
  const pd: PropertyDescription = {
    typename: "text",
    name: column.key,
    displayLabel: column.label,
  };
  column.propertyDescription = pd;
  return new PropertyRecord(v, pd);
};
github imodeljs / imodeljs / test-apps / ui-test-app / src / frontend / appui / contentviews / TableExampleContent.tsx View on Github external
const createEnumPropertyRecord = (rowIndex: number, column: ColumnDescription) => {
  const value = rowIndex % 4;
  const v: PropertyValue = {
    valueFormat: PropertyValueFormat.Primitive,
    value,
    displayValue: value.toString(),
  };
  const pd: PropertyDescription = {
    typename: "enum",
    name: column.key,
    displayLabel: column.label,
  };
  column.propertyDescription = pd;
  const enumPropertyRecord = new PropertyRecord(v, pd);
  enumPropertyRecord.property.enum = { choices: [], isStrict: false };
  enumPropertyRecord.property.enum.choices = [
    { label: "Yellow", value: 0 },
    { label: "Red", value: 1 },
    { label: "Green", value: 2 },
    { label: "Blue", value: 3 },
  ];
  return enumPropertyRecord;
};
github imodeljs / imodeljs / test-apps / ui-test-app / src / frontend / appui / contentviews / TableExampleContent.tsx View on Github external
const createPropertyRecord = (value: any, column: ColumnDescription, typename: string) => {
  const v: PropertyValue = {
    valueFormat: PropertyValueFormat.Primitive,
    value,
    displayValue: value,
  };
  const pd: PropertyDescription = {
    typename,
    name: column.key,
    displayLabel: column.label,
  };
  column.propertyDescription = pd;
  return new PropertyRecord(v, pd);
};
github imodeljs / imodeljs / ui / components / src / ui-components / properties / renderers / NonPrimitivePropertyRenderer.tsx View on Github external
private getArrayProperties(items: PropertyRecord[]) {
    const additionalProperties: PropertyRecord[] = [
      new PropertyRecord(
        {
          valueFormat: PropertyValueFormat.Primitive,
          value: items.length,
          displayValue: items.length.toString(),
        },
        {
          displayLabel: UiComponents.translate("property.arrayLength"),
          name: "array_length",
          typename: "int",
        }),
    ];

    const modifiedProperties: PropertyRecord[] = items.map((item, index): PropertyRecord => {
      const newProperty = { ...item.property };
      newProperty.displayLabel = `[${index + 1}]`;
      newProperty.name = `${newProperty.name}_${index}`;
github imodeljs / imodeljs / ui / components / src / ui-components / tree / CellEditingEngine.tsx View on Github external
const v: PrimitiveValue = {
      valueFormat: PropertyValueFormat.Primitive,
      value,
      displayValue: value,
    };

    const p: PropertyDescription = {
      name: "tree-cell-editor",
      displayLabel: "Tree Cell Editor",
      typename,
    };

    if (editor)
      p.editor = { name: editor, params: [] };

    const record = new PropertyRecord(v, p);
    record.description = "";
    record.isReadonly = false;

    return record;
  }
github imodeljs / imodeljs / presentation / components / src / common / ContentBuilder.ts View on Github external
const createRecord = (propertyDescription: PropertyDescription, typeDescription: TypeDescription,
  value: Value, displayValue: DisplayValue, isReadOnly: boolean, isMerged: boolean, extendedData?: { [key: string]: any }): PropertyRecord => {
  const valueObj = createValue(propertyDescription, typeDescription, isMerged, value, displayValue);
  const record = new PropertyRecord(valueObj, propertyDescription);
  if (displayValue)
    record.description = createRecordDescription(typeDescription, displayValue);
  if (isMerged)
    record.isMerged = true;
  if (isReadOnly)
    record.isReadonly = true;
  if (extendedData)
    record.extendedData = extendedData;
  if (displayValue && DisplayValue.isPrimitive(displayValue) && getLinks(displayValue).length !== 0)
    record.links = {
      matcher: getLinks,
    };
  return record;
};
github imodeljs / imodeljs / ui / components / src / ui-components / tree / controlled / component / NodeContent.tsx View on Github external
function nodeToPropertyRecord(node: TreeModelNode) {
  const value: PrimitiveValue = {
    displayValue: node.item.label,
    value: node.item.label,
    valueFormat: PropertyValueFormat.Primitive,
  };
  const property: PropertyDescription = {
    displayLabel: UiComponents.translate("general.label"),
    typename: node.item && node.item.typename ? node.item.typename : "string",
    name: "node_label",
  };

  return new PropertyRecord(value, property);
}