How to use the @bentley/presentation-frontend.Presentation.favoriteProperties function in @bentley/presentation-frontend

To help you get started, we’ve selected a few @bentley/presentation-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 / presentation-test-app / src / frontend / components / properties-widget / PropertiesWidget.tsx View on Github external
private _onAddFavorite = async (propertyField: Field) => {
    await Presentation.favoriteProperties.add(propertyField);
    this.setState({ contextMenu: undefined });
  }
  private _onRemoveFavorite = async (propertyField: Field) => {
github imodeljs / imodeljs / test-apps / ui-test-app / src / frontend / appui / widgets / UnifiedSelectionPropertyGridWidget.tsx View on Github external
private async buildContextMenu(args: PropertyGridContextMenuArgs) {
    const field = await this.state.dataProvider.getFieldByPropertyRecord(args.propertyRecord);
    const items: ContextMenuItemInfo[] = [];
    if (field !== undefined) {
      const imodelId = this.props.iModelConnection.iModelToken.iModelId;
      const projectId = this.props.iModelConnection.iModelToken.contextId;
      if (Presentation.favoriteProperties.has(field, projectId, imodelId)) {
        items.push({
          key: "remove-favorite",
          icon: "icon-remove-2",
          onSelect: () => this._onRemoveFavorite(field),
          title: IModelApp.i18n.translate("SampleApp:properties.context-menu.remove-favorite.description"),
          label: IModelApp.i18n.translate("SampleApp:properties.context-menu.remove-favorite.label"),
        });
      } else {
        items.push({
          key: "add-favorite",
          icon: "icon-add",
          onSelect: () => this._onAddFavorite(field),
          title: IModelApp.i18n.translate("SampleApp:properties.context-menu.add-favorite.description"),
          label: IModelApp.i18n.translate("SampleApp:properties.context-menu.add-favorite.label"),
        });
      }
github imodeljs / imodeljs / test-apps / presentation-test-app / src / frontend / components / properties-widget / PropertiesWidget.tsx View on Github external
private _onRemoveFavorite = async (propertyField: Field) => {
    await Presentation.favoriteProperties.remove(propertyField);
    this.setState({ contextMenu: undefined });
  }
  private _onPropertyContextMenu = (args: PropertyGridContextMenuArgs) => {
github imodeljs / imodeljs / test-apps / ui-test-app / src / frontend / appui / widgets / UnifiedSelectionPropertyGridWidget.tsx View on Github external
private _onAddFavorite = async (propertyField: Field) => {
    const imodelId = this.props.iModelConnection.iModelToken.iModelId;
    const projectId = this.props.iModelConnection.iModelToken.contextId;
    await Presentation.favoriteProperties.add(propertyField, projectId, imodelId);
    this.setState({ contextMenu: undefined });
  }
  private _onRemoveFavorite = async (propertyField: Field) => {
github imodeljs / imodeljs / test-apps / presentation-test-app / src / frontend / components / properties-widget / PropertiesWidget.tsx View on Github external
private async buildContextMenu(args: PropertyGridContextMenuArgs) {
    const field = await this.state.dataProvider.getFieldByPropertyRecord(args.propertyRecord);
    const items: ContextMenuItemInfo[] = [];
    if (field !== undefined) {
      if (Presentation.favoriteProperties.has(field)) {
        items.push({
          key: "remove-favorite",
          onSelect: () => this._onRemoveFavorite(field),
          title: IModelApp.i18n.translate("Sample:controls.properties.context-menu.remove-favorite.description"),
          label: IModelApp.i18n.translate("Sample:controls.properties.context-menu.remove-favorite.label"),
        });
      } else {
        items.push({
          key: "add-favorite",
          onSelect: () => this._onAddFavorite(field),
          title: IModelApp.i18n.translate("Sample:controls.properties.context-menu.add-favorite.description"),
          label: IModelApp.i18n.translate("Sample:controls.properties.context-menu.add-favorite.label"),
        });
      }
    }
github imodeljs / imodeljs / presentation / components / src / propertygrid / DataProvider.ts View on Github external
constructor(imodel: IModelConnection, rulesetId?: string) {
    super(imodel, rulesetId ? rulesetId : DEFAULT_PROPERTY_GRID_RULESET.id, DefaultContentDisplayTypes.PropertyPane);
    this._useDefaultRuleset = !rulesetId;
    this._includeFieldsWithNoValues = true;
    this._includeFieldsWithCompositeValues = true;
    this._onFavoritesChangedRemoveListener = Presentation.favoriteProperties.onFavoritesChanged.addListener(() => this.invalidateCache({}));
  }
github imodeljs / imodeljs / presentation / components / src / propertygrid / DataProvider.ts View on Github external
protected isFieldFavorite = (field: Field): boolean => {
    const projectId = this.imodel.iModelToken.contextId;
    const imodelId = this.imodel.iModelToken.iModelId;

    return Presentation.favoriteProperties.has(field, projectId, imodelId);
  }