How to use the @bentley/imodeljs-frontend.PropertyValueFormat.Primitive 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 / ui / components / src / ui-components / editors / EnumButtonGroupEditor.tsx View on Github external
private static getStateFromProps(props: PropertyEditorProps): EnumEditorState | null {
    const propertyRecord = props.propertyRecord;
    let selectValue: string | number;

    // istanbul ignore else
    if (propertyRecord && propertyRecord.value.valueFormat === PropertyValueFormat.Primitive) {
      const primitiveValue = (propertyRecord.value as PrimitiveValue).value;
      if (typeof primitiveValue === "string") {
        selectValue = primitiveValue as string;
      } else {
        selectValue = primitiveValue as number;
      }
      return { selectValue };
    }
    return null;
  }
github imodeljs / imodeljs / ui / components / src / ui-components / editors / IconEditor.tsx View on Github external
private async setStateFromProps() {
    const record = this.props.propertyRecord;
    let initialValue = "";

    // istanbul ignore else
    if (record && record.value.valueFormat === PropertyValueFormat.Primitive) {
      initialValue = (record.value as PrimitiveValue).value as string;
    }

    const readonly = record && undefined !== record.isReadonly ? record.isReadonly : false;
    const isDisabled = record ? record.isDisabled : undefined;

    // istanbul ignore else
    if (this._isMounted)
      this.setState(
        { icon: initialValue, readonly, isDisabled },
        () => {
          if (this.props.setFocus) {
            this.setFocus();
          }
        },
      );
github imodeljs / imodeljs / ui / components / src / ui-components / editors / CustomNumberEditor.tsx View on Github external
private _resetToOriginalValue() {
    const record = this.props.propertyRecord;
    let initialDisplayValue = "";
    let numberValue = 0;
    // istanbul ignore else
    if (record) {
      // istanbul ignore else
      if (record.value.valueFormat === PropertyValueFormat.Primitive) {
        const primitiveValue = (record.value as PrimitiveValue);
        numberValue = (undefined !== primitiveValue.value) ? primitiveValue.value as number : 0;
        if (primitiveValue.displayValue)
          initialDisplayValue = primitiveValue.displayValue;
        else
          initialDisplayValue = (this._formatParams as CustomFormattedNumberParams).formatFunction(numberValue, record.property!.quantityType);
      }
    }

    this.setState({ inputValue: initialDisplayValue });
  }
github imodeljs / imodeljs / ui / components / src / ui-components / editors / ColorEditor.tsx View on Github external
public async getPropertyValue(): Promise {
    const record = this.props.propertyRecord;
    let propertyValue: PropertyValue | undefined;

    // istanbul ignore else
    if (record && record.value.valueFormat === PropertyValueFormat.Primitive) {
      propertyValue = {
        valueFormat: PropertyValueFormat.Primitive,
        value: this.state.colorValue,
        displayValue: "",
      };
    }

    return propertyValue;
  }
github imodeljs / imodeljs / ui / components / src / ui-components / editors / BooleanEditor.tsx View on Github external
public async getPropertyValue(): Promise {
    const record = this.props.propertyRecord;
    let propertyValue: PropertyValue | undefined;

    // istanbul ignore else
    if (record && record.value.valueFormat === PropertyValueFormat.Primitive) {
      propertyValue = {
        valueFormat: PropertyValueFormat.Primitive,
        value: this.state.checkboxValue,
        displayValue: "",
      };
    }

    return propertyValue;
  }
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 },
github imodeljs / imodeljs / presentation / components / src / common / ContentBuilder.ts View on Github external
const createValue = (propertyDescription: PropertyDescription, typeDescription: TypeDescription, isMerged: boolean, value: Value, displayValue: DisplayValue): PropertyValue => {
  if (undefined === value && undefined === displayValue) {
    return {
      valueFormat: UiPropertyValueFormat.Primitive,
      value,
      displayValue: "",
    };
  }
  if (!isMerged) {
    if (typeDescription.valueFormat === PropertyValueFormat.Array) {
      if (!Value.isArray(value) || !DisplayValue.isArray(displayValue))
        throw new PresentationError(PresentationStatus.InvalidArgument, "value and displayValue should both be arrays");
      return createArrayValue(propertyDescription, typeDescription, value, displayValue);
    }
    if (typeDescription.valueFormat === PropertyValueFormat.Struct) {
      if (!Value.isMap(value) || !DisplayValue.isMap(displayValue))
        throw new PresentationError(PresentationStatus.InvalidArgument, "value and displayValue should both be of map type");
      return createStructValue(typeDescription, value, displayValue);
    }
  }
github imodeljs / imodeljs / ui / components / src / ui-components / table / component / Table.tsx View on Github external
private async getCellDisplayValue(cellItem: CellItem): Promise {
    if (!cellItem.record || cellItem.record!.value.valueFormat !== PropertyValueFormat.Primitive)
      return "";

    const value = (cellItem.record!.value as PrimitiveValue).value;

    if (value === undefined)
      return "";

    const displayValue = await TypeConverterManager
      .getConverter(cellItem.record!.property.typename)
      .convertPropertyToString(cellItem.record!.property, value);

    return displayValue ? displayValue : "";
  }
github imodeljs / imodeljs / ui / components / src / ui-components / properties / renderers / value / DoublePropertyValueRenderer.tsx View on Github external
public canRender(record: PropertyRecord) {
    return record.value.valueFormat === PropertyValueFormat.Primitive
      && record.property.typename === "double";
  }
github imodeljs / imodeljs / ui / components / src / ui-components / propertygrid / component / PropertyGrid.tsx View on Github external
private _onEnabledPropertyClicked(property: PropertyRecord, key: string | undefined, rightClick: boolean = false) {
    let selectedPropertyKey = this.state.selectedPropertyKey;
    let editingPropertyKey = this.state.editingPropertyKey;

    if (this.props.isPropertyEditingEnabled && property.value.valueFormat === PropertyValueFormat.Primitive && !rightClick) {
      if (this.props.isPropertySelectionEnabled) {
        if (selectedPropertyKey === key)
          editingPropertyKey = key;
        else
          editingPropertyKey = undefined;
      } else {
        editingPropertyKey = key;
      }
    }
    if (editingPropertyKey !== key || rightClick) {
      if (rightClick) {
        editingPropertyKey = undefined;
        if (selectedPropertyKey !== key)
          selectedPropertyKey = key;
      } else
        if (selectedPropertyKey === key) {