@itwin/grouping-mapping-widget 0.2.3 → 0.3.2
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/widget/GroupingMappingWidget.d.ts +4 -0
- package/lib/cjs/widget/GroupingMappingWidget.js +6 -23
- package/lib/cjs/widget/GroupingMappingWidget.js.map +1 -1
- package/lib/cjs/widget/components/ActionPanel.d.ts +3 -2
- package/lib/cjs/widget/components/ActionPanel.js +3 -3
- package/lib/cjs/widget/components/ActionPanel.js.map +1 -1
- package/lib/cjs/widget/components/CalculatedPropertyAction.d.ts +2 -2
- package/lib/cjs/widget/components/CalculatedPropertyAction.js +14 -9
- package/lib/cjs/widget/components/CalculatedPropertyAction.js.map +1 -1
- package/lib/cjs/widget/components/CalculatedPropertyAction.scss +5 -5
- package/lib/cjs/widget/components/CalculatedPropertyTable.d.ts +5 -5
- package/lib/cjs/widget/components/CalculatedPropertyTable.js +15 -16
- package/lib/cjs/widget/components/CalculatedPropertyTable.js.map +1 -1
- package/lib/cjs/widget/components/ConfirmMappingsImport.d.ts +3 -3
- package/lib/cjs/widget/components/ConfirmMappingsImport.js +6 -3
- package/lib/cjs/widget/components/ConfirmMappingsImport.js.map +1 -1
- package/lib/cjs/widget/components/CustomCalculationAction.d.ts +2 -2
- package/lib/cjs/widget/components/CustomCalculationAction.js +15 -9
- package/lib/cjs/widget/components/CustomCalculationAction.js.map +1 -1
- package/lib/cjs/widget/components/CustomCalculationTable.d.ts +5 -5
- package/lib/cjs/widget/components/CustomCalculationTable.js +15 -16
- package/lib/cjs/widget/components/CustomCalculationTable.js.map +1 -1
- package/lib/cjs/widget/components/GroupAction.d.ts +2 -2
- package/lib/cjs/widget/components/GroupAction.js +25 -42
- package/lib/cjs/widget/components/GroupAction.js.map +1 -1
- package/lib/cjs/widget/components/GroupPropertyAction.js +9 -5
- package/lib/cjs/widget/components/GroupPropertyAction.js.map +1 -1
- package/lib/cjs/widget/components/GroupPropertyTable.d.ts +5 -5
- package/lib/cjs/widget/components/GroupPropertyTable.js +15 -16
- package/lib/cjs/widget/components/GroupPropertyTable.js.map +1 -1
- package/lib/cjs/widget/components/Grouping.d.ts +3 -3
- package/lib/cjs/widget/components/Grouping.js +26 -26
- package/lib/cjs/widget/components/Grouping.js.map +1 -1
- package/lib/cjs/widget/components/GroupingMapping.d.ts +12 -2
- package/lib/cjs/widget/components/GroupingMapping.js +18 -4
- package/lib/cjs/widget/components/GroupingMapping.js.map +1 -1
- package/lib/cjs/widget/components/Mapping.d.ts +2 -2
- package/lib/cjs/widget/components/Mapping.js +14 -14
- package/lib/cjs/widget/components/Mapping.js.map +1 -1
- package/lib/cjs/widget/components/MappingAction.d.ts +2 -2
- package/lib/cjs/widget/components/MappingAction.js +7 -4
- package/lib/cjs/widget/components/MappingAction.js.map +1 -1
- package/lib/cjs/widget/components/MappingImportWizardModal.js.map +1 -1
- package/lib/cjs/widget/components/PropertyMenu.d.ts +2 -2
- package/lib/cjs/widget/components/PropertyMenu.js.map +1 -1
- package/lib/cjs/widget/components/SelectIModel.js +4 -8
- package/lib/cjs/widget/components/SelectIModel.js.map +1 -1
- package/lib/cjs/widget/components/SelectMappings.d.ts +2 -2
- package/lib/cjs/widget/components/SelectMappings.js +10 -11
- package/lib/cjs/widget/components/SelectMappings.js.map +1 -1
- package/lib/cjs/widget/components/SelectProject.js +4 -8
- package/lib/cjs/widget/components/SelectProject.js.map +1 -1
- package/lib/cjs/widget/components/property-grid/PropertyView.js +4 -1
- package/lib/cjs/widget/components/property-grid/PropertyView.js.map +1 -1
- package/lib/esm/widget/GroupingMappingWidget.d.ts +4 -0
- package/lib/esm/widget/GroupingMappingWidget.js +6 -4
- package/lib/esm/widget/GroupingMappingWidget.js.map +1 -1
- package/lib/esm/widget/components/ActionPanel.d.ts +3 -2
- package/lib/esm/widget/components/ActionPanel.js +3 -3
- package/lib/esm/widget/components/ActionPanel.js.map +1 -1
- package/lib/esm/widget/components/CalculatedPropertyAction.d.ts +2 -2
- package/lib/esm/widget/components/CalculatedPropertyAction.js +15 -10
- package/lib/esm/widget/components/CalculatedPropertyAction.js.map +1 -1
- package/lib/esm/widget/components/CalculatedPropertyAction.scss +5 -5
- package/lib/esm/widget/components/CalculatedPropertyTable.d.ts +5 -5
- package/lib/esm/widget/components/CalculatedPropertyTable.js +16 -17
- package/lib/esm/widget/components/CalculatedPropertyTable.js.map +1 -1
- package/lib/esm/widget/components/ConfirmMappingsImport.d.ts +3 -3
- package/lib/esm/widget/components/ConfirmMappingsImport.js +7 -4
- package/lib/esm/widget/components/ConfirmMappingsImport.js.map +1 -1
- package/lib/esm/widget/components/CustomCalculationAction.d.ts +2 -2
- package/lib/esm/widget/components/CustomCalculationAction.js +16 -10
- package/lib/esm/widget/components/CustomCalculationAction.js.map +1 -1
- package/lib/esm/widget/components/CustomCalculationTable.d.ts +5 -5
- package/lib/esm/widget/components/CustomCalculationTable.js +16 -17
- package/lib/esm/widget/components/CustomCalculationTable.js.map +1 -1
- package/lib/esm/widget/components/GroupAction.d.ts +2 -2
- package/lib/esm/widget/components/GroupAction.js +26 -43
- package/lib/esm/widget/components/GroupAction.js.map +1 -1
- package/lib/esm/widget/components/GroupPropertyAction.js +10 -6
- package/lib/esm/widget/components/GroupPropertyAction.js.map +1 -1
- package/lib/esm/widget/components/GroupPropertyTable.d.ts +5 -5
- package/lib/esm/widget/components/GroupPropertyTable.js +16 -17
- package/lib/esm/widget/components/GroupPropertyTable.js.map +1 -1
- package/lib/esm/widget/components/Grouping.d.ts +3 -3
- package/lib/esm/widget/components/Grouping.js +27 -27
- package/lib/esm/widget/components/Grouping.js.map +1 -1
- package/lib/esm/widget/components/GroupingMapping.d.ts +12 -2
- package/lib/esm/widget/components/GroupingMapping.js +17 -4
- package/lib/esm/widget/components/GroupingMapping.js.map +1 -1
- package/lib/esm/widget/components/Mapping.d.ts +2 -2
- package/lib/esm/widget/components/Mapping.js +15 -15
- package/lib/esm/widget/components/Mapping.js.map +1 -1
- package/lib/esm/widget/components/MappingAction.d.ts +2 -2
- package/lib/esm/widget/components/MappingAction.js +8 -5
- package/lib/esm/widget/components/MappingAction.js.map +1 -1
- package/lib/esm/widget/components/MappingImportWizardModal.js.map +1 -1
- package/lib/esm/widget/components/PropertyMenu.d.ts +2 -2
- package/lib/esm/widget/components/PropertyMenu.js.map +1 -1
- package/lib/esm/widget/components/SelectIModel.js +5 -6
- package/lib/esm/widget/components/SelectIModel.js.map +1 -1
- package/lib/esm/widget/components/SelectMappings.d.ts +2 -2
- package/lib/esm/widget/components/SelectMappings.js +11 -12
- package/lib/esm/widget/components/SelectMappings.js.map +1 -1
- package/lib/esm/widget/components/SelectProject.js +5 -6
- package/lib/esm/widget/components/SelectProject.js.map +1 -1
- package/lib/esm/widget/components/property-grid/PropertyView.js +4 -1
- package/lib/esm/widget/components/property-grid/PropertyView.js.map +1 -1
- package/package.json +6 -3
- package/lib/cjs/api/generated/api.d.ts +0 -3222
- package/lib/cjs/api/generated/api.js +0 -5291
- package/lib/cjs/api/generated/api.js.map +0 -1
- package/lib/cjs/api/generated/configuration.d.ts +0 -56
- package/lib/cjs/api/generated/configuration.js +0 -30
- package/lib/cjs/api/generated/configuration.js.map +0 -1
- package/lib/cjs/api/generated/index.d.ts +0 -14
- package/lib/cjs/api/generated/index.js +0 -31
- package/lib/cjs/api/generated/index.js.map +0 -1
- package/lib/cjs/api/reportingClient.d.ts +0 -34
- package/lib/cjs/api/reportingClient.js +0 -177
- package/lib/cjs/api/reportingClient.js.map +0 -1
- package/lib/cjs/widget/hooks/useFetchAccessToken.d.ts +0 -3
- package/lib/cjs/widget/hooks/useFetchAccessToken.js +0 -22
- package/lib/cjs/widget/hooks/useFetchAccessToken.js.map +0 -1
- package/lib/esm/api/generated/api.d.ts +0 -3222
- package/lib/esm/api/generated/api.js +0 -5248
- package/lib/esm/api/generated/api.js.map +0 -1
- package/lib/esm/api/generated/configuration.d.ts +0 -56
- package/lib/esm/api/generated/configuration.js +0 -26
- package/lib/esm/api/generated/configuration.js.map +0 -1
- package/lib/esm/api/generated/index.d.ts +0 -14
- package/lib/esm/api/generated/index.js +0 -19
- package/lib/esm/api/generated/index.js.map +0 -1
- package/lib/esm/api/reportingClient.d.ts +0 -34
- package/lib/esm/api/reportingClient.js +0 -173
- package/lib/esm/api/reportingClient.js.map +0 -1
- package/lib/esm/widget/hooks/useFetchAccessToken.d.ts +0 -3
- package/lib/esm/widget/hooks/useFetchAccessToken.js +0 -20
- package/lib/esm/widget/hooks/useFetchAccessToken.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectMappings.js","sourceRoot":"","sources":["../../../../src/widget/components/SelectMappings.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAOA,wDAK8B;AAC9B,+
|
|
1
|
+
{"version":3,"file":"SelectMappings.js","sourceRoot":"","sources":["../../../../src/widget/components/SelectMappings.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAOA,wDAK8B;AAC9B,+CAAqF;AAErF,4DAAyD;AAEzD,uDAA+C;AAE/C,gCAA8B;AAC9B,mCAAsC;AAEtC,MAAM,aAAa,GAAG,KAAK,EACzB,WAA4D,EAC5D,QAAgB,EAChB,YAA2D,EAC3D,UAAe,EACf,EAAE;IACF,IAAI;QACF,YAAY,CAAC,IAAI,CAAC,CAAC;QACnB,MAAM,kBAAkB,GAAG,IAAI,iCAAe,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;QAClE,MAAM,QAAQ,GAAG,MAAM,kBAAkB,CAAC,WAAW,CAAC,UAAU,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;QACxF,WAAW,CAAC,QAAQ,CAAC,CAAC;KACvB;IAAC,OAAO,KAAU,EAAE;QACnB,mBAAW,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;KAC3B;YAAS;QACR,YAAY,CAAC,KAAK,CAAC,CAAC;KACrB;AACH,CAAC,CAAC;AASF,MAAM,cAAc,GAAG,CAAC,E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YAAY,CAAC,CACf,CAAC;IAEF,OAAO,CACL,uCAAK,SAAS,EAAC,0BAA0B;QACvC,8BAAC,qBAAK,IACJ,IAAI,EAAE,QAAQ,EACd,OAAO,EAAE,eAAe,EACxB,SAAS,EAAC,sBAAsB,EAChC,iBAAiB,EAAC,wBAAwB,EAC1C,UAAU,QACV,YAAY,QACZ,SAAS,EAAE,SAAS,EACpB,QAAQ,EAAE,CAAC,UAAqC,EAAE,EAAE;gBAClD,UAAU,IAAI,mBAAmB,CAAC,UAAU,CAAC,CAAC;YAChD,CAAC,EACD,iBAAiB,EAAE,SAAS,GAC5B;QACF,uCAAK,SAAS,EAAC,qBAAqB;YAClC,8BAAC,sBAAM,IAAC,OAAO,EAAE,MAAM,WAAe;YACtC,8BAAC,sBAAM,IACL,SAAS,EAAC,iBAAiB,EAC3B,OAAO,EAAE,GAAG,EAAE;oBACZ,QAAQ,CAAC,gBAAgB,CAAC,CAAC;gBAC7B,CAAC,EACD,QAAQ,EAAE,SAAS,IAAI,gBAAgB,CAAC,MAAM,KAAK,CAAC,WAG7C;YACT,8BAAC,sBAAM,IAAC,OAAO,EAAE,QAAQ,aAAiB,CACtC,CACF,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,cAAc,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\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*--------------------------------------------------------------------------------------------*/\nimport type {\n TablePaginatorRendererProps,\n} from \"@itwin/itwinui-react\";\nimport {\n Button,\n Table,\n tableFilters,\n TablePaginator,\n} from \"@itwin/itwinui-react\";\nimport React, { useCallback, useContext, useEffect, useMemo, useState } from \"react\";\nimport type { Mapping } from \"@itwin/insights-client\";\nimport { ReportingClient } from \"@itwin/insights-client\";\nimport type { Api } from \"./GroupingMapping\";\nimport { ApiContext } from \"./GroupingMapping\";\nimport type { MappingType } from \"./Mapping\";\nimport \"./SelectMapping.scss\";\nimport { handleError } from \"./utils\";\n\nconst fetchMappings = async (\n setMappings: React.Dispatch<React.SetStateAction<Mapping[]>>,\n iModelId: string,\n setIsLoading: React.Dispatch<React.SetStateAction<boolean>>,\n apiContext: Api\n) => {\n try {\n setIsLoading(true);\n const reportingClientApi = new ReportingClient(apiContext.prefix);\n const mappings = await reportingClientApi.getMappings(apiContext.accessToken, iModelId);\n setMappings(mappings);\n } catch (error: any) {\n handleError(error.status);\n } finally {\n setIsLoading(false);\n }\n};\n\ninterface SelectMappingsProps {\n iModelId: string;\n onSelect: (selectedMappings: MappingType[]) => void;\n onCancel: () => void;\n backFn: () => void;\n}\n\nconst SelectMappings = ({\n iModelId,\n onSelect,\n onCancel,\n backFn,\n}: SelectMappingsProps) => {\n const apiContext = useContext(ApiContext);\n const [isLoading, setIsLoading] = useState<boolean>(true);\n const [selectedMappings, setSelectedMappings] = useState<MappingType[]>([]);\n const [mappings, setMappings] = useState<Mapping[]>([]);\n\n useEffect(() => {\n void fetchMappings(setMappings, iModelId, setIsLoading, apiContext);\n }, [apiContext, iModelId, setIsLoading]);\n\n const mappingsColumns = useMemo(\n () => [\n {\n Header: \"Table\",\n columns: [\n {\n id: \"mappingName\",\n Header: \"Mapping Name\",\n accessor: \"mappingName\",\n Filter: tableFilters.TextFilter(),\n },\n {\n id: \"description\",\n Header: \"Description\",\n accessor: \"description\",\n Filter: tableFilters.TextFilter(),\n },\n ],\n },\n ],\n []\n );\n\n const pageSizeList = useMemo(() => [10, 25, 50], []);\n const paginator = useCallback(\n (props: TablePaginatorRendererProps) => (\n <TablePaginator {...props} pageSizeList={pageSizeList} />\n ),\n [pageSizeList]\n );\n\n return (\n <div className='select-mapping-container'>\n <Table<MappingType>\n data={mappings}\n columns={mappingsColumns}\n className='select-mapping-table'\n emptyTableContent='No Mappings available.'\n isSortable\n isSelectable\n isLoading={isLoading}\n onSelect={(selectData: MappingType[] | undefined) => {\n selectData && setSelectedMappings(selectData);\n }}\n paginatorRenderer={paginator}\n />\n <div className='import-action-panel'>\n <Button onClick={backFn}>Back</Button>\n <Button\n styleType='high-visibility'\n onClick={() => {\n onSelect(selectedMappings);\n }}\n disabled={isLoading || selectedMappings.length === 0}\n >\n Next\n </Button>\n <Button onClick={onCancel}>Cancel</Button>\n </div>\n </div>\n );\n};\n\nexport default SelectMappings;\n"]}
|
|
@@ -18,16 +18,12 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
18
18
|
__setModuleDefault(result, mod);
|
|
19
19
|
return result;
|
|
20
20
|
};
|
|
21
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
|
-
};
|
|
24
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
22
|
const imodel_browser_react_1 = require("@itwin/imodel-browser-react");
|
|
26
23
|
const itwinui_icons_react_1 = require("@itwin/itwinui-icons-react");
|
|
27
24
|
const itwinui_react_1 = require("@itwin/itwinui-react");
|
|
28
25
|
const react_1 = __importStar(require("react"));
|
|
29
|
-
const
|
|
30
|
-
const useFetchAccessToken_1 = __importDefault(require("../hooks/useFetchAccessToken"));
|
|
26
|
+
const GroupingMapping_1 = require("./GroupingMapping");
|
|
31
27
|
require("./SelectProject.scss");
|
|
32
28
|
const tabsWithIcons = [
|
|
33
29
|
react_1.default.createElement(itwinui_react_1.Tab, { key: 'favorite', label: 'Favorite projects', startIcon: react_1.default.createElement(itwinui_icons_react_1.SvgStarHollow, null) }),
|
|
@@ -35,14 +31,14 @@ const tabsWithIcons = [
|
|
|
35
31
|
react_1.default.createElement(itwinui_react_1.Tab, { key: 'all', label: 'My projects', startIcon: react_1.default.createElement(itwinui_icons_react_1.SvgList, null) }),
|
|
36
32
|
];
|
|
37
33
|
const SelectProject = ({ onSelect, onCancel }) => {
|
|
38
|
-
const
|
|
34
|
+
const apiContext = react_1.useContext(GroupingMapping_1.ApiContext);
|
|
39
35
|
const [projectType, setProjectType] = react_1.useState(0);
|
|
40
36
|
const [searchInput, setSearchInput] = react_1.useState("");
|
|
41
37
|
const [activeSearchInput, setActiveSearchInput] = react_1.useState("");
|
|
42
38
|
const startSearch = react_1.useCallback(() => {
|
|
43
39
|
setActiveSearchInput(searchInput);
|
|
44
40
|
}, [searchInput]);
|
|
45
|
-
const apiOverrides = react_1.useMemo(() => ({ serverEnvironmentPrefix:
|
|
41
|
+
const apiOverrides = react_1.useMemo(() => ({ serverEnvironmentPrefix: apiContext.prefix }), [apiContext.prefix]);
|
|
46
42
|
return (react_1.default.createElement("div", { className: 'select-project-grid-container' },
|
|
47
43
|
react_1.default.createElement(itwinui_react_1.HorizontalTabs, { labels: tabsWithIcons, onTabSelected: setProjectType, activeIndex: projectType, type: "borderless", contentClassName: 'grid-holding-tab' },
|
|
48
44
|
react_1.default.createElement(itwinui_react_1.LabeledInput, { displayStyle: 'inline', iconDisplayStyle: 'inline', className: 'search-input', label: 'Search', value: searchInput, onChange: (event) => {
|
|
@@ -59,7 +55,7 @@ const SelectProject = ({ onSelect, onCancel }) => {
|
|
|
59
55
|
}, svgIcon: react_1.default.createElement(itwinui_react_1.IconButton, { onClick: () => startSearch(), styleType: 'borderless' },
|
|
60
56
|
react_1.default.createElement(itwinui_icons_react_1.SvgSearch, null)) }),
|
|
61
57
|
react_1.default.createElement("div", { className: 'project-grid' },
|
|
62
|
-
react_1.default.createElement(imodel_browser_react_1.ProjectGrid, { onThumbnailClick: onSelect, accessToken: accessToken, apiOverrides: apiOverrides, filterOptions: activeSearchInput, requestType: projectType === 0
|
|
58
|
+
react_1.default.createElement(imodel_browser_react_1.ProjectGrid, { onThumbnailClick: onSelect, accessToken: apiContext.accessToken, apiOverrides: apiOverrides, filterOptions: activeSearchInput, requestType: projectType === 0
|
|
63
59
|
? "favorites"
|
|
64
60
|
: projectType === 1
|
|
65
61
|
? "recents"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectProject.js","sourceRoot":"","sources":["../../../../src/widget/components/SelectProject.tsx"],"names":[],"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AC,SAAS;4BACX,CAAC,CAAC,EAAE,GAEV,CACE;YACN,uCAAK,SAAS,EAAC,6BAA6B;gBAC1C,8BAAC,sBAAM,IAAC,OAAO,EAAE,QAAQ,aAAiB,CACtC,CACS,CACb,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,aAAa,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\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*--------------------------------------------------------------------------------------------*/\nimport type {\n ApiOverrides,\n ProjectFull,\n} from \"@itwin/imodel-browser-react\";\nimport {\n ProjectGrid,\n} from \"@itwin/imodel-browser-react\";\nimport {\n SvgCalendar,\n SvgList,\n SvgSearch,\n SvgStarHollow,\n} from \"@itwin/itwinui-icons-react\";\nimport {\n Button,\n HorizontalTabs,\n IconButton,\n LabeledInput,\n Tab,\n} from \"@itwin/itwinui-react\";\nimport React, { useCallback, useContext, useMemo, useState } from \"react\";\nimport { ApiContext } from \"./GroupingMapping\";\nimport \"./SelectProject.scss\";\n\nconst tabsWithIcons = [\n <Tab\n key='favorite'\n label='Favorite projects'\n startIcon={<SvgStarHollow />}\n />,\n <Tab key='recents' label='Recent projects' startIcon={<SvgCalendar />} />,\n <Tab key='all' label='My projects' startIcon={<SvgList />} />,\n];\ninterface SelectProjectProps {\n onSelect: (project: ProjectFull) => void;\n onCancel: () => void;\n}\nconst SelectProject = ({ onSelect, onCancel }: SelectProjectProps) => {\n const apiContext = useContext(ApiContext);\n const [projectType, setProjectType] = useState<number>(0);\n const [searchInput, setSearchInput] = useState<string>(\"\");\n const [activeSearchInput, setActiveSearchInput] = useState<string>(\"\");\n\n const startSearch = useCallback(() => {\n setActiveSearchInput(searchInput);\n }, [searchInput]);\n\n const apiOverrides = useMemo<ApiOverrides<ProjectFull[]>>(\n () => ({ serverEnvironmentPrefix: apiContext.prefix }),\n [apiContext.prefix],\n );\n\n return (\n <div className='select-project-grid-container'>\n <HorizontalTabs\n labels={tabsWithIcons}\n onTabSelected={setProjectType}\n activeIndex={projectType}\n type={\"borderless\"}\n contentClassName='grid-holding-tab'\n >\n <LabeledInput\n displayStyle='inline'\n iconDisplayStyle='inline'\n className='search-input'\n label='Search'\n value={searchInput}\n onChange={(event) => {\n const {\n target: { value },\n } = event;\n setSearchInput(value);\n }}\n onKeyDown={(event) => {\n if (event.key === \"Enter\") {\n startSearch();\n }\n if (event.key === \"Escape\") {\n setSearchInput(\"\");\n setActiveSearchInput(\"\");\n }\n }}\n svgIcon={\n <IconButton onClick={() => startSearch()} styleType='borderless'>\n <SvgSearch />\n </IconButton>\n }\n />\n <div className='project-grid'>\n <ProjectGrid\n onThumbnailClick={onSelect}\n accessToken={apiContext.accessToken}\n apiOverrides={apiOverrides}\n filterOptions={activeSearchInput}\n requestType={\n projectType === 0\n ? \"favorites\"\n : projectType === 1\n ? \"recents\"\n : \"\"\n }\n />\n </div>\n <div className='select-project-action-panel'>\n <Button onClick={onCancel}>Cancel</Button>\n </div>\n </HorizontalTabs>\n </div>\n );\n};\n\nexport default SelectProject;\n"]}
|
|
@@ -138,7 +138,9 @@ const PropertyView = (props) => {
|
|
|
138
138
|
React.useEffect(() => {
|
|
139
139
|
if (props === null || props === void 0 ? void 0 : props.propertyRecord) {
|
|
140
140
|
if (isPropertySelected) {
|
|
141
|
-
|
|
141
|
+
if (context.isRendering) {
|
|
142
|
+
setIsCheckboxLoading(true);
|
|
143
|
+
}
|
|
142
144
|
_addNestedProperties(props.propertyRecord);
|
|
143
145
|
}
|
|
144
146
|
else {
|
|
@@ -150,6 +152,7 @@ const PropertyView = (props) => {
|
|
|
150
152
|
_removeNestedProperties,
|
|
151
153
|
isPropertySelected,
|
|
152
154
|
props.propertyRecord,
|
|
155
|
+
context.isRendering,
|
|
153
156
|
]);
|
|
154
157
|
React.useEffect(() => {
|
|
155
158
|
if (!context.isRendering)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PropertyView.js","sourceR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AqB,GAClD,CACH,CAAC,CAAC,CAAC,SAAS,CACT,CACP,CAAC;AACJ,CAAC,CAAC;AArSW,QAAA,YAAY,gBAqSvB","sourcesContent":["/*---------------------------------------------------------------------------------------------\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*--------------------------------------------------------------------------------------------*/\nimport * as React from \"react\";\nimport type { PropertyRecord } from \"@itwin/appui-abstract\";\nimport { PropertyValueFormat } from \"@itwin/appui-abstract\";\nimport { ElementSeparator, Orientation } from \"@itwin/core-react\";\nimport { ActionButtonList } from \"@itwin/components-react\";\n\nimport \"./PropertyView.scss\";\nimport type { SharedRendererProps } from \"./PropertyRender\";\nimport { GroupQueryBuilderContext } from \"../GroupQueryBuilderContext\";\nimport { useCallback } from \"react\";\nimport { PropertyGridColumnStyleProvider } from \"@itwin/components-react/lib/cjs/components-react/properties/renderers/PropertyGridColumns\";\nimport { Checkbox } from \"@itwin/itwinui-react\";\nimport { CommonPropertyRenderer } from \"@itwin/components-react/lib/cjs/components-react/properties/renderers/CommonPropertyRenderer\";\n\n/** Properties of [[PropertyView]] React component\n * @public\n */\nexport interface PropertyViewProps extends SharedRendererProps {\n /** Property label as a React element */\n labelElement: React.ReactNode;\n /** Property value as a React element */\n valueElement?: React.ReactNode;\n /** Render callback for property value. If specified, `valueElement` is ignored. */\n valueElementRenderer?: () => React.ReactNode;\n /** Multiplier of how much the property is indented to the right */\n indentation?: number;\n}\n\n/**\n * A React component that renders property as label/value pair\n * @public\n */\nexport const PropertyView = (props: PropertyViewProps) => {\n const context = React.useContext(GroupQueryBuilderContext);\n const [isCheckboxLoading, setIsCheckboxLoading] = React.useState(false);\n\n const _validatePropertySelection = () => {\n if (context.currentPropertyList.includes(props.propertyRecord)) {\n return true;\n }\n // Check if all subproperties are selected\n if (!_validateNestedPropertiesSelection(props.propertyRecord)) {\n return false;\n }\n return true;\n };\n\n const _validateNestedPropertiesSelection = (prop: PropertyRecord) => {\n switch (prop.value.valueFormat) {\n case PropertyValueFormat.Primitive:\n if (!context.currentPropertyList.includes(prop)) {\n return false;\n }\n break;\n case PropertyValueFormat.Array:\n if (prop.value.items.length === 0) {\n if (!context.currentPropertyList.includes(prop)) {\n return false;\n }\n }\n break;\n case PropertyValueFormat.Struct:\n for (const subPropName in prop.value.members) {\n if (\n Object.prototype.hasOwnProperty.call(\n prop.value.members,\n subPropName\n )\n ) {\n if (\n !_validateNestedPropertiesSelection(\n prop.value.members[subPropName]\n )\n ) {\n return false;\n }\n }\n }\n }\n return true;\n };\n\n const [isHovered, setIsHovered] = React.useState<boolean>(false);\n const [isPropertySelected, setIsPropertySelected] = React.useState<boolean>(\n _validatePropertySelection()\n );\n\n const _addSelectedProperty = useCallback(\n async (prop: PropertyRecord) => {\n // TODO: roof selected item/category value is an object but format is primitive(needs further exploration)\n if (\n !context.currentPropertyList.includes(prop) &&\n prop.value.valueFormat === PropertyValueFormat.Primitive\n ) {\n\n if (!(await context.queryBuilder.addProperty(prop))) {\n setIsCheckboxLoading(false);\n setIsPropertySelected(false);\n return;\n }\n context.setCurrentPropertyList(\n context.currentPropertyList.concat(prop)\n );\n context.setQuery(context.queryBuilder.buildQueryString());\n }\n },\n [context]\n );\n\n const _addNestedProperties = useCallback(\n (prop: PropertyRecord) => {\n switch (prop.value.valueFormat) {\n case PropertyValueFormat.Primitive:\n void _addSelectedProperty(prop);\n break;\n case PropertyValueFormat.Array:\n if (prop.value.items.length === 0) {\n void _addSelectedProperty(prop);\n }\n break;\n case PropertyValueFormat.Struct:\n for (const subPropName in prop.value.members) {\n if (\n Object.prototype.hasOwnProperty.call(\n prop.value.members,\n subPropName\n )\n ) {\n _addNestedProperties(prop.value.members[subPropName]);\n }\n }\n }\n },\n [_addSelectedProperty]\n );\n\n const _removeSelectedProperty = useCallback(\n async (prop: PropertyRecord): Promise<void> => {\n if (context.currentPropertyList.includes(prop)) {\n context.setCurrentPropertyList(\n context.currentPropertyList.filter((x: PropertyRecord) => x !== prop)\n );\n await context.queryBuilder.removeProperty(prop);\n context.setQuery(context.queryBuilder.buildQueryString());\n }\n },\n [context]\n );\n\n const _removeNestedProperties = useCallback(\n (prop: PropertyRecord) => {\n switch (prop.value.valueFormat) {\n case PropertyValueFormat.Primitive:\n void _removeSelectedProperty(prop);\n break;\n case PropertyValueFormat.Array:\n if (prop.value.items.length === 0) {\n void _removeSelectedProperty(prop);\n }\n break;\n case PropertyValueFormat.Struct:\n for (const subPropName in prop.value.members) {\n if (\n Object.prototype.hasOwnProperty.call(\n prop.value.members,\n subPropName\n )\n ) {\n _removeNestedProperties(prop.value.members[subPropName]);\n }\n }\n }\n },\n [_removeSelectedProperty]\n );\n\n React.useEffect(() => {\n if (props?.propertyRecord) {\n if (isPropertySelected) {\n setIsCheckboxLoading(true);\n _addNestedProperties(props.propertyRecord);\n } else {\n _removeNestedProperties(props.propertyRecord);\n }\n }\n }, [\n _addNestedProperties,\n _removeNestedProperties,\n isPropertySelected,\n props.propertyRecord,\n ]);\n\n React.useEffect(() => {\n if (!context.isRendering)\n setIsCheckboxLoading(false);\n }, [context.isRendering]);\n\n const _onPropertySelectionChanged = () => {\n setIsPropertySelected(!isPropertySelected);\n };\n\n const _onClick = () => {\n if (props.onClick) {\n props.onClick(props.propertyRecord, props.uniqueKey);\n }\n };\n\n const _onMouseEnter = () => {\n if (props.isHoverable) {\n setIsHovered(true);\n }\n };\n\n const _onMouseLeave = () => {\n if (props.isHoverable) {\n setIsHovered(false);\n }\n };\n\n const _onContextMenu = (e: React.MouseEvent) => {\n if (props.onContextMenu) {\n props.onContextMenu(props.propertyRecord, e);\n }\n if (props.onRightClick) {\n props.onRightClick(props.propertyRecord, props.uniqueKey);\n }\n e.preventDefault();\n return false;\n };\n\n const getClassName = (viewProps: PropertyViewProps) => {\n let propertyRecordClassName =\n viewProps.orientation === Orientation.Horizontal\n ? \"components-property-record--horizontal\"\n : \"components-property-record--vertical\";\n if (viewProps.isSelected) {\n propertyRecordClassName += \" components--selected\";\n }\n if (viewProps.onClick) {\n propertyRecordClassName += \" components--clickable\";\n }\n if (viewProps.isHoverable) {\n propertyRecordClassName += \" components--hoverable\";\n }\n return propertyRecordClassName;\n };\n\n const ratio = props.columnRatio ? props.columnRatio : 0.25;\n const needElementSeparator =\n props.orientation === Orientation.Horizontal &&\n !!props.onColumnRatioChanged;\n const needActionButtons = !!props.actionButtonRenderers;\n const columnsStyleProvider = new PropertyGridColumnStyleProvider(\n props.columnInfo\n );\n\n const offset = CommonPropertyRenderer.getLabelOffset(\n props.indentation,\n props.orientation,\n props.width,\n props.columnRatio,\n props.columnInfo?.minLabelWidth,\n );\n\n return (\n <div\n style={columnsStyleProvider.getStyle(\n props.orientation,\n needActionButtons,\n ratio,\n needElementSeparator\n )}\n className={getClassName(props)}\n onClick={_onClick}\n onContextMenu={_onContextMenu}\n onMouseEnter={_onMouseEnter}\n onMouseLeave={_onMouseLeave}\n role='presentation'\n >\n <div className='components-property-record-label'>\n {props.propertyRecord.value.valueFormat ===\n PropertyValueFormat.Primitive && (\n <Checkbox\n style={{ marginLeft: offset }}\n className='components-property-selection-checkbox'\n checked={isPropertySelected}\n onChange={_onPropertySelectionChanged}\n disabled={context.isLoading || context.isRendering || (props.propertyRecord.value.value === undefined)}\n isLoading={isCheckboxLoading}\n />\n )}\n {props.labelElement}\n </div>\n {needElementSeparator ? (\n <ElementSeparator\n movableArea={props.width}\n onRatioChanged={props.onColumnRatioChanged}\n ratio={ratio}\n orientation={props.orientation}\n isResizeHandleHovered={props.isResizeHandleHovered}\n onResizeHandleHoverChanged={props.onResizeHandleHoverChanged}\n isResizeHandleBeingDragged={props.isResizeHandleBeingDragged}\n onResizeHandleDragChanged={props.onResizeHandleDragChanged}\n />\n ) : undefined}\n {props.propertyRecord.value.valueFormat ===\n PropertyValueFormat.Primitive ? (\n <div className='components-property-record-value'>\n <span>\n {props.valueElementRenderer\n ? props.valueElementRenderer()\n : props.valueElement}\n </span>\n </div>\n ) : undefined}\n {props.actionButtonRenderers ? (\n <ActionButtonList\n orientation={props.orientation}\n property={props.propertyRecord}\n isPropertyHovered={isHovered}\n actionButtonRenderers={props.actionButtonRenderers}\n />\n ) : undefined}\n </div>\n );\n};\n"]}
|
|
1
|
+
{"version":3,"file":"PropertyView.js","sourceRoot":"","sources":["../../../../../src/widget/components/property-grid/PropertyView.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA;;;+FAG+F;AAC/F,6CAA+B;AAE/B,0DAA4D;AAC5D,kDAAkE;AAClE,8DAA2D;AAE3D,+BAA6B;AAE7B,0EAAuE;AACvE,iCAAoC;AACpC,mIAA4I;AAC5I,wDAAgD;AAChD,yIAAsI;AAgBtI;;;GAGG;AACI,MAAM,YAAY,GAAG,CAAC,KAAwB,EAAE,EAAE;;IACvD,MAAM,OAAO,GAAG,KAAK,CAAC,UAAU,CAAC,mDAAwB,CAAC,CAAC;IAC3D,MAAM,CAAC,iBAAiB,EAAE,oBAAoB,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IAExE,MAAM,0BAA0B,GAAG,GAAG,EAAE;QACtC,IAAI,OAAO,CAAC,mBAAmB,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,EAAE;YAC9D,OAAO,IAAI,CAAC;SACb;QACD,0CAA0C;QAC1C,IAAI,CAAC,kCAAkC,CAAC,KAAK,CAAC,cAAc,CAAC,EAAE;YAC7D,OAAO,KAAK,CAAC;SACd;QACD,OAAO,IAAI,CAAC;IACd,CAAC,CAAC;IAEF,MAAM,kCAAkC,GAAG,CAAC,IAAoB,EAAE,EAAE;QAClE,QAAQ,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE;YAC9B,KAAK,oCAAmB,CAAC,SAAS;gBAChC,IAAI,CAAC,OAAO,CAAC,mBAAmB,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE;oBAC/C,OAAO,KAAK,CAAC;iBACd;gBACD,MAAM;YACR,KAAK,oCAAmB,CAAC,KA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,CACP,CAAC,CAAC,CAAC,SAAS;QACd,KAAK,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAC7B,oBAAC,mCAAgB,IACf,WAAW,EAAE,KAAK,CAAC,WAAW,EAC9B,QAAQ,EAAE,KAAK,CAAC,cAAc,EAC9B,iBAAiB,EAAE,SAAS,EAC5B,qBAAqB,EAAE,KAAK,CAAC,qBAAqB,GAClD,CACH,CAAC,CAAC,CAAC,SAAS,CACT,CACP,CAAC;AACJ,CAAC,CAAC;AAxSW,QAAA,YAAY,gBAwSvB","sourcesContent":["/*---------------------------------------------------------------------------------------------\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*--------------------------------------------------------------------------------------------*/\nimport * as React from \"react\";\nimport type { PropertyRecord } from \"@itwin/appui-abstract\";\nimport { PropertyValueFormat } from \"@itwin/appui-abstract\";\nimport { ElementSeparator, Orientation } from \"@itwin/core-react\";\nimport { ActionButtonList } from \"@itwin/components-react\";\n\nimport \"./PropertyView.scss\";\nimport type { SharedRendererProps } from \"./PropertyRender\";\nimport { GroupQueryBuilderContext } from \"../GroupQueryBuilderContext\";\nimport { useCallback } from \"react\";\nimport { PropertyGridColumnStyleProvider } from \"@itwin/components-react/lib/cjs/components-react/properties/renderers/PropertyGridColumns\";\nimport { Checkbox } from \"@itwin/itwinui-react\";\nimport { CommonPropertyRenderer } from \"@itwin/components-react/lib/cjs/components-react/properties/renderers/CommonPropertyRenderer\";\n\n/** Properties of [[PropertyView]] React component\n * @public\n */\nexport interface PropertyViewProps extends SharedRendererProps {\n /** Property label as a React element */\n labelElement: React.ReactNode;\n /** Property value as a React element */\n valueElement?: React.ReactNode;\n /** Render callback for property value. If specified, `valueElement` is ignored. */\n valueElementRenderer?: () => React.ReactNode;\n /** Multiplier of how much the property is indented to the right */\n indentation?: number;\n}\n\n/**\n * A React component that renders property as label/value pair\n * @public\n */\nexport const PropertyView = (props: PropertyViewProps) => {\n const context = React.useContext(GroupQueryBuilderContext);\n const [isCheckboxLoading, setIsCheckboxLoading] = React.useState(false);\n\n const _validatePropertySelection = () => {\n if (context.currentPropertyList.includes(props.propertyRecord)) {\n return true;\n }\n // Check if all subproperties are selected\n if (!_validateNestedPropertiesSelection(props.propertyRecord)) {\n return false;\n }\n return true;\n };\n\n const _validateNestedPropertiesSelection = (prop: PropertyRecord) => {\n switch (prop.value.valueFormat) {\n case PropertyValueFormat.Primitive:\n if (!context.currentPropertyList.includes(prop)) {\n return false;\n }\n break;\n case PropertyValueFormat.Array:\n if (prop.value.items.length === 0) {\n if (!context.currentPropertyList.includes(prop)) {\n return false;\n }\n }\n break;\n case PropertyValueFormat.Struct:\n for (const subPropName in prop.value.members) {\n if (\n Object.prototype.hasOwnProperty.call(\n prop.value.members,\n subPropName\n )\n ) {\n if (\n !_validateNestedPropertiesSelection(\n prop.value.members[subPropName]\n )\n ) {\n return false;\n }\n }\n }\n }\n return true;\n };\n\n const [isHovered, setIsHovered] = React.useState<boolean>(false);\n const [isPropertySelected, setIsPropertySelected] = React.useState<boolean>(\n _validatePropertySelection()\n );\n\n const _addSelectedProperty = useCallback(\n async (prop: PropertyRecord) => {\n // TODO: roof selected item/category value is an object but format is primitive(needs further exploration)\n if (\n !context.currentPropertyList.includes(prop) &&\n prop.value.valueFormat === PropertyValueFormat.Primitive\n ) {\n\n if (!(await context.queryBuilder.addProperty(prop))) {\n setIsCheckboxLoading(false);\n setIsPropertySelected(false);\n return;\n }\n context.setCurrentPropertyList(\n context.currentPropertyList.concat(prop)\n );\n context.setQuery(context.queryBuilder.buildQueryString());\n }\n },\n [context]\n );\n\n const _addNestedProperties = useCallback(\n (prop: PropertyRecord) => {\n switch (prop.value.valueFormat) {\n case PropertyValueFormat.Primitive:\n void _addSelectedProperty(prop);\n break;\n case PropertyValueFormat.Array:\n if (prop.value.items.length === 0) {\n void _addSelectedProperty(prop);\n }\n break;\n case PropertyValueFormat.Struct:\n for (const subPropName in prop.value.members) {\n if (\n Object.prototype.hasOwnProperty.call(\n prop.value.members,\n subPropName\n )\n ) {\n _addNestedProperties(prop.value.members[subPropName]);\n }\n }\n }\n },\n [_addSelectedProperty]\n );\n\n const _removeSelectedProperty = useCallback(\n async (prop: PropertyRecord): Promise<void> => {\n if (context.currentPropertyList.includes(prop)) {\n context.setCurrentPropertyList(\n context.currentPropertyList.filter((x: PropertyRecord) => x !== prop)\n );\n await context.queryBuilder.removeProperty(prop);\n context.setQuery(context.queryBuilder.buildQueryString());\n }\n },\n [context]\n );\n\n const _removeNestedProperties = useCallback(\n (prop: PropertyRecord) => {\n switch (prop.value.valueFormat) {\n case PropertyValueFormat.Primitive:\n void _removeSelectedProperty(prop);\n break;\n case PropertyValueFormat.Array:\n if (prop.value.items.length === 0) {\n void _removeSelectedProperty(prop);\n }\n break;\n case PropertyValueFormat.Struct:\n for (const subPropName in prop.value.members) {\n if (\n Object.prototype.hasOwnProperty.call(\n prop.value.members,\n subPropName\n )\n ) {\n _removeNestedProperties(prop.value.members[subPropName]);\n }\n }\n }\n },\n [_removeSelectedProperty]\n );\n\n React.useEffect(() => {\n if (props?.propertyRecord) {\n if (isPropertySelected) {\n if (context.isRendering) {\n setIsCheckboxLoading(true);\n }\n _addNestedProperties(props.propertyRecord);\n } else {\n _removeNestedProperties(props.propertyRecord);\n }\n }\n }, [\n _addNestedProperties,\n _removeNestedProperties,\n isPropertySelected,\n props.propertyRecord,\n context.isRendering,\n ]);\n\n React.useEffect(() => {\n if (!context.isRendering)\n setIsCheckboxLoading(false);\n }, [context.isRendering]);\n\n const _onPropertySelectionChanged = () => {\n setIsPropertySelected(!isPropertySelected);\n };\n\n const _onClick = () => {\n if (props.onClick) {\n props.onClick(props.propertyRecord, props.uniqueKey);\n }\n };\n\n const _onMouseEnter = () => {\n if (props.isHoverable) {\n setIsHovered(true);\n }\n };\n\n const _onMouseLeave = () => {\n if (props.isHoverable) {\n setIsHovered(false);\n }\n };\n\n const _onContextMenu = (e: React.MouseEvent) => {\n if (props.onContextMenu) {\n props.onContextMenu(props.propertyRecord, e);\n }\n if (props.onRightClick) {\n props.onRightClick(props.propertyRecord, props.uniqueKey);\n }\n e.preventDefault();\n return false;\n };\n\n const getClassName = (viewProps: PropertyViewProps) => {\n let propertyRecordClassName =\n viewProps.orientation === Orientation.Horizontal\n ? \"components-property-record--horizontal\"\n : \"components-property-record--vertical\";\n if (viewProps.isSelected) {\n propertyRecordClassName += \" components--selected\";\n }\n if (viewProps.onClick) {\n propertyRecordClassName += \" components--clickable\";\n }\n if (viewProps.isHoverable) {\n propertyRecordClassName += \" components--hoverable\";\n }\n return propertyRecordClassName;\n };\n\n const ratio = props.columnRatio ? props.columnRatio : 0.25;\n const needElementSeparator =\n props.orientation === Orientation.Horizontal &&\n !!props.onColumnRatioChanged;\n const needActionButtons = !!props.actionButtonRenderers;\n const columnsStyleProvider = new PropertyGridColumnStyleProvider(\n props.columnInfo\n );\n\n const offset = CommonPropertyRenderer.getLabelOffset(\n props.indentation,\n props.orientation,\n props.width,\n props.columnRatio,\n props.columnInfo?.minLabelWidth,\n );\n\n return (\n <div\n style={columnsStyleProvider.getStyle(\n props.orientation,\n needActionButtons,\n ratio,\n needElementSeparator\n )}\n className={getClassName(props)}\n onClick={_onClick}\n onContextMenu={_onContextMenu}\n onMouseEnter={_onMouseEnter}\n onMouseLeave={_onMouseLeave}\n role='presentation'\n >\n <div className='components-property-record-label'>\n {props.propertyRecord.value.valueFormat ===\n PropertyValueFormat.Primitive && (\n <Checkbox\n style={{ marginLeft: offset }}\n className='components-property-selection-checkbox'\n checked={isPropertySelected}\n onChange={_onPropertySelectionChanged}\n disabled={context.isLoading || context.isRendering || (props.propertyRecord.value.value === undefined)}\n isLoading={isCheckboxLoading}\n />\n )}\n {props.labelElement}\n </div>\n {needElementSeparator ? (\n <ElementSeparator\n movableArea={props.width}\n onRatioChanged={props.onColumnRatioChanged}\n ratio={ratio}\n orientation={props.orientation}\n isResizeHandleHovered={props.isResizeHandleHovered}\n onResizeHandleHoverChanged={props.onResizeHandleHoverChanged}\n isResizeHandleBeingDragged={props.isResizeHandleBeingDragged}\n onResizeHandleDragChanged={props.onResizeHandleDragChanged}\n />\n ) : undefined}\n {props.propertyRecord.value.valueFormat ===\n PropertyValueFormat.Primitive ? (\n <div className='components-property-record-value'>\n <span>\n {props.valueElementRenderer\n ? props.valueElementRenderer()\n : props.valueElement}\n </span>\n </div>\n ) : undefined}\n {props.actionButtonRenderers ? (\n <ActionButtonList\n orientation={props.orientation}\n property={props.propertyRecord}\n isPropertyHovered={isHovered}\n actionButtonRenderers={props.actionButtonRenderers}\n />\n ) : undefined}\n </div>\n );\n};\n"]}
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import type { AbstractWidgetProps, UiItemsProvider } from "@itwin/appui-abstract";
|
|
2
2
|
import { AbstractZoneLocation, StagePanelLocation, StagePanelSection } from "@itwin/appui-abstract";
|
|
3
|
+
import type { AccessToken } from "@itwin/core-bentley";
|
|
3
4
|
export declare class GroupingMappingProvider implements UiItemsProvider {
|
|
4
5
|
readonly id = "GroupingMappingProvider";
|
|
6
|
+
private readonly _accessToken?;
|
|
7
|
+
private readonly _prefix?;
|
|
8
|
+
constructor(accessToken?: AccessToken, prefix?: "" | "dev" | "qa");
|
|
5
9
|
provideWidgets(_stageId: string, stageUsage: string, location: StagePanelLocation, section?: StagePanelSection, zonelocation?: AbstractZoneLocation): ReadonlyArray<AbstractWidgetProps>;
|
|
6
10
|
}
|
|
7
11
|
//# sourceMappingURL=GroupingMappingWidget.d.ts.map
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { AbstractZoneLocation, StagePanelLocation, StagePanelSection, StageUsage, } from "@itwin/appui-abstract";
|
|
2
|
-
import
|
|
2
|
+
import React from "react";
|
|
3
3
|
import GroupingMapping from "./components/GroupingMapping";
|
|
4
4
|
export class GroupingMappingProvider {
|
|
5
|
-
constructor() {
|
|
5
|
+
constructor(accessToken, prefix) {
|
|
6
6
|
this.id = "GroupingMappingProvider";
|
|
7
|
+
this._accessToken = accessToken;
|
|
8
|
+
this._prefix = prefix;
|
|
7
9
|
}
|
|
8
10
|
provideWidgets(_stageId, stageUsage, location, section, zonelocation) {
|
|
9
11
|
const widgets = [];
|
|
@@ -14,8 +16,8 @@ export class GroupingMappingProvider {
|
|
|
14
16
|
const GroupingMappingWidget = {
|
|
15
17
|
id: "GroupingMappingWidget",
|
|
16
18
|
label: "Grouping & Mapping",
|
|
17
|
-
getWidgetContent() {
|
|
18
|
-
return React.createElement(GroupingMapping,
|
|
19
|
+
getWidgetContent: () => {
|
|
20
|
+
return React.createElement(GroupingMapping, { accessToken: this._accessToken, prefix: this._prefix });
|
|
19
21
|
},
|
|
20
22
|
};
|
|
21
23
|
widgets.push(GroupingMappingWidget);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GroupingMappingWidget.js","sourceRoot":"","sources":["../../../src/widget/GroupingMappingWidget.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"GroupingMappingWidget.js","sourceRoot":"","sources":["../../../src/widget/GroupingMappingWidget.tsx"],"names":[],"mappings":"AAQA,OAAO,EACL,oBAAoB,EACpB,kBAAkB,EAClB,iBAAiB,EACjB,UAAU,GACX,MAAM,uBAAuB,CAAC;AAE/B,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,eAAe,MAAM,8BAA8B,CAAC;AAE3D,MAAM,OAAO,uBAAuB;IAMlC,YAAY,WAAyB,EAAE,MAA0B;QALjD,OAAE,GAAG,yBAAyB,CAAC;QAM7C,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC;QAChC,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IACxB,CAAC;IAEM,cAAc,CACnB,QAAgB,EAChB,UAAkB,EAClB,QAA4B,EAC5B,OAA2B,EAC3B,YAAmC;QAEnC,MAAM,OAAO,GAA0B,EAAE,CAAC;QAC1C,IACE,CAAC,QAAQ,KAAK,kBAAkB,CAAC,IAAI;YACnC,OAAO,KAAK,iBAAiB,CAAC,KAAK;YACnC,UAAU,KAAK,UAAU,CAAC,OAAO,CAAC;YACpC,YAAY,KAAK,oBAAoB,CAAC,UAAU,EAChD;YACA,MAAM,qBAAqB,GAAwB;gBACjD,EAAE,EAAE,uBAAuB;gBAC3B,KAAK,EAAE,oBAAoB;gBAC3B,gBAAgB,EAAE,GAAG,EAAE;oBACrB,OAAO,oBAAC,eAAe,IAAC,WAAW,EAAE,IAAI,CAAC,YAAY,EAAE,MAAM,EAAE,IAAI,CAAC,OAAO,GAAI,CAAC;gBACnF,CAAC;aACF,CAAC;YAEF,OAAO,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;SACrC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\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*--------------------------------------------------------------------------------------------*/\nimport type {\n AbstractWidgetProps,\n UiItemsProvider,\n} from \"@itwin/appui-abstract\";\nimport {\n AbstractZoneLocation,\n StagePanelLocation,\n StagePanelSection,\n StageUsage,\n} from \"@itwin/appui-abstract\";\nimport type { AccessToken } from \"@itwin/core-bentley\";\nimport React from \"react\";\nimport GroupingMapping from \"./components/GroupingMapping\";\n\nexport class GroupingMappingProvider implements UiItemsProvider {\n public readonly id = \"GroupingMappingProvider\";\n\n private readonly _accessToken?: AccessToken;\n private readonly _prefix?: \"\" | \"dev\" | \"qa\";\n\n constructor(accessToken?: AccessToken, prefix?: \"\" | \"dev\" | \"qa\") {\n this._accessToken = accessToken;\n this._prefix = prefix;\n }\n\n public provideWidgets(\n _stageId: string,\n stageUsage: string,\n location: StagePanelLocation,\n section?: StagePanelSection,\n zonelocation?: AbstractZoneLocation\n ): ReadonlyArray<AbstractWidgetProps> {\n const widgets: AbstractWidgetProps[] = [];\n if (\n (location === StagePanelLocation.Left &&\n section === StagePanelSection.Start &&\n stageUsage === StageUsage.General) ||\n zonelocation === AbstractZoneLocation.CenterLeft\n ) {\n const GroupingMappingWidget: AbstractWidgetProps = {\n id: \"GroupingMappingWidget\",\n label: \"Grouping & Mapping\",\n getWidgetContent: () => {\n return <GroupingMapping accessToken={this._accessToken} prefix={this._prefix} />;\n },\n };\n\n widgets.push(GroupingMappingWidget);\n }\n\n return widgets;\n }\n}\n"]}
|
|
@@ -3,9 +3,10 @@ import "./ActionPanel.scss";
|
|
|
3
3
|
export interface ActionPanelProps {
|
|
4
4
|
onSave: () => void;
|
|
5
5
|
onCancel: () => void;
|
|
6
|
-
|
|
6
|
+
isCancelDisabled?: boolean;
|
|
7
|
+
isSavingDisabled?: boolean;
|
|
7
8
|
isLoading?: boolean;
|
|
8
9
|
}
|
|
9
|
-
declare const ActionPanel: ({ onSave, onCancel,
|
|
10
|
+
declare const ActionPanel: ({ onSave, onCancel, isCancelDisabled, isSavingDisabled, isLoading, }: ActionPanelProps) => JSX.Element;
|
|
10
11
|
export default ActionPanel;
|
|
11
12
|
//# sourceMappingURL=ActionPanel.d.ts.map
|
|
@@ -6,13 +6,13 @@ import { Button } from "@itwin/itwinui-react";
|
|
|
6
6
|
import * as React from "react";
|
|
7
7
|
import "./ActionPanel.scss";
|
|
8
8
|
import { LoadingSpinner } from "./utils";
|
|
9
|
-
const ActionPanel = ({ onSave, onCancel,
|
|
9
|
+
const ActionPanel = ({ onSave, onCancel, isCancelDisabled = false, isSavingDisabled = false, isLoading = false, }) => {
|
|
10
10
|
return (React.createElement("div", { id: 'action', className: 'action-panel-container' },
|
|
11
11
|
React.createElement("div", { className: 'action-panel' },
|
|
12
12
|
isLoading &&
|
|
13
13
|
React.createElement(LoadingSpinner, null),
|
|
14
|
-
React.createElement(Button, { disabled:
|
|
15
|
-
React.createElement(Button, { styleType: 'default', type: 'button', id: 'cancel', onClick: onCancel, disabled:
|
|
14
|
+
React.createElement(Button, { disabled: isSavingDisabled || isLoading, styleType: 'high-visibility', id: 'save-app', onClick: onSave }, "Save"),
|
|
15
|
+
React.createElement(Button, { styleType: 'default', type: 'button', id: 'cancel', onClick: onCancel, disabled: isCancelDisabled || isLoading }, "Cancel"))));
|
|
16
16
|
};
|
|
17
17
|
export default ActionPanel;
|
|
18
18
|
//# sourceMappingURL=ActionPanel.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActionPanel.js","sourceRoot":"","sources":["../../../../src/widget/components/ActionPanel.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,oBAAoB,CAAC;AAC5B,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"ActionPanel.js","sourceRoot":"","sources":["../../../../src/widget/components/ActionPanel.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,oBAAoB,CAAC;AAC5B,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAUzC,MAAM,WAAW,GAAG,CAAC,EACnB,MAAM,EACN,QAAQ,EACR,gBAAgB,GAAG,KAAK,EACxB,gBAAgB,GAAG,KAAK,EACxB,SAAS,GAAG,KAAK,GACA,EAAe,EAAE;IAClC,OAAO,CACL,6BAAK,EAAE,EAAC,QAAQ,EAAC,SAAS,EAAC,wBAAwB;QACjD,6BAAK,SAAS,EAAC,cAAc;YAC1B,SAAS;gBACR,oBAAC,cAAc,OAAG;YAEpB,oBAAC,MAAM,IACL,QAAQ,EAAE,gBAAgB,IAAI,SAAS,EACvC,SAAS,EAAC,iBAAiB,EAC3B,EAAE,EAAC,UAAU,EACb,OAAO,EAAE,MAAM,WAGR;YACT,oBAAC,MAAM,IACL,SAAS,EAAC,SAAS,EACnB,IAAI,EAAC,QAAQ,EACb,EAAE,EAAC,QAAQ,EACX,OAAO,EAAE,QAAQ,EACjB,QAAQ,EAAE,gBAAgB,IAAI,SAAS,aAGhC,CACL,CACF,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,WAAW,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\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*--------------------------------------------------------------------------------------------*/\nimport { Button } from \"@itwin/itwinui-react\";\nimport * as React from \"react\";\nimport \"./ActionPanel.scss\";\nimport { LoadingSpinner } from \"./utils\";\n\nexport interface ActionPanelProps {\n onSave: () => void;\n onCancel: () => void;\n isCancelDisabled?: boolean;\n isSavingDisabled?: boolean;\n isLoading?: boolean;\n}\n\nconst ActionPanel = ({\n onSave,\n onCancel,\n isCancelDisabled = false,\n isSavingDisabled = false,\n isLoading = false,\n}: ActionPanelProps): JSX.Element => {\n return (\n <div id='action' className='action-panel-container'>\n <div className='action-panel'>\n {isLoading &&\n <LoadingSpinner />\n }\n <Button\n disabled={isSavingDisabled || isLoading}\n styleType='high-visibility'\n id='save-app'\n onClick={onSave}\n >\n Save\n </Button>\n <Button\n styleType='default'\n type='button'\n id='cancel'\n onClick={onCancel}\n disabled={isCancelDisabled || isLoading}\n >\n Cancel\n </Button>\n </div>\n </div>\n );\n};\n\nexport default ActionPanel;\n"]}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import "./CalculatedPropertyAction.scss";
|
|
3
|
-
import type {
|
|
3
|
+
import type { CalculatedPropertyType } from "./CalculatedPropertyTable";
|
|
4
4
|
interface CalculatedPropertyActionProps {
|
|
5
5
|
iModelId: string;
|
|
6
6
|
mappingId: string;
|
|
7
7
|
groupId: string;
|
|
8
|
-
property?:
|
|
8
|
+
property?: CalculatedPropertyType;
|
|
9
9
|
ids: string[];
|
|
10
10
|
returnFn: () => Promise<void>;
|
|
11
11
|
}
|
|
@@ -4,16 +4,18 @@
|
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
5
|
import { IModelApp } from "@itwin/core-frontend";
|
|
6
6
|
import { Fieldset, LabeledInput, LabeledSelect, MenuItem, Small, } from "@itwin/itwinui-react";
|
|
7
|
-
import React, { useEffect, useState } from "react";
|
|
8
|
-
import { reportingClientApi } from "../../api/reportingClient";
|
|
7
|
+
import React, { useContext, useEffect, useState } from "react";
|
|
9
8
|
import ActionPanel from "./ActionPanel";
|
|
10
9
|
import { BboxDimension, BboxDimensionsDecorator, } from "../../decorators/BboxDimensionsDecorator";
|
|
11
10
|
import useValidator, { NAME_REQUIREMENTS } from "../hooks/useValidator";
|
|
12
11
|
import { handleError, WidgetHeader } from "./utils";
|
|
13
12
|
import { visualizeElements, zoomToElements } from "./viewerUtils";
|
|
14
13
|
import "./CalculatedPropertyAction.scss";
|
|
14
|
+
import { ReportingClient } from "@itwin/insights-client";
|
|
15
|
+
import { ApiContext } from "./GroupingMapping";
|
|
15
16
|
const CalculatedPropertyAction = ({ iModelId, mappingId, groupId, property, ids, returnFn, }) => {
|
|
16
17
|
var _a, _b, _c;
|
|
18
|
+
const apiContext = useContext(ApiContext);
|
|
17
19
|
const [propertyName, setPropertyName] = useState((_a = property === null || property === void 0 ? void 0 : property.propertyName) !== null && _a !== void 0 ? _a : "");
|
|
18
20
|
const [type, setType] = useState((_b = property === null || property === void 0 ? void 0 : property.type) !== null && _b !== void 0 ? _b : "");
|
|
19
21
|
const [bboxDecorator, setBboxDecorator] = useState();
|
|
@@ -62,13 +64,16 @@ const CalculatedPropertyAction = ({ iModelId, mappingId, groupId, property, ids,
|
|
|
62
64
|
}
|
|
63
65
|
try {
|
|
64
66
|
setIsLoading(true);
|
|
65
|
-
const
|
|
66
|
-
propertyName,
|
|
67
|
-
type,
|
|
68
|
-
};
|
|
67
|
+
const reportingClientApi = new ReportingClient(apiContext.prefix);
|
|
69
68
|
property
|
|
70
|
-
? await reportingClientApi.updateCalculatedProperty(iModelId, mappingId, groupId, (_a = property.id) !== null && _a !== void 0 ? _a : "",
|
|
71
|
-
|
|
69
|
+
? await reportingClientApi.updateCalculatedProperty(apiContext.accessToken, iModelId, mappingId, groupId, (_a = property.id) !== null && _a !== void 0 ? _a : "", {
|
|
70
|
+
propertyName,
|
|
71
|
+
type,
|
|
72
|
+
})
|
|
73
|
+
: await reportingClientApi.createCalculatedProperty(apiContext.accessToken, iModelId, mappingId, groupId, {
|
|
74
|
+
propertyName,
|
|
75
|
+
type,
|
|
76
|
+
});
|
|
72
77
|
await returnFn();
|
|
73
78
|
}
|
|
74
79
|
catch (error) {
|
|
@@ -131,12 +136,12 @@ const CalculatedPropertyAction = ({ iModelId, mappingId, groupId, property, ids,
|
|
|
131
136
|
label: "Shortest Face Diagonal Length",
|
|
132
137
|
},
|
|
133
138
|
], value: type, onChange: setType, itemRenderer: (option) => (React.createElement(MenuItem, null,
|
|
134
|
-
React.createElement("div", { className: 'menu-item' },
|
|
139
|
+
React.createElement("div", { className: 'gr-cp-menu-item' },
|
|
135
140
|
React.createElement("div", null, option.label),
|
|
136
141
|
getSpatialData(option.value)))), selectedItemRenderer: (option) => (React.createElement("div", { className: 'select-item' },
|
|
137
142
|
React.createElement("div", null, option.label),
|
|
138
143
|
getSpatialData(option.value))), onShow: () => { }, onHide: () => { } }))),
|
|
139
|
-
React.createElement(ActionPanel, { onSave: onSave, onCancel: returnFn,
|
|
144
|
+
React.createElement(ActionPanel, { onSave: onSave, onCancel: returnFn, isSavingDisabled: !(type && propertyName), isLoading: isLoading })));
|
|
140
145
|
};
|
|
141
146
|
export default CalculatedPropertyAction;
|
|
142
147
|
//# sourceMappingURL=CalculatedPropertyAction.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CalculatedPropertyAction.js","sourceRoot":"","sources":["../../../../src/widget/components/CalculatedPropertyAction.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,EAAE,SAAS,EAAE,MAAM,s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ACjC,SAAS,EAAE,SAAS,GACpB,CACD,CACJ,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,wBAAwB,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\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*--------------------------------------------------------------------------------------------*/\nimport { IModelApp } from \"@itwin/core-frontend\";\nimport type {\n SelectOption,\n} from \"@itwin/itwinui-react\";\nimport {\n Fieldset,\n LabeledInput,\n LabeledSelect,\n MenuItem,\n Small,\n} from \"@itwin/itwinui-react\";\nimport React, { useEffect, useState } from \"react\";\nimport type { CalculatedPropertyCreateReportingAPI } from \"../../api/generated/api\";\nimport { reportingClientApi } from \"../../api/reportingClient\";\nimport ActionPanel from \"./ActionPanel\";\nimport {\n BboxDimension,\n BboxDimensionsDecorator,\n} from \"../../decorators/BboxDimensionsDecorator\";\nimport useValidator, { NAME_REQUIREMENTS } from \"../hooks/useValidator\";\nimport { handleError, WidgetHeader } from \"./utils\";\nimport { visualizeElements, zoomToElements } from \"./viewerUtils\";\nimport \"./CalculatedPropertyAction.scss\";\nimport type { CalculatedProperty } from \"./CalculatedPropertyTable\";\n\ninterface CalculatedPropertyActionProps {\n iModelId: string;\n mappingId: string;\n groupId: string;\n property?: CalculatedProperty;\n ids: string[];\n returnFn: () => Promise<void>;\n}\n\nconst CalculatedPropertyAction = ({\n iModelId,\n mappingId,\n groupId,\n property,\n ids,\n returnFn,\n}: CalculatedPropertyActionProps) => {\n const [propertyName, setPropertyName] = useState<string>(\n property?.propertyName ?? \"\",\n );\n const [type, setType] = useState<string>(property?.type ?? \"\");\n const [bboxDecorator, setBboxDecorator] = useState<\n BboxDimensionsDecorator | undefined\n >();\n const [isLoading, setIsLoading] = useState<boolean>(false);\n const [inferredSpatialData, setInferredSpatialData] = useState<\n Map<BboxDimension, number> | undefined\n >();\n const [validator, showValidationMessage] = useValidator();\n\n useEffect(() => {\n const decorator = new BboxDimensionsDecorator();\n IModelApp.viewManager.addDecorator(decorator);\n setBboxDecorator(decorator);\n return () => {\n IModelApp.viewManager.dropDecorator(decorator);\n };\n }, []);\n\n useEffect(() => {\n if (ids.length === 0) {\n return;\n }\n visualizeElements([ids[0]], \"red\");\n void zoomToElements([ids[0]]);\n }, [ids]);\n\n useEffect(() => {\n if (ids.length === 0) {\n return;\n }\n const setContext = async () => {\n if (bboxDecorator) {\n await bboxDecorator.setContext(ids[0]);\n setInferredSpatialData(bboxDecorator.getInferredSpatialData());\n }\n };\n void setContext();\n }, [bboxDecorator, ids]);\n\n useEffect(() => {\n if (bboxDecorator && type && inferredSpatialData) {\n inferredSpatialData.has(BboxDimension[type as keyof typeof BboxDimension])\n ? bboxDecorator.drawContext(\n BboxDimension[type as keyof typeof BboxDimension],\n )\n : bboxDecorator.clearContext();\n }\n }, [bboxDecorator, inferredSpatialData, type]);\n\n const onSave = async () => {\n if (!validator.allValid()) {\n showValidationMessage(true);\n return;\n }\n try {\n setIsLoading(true);\n\n const calculatedProperty: CalculatedPropertyCreateReportingAPI = {\n propertyName,\n type,\n };\n\n property\n ? await reportingClientApi.updateCalculatedProperty(\n iModelId,\n mappingId,\n groupId,\n property.id ?? \"\",\n calculatedProperty,\n )\n : await reportingClientApi.createCalculatedProperty(\n iModelId,\n mappingId,\n groupId,\n calculatedProperty,\n );\n await returnFn();\n } catch (error: any) {\n handleError(error.status);\n setIsLoading(false);\n }\n };\n\n const getSpatialData = (value: string) =>\n inferredSpatialData?.has(\n BboxDimension[value as keyof typeof BboxDimension],\n ) && (\n <div>\n {`${inferredSpatialData\n ?.get(BboxDimension[value as keyof typeof BboxDimension])\n ?.toPrecision(4)}m`}\n </div>\n );\n\n return (\n <>\n <WidgetHeader\n title={\n property\n ? `${property?.propertyName ?? \"\"}`\n : \"Create Calculated Property\"\n }\n returnFn={returnFn}\n />\n <div className='calculated-properties-action-container'>\n <Fieldset legend='Calculated Property Details' className='details-form'>\n <Small className='field-legend'>\n Asterisk * indicates mandatory fields.\n </Small>\n <LabeledInput\n value={propertyName}\n required\n name='name'\n label='Name'\n onChange={(event) => {\n setPropertyName(event.target.value);\n validator.showMessageFor(\"name\");\n }}\n message={validator.message(\"name\", propertyName, NAME_REQUIREMENTS)}\n status={\n validator.message(\"name\", propertyName, NAME_REQUIREMENTS)\n ? \"negative\"\n : undefined\n }\n onBlur={() => {\n validator.showMessageFor(\"name\");\n }}\n onBlurCapture={(event) => {\n setPropertyName(event.target.value);\n validator.showMessageFor(\"name\");\n }}\n />\n <LabeledSelect<string>\n label='Quantity Type'\n required\n options={[\n { value: \"Length\", label: \"Length\" },\n { value: \"Area\", label: \"Area\" },\n { value: \"Volume\", label: \"Volume\" },\n {\n value: \"BoundingBoxLongestEdgeLength\",\n label: \"Longest Edge Length\",\n },\n {\n value: \"BoundingBoxIntermediateEdgeLength\",\n label: \"Intermediate Edge Length\",\n },\n {\n value: \"BoundingBoxShortestEdgeLength\",\n label: \"Shortest Edge Length\",\n },\n {\n value: \"BoundingBoxDiagonalLength\",\n label: \"Diagonal Length\",\n },\n {\n value: \"BoundingBoxLongestFaceDiagonalLength\",\n label: \"Longest Face Diagonal Length\",\n },\n {\n value: \"BoundingBoxIntermediateFaceDiagonalLength\",\n label: \"Intermediate Face Diagonal Length\",\n },\n {\n value: \"BoundingBoxShortestFaceDiagonalLength\",\n label: \"Shortest Face Diagonal Length\",\n },\n ]}\n value={type}\n onChange={setType}\n itemRenderer={(option: SelectOption<string>) => (\n <MenuItem>\n <div className='menu-item'>\n <div>{option.label}</div>\n {getSpatialData(option.value)}\n </div>\n </MenuItem>\n )}\n selectedItemRenderer={(option: SelectOption<string>) => (\n <div className='select-item'>\n <div>{option.label}</div>\n {getSpatialData(option.value)}\n </div>\n )}\n onShow={() => { }}\n onHide={() => { }}\n />\n </Fieldset>\n </div>\n <ActionPanel\n onSave={onSave}\n onCancel={returnFn}\n disabled={!(type && propertyName)}\n isLoading={isLoading}\n />\n </>\n );\n};\n\nexport default CalculatedPropertyAction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B,EAAE,CAAC,MAA4B,EAAE,EAAE,CAAC,CACtD,6BAAK,SAAS,EAAC,aAAa;wBAC1B,iCAAM,MAAM,CAAC,KAAK,CAAO;wBACxB,cAAc,CAAC,MAAM,CAAC,KAAK,CAAC,CACzB,CACP,EACD,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,EACjB,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,GACjB,CACO,CACP;QACN,oBAAC,WAAW,IACV,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,QAAQ,EAClB,gBAAgB,EAAE,CAAC,CAAC,IAAI,IAAI,YAAY,CAAC,EACzC,SAAS,EAAE,SAAS,GACpB,CACD,CACJ,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,wBAAwB,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\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*--------------------------------------------------------------------------------------------*/\nimport { IModelApp } from \"@itwin/core-frontend\";\nimport type {\n SelectOption,\n} from \"@itwin/itwinui-react\";\nimport {\n Fieldset,\n LabeledInput,\n LabeledSelect,\n MenuItem,\n Small,\n} from \"@itwin/itwinui-react\";\nimport React, { useContext, useEffect, useState } from \"react\";\nimport ActionPanel from \"./ActionPanel\";\nimport {\n BboxDimension,\n BboxDimensionsDecorator,\n} from \"../../decorators/BboxDimensionsDecorator\";\nimport useValidator, { NAME_REQUIREMENTS } from \"../hooks/useValidator\";\nimport { handleError, WidgetHeader } from \"./utils\";\nimport { visualizeElements, zoomToElements } from \"./viewerUtils\";\nimport \"./CalculatedPropertyAction.scss\";\nimport type { CalculatedPropertyType } from \"./CalculatedPropertyTable\";\nimport { ReportingClient } from \"@itwin/insights-client\";\nimport { ApiContext } from \"./GroupingMapping\";\n\ninterface CalculatedPropertyActionProps {\n iModelId: string;\n mappingId: string;\n groupId: string;\n property?: CalculatedPropertyType;\n ids: string[];\n returnFn: () => Promise<void>;\n}\n\nconst CalculatedPropertyAction = ({\n iModelId,\n mappingId,\n groupId,\n property,\n ids,\n returnFn,\n}: CalculatedPropertyActionProps) => {\n const apiContext = useContext(ApiContext);\n const [propertyName, setPropertyName] = useState<string>(\n property?.propertyName ?? \"\",\n );\n const [type, setType] = useState<string>(property?.type ?? \"\");\n const [bboxDecorator, setBboxDecorator] = useState<\n BboxDimensionsDecorator | undefined\n >();\n const [isLoading, setIsLoading] = useState<boolean>(false);\n const [inferredSpatialData, setInferredSpatialData] = useState<\n Map<BboxDimension, number> | undefined\n >();\n const [validator, showValidationMessage] = useValidator();\n\n useEffect(() => {\n const decorator = new BboxDimensionsDecorator();\n IModelApp.viewManager.addDecorator(decorator);\n setBboxDecorator(decorator);\n return () => {\n IModelApp.viewManager.dropDecorator(decorator);\n };\n }, []);\n\n useEffect(() => {\n if (ids.length === 0) {\n return;\n }\n visualizeElements([ids[0]], \"red\");\n void zoomToElements([ids[0]]);\n }, [ids]);\n\n useEffect(() => {\n if (ids.length === 0) {\n return;\n }\n const setContext = async () => {\n if (bboxDecorator) {\n await bboxDecorator.setContext(ids[0]);\n setInferredSpatialData(bboxDecorator.getInferredSpatialData());\n }\n };\n void setContext();\n }, [bboxDecorator, ids]);\n\n useEffect(() => {\n if (bboxDecorator && type && inferredSpatialData) {\n inferredSpatialData.has(BboxDimension[type as keyof typeof BboxDimension])\n ? bboxDecorator.drawContext(\n BboxDimension[type as keyof typeof BboxDimension],\n )\n : bboxDecorator.clearContext();\n }\n }, [bboxDecorator, inferredSpatialData, type]);\n\n const onSave = async () => {\n if (!validator.allValid()) {\n showValidationMessage(true);\n return;\n }\n try {\n setIsLoading(true);\n\n const reportingClientApi = new ReportingClient(apiContext.prefix);\n\n property\n ? await reportingClientApi.updateCalculatedProperty(\n apiContext.accessToken,\n iModelId,\n mappingId,\n groupId,\n property.id ?? \"\",\n {\n propertyName,\n type,\n },\n )\n : await reportingClientApi.createCalculatedProperty(\n apiContext.accessToken,\n iModelId,\n mappingId,\n groupId,\n {\n propertyName,\n type,\n },\n );\n await returnFn();\n } catch (error: any) {\n handleError(error.status);\n setIsLoading(false);\n }\n };\n\n const getSpatialData = (value: string) =>\n inferredSpatialData?.has(\n BboxDimension[value as keyof typeof BboxDimension],\n ) && (\n <div>\n {`${inferredSpatialData\n ?.get(BboxDimension[value as keyof typeof BboxDimension])\n ?.toPrecision(4)}m`}\n </div>\n );\n\n return (\n <>\n <WidgetHeader\n title={\n property\n ? `${property?.propertyName ?? \"\"}`\n : \"Create Calculated Property\"\n }\n returnFn={returnFn}\n />\n <div className='calculated-properties-action-container'>\n <Fieldset legend='Calculated Property Details' className='details-form'>\n <Small className='field-legend'>\n Asterisk * indicates mandatory fields.\n </Small>\n <LabeledInput\n value={propertyName}\n required\n name='name'\n label='Name'\n onChange={(event) => {\n setPropertyName(event.target.value);\n validator.showMessageFor(\"name\");\n }}\n message={validator.message(\"name\", propertyName, NAME_REQUIREMENTS)}\n status={\n validator.message(\"name\", propertyName, NAME_REQUIREMENTS)\n ? \"negative\"\n : undefined\n }\n onBlur={() => {\n validator.showMessageFor(\"name\");\n }}\n onBlurCapture={(event) => {\n setPropertyName(event.target.value);\n validator.showMessageFor(\"name\");\n }}\n />\n <LabeledSelect<string>\n label='Quantity Type'\n required\n options={[\n { value: \"Length\", label: \"Length\" },\n { value: \"Area\", label: \"Area\" },\n { value: \"Volume\", label: \"Volume\" },\n {\n value: \"BoundingBoxLongestEdgeLength\",\n label: \"Longest Edge Length\",\n },\n {\n value: \"BoundingBoxIntermediateEdgeLength\",\n label: \"Intermediate Edge Length\",\n },\n {\n value: \"BoundingBoxShortestEdgeLength\",\n label: \"Shortest Edge Length\",\n },\n {\n value: \"BoundingBoxDiagonalLength\",\n label: \"Diagonal Length\",\n },\n {\n value: \"BoundingBoxLongestFaceDiagonalLength\",\n label: \"Longest Face Diagonal Length\",\n },\n {\n value: \"BoundingBoxIntermediateFaceDiagonalLength\",\n label: \"Intermediate Face Diagonal Length\",\n },\n {\n value: \"BoundingBoxShortestFaceDiagonalLength\",\n label: \"Shortest Face Diagonal Length\",\n },\n ]}\n value={type}\n onChange={setType}\n itemRenderer={(option: SelectOption<string>) => (\n <MenuItem>\n <div className='gr-cp-menu-item'>\n <div>{option.label}</div>\n {getSpatialData(option.value)}\n </div>\n </MenuItem>\n )}\n selectedItemRenderer={(option: SelectOption<string>) => (\n <div className='select-item'>\n <div>{option.label}</div>\n {getSpatialData(option.value)}\n </div>\n )}\n onShow={() => { }}\n onHide={() => { }}\n />\n </Fieldset>\n </div>\n <ActionPanel\n onSave={onSave}\n onCancel={returnFn}\n isSavingDisabled={!(type && propertyName)}\n isLoading={isLoading}\n />\n </>\n );\n};\n\nexport default CalculatedPropertyAction;\n"]}
|
|
@@ -13,11 +13,6 @@
|
|
|
13
13
|
flex-direction: column;
|
|
14
14
|
gap: $iui-baseline;
|
|
15
15
|
|
|
16
|
-
.menu-item {
|
|
17
|
-
display: flex;
|
|
18
|
-
justify-content: space-between;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
16
|
.select-item {
|
|
22
17
|
display: flex;
|
|
23
18
|
justify-content: space-between;
|
|
@@ -25,3 +20,8 @@
|
|
|
25
20
|
}
|
|
26
21
|
}
|
|
27
22
|
}
|
|
23
|
+
|
|
24
|
+
.gr-cp-menu-item {
|
|
25
|
+
display: flex;
|
|
26
|
+
justify-content: space-between;
|
|
27
|
+
}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import type { CalculatedPropertyReportingAPI } from "../../api/generated/api";
|
|
3
2
|
import type { CreateTypeFromInterface } from "../utils";
|
|
4
3
|
import { PropertyMenuView } from "./PropertyMenu";
|
|
5
4
|
import type { CellProps } from "react-table";
|
|
6
|
-
|
|
5
|
+
import type { CalculatedProperty } from "@itwin/insights-client";
|
|
6
|
+
export declare type CalculatedPropertyType = CreateTypeFromInterface<CalculatedProperty>;
|
|
7
7
|
interface CalculatedPropertyTableProps {
|
|
8
8
|
iModelId: string;
|
|
9
9
|
mappingId: string;
|
|
10
10
|
groupId: string;
|
|
11
|
-
setSelectedCalculatedProperty: React.Dispatch<React.SetStateAction<CreateTypeFromInterface<
|
|
11
|
+
setSelectedCalculatedProperty: React.Dispatch<React.SetStateAction<CreateTypeFromInterface<CalculatedProperty> | undefined>>;
|
|
12
12
|
setGroupModifyView: React.Dispatch<React.SetStateAction<PropertyMenuView>>;
|
|
13
|
-
onCalculatedPropertyModify: (value: CellProps<
|
|
14
|
-
selectedCalculatedProperty?:
|
|
13
|
+
onCalculatedPropertyModify: (value: CellProps<CalculatedPropertyType>) => void;
|
|
14
|
+
selectedCalculatedProperty?: CalculatedPropertyType;
|
|
15
15
|
}
|
|
16
16
|
declare const CalculatedPropertyTable: ({ iModelId, mappingId, groupId, setSelectedCalculatedProperty, setGroupModifyView, onCalculatedPropertyModify, selectedCalculatedProperty, }: CalculatedPropertyTableProps) => JSX.Element;
|
|
17
17
|
export default CalculatedPropertyTable;
|
|
@@ -4,17 +4,18 @@
|
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
5
|
import { SvgAdd, SvgDelete, SvgEdit, SvgMore, } from "@itwin/itwinui-icons-react";
|
|
6
6
|
import { Button, DropdownMenu, IconButton, MenuItem, Table, } from "@itwin/itwinui-react";
|
|
7
|
-
import React, { useCallback, useEffect, useMemo, useState } from "react";
|
|
8
|
-
import { reportingClientApi } from "../../api/reportingClient";
|
|
7
|
+
import React, { useCallback, useContext, useEffect, useMemo, useState } from "react";
|
|
9
8
|
import { PropertyMenuView } from "./PropertyMenu";
|
|
10
9
|
import DeleteModal from "./DeleteModal";
|
|
11
10
|
import { handleError } from "./utils";
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
import { ReportingClient } from "@itwin/insights-client";
|
|
12
|
+
import { ApiContext } from "./GroupingMapping";
|
|
13
|
+
const fetchCalculatedProperties = async (setCalculatedProperties, iModelId, mappingId, groupId, setIsLoading, apiContext) => {
|
|
14
14
|
try {
|
|
15
15
|
setIsLoading(true);
|
|
16
|
-
const
|
|
17
|
-
|
|
16
|
+
const reportingClientApi = new ReportingClient(apiContext.prefix);
|
|
17
|
+
const calculatedProperties = await reportingClientApi.getCalculatedProperties(apiContext.accessToken, iModelId, mappingId, groupId);
|
|
18
|
+
setCalculatedProperties(calculatedProperties);
|
|
18
19
|
}
|
|
19
20
|
catch (error) {
|
|
20
21
|
handleError(error.status);
|
|
@@ -23,22 +24,19 @@ const fetchCalculatedProperties = async (setCalculatedProperties, iModelId, mapp
|
|
|
23
24
|
setIsLoading(false);
|
|
24
25
|
}
|
|
25
26
|
};
|
|
26
|
-
const useFetchCalculatedProperties = (iModelId, mappingId, groupId, setIsLoading) => {
|
|
27
|
-
const [calculatedProperties, setCalculatedProperties] = useState([]);
|
|
28
|
-
useEffect(() => {
|
|
29
|
-
void fetchCalculatedProperties(setCalculatedProperties, iModelId, mappingId, groupId, setIsLoading);
|
|
30
|
-
}, [groupId, iModelId, mappingId, setIsLoading]);
|
|
31
|
-
return [calculatedProperties, setCalculatedProperties];
|
|
32
|
-
};
|
|
33
27
|
const CalculatedPropertyTable = ({ iModelId, mappingId, groupId, setSelectedCalculatedProperty, setGroupModifyView, onCalculatedPropertyModify, selectedCalculatedProperty, }) => {
|
|
34
28
|
var _a;
|
|
29
|
+
const apiContext = useContext(ApiContext);
|
|
35
30
|
const [isLoading, setIsLoading] = useState(true);
|
|
36
|
-
const [calculatedProperties, setCalculatedProperties] = useFetchCalculatedProperties(iModelId, mappingId, groupId, setIsLoading);
|
|
37
31
|
const [showCalculatedPropertyDeleteModal, setShowCalculatedPropertyDeleteModal,] = useState(false);
|
|
32
|
+
const [calculatedProperties, setCalculatedProperties] = useState([]);
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
void fetchCalculatedProperties(setCalculatedProperties, iModelId, mappingId, groupId, setIsLoading, apiContext);
|
|
35
|
+
}, [apiContext, groupId, iModelId, mappingId, setIsLoading]);
|
|
38
36
|
const refresh = useCallback(async () => {
|
|
39
37
|
setCalculatedProperties([]);
|
|
40
|
-
await fetchCalculatedProperties(setCalculatedProperties, iModelId, mappingId, groupId, setIsLoading);
|
|
41
|
-
}, [groupId, iModelId, mappingId, setCalculatedProperties]);
|
|
38
|
+
await fetchCalculatedProperties(setCalculatedProperties, iModelId, mappingId, groupId, setIsLoading, apiContext);
|
|
39
|
+
}, [apiContext, groupId, iModelId, mappingId, setCalculatedProperties]);
|
|
42
40
|
const calculatedPropertiesColumns = useMemo(() => [
|
|
43
41
|
{
|
|
44
42
|
Header: "Table",
|
|
@@ -79,7 +77,8 @@ const CalculatedPropertyTable = ({ iModelId, mappingId, groupId, setSelectedCalc
|
|
|
79
77
|
React.createElement(Table, { data: calculatedProperties, density: 'extra-condensed', columns: calculatedPropertiesColumns, emptyTableContent: 'No Calculated Properties', isSortable: true, isLoading: isLoading }),
|
|
80
78
|
React.createElement(DeleteModal, { entityName: (_a = selectedCalculatedProperty === null || selectedCalculatedProperty === void 0 ? void 0 : selectedCalculatedProperty.propertyName) !== null && _a !== void 0 ? _a : "", show: showCalculatedPropertyDeleteModal, setShow: setShowCalculatedPropertyDeleteModal, onDelete: async () => {
|
|
81
79
|
var _a;
|
|
82
|
-
|
|
80
|
+
const reportingClientApi = new ReportingClient(apiContext.prefix);
|
|
81
|
+
await reportingClientApi.deleteCalculatedProperty(apiContext.accessToken, iModelId, mappingId, groupId, (_a = selectedCalculatedProperty === null || selectedCalculatedProperty === void 0 ? void 0 : selectedCalculatedProperty.id) !== null && _a !== void 0 ? _a : "");
|
|
83
82
|
}, refresh: refresh })));
|
|
84
83
|
};
|
|
85
84
|
export default CalculatedPropertyTable;
|