Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private _onAddFavorite = async (propertyField: Field) => {
await Presentation.favoriteProperties.add(propertyField);
this.setState({ contextMenu: undefined });
}
private _onRemoveFavorite = async (propertyField: Field) => {
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"),
});
}
private _onRemoveFavorite = async (propertyField: Field) => {
await Presentation.favoriteProperties.remove(propertyField);
this.setState({ contextMenu: undefined });
}
private _onPropertyContextMenu = (args: PropertyGridContextMenuArgs) => {
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) => {
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"),
});
}
}
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({}));
}
protected isFieldFavorite = (field: Field): boolean => {
const projectId = this.imodel.iModelToken.contextId;
const imodelId = this.imodel.iModelToken.iModelId;
return Presentation.favoriteProperties.has(field, projectId, imodelId);
}