@itwin/presentation-frontend 4.5.0-dev.16 → 4.5.0-dev.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/presentation-frontend/ConnectivityInformationProvider.js.map +1 -1
- package/lib/cjs/presentation-frontend/Diagnostics.js.map +1 -1
- package/lib/cjs/presentation-frontend/FrontendLoggerCategory.js.map +1 -1
- package/lib/cjs/presentation-frontend/IpcRequestsHandler.js.map +1 -1
- package/lib/cjs/presentation-frontend/LocalizationHelper.js.map +1 -1
- package/lib/cjs/presentation-frontend/Presentation.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/Presentation.js +2 -2
- package/lib/cjs/presentation-frontend/Presentation.js.map +1 -1
- package/lib/cjs/presentation-frontend/PresentationManager.d.ts +7 -4
- package/lib/cjs/presentation-frontend/PresentationManager.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/PresentationManager.js +79 -71
- package/lib/cjs/presentation-frontend/PresentationManager.js.map +1 -1
- package/lib/cjs/presentation-frontend/RulesetManager.js.map +1 -1
- package/lib/cjs/presentation-frontend/RulesetVariablesManager.js.map +1 -1
- package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesManager.d.ts +33 -4
- package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesManager.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesManager.js +76 -16
- package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesManager.js.map +1 -1
- package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesStorage.js.map +1 -1
- package/lib/cjs/presentation-frontend/selection/HiliteRules.json +172 -172
- package/lib/cjs/presentation-frontend/selection/HiliteSetProvider.js.map +1 -1
- package/lib/cjs/presentation-frontend/selection/ISelectionProvider.js.map +1 -1
- package/lib/cjs/presentation-frontend/selection/SelectionChangeEvent.js.map +1 -1
- package/lib/cjs/presentation-frontend/selection/SelectionHandler.js.map +1 -1
- package/lib/cjs/presentation-frontend/selection/SelectionHelper.js.map +1 -1
- package/lib/cjs/presentation-frontend/selection/SelectionManager.js.map +1 -1
- package/lib/cjs/presentation-frontend/selection/SelectionScopesManager.js.map +1 -1
- package/lib/cjs/presentation-frontend.js.map +1 -1
- package/lib/esm/presentation-frontend/ConnectivityInformationProvider.js.map +1 -1
- package/lib/esm/presentation-frontend/Diagnostics.js.map +1 -1
- package/lib/esm/presentation-frontend/FrontendLoggerCategory.js.map +1 -1
- package/lib/esm/presentation-frontend/IpcRequestsHandler.js.map +1 -1
- package/lib/esm/presentation-frontend/LocalizationHelper.js.map +1 -1
- package/lib/esm/presentation-frontend/Presentation.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/Presentation.js +2 -2
- package/lib/esm/presentation-frontend/Presentation.js.map +1 -1
- package/lib/esm/presentation-frontend/PresentationManager.d.ts +7 -4
- package/lib/esm/presentation-frontend/PresentationManager.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/PresentationManager.js +79 -71
- package/lib/esm/presentation-frontend/PresentationManager.js.map +1 -1
- package/lib/esm/presentation-frontend/RulesetManager.js.map +1 -1
- package/lib/esm/presentation-frontend/RulesetVariablesManager.js.map +1 -1
- package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesManager.d.ts +33 -4
- package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesManager.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesManager.js +76 -16
- package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesManager.js.map +1 -1
- package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesStorage.js.map +1 -1
- package/lib/esm/presentation-frontend/selection/HiliteRules.json +172 -172
- package/lib/esm/presentation-frontend/selection/HiliteSetProvider.js.map +1 -1
- package/lib/esm/presentation-frontend/selection/ISelectionProvider.js.map +1 -1
- package/lib/esm/presentation-frontend/selection/SelectionChangeEvent.js.map +1 -1
- package/lib/esm/presentation-frontend/selection/SelectionHandler.js.map +1 -1
- package/lib/esm/presentation-frontend/selection/SelectionHelper.js.map +1 -1
- package/lib/esm/presentation-frontend/selection/SelectionManager.js.map +1 -1
- package/lib/esm/presentation-frontend/selection/SelectionScopesManager.js.map +1 -1
- package/lib/esm/presentation-frontend.js.map +1 -1
- package/package.json +15 -15
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RulesetVariablesManager.js","sourceRoot":"","sources":["../../../src/presentation-frontend/RulesetVariablesManager.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAc,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC7F,OAAO,EAAkC,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAkFhG,gBAAgB;AAChB,MAAM,OAAO,2BAA2B;IAMtC,YAAmB,SAAiB,EAAE,UAA+B;QAL7D,kBAAa,GAAG,IAAI,GAAG,EAA2B,CAAC;QAGpD,sBAAiB,GAAG,IAAI,OAAO,EAA4G,CAAC;QAGjJ,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAC5B,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC;IAChC,CAAC;IAEM,eAAe;QACpB,MAAM,SAAS,GAAsB,EAAE,CAAC;QACxC,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,aAAa,EAAE;YACtC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;SAC1B;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;IAEO,eAAe,CAAC,QAAyB,EAAE,MAA0B;QAC3E,QAAQ,MAAM,EAAE;YACd,KAAK,kBAAkB,CAAC,IAAI;gBAC1B,QAAQ,QAAQ,CAAC,IAAI,EAAE;oBACrB,KAAK,kBAAkB,CAAC,GAAG;wBACzB,OAAO,CAAC,KAAK,QAAQ,CAAC,KAAK,CAAC;oBAC9B,KAAK,kBAAkB,CAAC,IAA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CAAC;KACd;IAED,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE;QACnC,IAAI,GAAG,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,EAAE;YACrB,OAAO,KAAK,CAAC;SACd;KACF;IACD,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n * See LICENSE.md in the project root for license terms and full copyright notice.\r\n *--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Core\r\n */\r\n\r\nimport { assert, BeEvent, Id64, Id64String, OrderedId64Iterable } from \"@itwin/core-bentley\";\r\nimport { RulesetVariable, VariableValue, VariableValueTypes } from \"@itwin/presentation-common\";\r\nimport { IpcRequestsHandler } from \"./IpcRequestsHandler\";\r\n\r\n/**\r\n * Presentation ruleset variables' registry.\r\n * @public\r\n */\r\nexport interface RulesetVariablesManager {\r\n /**\r\n * An event that is raised when variable changes.\r\n */\r\n onVariableChanged: BeEvent<(variableId: string, prevValue: VariableValue | undefined, currValue: VariableValue | undefined) => void>;\r\n\r\n /**\r\n * Retrieves `string` variable value.\r\n * Returns empty string if variable does not exist or does not convert to string.\r\n */\r\n getString(variableId: string): Promise<string>;\r\n /**\r\n * Sets `string` variable value\r\n */\r\n setString(variableId: string, value: string): Promise<void>;\r\n\r\n /**\r\n * Retrieves `boolean` variable value.\r\n * Returns `false` if variable does not exist or does not convert to boolean.\r\n */\r\n getBool(variableId: string): Promise<boolean>;\r\n /**\r\n * Sets `boolean` variable value\r\n */\r\n setBool(variableId: string, value: boolean): Promise<void>;\r\n\r\n /**\r\n * Retrieves `number` variable value.\r\n * Returns `0` if variable does not exist or does not convert to integer.\r\n */\r\n getInt(variableId: string): Promise<number>;\r\n /**\r\n * Sets `number` variable value\r\n */\r\n setInt(variableId: string, value: number): Promise<void>;\r\n\r\n /**\r\n * Retrieves `number[]` variable value.\r\n * Returns empty array if variable does not exist or does not convert to integer array.\r\n */\r\n getInts(variableId: string): Promise<number[]>;\r\n /**\r\n * Sets `number[]` variable value\r\n */\r\n setInts(variableId: string, value: number[]): Promise<void>;\r\n\r\n /**\r\n * Retrieves `Id64String` variable value.\r\n * Returns invalid Id64String if variable does not exist or does not convert to Id64String.\r\n */\r\n getId64(variableId: string): Promise<Id64String>;\r\n /**\r\n * Sets `Id64String` variable value\r\n */\r\n setId64(variableId: string, value: Id64String): Promise<void>;\r\n\r\n /**\r\n * Retrieves `Id64String[]` variable value.\r\n * Returns empty array if variable does not exist or does not convert to Id64String array.\r\n */\r\n getId64s(variableId: string): Promise<Id64String[]>;\r\n /**\r\n * Sets `Id64String[]` variable value\r\n */\r\n setId64s(variableId: string, value: Id64String[]): Promise<void>;\r\n\r\n /** Unsets variable with given id. */\r\n unset(variableId: string): Promise<void>;\r\n\r\n /** Retrieves all variables.\r\n * @internal\r\n */\r\n getAllVariables(): RulesetVariable[];\r\n}\r\n\r\n/** @internal */\r\nexport class RulesetVariablesManagerImpl implements RulesetVariablesManager {\r\n private _clientValues = new Map<string, RulesetVariable>();\r\n private _rulesetId: string;\r\n private _ipcHandler?: IpcRequestsHandler;\r\n public onVariableChanged = new BeEvent<(variableId: string, prevValue: VariableValue | undefined, currValue: VariableValue | undefined) => void>();\r\n\r\n public constructor(rulesetId: string, ipcHandler?: IpcRequestsHandler) {\r\n this._rulesetId = rulesetId;\r\n this._ipcHandler = ipcHandler;\r\n }\r\n\r\n public getAllVariables(): RulesetVariable[] {\r\n const variables: RulesetVariable[] = [];\r\n for (const entry of this._clientValues) {\r\n variables.push(entry[1]);\r\n }\r\n return variables;\r\n }\r\n\r\n private changeValueType(variable: RulesetVariable, toType: VariableValueTypes): VariableValue | undefined {\r\n switch (toType) {\r\n case VariableValueTypes.Bool:\r\n switch (variable.type) {\r\n case VariableValueTypes.Int:\r\n return 0 !== variable.value;\r\n case VariableValueTypes.Id64:\r\n return Id64.isValidId64(variable.value);\r\n default:\r\n return undefined;\r\n }\r\n case VariableValueTypes.Int:\r\n switch (variable.type) {\r\n case VariableValueTypes.Bool:\r\n return variable.value ? 1 : 0;\r\n case VariableValueTypes.Id64:\r\n return Id64.getUpperUint32(variable.value);\r\n default:\r\n return undefined;\r\n }\r\n case VariableValueTypes.IntArray:\r\n switch (variable.type) {\r\n case VariableValueTypes.Id64Array:\r\n return variable.value.map((id) => Id64.getUpperUint32(id));\r\n default:\r\n return undefined;\r\n }\r\n case VariableValueTypes.Id64:\r\n switch (variable.type) {\r\n case VariableValueTypes.Bool:\r\n return Id64.fromLocalAndBriefcaseIds(variable.value ? 1 : 0, 0);\r\n case VariableValueTypes.Int:\r\n return Id64.fromLocalAndBriefcaseIds(variable.value, 0);\r\n default:\r\n return undefined;\r\n }\r\n case VariableValueTypes.Id64Array:\r\n switch (variable.type) {\r\n case VariableValueTypes.IntArray:\r\n return variable.value.map((int) => Id64.fromLocalAndBriefcaseIds(int, 0));\r\n default:\r\n return undefined;\r\n }\r\n case VariableValueTypes.String:\r\n switch (variable.type) {\r\n case VariableValueTypes.IntArray:\r\n case VariableValueTypes.Id64Array:\r\n return undefined;\r\n default:\r\n variable.value.toString();\r\n }\r\n }\r\n return undefined;\r\n }\r\n\r\n private async getValue(id: string, type: VariableValueTypes): Promise<VariableValue | undefined> {\r\n const variable = this._clientValues.get(id);\r\n if (!variable) {\r\n return undefined;\r\n }\r\n if (variable.type !== type) {\r\n return this.changeValueType(variable, type);\r\n }\r\n return variable.value;\r\n }\r\n\r\n private async setValue(variable: RulesetVariable): Promise<void> {\r\n const oldVariable = this._clientValues.get(variable.id);\r\n if (oldVariable && variablesEqual(oldVariable, variable)) {\r\n return;\r\n }\r\n\r\n this._clientValues.set(variable.id, variable);\r\n if (this._ipcHandler) {\r\n await this._ipcHandler.setRulesetVariable({ rulesetId: this._rulesetId, variable });\r\n }\r\n\r\n this.onVariableChanged.raiseEvent(variable.id, oldVariable?.value, variable.value);\r\n }\r\n\r\n public async unset(variableId: string): Promise<void> {\r\n const variable = this._clientValues.get(variableId);\r\n if (variable === undefined) {\r\n return;\r\n }\r\n\r\n this._clientValues.delete(variable.id);\r\n if (this._ipcHandler) {\r\n await this._ipcHandler.unsetRulesetVariable({ rulesetId: this._rulesetId, variableId });\r\n }\r\n this.onVariableChanged.raiseEvent(variable.id, variable.value, undefined);\r\n }\r\n\r\n /**\r\n * Retrieves `string` variable value.\r\n * Returns empty string if variable does not exist or does not convert to string.\r\n */\r\n public async getString(variableId: string): Promise<string> {\r\n return ((await this.getValue(variableId, VariableValueTypes.String)) as string) || \"\";\r\n }\r\n\r\n /**\r\n * Sets `string` variable value\r\n */\r\n public async setString(variableId: string, value: string): Promise<void> {\r\n await this.setValue({ id: variableId, type: VariableValueTypes.String, value });\r\n }\r\n\r\n /**\r\n * Retrieves `boolean` variable value.\r\n * Returns `false` if variable does not exist or does not convert to boolean.\r\n */\r\n public async getBool(variableId: string): Promise<boolean> {\r\n return ((await this.getValue(variableId, VariableValueTypes.Bool)) as boolean) || false;\r\n }\r\n\r\n /**\r\n * Sets `boolean` variable value\r\n */\r\n public async setBool(variableId: string, value: boolean): Promise<void> {\r\n await this.setValue({ id: variableId, type: VariableValueTypes.Bool, value });\r\n }\r\n\r\n /**\r\n * Retrieves `number` variable value.\r\n * Returns `0` if variable does not exist or does not convert to integer.\r\n */\r\n public async getInt(variableId: string): Promise<number> {\r\n return ((await this.getValue(variableId, VariableValueTypes.Int)) as number) || 0;\r\n }\r\n\r\n /**\r\n * Sets `number` variable value\r\n */\r\n public async setInt(variableId: string, value: number): Promise<void> {\r\n await this.setValue({ id: variableId, type: VariableValueTypes.Int, value });\r\n }\r\n\r\n /**\r\n * Retrieves `number[]` variable value.\r\n * Returns empty array if variable does not exist or does not convert to integer array.\r\n */\r\n public async getInts(variableId: string): Promise<number[]> {\r\n return ((await this.getValue(variableId, VariableValueTypes.IntArray)) as number[]) || [];\r\n }\r\n\r\n /**\r\n * Sets `number[]` variable value\r\n */\r\n public async setInts(variableId: string, value: number[]): Promise<void> {\r\n await this.setValue({ id: variableId, type: VariableValueTypes.IntArray, value: [...value] });\r\n }\r\n\r\n /**\r\n * Retrieves `Id64String` variable value.\r\n * Returns invalid Id64String if variable does not exist or does not convert to Id64String.\r\n */\r\n public async getId64(variableId: string): Promise<Id64String> {\r\n return ((await this.getValue(variableId, VariableValueTypes.Id64)) as Id64String) || Id64.invalid;\r\n }\r\n\r\n /**\r\n * Sets `Id64String` variable value\r\n */\r\n public async setId64(variableId: string, value: Id64String): Promise<void> {\r\n await this.setValue({ id: variableId, type: VariableValueTypes.Id64, value });\r\n }\r\n\r\n /**\r\n * Retrieves `Id64String[]` variable value.\r\n * Returns empty array if variable does not exist or does not convert to Id64String array.\r\n */\r\n public async getId64s(variableId: string): Promise<Id64String[]> {\r\n return ((await this.getValue(variableId, VariableValueTypes.Id64Array)) as Id64String[]) || [];\r\n }\r\n\r\n /**\r\n * Sets `Id64String[]` variable value\r\n */\r\n public async setId64s(variableId: string, value: Id64String[]): Promise<void> {\r\n await this.setValue({ id: variableId, type: VariableValueTypes.Id64Array, value: [...OrderedId64Iterable.sortArray(value)] });\r\n }\r\n}\r\n\r\nfunction variablesEqual(lhs: RulesetVariable, rhs: RulesetVariable) {\r\n if (lhs.type !== rhs.type) {\r\n return false;\r\n }\r\n\r\n switch (lhs.type) {\r\n case VariableValueTypes.IntArray:\r\n case VariableValueTypes.Id64Array:\r\n assert(rhs.type === lhs.type);\r\n return arraysEqual(lhs.value, rhs.value);\r\n\r\n default:\r\n return lhs.value === rhs.value;\r\n }\r\n}\r\n\r\nfunction arraysEqual(lhs: any[], rhs: any[]) {\r\n if (lhs.length !== rhs.length) {\r\n return false;\r\n }\r\n\r\n for (let i = 0; i < lhs.length; ++i) {\r\n if (lhs[i] !== rhs[i]) {\r\n return false;\r\n }\r\n }\r\n return true;\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"RulesetVariablesMan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["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Core\n */\n\nimport { assert, BeEvent, Id64, Id64String, OrderedId64Iterable } from \"@itwin/core-bentley\";\nimport { RulesetVariable, VariableValue, VariableValueTypes } from \"@itwin/presentation-common\";\nimport { IpcRequestsHandler } from \"./IpcRequestsHandler\";\n\n/**\n * Presentation ruleset variables' registry.\n * @public\n */\nexport interface RulesetVariablesManager {\n /**\n * An event that is raised when variable changes.\n */\n onVariableChanged: BeEvent<(variableId: string, prevValue: VariableValue | undefined, currValue: VariableValue | undefined) => void>;\n\n /**\n * Retrieves `string` variable value.\n * Returns empty string if variable does not exist or does not convert to string.\n */\n getString(variableId: string): Promise<string>;\n /**\n * Sets `string` variable value\n */\n setString(variableId: string, value: string): Promise<void>;\n\n /**\n * Retrieves `boolean` variable value.\n * Returns `false` if variable does not exist or does not convert to boolean.\n */\n getBool(variableId: string): Promise<boolean>;\n /**\n * Sets `boolean` variable value\n */\n setBool(variableId: string, value: boolean): Promise<void>;\n\n /**\n * Retrieves `number` variable value.\n * Returns `0` if variable does not exist or does not convert to integer.\n */\n getInt(variableId: string): Promise<number>;\n /**\n * Sets `number` variable value\n */\n setInt(variableId: string, value: number): Promise<void>;\n\n /**\n * Retrieves `number[]` variable value.\n * Returns empty array if variable does not exist or does not convert to integer array.\n */\n getInts(variableId: string): Promise<number[]>;\n /**\n * Sets `number[]` variable value\n */\n setInts(variableId: string, value: number[]): Promise<void>;\n\n /**\n * Retrieves `Id64String` variable value.\n * Returns invalid Id64String if variable does not exist or does not convert to Id64String.\n */\n getId64(variableId: string): Promise<Id64String>;\n /**\n * Sets `Id64String` variable value\n */\n setId64(variableId: string, value: Id64String): Promise<void>;\n\n /**\n * Retrieves `Id64String[]` variable value.\n * Returns empty array if variable does not exist or does not convert to Id64String array.\n */\n getId64s(variableId: string): Promise<Id64String[]>;\n /**\n * Sets `Id64String[]` variable value\n */\n setId64s(variableId: string, value: Id64String[]): Promise<void>;\n\n /** Unsets variable with given id. */\n unset(variableId: string): Promise<void>;\n\n /** Retrieves all variables.\n * @internal\n */\n getAllVariables(): RulesetVariable[];\n}\n\n/** @internal */\nexport class RulesetVariablesManagerImpl implements RulesetVariablesManager {\n private _clientValues = new Map<string, RulesetVariable>();\n private _rulesetId: string;\n private _ipcHandler?: IpcRequestsHandler;\n public onVariableChanged = new BeEvent<(variableId: string, prevValue: VariableValue | undefined, currValue: VariableValue | undefined) => void>();\n\n public constructor(rulesetId: string, ipcHandler?: IpcRequestsHandler) {\n this._rulesetId = rulesetId;\n this._ipcHandler = ipcHandler;\n }\n\n public getAllVariables(): RulesetVariable[] {\n const variables: RulesetVariable[] = [];\n for (const entry of this._clientValues) {\n variables.push(entry[1]);\n }\n return variables;\n }\n\n private changeValueType(variable: RulesetVariable, toType: VariableValueTypes): VariableValue | undefined {\n switch (toType) {\n case VariableValueTypes.Bool:\n switch (variable.type) {\n case VariableValueTypes.Int:\n return 0 !== variable.value;\n case VariableValueTypes.Id64:\n return Id64.isValidId64(variable.value);\n default:\n return undefined;\n }\n case VariableValueTypes.Int:\n switch (variable.type) {\n case VariableValueTypes.Bool:\n return variable.value ? 1 : 0;\n case VariableValueTypes.Id64:\n return Id64.getUpperUint32(variable.value);\n default:\n return undefined;\n }\n case VariableValueTypes.IntArray:\n switch (variable.type) {\n case VariableValueTypes.Id64Array:\n return variable.value.map((id) => Id64.getUpperUint32(id));\n default:\n return undefined;\n }\n case VariableValueTypes.Id64:\n switch (variable.type) {\n case VariableValueTypes.Bool:\n return Id64.fromLocalAndBriefcaseIds(variable.value ? 1 : 0, 0);\n case VariableValueTypes.Int:\n return Id64.fromLocalAndBriefcaseIds(variable.value, 0);\n default:\n return undefined;\n }\n case VariableValueTypes.Id64Array:\n switch (variable.type) {\n case VariableValueTypes.IntArray:\n return variable.value.map((int) => Id64.fromLocalAndBriefcaseIds(int, 0));\n default:\n return undefined;\n }\n case VariableValueTypes.String:\n switch (variable.type) {\n case VariableValueTypes.IntArray:\n case VariableValueTypes.Id64Array:\n return undefined;\n default:\n variable.value.toString();\n }\n }\n return undefined;\n }\n\n private async getValue(id: string, type: VariableValueTypes): Promise<VariableValue | undefined> {\n const variable = this._clientValues.get(id);\n if (!variable) {\n return undefined;\n }\n if (variable.type !== type) {\n return this.changeValueType(variable, type);\n }\n return variable.value;\n }\n\n private async setValue(variable: RulesetVariable): Promise<void> {\n const oldVariable = this._clientValues.get(variable.id);\n if (oldVariable && variablesEqual(oldVariable, variable)) {\n return;\n }\n\n this._clientValues.set(variable.id, variable);\n if (this._ipcHandler) {\n await this._ipcHandler.setRulesetVariable({ rulesetId: this._rulesetId, variable });\n }\n\n this.onVariableChanged.raiseEvent(variable.id, oldVariable?.value, variable.value);\n }\n\n public async unset(variableId: string): Promise<void> {\n const variable = this._clientValues.get(variableId);\n if (variable === undefined) {\n return;\n }\n\n this._clientValues.delete(variable.id);\n if (this._ipcHandler) {\n await this._ipcHandler.unsetRulesetVariable({ rulesetId: this._rulesetId, variableId });\n }\n this.onVariableChanged.raiseEvent(variable.id, variable.value, undefined);\n }\n\n /**\n * Retrieves `string` variable value.\n * Returns empty string if variable does not exist or does not convert to string.\n */\n public async getString(variableId: string): Promise<string> {\n return ((await this.getValue(variableId, VariableValueTypes.String)) as string) || \"\";\n }\n\n /**\n * Sets `string` variable value\n */\n public async setString(variableId: string, value: string): Promise<void> {\n await this.setValue({ id: variableId, type: VariableValueTypes.String, value });\n }\n\n /**\n * Retrieves `boolean` variable value.\n * Returns `false` if variable does not exist or does not convert to boolean.\n */\n public async getBool(variableId: string): Promise<boolean> {\n return ((await this.getValue(variableId, VariableValueTypes.Bool)) as boolean) || false;\n }\n\n /**\n * Sets `boolean` variable value\n */\n public async setBool(variableId: string, value: boolean): Promise<void> {\n await this.setValue({ id: variableId, type: VariableValueTypes.Bool, value });\n }\n\n /**\n * Retrieves `number` variable value.\n * Returns `0` if variable does not exist or does not convert to integer.\n */\n public async getInt(variableId: string): Promise<number> {\n return ((await this.getValue(variableId, VariableValueTypes.Int)) as number) || 0;\n }\n\n /**\n * Sets `number` variable value\n */\n public async setInt(variableId: string, value: number): Promise<void> {\n await this.setValue({ id: variableId, type: VariableValueTypes.Int, value });\n }\n\n /**\n * Retrieves `number[]` variable value.\n * Returns empty array if variable does not exist or does not convert to integer array.\n */\n public async getInts(variableId: string): Promise<number[]> {\n return ((await this.getValue(variableId, VariableValueTypes.IntArray)) as number[]) || [];\n }\n\n /**\n * Sets `number[]` variable value\n */\n public async setInts(variableId: string, value: number[]): Promise<void> {\n await this.setValue({ id: variableId, type: VariableValueTypes.IntArray, value: [...value] });\n }\n\n /**\n * Retrieves `Id64String` variable value.\n * Returns invalid Id64String if variable does not exist or does not convert to Id64String.\n */\n public async getId64(variableId: string): Promise<Id64String> {\n return ((await this.getValue(variableId, VariableValueTypes.Id64)) as Id64String) || Id64.invalid;\n }\n\n /**\n * Sets `Id64String` variable value\n */\n public async setId64(variableId: string, value: Id64String): Promise<void> {\n await this.setValue({ id: variableId, type: VariableValueTypes.Id64, value });\n }\n\n /**\n * Retrieves `Id64String[]` variable value.\n * Returns empty array if variable does not exist or does not convert to Id64String array.\n */\n public async getId64s(variableId: string): Promise<Id64String[]> {\n return ((await this.getValue(variableId, VariableValueTypes.Id64Array)) as Id64String[]) || [];\n }\n\n /**\n * Sets `Id64String[]` variable value\n */\n public async setId64s(variableId: string, value: Id64String[]): Promise<void> {\n await this.setValue({ id: variableId, type: VariableValueTypes.Id64Array, value: [...OrderedId64Iterable.sortArray(value)] });\n }\n}\n\nfunction variablesEqual(lhs: RulesetVariable, rhs: RulesetVariable) {\n if (lhs.type !== rhs.type) {\n return false;\n }\n\n switch (lhs.type) {\n case VariableValueTypes.IntArray:\n case VariableValueTypes.Id64Array:\n assert(rhs.type === lhs.type);\n return arraysEqual(lhs.value, rhs.value);\n\n default:\n return lhs.value === rhs.value;\n }\n}\n\nfunction arraysEqual(lhs: any[], rhs: any[]) {\n if (lhs.length !== rhs.length) {\n return false;\n }\n\n for (let i = 0; i < lhs.length; ++i) {\n if (lhs[i] !== rhs[i]) {\n return false;\n }\n }\n return true;\n}\n"]}
|
|
@@ -62,12 +62,14 @@ export declare class FavoritePropertiesManager implements IDisposable {
|
|
|
62
62
|
private _iTwinProperties;
|
|
63
63
|
private _imodelProperties;
|
|
64
64
|
private _imodelBaseClassesByClass;
|
|
65
|
+
private _imodelInitializationPromises;
|
|
65
66
|
/** Property order is saved only in iModel scope */
|
|
66
67
|
private _propertiesOrder;
|
|
67
68
|
constructor(props: FavoritePropertiesManagerProps);
|
|
68
69
|
dispose(): void;
|
|
69
70
|
/**
|
|
70
71
|
* Initialize favorite properties for the provided IModelConnection.
|
|
72
|
+
* @deprecated in 4.5. Initialization is performed automatically by all async methods and only needed for deprecated [[FavoritePropertiesManager.has]] and [[FavoritePropertiesManager.sortFields]].
|
|
71
73
|
*/
|
|
72
74
|
initializeConnection: (imodel: IModelConnection) => Promise<void>;
|
|
73
75
|
/**
|
|
@@ -75,13 +77,27 @@ export declare class FavoritePropertiesManager implements IDisposable {
|
|
|
75
77
|
* favorited and adds missing order information for favorited properties.
|
|
76
78
|
*/
|
|
77
79
|
private _adjustPropertyOrderInfos;
|
|
80
|
+
private isInitialized;
|
|
81
|
+
/**
|
|
82
|
+
* Checks if [[FavoritePropertiesManager.initializeConnection]] has been called for a given imodel.
|
|
83
|
+
* Can be removed when [[FavoritePropertiesManager.has]] and [[FavoritePropertiesManager.sortFields]] are removed.
|
|
84
|
+
*/
|
|
78
85
|
private validateInitialization;
|
|
86
|
+
/**
|
|
87
|
+
* Calls [[FavoritePropertiesManager.initializeConnection]] and caches the promise which should be awaited by calling [[FavoritePropertiesManager.ensureInitialized]].
|
|
88
|
+
* @internal
|
|
89
|
+
*/
|
|
90
|
+
startConnectionInitialization(imodel: IModelConnection): void;
|
|
91
|
+
/**
|
|
92
|
+
* Performs the initialization process or finishes the one that was started by [[FavoritePropertiesManager.startConnectionInitialization]].
|
|
93
|
+
* @internal
|
|
94
|
+
*/
|
|
95
|
+
ensureInitialized(imodel: IModelConnection): Promise<void>;
|
|
79
96
|
/**
|
|
80
97
|
* Adds favorite properties into a certain scope.
|
|
81
98
|
* @param field Field that contains properties. If field contains multiple properties, all of them will be favorited.
|
|
82
99
|
* @param imodel IModelConnection.
|
|
83
100
|
* @param scope FavoritePropertiesScope to put the favorite properties into.
|
|
84
|
-
* @note `initializeConnection` must be called with the `imodel` before calling this function.
|
|
85
101
|
*/
|
|
86
102
|
add(field: Field, imodel: IModelConnection, scope: FavoritePropertiesScope): Promise<void>;
|
|
87
103
|
/**
|
|
@@ -89,14 +105,12 @@ export declare class FavoritePropertiesManager implements IDisposable {
|
|
|
89
105
|
* @param field Field that contains properties. If field contains multiple properties, all of them will be un-favorited.
|
|
90
106
|
* @param imodel IModelConnection.
|
|
91
107
|
* @param scope FavoritePropertiesScope to remove the favorite properties from. It also removes from more general scopes.
|
|
92
|
-
* @note `initializeConnection` must be called with the `imodel` before calling this function.
|
|
93
108
|
*/
|
|
94
109
|
remove(field: Field, imodel: IModelConnection, scope: FavoritePropertiesScope): Promise<void>;
|
|
95
110
|
/**
|
|
96
111
|
* Removes all favorite properties from a certain scope.
|
|
97
112
|
* @param imodel IModelConnection.
|
|
98
113
|
* @param scope FavoritePropertiesScope to remove the favorite properties from.
|
|
99
|
-
* @note `initializeConnection` must be called with the `imodel` before calling this function.
|
|
100
114
|
*/
|
|
101
115
|
clear(imodel: IModelConnection, scope: FavoritePropertiesScope): Promise<void>;
|
|
102
116
|
/**
|
|
@@ -105,16 +119,32 @@ export declare class FavoritePropertiesManager implements IDisposable {
|
|
|
105
119
|
* @param imodel IModelConnection.
|
|
106
120
|
* @param scope FavoritePropertiesScope to check for favorite properties. It also checks the more general scopes.
|
|
107
121
|
* @note `initializeConnection` must be called with the `imodel` before calling this function.
|
|
122
|
+
* @deprecated in 4.5. Use [[FavoritePropertiesManager.hasAsync]] instead. This method is not async, therefore it requires early initialization by calling [[FavoritePropertiesManager.initializeConnection]].
|
|
108
123
|
*/
|
|
109
124
|
has(field: Field, imodel: IModelConnection, scope: FavoritePropertiesScope): boolean;
|
|
125
|
+
/**
|
|
126
|
+
* Check if field contains at least one favorite property.
|
|
127
|
+
* @param field Field that contains properties.
|
|
128
|
+
* @param imodel IModelConnection.
|
|
129
|
+
* @param scope FavoritePropertiesScope to check for favorite properties. It also checks the more general scopes.
|
|
130
|
+
*/
|
|
131
|
+
hasAsync(field: Field, imodel: IModelConnection, scope: FavoritePropertiesScope): Promise<boolean>;
|
|
110
132
|
/**
|
|
111
133
|
* Sorts an array of fields with respect to favorite property order.
|
|
112
134
|
* Non-favorited fields get sorted by their default priority and always have lower priority than favorited fields.
|
|
113
135
|
* @param imodel IModelConnection.
|
|
114
136
|
* @param fields Array of Field's that needs to be sorted.
|
|
115
137
|
* @note `initializeConnection` must be called with the `imodel` before calling this function.
|
|
138
|
+
* @deprecated in 4.5. Use [[FavoritePropertiesManager.sortFieldsAsync]] instead. This method is not async, therefore it requires early initialization by calling [[FavoritePropertiesManager.initializeConnection]].
|
|
116
139
|
*/
|
|
117
140
|
sortFields: (imodel: IModelConnection, fields: Field[]) => Field[];
|
|
141
|
+
/**
|
|
142
|
+
* Sorts an array of fields with respect to favorite property order.
|
|
143
|
+
* Non-favorited fields get sorted by their default priority and always have lower priority than favorited fields.
|
|
144
|
+
* @param imodel IModelConnection.
|
|
145
|
+
* @param fields Array of Field's that needs to be sorted.
|
|
146
|
+
*/
|
|
147
|
+
sortFieldsAsync(imodel: IModelConnection, fields: Field[]): Promise<Field[]>;
|
|
118
148
|
private getFieldPriority;
|
|
119
149
|
private _getBaseClassesByClass;
|
|
120
150
|
/** Changes field properties priorities to lower than another fields priority
|
|
@@ -122,7 +152,6 @@ export declare class FavoritePropertiesManager implements IDisposable {
|
|
|
122
152
|
* @param field Field that priority is being changed.
|
|
123
153
|
* @param afterField Field that goes before the moved field. If undefined the moving field is changed to the highest priority (to the top).
|
|
124
154
|
* @param visibleFields Array of fields to move the field in.
|
|
125
|
-
* @note `initializeConnection` must be called with the `imodel` before calling this function.
|
|
126
155
|
*/
|
|
127
156
|
changeFieldPriority(imodel: IModelConnection, field: Field, afterField: Field | undefined, visibleFields: Field[]): Promise<void>;
|
|
128
157
|
}
|
package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesManager.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FavoritePropertiesManager.d.ts","sourceRoot":"","sources":["../../../../src/presentation-frontend/favorite-properties/FavoritePropertiesManager.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,WAAW,EAAiB,MAAM,qBAAqB,CAAC;AAE1E,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAW,KAAK,EAAuC,MAAM,4BAA4B,CAAC;AACjG,OAAO,EAAE,0BAA0B,EAAE,MAAM,6BAA6B,CAAC;AAEzE;;;GAGG;AACH,oBAAY,uBAAuB;IACjC,MAAM,IAAA;IACN,KAAK,IAAA;IACL,MAAM,IAAA;CACP;AAED;;;;;;GAMG;AACH,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAC;AAEtC;;;GAGG;AACH,MAAM,WAAW,2BAA2B;IAC1C,eAAe,EAAE,MAAM,GAAG,SAAS,CAAC;IACpC,IAAI,EAAE,gBAAgB,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,gBAAgB,EAAE,IAAI,CAAC;CACxB;AAED;;;GAGG;AACH,MAAM,WAAW,8BAA8B;IAC7C;;;OAGG;IACH,OAAO,EAAE,0BAA0B,CAAC;CACrC;AAED;;;;;GAKG;AACH,qBAAa,yBAA0B,YAAW,WAAW;IAC3D;;;OAGG;IACH,OAAc,2BAA2B,SAAM;IAE/C,2DAA2D;IACpD,kBAAkB,gBAAqB,IAAI,EAAI;IAEtD,OAAO,CAAC,QAAQ,CAA6B;IAC7C,OAAO,CAAC,iBAAiB,CAAoC;IAC7D,OAAO,CAAC,gBAAgB,CAAqC;IAC7D,OAAO,CAAC,iBAAiB,CAAqC;IAC9D,OAAO,CAAC,yBAAyB,CAAiD;
|
|
1
|
+
{"version":3,"file":"FavoritePropertiesManager.d.ts","sourceRoot":"","sources":["../../../../src/presentation-frontend/favorite-properties/FavoritePropertiesManager.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,WAAW,EAAiB,MAAM,qBAAqB,CAAC;AAE1E,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAW,KAAK,EAAuC,MAAM,4BAA4B,CAAC;AACjG,OAAO,EAAE,0BAA0B,EAAE,MAAM,6BAA6B,CAAC;AAEzE;;;GAGG;AACH,oBAAY,uBAAuB;IACjC,MAAM,IAAA;IACN,KAAK,IAAA;IACL,MAAM,IAAA;CACP;AAED;;;;;;GAMG;AACH,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAC;AAEtC;;;GAGG;AACH,MAAM,WAAW,2BAA2B;IAC1C,eAAe,EAAE,MAAM,GAAG,SAAS,CAAC;IACpC,IAAI,EAAE,gBAAgB,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,gBAAgB,EAAE,IAAI,CAAC;CACxB;AAED;;;GAGG;AACH,MAAM,WAAW,8BAA8B;IAC7C;;;OAGG;IACH,OAAO,EAAE,0BAA0B,CAAC;CACrC;AAED;;;;;GAKG;AACH,qBAAa,yBAA0B,YAAW,WAAW;IAC3D;;;OAGG;IACH,OAAc,2BAA2B,SAAM;IAE/C,2DAA2D;IACpD,kBAAkB,gBAAqB,IAAI,EAAI;IAEtD,OAAO,CAAC,QAAQ,CAA6B;IAC7C,OAAO,CAAC,iBAAiB,CAAoC;IAC7D,OAAO,CAAC,gBAAgB,CAAqC;IAC7D,OAAO,CAAC,i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AAgB,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC;IAMzF,OAAO,CAAC,gBAAgB;IAUxB,OAAO,CAAC,sBAAsB,CAuC5B;IAEF;;;;;OAKG;IACU,mBAAmB,CAAC,MAAM,EAAE,gBAAgB,EAAE,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,GAAG,SAAS,EAAE,aAAa,EAAE,KAAK,EAAE;CAgI/H;AAuDD,gBAAgB;AAChB,eAAO,MAAM,aAAa,UAAW,KAAK,KAAG,IAAI,gBAAgB,CAUhE,CAAC;AAiCF,gBAAgB;AAChB,eAAO,MAAM,qBAAqB,UAAW,KAAK,KAAG,2BAA2B,EA4B/E,CAAC"}
|
|
@@ -29,6 +29,7 @@ class FavoritePropertiesManager {
|
|
|
29
29
|
this.onFavoritesChanged = new BeEvent();
|
|
30
30
|
/**
|
|
31
31
|
* Initialize favorite properties for the provided IModelConnection.
|
|
32
|
+
* @deprecated in 4.5. Initialization is performed automatically by all async methods and only needed for deprecated [[FavoritePropertiesManager.has]] and [[FavoritePropertiesManager.sortFields]].
|
|
32
33
|
*/
|
|
33
34
|
this.initializeConnection = async (imodel) => {
|
|
34
35
|
const imodelId = imodel.iModelId;
|
|
@@ -82,6 +83,7 @@ class FavoritePropertiesManager {
|
|
|
82
83
|
* @param imodel IModelConnection.
|
|
83
84
|
* @param fields Array of Field's that needs to be sorted.
|
|
84
85
|
* @note `initializeConnection` must be called with the `imodel` before calling this function.
|
|
86
|
+
* @deprecated in 4.5. Use [[FavoritePropertiesManager.sortFieldsAsync]] instead. This method is not async, therefore it requires early initialization by calling [[FavoritePropertiesManager.initializeConnection]].
|
|
85
87
|
*/
|
|
86
88
|
this.sortFields = (imodel, fields) => {
|
|
87
89
|
this.validateInitialization(imodel);
|
|
@@ -124,13 +126,13 @@ class FavoritePropertiesManager {
|
|
|
124
126
|
if (missingClasses.size === 0) {
|
|
125
127
|
return baseClasses;
|
|
126
128
|
}
|
|
127
|
-
const query = `
|
|
128
|
-
SELECT (derivedSchema.Name || ':' || derivedClass.Name) AS "ClassFullName", (baseSchema.Name || ':' || baseClass.Name) AS "BaseClassFullName"
|
|
129
|
-
FROM ECDbMeta.ClassHasAllBaseClasses baseClassRels
|
|
130
|
-
INNER JOIN ECDbMeta.ECClassDef derivedClass ON derivedClass.ECInstanceId = baseClassRels.SourceECInstanceId
|
|
131
|
-
INNER JOIN ECDbMeta.ECSchemaDef derivedSchema ON derivedSchema.ECInstanceId = derivedClass.Schema.Id
|
|
132
|
-
INNER JOIN ECDbMeta.ECClassDef baseClass ON baseClass.ECInstanceId = baseClassRels.TargetECInstanceId
|
|
133
|
-
INNER JOIN ECDbMeta.ECSchemaDef baseSchema ON baseSchema.ECInstanceId = baseClass.Schema.Id
|
|
129
|
+
const query = `
|
|
130
|
+
SELECT (derivedSchema.Name || ':' || derivedClass.Name) AS "ClassFullName", (baseSchema.Name || ':' || baseClass.Name) AS "BaseClassFullName"
|
|
131
|
+
FROM ECDbMeta.ClassHasAllBaseClasses baseClassRels
|
|
132
|
+
INNER JOIN ECDbMeta.ECClassDef derivedClass ON derivedClass.ECInstanceId = baseClassRels.SourceECInstanceId
|
|
133
|
+
INNER JOIN ECDbMeta.ECSchemaDef derivedSchema ON derivedSchema.ECInstanceId = derivedClass.Schema.Id
|
|
134
|
+
INNER JOIN ECDbMeta.ECClassDef baseClass ON baseClass.ECInstanceId = baseClassRels.TargetECInstanceId
|
|
135
|
+
INNER JOIN ECDbMeta.ECSchemaDef baseSchema ON baseSchema.ECInstanceId = baseClass.Schema.Id
|
|
134
136
|
WHERE (derivedSchema.Name || ':' || derivedClass.Name) IN (${[...missingClasses].map((className) => `'${className}'`).join(",")})`;
|
|
135
137
|
const reader = imodel.createQueryReader(query, undefined, { rowFormat: QueryRowFormat.UseJsPropertyNames });
|
|
136
138
|
while (await reader.step()) {
|
|
@@ -147,6 +149,7 @@ class FavoritePropertiesManager {
|
|
|
147
149
|
this._imodelProperties = new Map();
|
|
148
150
|
this._propertiesOrder = new Map();
|
|
149
151
|
this._imodelBaseClassesByClass = new Map();
|
|
152
|
+
this._imodelInitializationPromises = new Map();
|
|
150
153
|
}
|
|
151
154
|
dispose() {
|
|
152
155
|
// istanbul ignore else
|
|
@@ -154,22 +157,59 @@ class FavoritePropertiesManager {
|
|
|
154
157
|
this._storage.dispose();
|
|
155
158
|
}
|
|
156
159
|
}
|
|
160
|
+
isInitialized(imodel) {
|
|
161
|
+
const iTwinId = imodel.iTwinId;
|
|
162
|
+
const imodelId = imodel.iModelId;
|
|
163
|
+
return this._imodelProperties.has(getiModelInfo(iTwinId, imodelId));
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Checks if [[FavoritePropertiesManager.initializeConnection]] has been called for a given imodel.
|
|
167
|
+
* Can be removed when [[FavoritePropertiesManager.has]] and [[FavoritePropertiesManager.sortFields]] are removed.
|
|
168
|
+
*/
|
|
157
169
|
validateInitialization(imodel) {
|
|
158
170
|
const iTwinId = imodel.iTwinId;
|
|
159
171
|
const imodelId = imodel.iModelId;
|
|
160
|
-
if (!this.
|
|
172
|
+
if (!this.isInitialized(imodel)) {
|
|
161
173
|
throw Error(`Favorite properties are not initialized for iModel: '${imodelId}', in iTwin: '${iTwinId}'. Call initializeConnection() with an IModelConnection to initialize.`);
|
|
162
174
|
}
|
|
163
175
|
}
|
|
176
|
+
/**
|
|
177
|
+
* Calls [[FavoritePropertiesManager.initializeConnection]] and caches the promise which should be awaited by calling [[FavoritePropertiesManager.ensureInitialized]].
|
|
178
|
+
* @internal
|
|
179
|
+
*/
|
|
180
|
+
startConnectionInitialization(imodel) {
|
|
181
|
+
if (!this.isInitialized(imodel) && !this._imodelInitializationPromises.has(imodel)) {
|
|
182
|
+
// eslint-disable-next-line deprecation/deprecation
|
|
183
|
+
this._imodelInitializationPromises.set(imodel, this.initializeConnection(imodel));
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Performs the initialization process or finishes the one that was started by [[FavoritePropertiesManager.startConnectionInitialization]].
|
|
188
|
+
* @internal
|
|
189
|
+
*/
|
|
190
|
+
async ensureInitialized(imodel) {
|
|
191
|
+
if (this.isInitialized(imodel)) {
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
let promise = this._imodelInitializationPromises.get(imodel);
|
|
195
|
+
if (!promise) {
|
|
196
|
+
// eslint-disable-next-line deprecation/deprecation
|
|
197
|
+
promise = this.initializeConnection(imodel);
|
|
198
|
+
// Put the promise in the map to avoid possible multiple initializations from different promises.
|
|
199
|
+
this._imodelInitializationPromises.set(imodel, promise);
|
|
200
|
+
}
|
|
201
|
+
await promise;
|
|
202
|
+
// Remove this promise from the map, because the next time this method is called, `this.isInitialized` should return true.
|
|
203
|
+
this._imodelInitializationPromises.delete(imodel);
|
|
204
|
+
}
|
|
164
205
|
/**
|
|
165
206
|
* Adds favorite properties into a certain scope.
|
|
166
207
|
* @param field Field that contains properties. If field contains multiple properties, all of them will be favorited.
|
|
167
208
|
* @param imodel IModelConnection.
|
|
168
209
|
* @param scope FavoritePropertiesScope to put the favorite properties into.
|
|
169
|
-
* @note `initializeConnection` must be called with the `imodel` before calling this function.
|
|
170
210
|
*/
|
|
171
211
|
async add(field, imodel, scope) {
|
|
172
|
-
this.
|
|
212
|
+
await this.ensureInitialized(imodel);
|
|
173
213
|
const iTwinId = imodel.iTwinId;
|
|
174
214
|
const imodelId = imodel.iModelId;
|
|
175
215
|
let favoriteProperties;
|
|
@@ -205,10 +245,9 @@ class FavoritePropertiesManager {
|
|
|
205
245
|
* @param field Field that contains properties. If field contains multiple properties, all of them will be un-favorited.
|
|
206
246
|
* @param imodel IModelConnection.
|
|
207
247
|
* @param scope FavoritePropertiesScope to remove the favorite properties from. It also removes from more general scopes.
|
|
208
|
-
* @note `initializeConnection` must be called with the `imodel` before calling this function.
|
|
209
248
|
*/
|
|
210
249
|
async remove(field, imodel, scope) {
|
|
211
|
-
this.
|
|
250
|
+
await this.ensureInitialized(imodel);
|
|
212
251
|
const iTwinId = imodel.iTwinId;
|
|
213
252
|
const imodelId = imodel.iModelId;
|
|
214
253
|
const fieldInfos = getFieldInfos(field);
|
|
@@ -252,10 +291,9 @@ class FavoritePropertiesManager {
|
|
|
252
291
|
* Removes all favorite properties from a certain scope.
|
|
253
292
|
* @param imodel IModelConnection.
|
|
254
293
|
* @param scope FavoritePropertiesScope to remove the favorite properties from.
|
|
255
|
-
* @note `initializeConnection` must be called with the `imodel` before calling this function.
|
|
256
294
|
*/
|
|
257
295
|
async clear(imodel, scope) {
|
|
258
|
-
this.
|
|
296
|
+
await this.ensureInitialized(imodel);
|
|
259
297
|
const iTwinId = imodel.iTwinId;
|
|
260
298
|
const imodelId = imodel.iModelId;
|
|
261
299
|
let favoriteProperties;
|
|
@@ -289,6 +327,7 @@ class FavoritePropertiesManager {
|
|
|
289
327
|
* @param imodel IModelConnection.
|
|
290
328
|
* @param scope FavoritePropertiesScope to check for favorite properties. It also checks the more general scopes.
|
|
291
329
|
* @note `initializeConnection` must be called with the `imodel` before calling this function.
|
|
330
|
+
* @deprecated in 4.5. Use [[FavoritePropertiesManager.hasAsync]] instead. This method is not async, therefore it requires early initialization by calling [[FavoritePropertiesManager.initializeConnection]].
|
|
292
331
|
*/
|
|
293
332
|
has(field, imodel, scope) {
|
|
294
333
|
this.validateInitialization(imodel);
|
|
@@ -299,6 +338,28 @@ class FavoritePropertiesManager {
|
|
|
299
338
|
(scope !== FavoritePropertiesScope.Global && setHasAny(this._iTwinProperties.get(iTwinId), fieldInfos)) ||
|
|
300
339
|
(scope === FavoritePropertiesScope.IModel && setHasAny(this._imodelProperties.get(getiModelInfo(iTwinId, imodelId)), fieldInfos)));
|
|
301
340
|
}
|
|
341
|
+
/**
|
|
342
|
+
* Check if field contains at least one favorite property.
|
|
343
|
+
* @param field Field that contains properties.
|
|
344
|
+
* @param imodel IModelConnection.
|
|
345
|
+
* @param scope FavoritePropertiesScope to check for favorite properties. It also checks the more general scopes.
|
|
346
|
+
*/
|
|
347
|
+
async hasAsync(field, imodel, scope) {
|
|
348
|
+
await this.ensureInitialized(imodel);
|
|
349
|
+
// eslint-disable-next-line deprecation/deprecation
|
|
350
|
+
return this.has(field, imodel, scope);
|
|
351
|
+
}
|
|
352
|
+
/**
|
|
353
|
+
* Sorts an array of fields with respect to favorite property order.
|
|
354
|
+
* Non-favorited fields get sorted by their default priority and always have lower priority than favorited fields.
|
|
355
|
+
* @param imodel IModelConnection.
|
|
356
|
+
* @param fields Array of Field's that needs to be sorted.
|
|
357
|
+
*/
|
|
358
|
+
async sortFieldsAsync(imodel, fields) {
|
|
359
|
+
await this.ensureInitialized(imodel);
|
|
360
|
+
// eslint-disable-next-line deprecation/deprecation
|
|
361
|
+
return this.sortFields(imodel, fields);
|
|
362
|
+
}
|
|
302
363
|
getFieldPriority(field, iTwinId, imodelId) {
|
|
303
364
|
const orderInfos = this._propertiesOrder.get(getiModelInfo(iTwinId, imodelId));
|
|
304
365
|
const fieldOrderInfos = getFieldOrderInfos(field, orderInfos);
|
|
@@ -313,7 +374,6 @@ class FavoritePropertiesManager {
|
|
|
313
374
|
* @param field Field that priority is being changed.
|
|
314
375
|
* @param afterField Field that goes before the moved field. If undefined the moving field is changed to the highest priority (to the top).
|
|
315
376
|
* @param visibleFields Array of fields to move the field in.
|
|
316
|
-
* @note `initializeConnection` must be called with the `imodel` before calling this function.
|
|
317
377
|
*/
|
|
318
378
|
async changeFieldPriority(imodel, field, afterField, visibleFields) {
|
|
319
379
|
/**
|
|
@@ -328,7 +388,7 @@ class FavoritePropertiesManager {
|
|
|
328
388
|
* 4. Irrelevant orderInfos's get moved after `orderInfo` (depends on the direction)
|
|
329
389
|
* 5. All `field` orderInfo's get moved after `afterOrderInfo`
|
|
330
390
|
*/
|
|
331
|
-
this.
|
|
391
|
+
await this.ensureInitialized(imodel);
|
|
332
392
|
const iTwinId = imodel.iTwinId;
|
|
333
393
|
const imodelId = imodel.iModelId;
|
|
334
394
|
if (field === afterField) {
|