packageDocumentation module import { PropertyRecord } from "@itwin/appui-abstract" ; import { IPropertyDataProvider , PropertyCategory , PropertyData , PropertyDataChangeEvent } from "./PropertyDataProvider" ; public export class SimplePropertyDataProvider implements IPropertyDataProvider , PropertyData { public label : PropertyRecord = PropertyRecord . fromString ( "" ) ; public description ? : string ; public categories : PropertyCategory [ ] = [ ] ; public records : { [ categoryName ] : PropertyRecord [ ] ; } = { } ; public onDataChanged = new PropertyDataChangeEvent ( ) ; public addCategory ( category ) { const categoryIdx = this . categories . push ( category ) - 1 ; this . records [ this . categories [ categoryIdx ] . name ] = [ ] ; this . onDataChanged . raiseEvent ( ) ; return categoryIdx ; } public findCategoryIndex ( category ) { const index = this . categories . findIndex ( ( testCategory ) => { return testCategory . name === category . name ; } ) ; return index ; } public addProperty ( propertyRecord , categoryIdx ) { this . records [ this . categories [ categoryIdx ] . name ] . push ( propertyRecord ) ; this . onDataChanged . raiseEvent ( ) ; } public removeProperty ( propertyRecord , categoryIdx ) { const index = this . records [ this . categories [ categoryIdx ] . name ] . findIndex ( ( record ) => { return record === propertyRecord ; } ) ; let result = false ; if ( index >= 0 ) { this . records [ this . categories [ categoryIdx ] . name ] . splice ( index , 1 ) ; this . onDataChanged . raiseEvent ( ) ; result = true ; } return result ; } public replaceProperty ( propertyRecord , categoryIdx , newRecord ) { const index = this . records [ this . categories [ categoryIdx ] . name ] . findIndex ( ( record ) => { return record === propertyRecord ; } ) ; let result = false ; if ( index >= 0 ) { this . records [ this . categories [ categoryIdx ] . name ] . splice ( index , 1 , newRecord ) ; result = true ; } return result ; } public async getData ( ) { return this ; } }