@corva/ui 3.77.0-9 → 3.78.0-0
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/MCP_README.md +9 -6
- package/README.md +6 -0
- package/cjs-bundle/components/AssetEditorV2/components/MultipleAssetsToggle.js.map +1 -1
- package/cjs-bundle/components/AssetEditorV2/components/PrimaryAssetSelect.js +1 -1
- package/cjs-bundle/components/AssetEditorV2/components/PrimaryAssetSelect.js.map +1 -1
- package/cjs-bundle/components/AssetEditorV2/components/PrimaryAssetSelectV2.js +1 -1
- package/cjs-bundle/components/AssetEditorV2/components/PrimaryAssetSelectV2.js.map +1 -1
- package/cjs-bundle/components/AssetEditorV2/components/SecondaryAssetSelect.js +1 -1
- package/cjs-bundle/components/AssetEditorV2/components/SecondaryAssetSelect.js.map +1 -1
- package/cjs-bundle/components/AssetEditorV2/components/SelectItem.js +1 -1
- package/cjs-bundle/components/AssetEditorV2/components/SelectItem.js.map +1 -1
- package/cjs-bundle/components/AssetEditorV2/constants.js.map +1 -1
- package/cjs-bundle/components/AssetEditorV2/effects/assetResponse.js +2 -0
- package/cjs-bundle/components/AssetEditorV2/effects/assetResponse.js.map +1 -0
- package/cjs-bundle/components/AssetEditorV2/effects/index.js +1 -1
- package/cjs-bundle/components/AssetEditorV2/effects/index.js.map +1 -1
- package/cjs-bundle/components/AssetEditorV2/effects/usePrimaryAssetSelectData.js +1 -1
- package/cjs-bundle/components/AssetEditorV2/effects/usePrimaryAssetSelectData.js.map +1 -1
- package/cjs-bundle/components/AssetEditorV2/index.js +1 -1
- package/cjs-bundle/components/AssetEditorV2/index.js.map +1 -1
- package/cjs-bundle/components/AssetEditorV2/utils/index.js +1 -1
- package/cjs-bundle/components/AssetEditorV2/utils/index.js.map +1 -1
- package/cjs-bundle/components/AttachmentLightbox/AttachmentDocument.js +1 -1
- package/cjs-bundle/components/AttachmentLightbox/AttachmentDocument.js.map +1 -1
- package/cjs-bundle/components/CommentComposer/useAttachmentUpload.js +1 -1
- package/cjs-bundle/components/CommentComposer/useAttachmentUpload.js.map +1 -1
- package/cjs-bundle/components/DevCenter/DevCenterAppContainer/components/AppSettingsDialog/AppSettingsDialog.js +1 -1
- package/cjs-bundle/components/DevCenter/DevCenterAppContainer/components/AppSettingsDialog/AppSettingsDialog.js.map +1 -1
- package/cjs-bundle/components/DevCenter/DevCenterRouterContext/UniversalLink/UniversalLink.js +1 -1
- package/cjs-bundle/components/DevCenter/DevCenterRouterContext/UniversalLink/UniversalLink.js.map +1 -1
- package/cjs-bundle/components/OffsetWellPickerV5/components/Filter/components/PeriodFilterSelect/PeriodFilterSelect.js.map +1 -1
- package/cjs-bundle/components/OffsetWellPickerV5/components/OffsetWellsTable/cells/MetricsCells/MetricsCells.js +1 -1
- package/cjs-bundle/components/OffsetWellPickerV5/components/OffsetWellsTable/cells/MetricsCells/MetricsCells.js.map +1 -1
- package/cjs-bundle/components/OffsetWellPickerV5/components/OffsetWellsTable/components/MetricCell/MetricCell.js +1 -1
- package/cjs-bundle/components/OffsetWellPickerV5/components/OffsetWellsTable/components/MetricCell/MetricCell.js.map +1 -1
- package/cjs-bundle/components/OffsetWellPickerV5/components/OffsetWellsTable/components/MetricCell/MetricCell.module.css.js +1 -1
- package/cjs-bundle/components/OffsetWellPickerV5/components/OffsetWellsTable/components/OffsetWellsTableRow/OffsetWellsTableRow.js +1 -1
- package/cjs-bundle/components/OffsetWellPickerV5/components/OffsetWellsTable/components/OffsetWellsTableRow/OffsetWellsTableRow.js.map +1 -1
- package/cjs-bundle/components/OffsetWellPickerV5/components/OffsetWellsTable/useRowInteractions.js +1 -1
- package/cjs-bundle/components/OffsetWellPickerV5/components/OffsetWellsTable/useRowInteractions.js.map +1 -1
- package/cjs-bundle/components/OffsetWellPickerV5/constants.js +1 -1
- package/cjs-bundle/components/OffsetWellPickerV5/constants.js.map +1 -1
- package/cjs-bundle/components/OffsetWellPickerV5/hooks/use-well-data-pipeline/useAdvancedWells.js +1 -1
- package/cjs-bundle/components/OffsetWellPickerV5/hooks/use-well-data-pipeline/useAdvancedWells.js.map +1 -1
- package/cjs-bundle/components/OffsetWellPickerV5/stores/filter-store/types.js.map +1 -1
- package/cjs-bundle/components/OffsetWellPickerV5/utils/getTimestampByPeriod.js +1 -1
- package/cjs-bundle/components/OffsetWellPickerV5/utils/getTimestampByPeriod.js.map +1 -1
- package/cjs-bundle/components/Search/Search.js.map +1 -1
- package/cjs-bundle/config/mapbox/index.js +1 -1
- package/cjs-bundle/config/mapbox/index.js.map +1 -1
- package/cjs-bundle/hocs/withAssetEditorLockHOC.js +1 -1
- package/cjs-bundle/hocs/withAssetEditorLockHOC.js.map +1 -1
- package/components/AssetEditorV2/__tests__/AssetEditorV2.test.d.ts +2 -0
- package/components/AssetEditorV2/__tests__/AssetEditorV2.test.d.ts.map +1 -0
- package/components/AssetEditorV2/__tests__/consumerTypes.test.d.ts +2 -0
- package/components/AssetEditorV2/__tests__/consumerTypes.test.d.ts.map +1 -0
- package/components/AssetEditorV2/components/MultipleAssetsToggle.d.ts +17 -6
- package/components/AssetEditorV2/components/MultipleAssetsToggle.d.ts.map +1 -1
- package/components/AssetEditorV2/components/MultipleAssetsToggle.js.map +1 -1
- package/components/AssetEditorV2/components/PrimaryAssetSelect.d.ts +30 -39
- package/components/AssetEditorV2/components/PrimaryAssetSelect.d.ts.map +1 -1
- package/components/AssetEditorV2/components/PrimaryAssetSelect.js +1 -1
- package/components/AssetEditorV2/components/PrimaryAssetSelect.js.map +1 -1
- package/components/AssetEditorV2/components/PrimaryAssetSelectV2.d.ts +4 -41
- package/components/AssetEditorV2/components/PrimaryAssetSelectV2.d.ts.map +1 -1
- package/components/AssetEditorV2/components/PrimaryAssetSelectV2.js +1 -1
- package/components/AssetEditorV2/components/PrimaryAssetSelectV2.js.map +1 -1
- package/components/AssetEditorV2/components/SecondaryAssetSelect.d.ts +22 -18
- package/components/AssetEditorV2/components/SecondaryAssetSelect.d.ts.map +1 -1
- package/components/AssetEditorV2/components/SecondaryAssetSelect.js +1 -1
- package/components/AssetEditorV2/components/SecondaryAssetSelect.js.map +1 -1
- package/components/AssetEditorV2/components/SelectItem.d.ts +10 -1
- package/components/AssetEditorV2/components/SelectItem.d.ts.map +1 -1
- package/components/AssetEditorV2/components/SelectItem.js +1 -1
- package/components/AssetEditorV2/components/SelectItem.js.map +1 -1
- package/components/AssetEditorV2/components/__tests__/AssetSelectors.test.d.ts +2 -0
- package/components/AssetEditorV2/components/__tests__/AssetSelectors.test.d.ts.map +1 -0
- package/components/AssetEditorV2/components/__tests__/MultipleAssetsToggle.test.d.ts.map +1 -1
- package/components/AssetEditorV2/components/__tests__/SelectItem.test.d.ts.map +1 -1
- package/components/AssetEditorV2/components/index.d.ts.map +1 -1
- package/components/AssetEditorV2/constants.d.ts +2 -9
- package/components/AssetEditorV2/constants.d.ts.map +1 -1
- package/components/AssetEditorV2/constants.js.map +1 -1
- package/components/AssetEditorV2/effects/__tests__/assetResponse.test.d.ts +2 -0
- package/components/AssetEditorV2/effects/__tests__/assetResponse.test.d.ts.map +1 -0
- package/components/AssetEditorV2/effects/__tests__/useLegacyPrimaryAssetSelectData.test.d.ts +2 -0
- package/components/AssetEditorV2/effects/__tests__/useLegacyPrimaryAssetSelectData.test.d.ts.map +1 -0
- package/components/AssetEditorV2/effects/__tests__/usePrimaryAssetSelectData.test.d.ts +2 -0
- package/components/AssetEditorV2/effects/__tests__/usePrimaryAssetSelectData.test.d.ts.map +1 -0
- package/components/AssetEditorV2/effects/assetResponse.d.ts +4 -0
- package/components/AssetEditorV2/effects/assetResponse.d.ts.map +1 -0
- package/components/AssetEditorV2/effects/assetResponse.js +2 -0
- package/components/AssetEditorV2/effects/assetResponse.js.map +1 -0
- package/components/AssetEditorV2/effects/index.d.ts +34 -28
- package/components/AssetEditorV2/effects/index.d.ts.map +1 -1
- package/components/AssetEditorV2/effects/index.js +1 -1
- package/components/AssetEditorV2/effects/index.js.map +1 -1
- package/components/AssetEditorV2/effects/usePrimaryAssetSelectData.d.ts +21 -17
- package/components/AssetEditorV2/effects/usePrimaryAssetSelectData.d.ts.map +1 -1
- package/components/AssetEditorV2/effects/usePrimaryAssetSelectData.js +1 -1
- package/components/AssetEditorV2/effects/usePrimaryAssetSelectData.js.map +1 -1
- package/components/AssetEditorV2/index.d.ts +36 -67
- package/components/AssetEditorV2/index.d.ts.map +1 -1
- package/components/AssetEditorV2/index.js +1 -1
- package/components/AssetEditorV2/index.js.map +1 -1
- package/components/AssetEditorV2/types.d.ts +82 -0
- package/components/AssetEditorV2/types.d.ts.map +1 -0
- package/components/AssetEditorV2/utils/__tests__/utils.test.d.ts.map +1 -1
- package/components/AssetEditorV2/utils/index.d.ts +23 -19
- package/components/AssetEditorV2/utils/index.d.ts.map +1 -1
- package/components/AssetEditorV2/utils/index.js +1 -1
- package/components/AssetEditorV2/utils/index.js.map +1 -1
- package/components/AttachmentLightbox/AttachmentDocument.d.ts.map +1 -1
- package/components/AttachmentLightbox/AttachmentDocument.js +1 -1
- package/components/AttachmentLightbox/AttachmentDocument.js.map +1 -1
- package/components/CommentComposer/__tests__/useAttachmentUpload.local.test.d.ts +2 -0
- package/components/CommentComposer/__tests__/useAttachmentUpload.local.test.d.ts.map +1 -0
- package/components/CommentComposer/useAttachmentUpload.d.ts.map +1 -1
- package/components/CommentComposer/useAttachmentUpload.js +1 -1
- package/components/CommentComposer/useAttachmentUpload.js.map +1 -1
- package/components/DevCenter/DevCenterAppContainer/components/AppSettingsDialog/AppSettingsDialog.d.ts.map +1 -1
- package/components/DevCenter/DevCenterAppContainer/components/AppSettingsDialog/AppSettingsDialog.js +1 -1
- package/components/DevCenter/DevCenterAppContainer/components/AppSettingsDialog/AppSettingsDialog.js.map +1 -1
- package/components/DevCenter/DevCenterRouterContext/UniversalLink/UniversalLink.d.ts.map +1 -1
- package/components/DevCenter/DevCenterRouterContext/UniversalLink/UniversalLink.js +1 -1
- package/components/DevCenter/DevCenterRouterContext/UniversalLink/UniversalLink.js.map +1 -1
- package/components/Drillstring/BHAComponentDetail/constants.d.ts +2 -2
- package/components/OffsetWellPickerV4/effects/__tests__/useCompanyMetricKey.test.d.ts +2 -0
- package/components/OffsetWellPickerV4/effects/__tests__/useCompanyMetricKey.test.d.ts.map +1 -0
- package/components/OffsetWellPickerV4/effects/useCompanyMetricKey.d.ts.map +1 -1
- package/components/OffsetWellPickerV5/__tests__/constants.test.d.ts +2 -0
- package/components/OffsetWellPickerV5/__tests__/constants.test.d.ts.map +1 -0
- package/components/OffsetWellPickerV5/components/Filter/components/PeriodFilterSelect/PeriodFilterSelect.js.map +1 -1
- package/components/OffsetWellPickerV5/components/OffsetWellsTable/cells/MetricsCells/MetricsCells.d.ts +2 -1
- package/components/OffsetWellPickerV5/components/OffsetWellsTable/cells/MetricsCells/MetricsCells.d.ts.map +1 -1
- package/components/OffsetWellPickerV5/components/OffsetWellsTable/cells/MetricsCells/MetricsCells.js +1 -1
- package/components/OffsetWellPickerV5/components/OffsetWellsTable/cells/MetricsCells/MetricsCells.js.map +1 -1
- package/components/OffsetWellPickerV5/components/OffsetWellsTable/components/MetricCell/MetricCell.d.ts +3 -1
- package/components/OffsetWellPickerV5/components/OffsetWellsTable/components/MetricCell/MetricCell.d.ts.map +1 -1
- package/components/OffsetWellPickerV5/components/OffsetWellsTable/components/MetricCell/MetricCell.js +1 -1
- package/components/OffsetWellPickerV5/components/OffsetWellsTable/components/MetricCell/MetricCell.js.map +1 -1
- package/components/OffsetWellPickerV5/components/OffsetWellsTable/components/MetricCell/MetricCell.module.css.js +1 -1
- package/components/OffsetWellPickerV5/components/OffsetWellsTable/components/MetricCell/__tests__/MetricCell.test.d.ts +2 -0
- package/components/OffsetWellPickerV5/components/OffsetWellsTable/components/MetricCell/__tests__/MetricCell.test.d.ts.map +1 -0
- package/components/OffsetWellPickerV5/components/OffsetWellsTable/components/OffsetWellsTableRow/OffsetWellsTableRow.d.ts.map +1 -1
- package/components/OffsetWellPickerV5/components/OffsetWellsTable/components/OffsetWellsTableRow/OffsetWellsTableRow.js +1 -1
- package/components/OffsetWellPickerV5/components/OffsetWellsTable/components/OffsetWellsTableRow/OffsetWellsTableRow.js.map +1 -1
- package/components/OffsetWellPickerV5/components/OffsetWellsTable/useRowInteractions.d.ts +0 -1
- package/components/OffsetWellPickerV5/components/OffsetWellsTable/useRowInteractions.d.ts.map +1 -1
- package/components/OffsetWellPickerV5/components/OffsetWellsTable/useRowInteractions.js +1 -1
- package/components/OffsetWellPickerV5/components/OffsetWellsTable/useRowInteractions.js.map +1 -1
- package/components/OffsetWellPickerV5/constants.d.ts +26 -3
- package/components/OffsetWellPickerV5/constants.d.ts.map +1 -1
- package/components/OffsetWellPickerV5/constants.js +1 -1
- package/components/OffsetWellPickerV5/constants.js.map +1 -1
- package/components/OffsetWellPickerV5/hooks/use-well-data-pipeline/__tests__/useAdvancedWells.test.d.ts +2 -0
- package/components/OffsetWellPickerV5/hooks/use-well-data-pipeline/__tests__/useAdvancedWells.test.d.ts.map +1 -0
- package/components/OffsetWellPickerV5/hooks/use-well-data-pipeline/__tests__/useCompanyMetricKey.test.d.ts +2 -0
- package/components/OffsetWellPickerV5/hooks/use-well-data-pipeline/__tests__/useCompanyMetricKey.test.d.ts.map +1 -0
- package/components/OffsetWellPickerV5/hooks/use-well-data-pipeline/useAdvancedWells.d.ts.map +1 -1
- package/components/OffsetWellPickerV5/hooks/use-well-data-pipeline/useAdvancedWells.js +1 -1
- package/components/OffsetWellPickerV5/hooks/use-well-data-pipeline/useAdvancedWells.js.map +1 -1
- package/components/OffsetWellPickerV5/stores/filter-store/types.d.ts +2 -1
- package/components/OffsetWellPickerV5/stores/filter-store/types.d.ts.map +1 -1
- package/components/OffsetWellPickerV5/stores/filter-store/types.js.map +1 -1
- package/components/OffsetWellPickerV5/utils/__tests__/getTimestampByPeriod.test.d.ts +2 -0
- package/components/OffsetWellPickerV5/utils/__tests__/getTimestampByPeriod.test.d.ts.map +1 -0
- package/components/OffsetWellPickerV5/utils/getTimestampByPeriod.d.ts +4 -0
- package/components/OffsetWellPickerV5/utils/getTimestampByPeriod.d.ts.map +1 -1
- package/components/OffsetWellPickerV5/utils/getTimestampByPeriod.js +1 -1
- package/components/OffsetWellPickerV5/utils/getTimestampByPeriod.js.map +1 -1
- package/components/Search/Search.d.ts +6 -3
- package/components/Search/Search.d.ts.map +1 -1
- package/components/Search/Search.js.map +1 -1
- package/components/index.d.ts +1 -0
- package/components/index.d.ts.map +1 -1
- package/config/mapbox/index.d.ts.map +1 -1
- package/config/mapbox/index.js +1 -1
- package/config/mapbox/index.js.map +1 -1
- package/hocs/__tests__/withAssetEditorLockHOC.test.d.ts +2 -0
- package/hocs/__tests__/withAssetEditorLockHOC.test.d.ts.map +1 -0
- package/hocs/withAssetEditorLockHOC.d.ts +11 -1
- package/hocs/withAssetEditorLockHOC.d.ts.map +1 -1
- package/hocs/withAssetEditorLockHOC.js +1 -1
- package/hocs/withAssetEditorLockHOC.js.map +1 -1
- package/mcp-server/server.mjs +312 -73
- package/mcp-server/setup.mjs +129 -44
- package/package.json +3 -2
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/components/AssetEditorV2/effects/index.js"],"sourcesContent":["import { useEffect, useRef, useState } from 'react';\nimport { isEmpty } from 'lodash';\n\nimport { formatAsset, getRequestOptions, sortAsset } from '../utils';\n\nimport { jsonApi } from '~/clients';\nimport { jsonaDataFormatter } from '~/utils/jsonaDataFormatter';\nimport { ASSET_TYPES } from '~/constants';\n\nconst getParentAssetKey = assetType => {\n if (assetType === ASSET_TYPES.intervention_unit.type) {\n return 'intervention_unit_id';\n }\n return assetType;\n};\n\nexport function useSecondaryAssetSelectData({\n appKey,\n assetType,\n assetId,\n company,\n parentAssetType,\n parentAssetId,\n queryParams,\n assetFields,\n activeWellId,\n isRequiredAssetId,\n}) {\n const [assets, setAssets] = useState([]);\n const [loading, setLoading] = useState(true);\n\n useEffect(() => {\n setLoading(true);\n async function loadAssets() {\n const response = await jsonApi.mapAssetGetRequest(assetType)({\n ...getRequestOptions(assetType, assetFields),\n per_page: 10000,\n company: company !== 'all' ? company : null,\n [getParentAssetKey(parentAssetType)]: parentAssetId,\n ...(appKey && { app_key: appKey }),\n ...queryParams,\n });\n\n const deserializedResponse = jsonaDataFormatter.deserialize(response);\n\n setAssets(\n deserializedResponse\n .map(asset => formatAsset({ asset, activeWellId, isRequiredAssetId }))\n .sort(sortAsset)\n );\n setLoading(false);\n }\n loadAssets();\n }, [assetType, assetId, parentAssetType, parentAssetId, appKey, activeWellId, company]);\n\n return { assets, loading };\n}\n\nconst getAssetFields = (assetType, assetFields) => {\n if (assetType === ASSET_TYPES.pad.type) {\n return [...assetFields, 'pad.active', 'pad.parent_frac_fleet_id', 'pad.current'];\n } else if (assetType === ASSET_TYPES.intervention_unit.type) {\n return [...assetFields, 'intervention_unit.active', 'intervention_unit.current'];\n }\n\n return assetFields;\n};\n\nexport function usePrimaryAssetSelectData({\n appKey,\n assetType,\n company,\n groups,\n isRequiredAssetId,\n parentAssetId,\n parentAssetType,\n searchText,\n assetFields,\n currentValue,\n setCurrentOption,\n onActiveAssetIdChange,\n}) {\n const [assets, setAssets] = useState([]);\n const [loading, setLoading] = useState(false);\n const prevCompany = useRef(null);\n\n const loadAssets = async group => {\n try {\n const currentAssetType = group?.type || assetType;\n const requestParams = { per_page: 10000 };\n if (parentAssetType && parentAssetId) requestParams[parentAssetType] = parentAssetId;\n if (company && company !== 'all') requestParams.company = company;\n if (searchText) requestParams.search = searchText;\n if (appKey) requestParams.app_key = appKey;\n\n prevCompany.current = company;\n\n const requestPromise = jsonApi.mapAssetGetRequest(currentAssetType)({\n ...getRequestOptions(currentAssetType, getAssetFields(currentAssetType, assetFields)),\n ...requestParams,\n });\n\n const response = await requestPromise;\n const deserializedResponse = jsonaDataFormatter.deserialize(response);\n\n const responseAssets = deserializedResponse\n .map(asset =>\n formatAsset({ asset, group: group?.name, isRequiredAssetId, isPrimaryAsset: true })\n )\n .filter(Boolean)\n .sort(sortAsset);\n\n if (prevCompany.current === company) {\n setAssets(prevState => [...prevState, ...responseAssets]);\n }\n if (currentValue && currentAssetType === assetType) {\n const currentAsset = responseAssets.find(\n asset => currentValue === asset.id || (asset.assetId && currentValue === asset.assetId)\n );\n if (!isEmpty(currentAsset)) {\n setCurrentOption(currentAsset);\n }\n\n if (currentAssetType === ASSET_TYPES.rig.type) {\n onActiveAssetIdChange(currentAsset?.activeWellId);\n }\n }\n } catch (e) {\n console.error(e);\n }\n };\n\n useEffect(() => {\n if (company) {\n setAssets([]);\n }\n }, [company]);\n\n useEffect(() => {\n const loadEverything = async () => {\n try {\n setLoading(true);\n\n if (groups) {\n await Promise.all(groups.map(group => loadAssets(group)));\n } else {\n await loadAssets();\n }\n } catch (e) {\n console.error(e);\n } finally {\n setLoading(false);\n }\n };\n\n loadEverything();\n }, [assetType, parentAssetType, parentAssetId, company, appKey, groups?.length]);\n\n return { assets: loading ? [] : assets, loading };\n}\n"],"names":["getParentAssetKey","assetType","ASSET_TYPES","intervention_unit","type","useSecondaryAssetSelectData","_ref","appKey","assetId","company","parentAssetType","parentAssetId","queryParams","assetFields","activeWellId","isRequiredAssetId","useState","_useState2","_slicedToArray","_useState","assets","setAssets","_useState4","_useState3","loading","setLoading","useEffect","_loadAssets","_asyncToGenerator","_regeneratorRuntime","mark","_callee","response","deserializedResponse","wrap","_context","prev","next","jsonApi","getRequestOptions","_defineProperty","per_page","app_key","sent","jsonaDataFormatter","deserialize","map","asset","formatAsset","sort","sortAsset","stop","apply","this","arguments","loadAssets","getAssetFields","pad","concat","_toConsumableArray","usePrimaryAssetSelectData","_ref2","_ref3","groups","searchText","currentValue","setCurrentOption","onActiveAssetIdChange","_useState6","_useState5","_useState8","_useState7","prevCompany","useRef","group","currentAssetType","requestParams","requestPromise","responseAssets","currentAsset","_context2","search","current","name","isPrimaryAsset","filter","Boolean","prevState","find","id","isEmpty","rig","t0","console","error","_callee2","_x","_ref4","loadEverything","_callee3","_context3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AgE,EAAA/D,MAAA,KAAA,EAEF,GAFE+D,EAAAhE,KAAA,EAEnBX,GAAW,IAEPsC,EAAM,CAAAqC,EAAA/D,KAAA,EAAA,KAAA,CAAA,OAAA+D,EAAA/D,KAAA,EACFgE,QAAQC,IAAIvC,EAAOjB,KAAI,SAAA4B,GAAK,OAAInB,EAAWmB,EAAM,KAAE,KAAA,EAAA0B,EAAA/D,KAAA,EAAA,MAAA,KAAA,EAAA,OAAA+D,EAAA/D,KAAA,EAEnDkB,IAAY,KAAA,EAAA6C,EAAA/D,KAAA,GAAA,MAAA,KAAA,GAAA+D,EAAAhE,KAAA,GAAAgE,EAAAR,GAAAQ,EAAA,MAAA,GAGpBP,QAAQC,MAAQM,EAAAR,IAAC,KAAA,GAEC,OAFDQ,EAAAhE,KAAA,GAEjBX,GAAW,GAAO2E,EAAAG,OAAA,IAAA,KAAA,GAAA,IAAA,MAAA,OAAAH,EAAAjD,OAAA,GAAAgD,EAAA,KAAA,CAAA,CAAA,EAAA,GAAA,GAAA,KAErB,KAAA,WAdmB,OAAAF,EAAA7C,MAAAC,KAAAC,UAAA,GAgBpB4C,MACC,CAACjG,EAAWS,EAAiBC,EAAeF,EAASF,EAAQwD,aAAM,EAANA,EAAQyC,SAEjE,CAAEpF,OAAQI,EAAU,GAAKJ,EAAQI,QAAAA,EAC1C"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/components/AssetEditorV2/effects/index.ts"],"sourcesContent":["import { useEffect, useRef, useState } from 'react';\n\nimport { AssetGroup, AssetId, AssetOption, AssetSelection } from '../types';\nimport { DEFAULT_ASSET_TYPE } from '../constants';\nimport { formatAsset, getRequestOptions, isAssetOption, sortAsset } from '../utils';\n\nimport { jsonApi } from '~/clients';\nimport { ASSET_TYPES } from '~/constants';\n\nimport { deserializeAssetResponse } from './assetResponse';\n\ntype QueryParams = Record<string, unknown>;\n\ntype UseSecondaryAssetSelectDataParams = {\n appKey?: string | null;\n assetType?: string | null;\n assetId?: AssetId | null;\n company?: AssetId | null;\n parentAssetType?: string | null;\n parentAssetId?: AssetId | null;\n queryParams?: QueryParams;\n assetFields?: string[];\n activeWellId?: AssetId | null;\n isRequiredAssetId?: boolean;\n};\n\ntype UsePrimaryAssetSelectDataParams = {\n appKey?: string | null;\n assetType?: string | null;\n company?: AssetId | null;\n groups?: AssetGroup[];\n isRequiredAssetId?: boolean;\n parentAssetId?: AssetId | null;\n parentAssetType?: string | null;\n searchText?: string;\n assetFields?: string[];\n currentValue?: AssetId | null;\n selectedGroup?: AssetGroup | null;\n setCurrentOption: (selection: AssetSelection) => void;\n onActiveAssetIdChange: (id: number | null) => void;\n};\n\nconst getParentAssetKey = (assetType?: string | null): string | null => {\n if (!assetType) return null;\n\n if (assetType === ASSET_TYPES.intervention_unit.type) {\n return 'intervention_unit_id';\n }\n\n return assetType;\n};\n\nexport const useSecondaryAssetSelectData = ({\n appKey,\n assetType,\n assetId,\n company,\n parentAssetType,\n parentAssetId,\n queryParams = {},\n assetFields = [],\n activeWellId,\n isRequiredAssetId,\n}: UseSecondaryAssetSelectDataParams): { assets: AssetOption[]; loading: boolean } => {\n const [assets, setAssets] = useState<AssetOption[]>([]);\n const [loading, setLoading] = useState(true);\n const requestAssetType = assetType || DEFAULT_ASSET_TYPE;\n\n useEffect(() => {\n setLoading(true);\n\n const loadAssets = async () => {\n const parentAssetKey = getParentAssetKey(parentAssetType);\n const response: unknown = await jsonApi.mapAssetGetRequest(requestAssetType)({\n ...getRequestOptions(requestAssetType, assetFields),\n per_page: 10000,\n company: company !== 'all' ? company : null,\n ...(parentAssetKey && { [parentAssetKey]: parentAssetId }),\n ...(appKey && { app_key: appKey }),\n ...queryParams,\n });\n\n const nextAssets = deserializeAssetResponse(response)\n .map(asset => formatAsset({ asset, activeWellId, isRequiredAssetId }))\n .filter(isAssetOption)\n .sort(sortAsset);\n\n setAssets(nextAssets);\n setLoading(false);\n };\n\n loadAssets();\n }, [assetType, assetId, parentAssetType, parentAssetId, appKey, activeWellId, company]);\n\n return { assets, loading };\n};\n\nconst getAssetFields = (assetType: string, assetFields: string[]): string[] => {\n if (assetType === ASSET_TYPES.pad.type) {\n return [...assetFields, 'pad.active', 'pad.parent_frac_fleet_id', 'pad.current'];\n }\n\n if (assetType === ASSET_TYPES.intervention_unit.type) {\n return [...assetFields, 'intervention_unit.active', 'intervention_unit.current'];\n }\n\n return assetFields;\n};\n\nexport const usePrimaryAssetSelectData = ({\n appKey,\n assetType,\n company,\n groups,\n isRequiredAssetId,\n parentAssetId,\n parentAssetType,\n searchText,\n assetFields = [],\n currentValue,\n setCurrentOption,\n onActiveAssetIdChange,\n}: UsePrimaryAssetSelectDataParams): { assets: AssetOption[]; loading: boolean } => {\n const [assets, setAssets] = useState<AssetOption[]>([]);\n const [loading, setLoading] = useState(false);\n const prevCompany = useRef<AssetId | null | undefined>(null);\n const requestAssetType = assetType || DEFAULT_ASSET_TYPE;\n\n const loadAssets = async (group?: AssetGroup) => {\n try {\n const currentAssetType = group?.type || requestAssetType;\n const requestParams: QueryParams = { per_page: 10000 };\n\n if (parentAssetType && parentAssetId) requestParams[parentAssetType] = parentAssetId;\n if (company && company !== 'all') requestParams.company = company;\n if (searchText) requestParams.search = searchText;\n if (appKey) requestParams.app_key = appKey;\n\n prevCompany.current = company;\n\n const response: unknown = await jsonApi.mapAssetGetRequest(currentAssetType)({\n ...getRequestOptions(currentAssetType, getAssetFields(currentAssetType, assetFields)),\n ...requestParams,\n });\n\n const responseAssets = deserializeAssetResponse(response)\n .map(asset =>\n formatAsset({\n asset,\n group: group?.name,\n isRequiredAssetId,\n isPrimaryAsset: true,\n })\n )\n .filter(isAssetOption)\n .sort(sortAsset);\n\n if (prevCompany.current === company) {\n setAssets(prevState => [...prevState, ...responseAssets]);\n }\n\n if (currentValue && currentAssetType === requestAssetType) {\n const currentAsset = responseAssets.find(\n asset =>\n Number(currentValue) === asset.id ||\n (asset.assetId && Number(currentValue) === asset.assetId)\n );\n\n if (currentAsset) {\n setCurrentOption(currentAsset);\n }\n\n if (currentAssetType === ASSET_TYPES.rig.type) {\n onActiveAssetIdChange(currentAsset?.activeWellId || null);\n }\n }\n } catch (error) {\n console.error(error);\n }\n };\n\n useEffect(() => {\n if (company) {\n setAssets([]);\n }\n }, [company]);\n\n useEffect(() => {\n const loadEverything = async () => {\n try {\n setLoading(true);\n\n if (groups) {\n await Promise.all(groups.map(group => loadAssets(group)));\n } else {\n await loadAssets();\n }\n } catch (error) {\n console.error(error);\n } finally {\n setLoading(false);\n }\n };\n\n loadEverything();\n }, [assetType, parentAssetType, parentAssetId, company, appKey, groups?.length]);\n\n return { assets: loading ? [] : assets, loading };\n};\n"],"names":["getParentAssetKey","assetType","ASSET_TYPES","intervention_unit","type","useSecondaryAssetSelectData","_ref","appKey","assetId","company","parentAssetType","parentAssetId","_ref$queryParams","queryParams","_ref$assetFields","assetFields","activeWellId","isRequiredAssetId","useState","_useState2","_slicedToArray","_useState","assets","setAssets","_useState4","_useState3","loading","setLoading","requestAssetType","DEFAULT_ASSET_TYPE","useEffect","loadAssets","_ref2","_asyncToGenerator","_regeneratorRuntime","mark","_callee","parentAssetKey","response","nextAssets","wrap","_context","prev","next","jsonApi","getRequestOptions","per_page","app_key","sent","deserializeAssetResponse","map","asset","formatAsset","filter","isAssetOption","sort","sortAsset","stop","apply","this","arguments","getAssetFields","pad","concat","_toConsumableArray","usePrimaryAssetSelectData","_ref4","groups","searchText","_ref4$assetFields","currentValue","setCurrentOption","onActiveAssetIdChange","_useState6","_useState5","_useState8","_useState7","prevCompany","useRef","_ref5","group","currentAssetType","requestParams","responseAssets","currentAsset","_context2","search","current","_objectSpread","name","isPrimaryAsset","prevState","find","Number","id","rig","t0","console","error","_callee2","_x","loadEverything","_ref6","_callee3","_context3","Promise","all","finish","length"],"mappings":"0pEA0CA,IAAMA,EAAoB,SAACC,GACzB,OAAKA,EAEDA,IAAcC,EAAYC,kBAAkBC,KACvC,uBAGFH,EANgB,IAOzB,EAEaI,EAA8B,SAW2CC,GAAA,I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|
|
3
|
+
appKey?: string | null;
|
|
4
|
+
assetType?: string | null;
|
|
5
|
+
company?: AssetId | null;
|
|
6
|
+
groups?: AssetGroup[];
|
|
7
|
+
isRequiredAssetId?: boolean;
|
|
8
|
+
parentAssetId?: AssetId | null;
|
|
9
|
+
parentAssetType?: string | null;
|
|
10
|
+
searchValue?: string;
|
|
11
|
+
assetFields?: string[];
|
|
12
|
+
currentValue?: AssetId | null;
|
|
13
|
+
selectedGroup?: AssetGroup | null;
|
|
14
|
+
setCurrentOption: (selection: AssetSelection) => void;
|
|
15
|
+
scrollPage: number;
|
|
16
|
+
onActiveAssetIdChange: (id: number | null) => void;
|
|
17
|
+
isDrillingPlatformApp?: boolean;
|
|
18
|
+
};
|
|
19
|
+
export declare const usePrimaryAssetSelectData: ({ appKey, assetType, company, groups, isRequiredAssetId, parentAssetId, parentAssetType, searchValue, assetFields, currentValue, setCurrentOption, scrollPage, onActiveAssetIdChange, isDrillingPlatformApp, }: UsePrimaryAssetSelectDataParams) => {
|
|
20
|
+
assets: AssetOption[];
|
|
18
21
|
loading: boolean;
|
|
19
22
|
};
|
|
23
|
+
export {};
|
|
20
24
|
//# sourceMappingURL=usePrimaryAssetSelectData.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePrimaryAssetSelectData.d.ts","sourceRoot":"","sources":["../../../../src/components/AssetEditorV2/effects/usePrimaryAssetSelectData.
|
|
1
|
+
{"version":3,"file":"usePrimaryAssetSelectData.d.ts","sourceRoot":"","sources":["../../../../src/components/AssetEditorV2/effects/usePrimaryAssetSelectData.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAY5E,KAAK,+BAA+B,GAAG;IACrC,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,OAAO,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IACzB,MAAM,CAAC,EAAE,UAAU,EAAE,CAAC;IACtB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,aAAa,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAC/B,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,YAAY,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAC9B,aAAa,CAAC,EAAE,UAAU,GAAG,IAAI,CAAC;IAClC,gBAAgB,EAAE,CAAC,SAAS,EAAE,cAAc,KAAK,IAAI,CAAC;IACtD,UAAU,EAAE,MAAM,CAAC;IACnB,qBAAqB,EAAE,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;IACnD,qBAAqB,CAAC,EAAE,OAAO,CAAC;CACjC,CAAC;AAEF,eAAO,MAAM,yBAAyB,mNAenC,+BAA+B,KAAG;IAAE,MAAM,EAAE,WAAW,EAAE,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAsJ7E,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import t from"@babel/runtime/helpers/defineProperty";import r from"@babel/runtime/helpers/asyncToGenerator";import e from"@babel/runtime/helpers/toConsumableArray";import n from"@babel/runtime/helpers/slicedToArray";import s from"@babel/runtime/regenerator";import{useState as o,useRef as i,useEffect as a}from"react";import{
|
|
1
|
+
import t from"@babel/runtime/helpers/defineProperty";import r from"@babel/runtime/helpers/asyncToGenerator";import e from"@babel/runtime/helpers/toConsumableArray";import n from"@babel/runtime/helpers/slicedToArray";import s from"@babel/runtime/regenerator";import{useState as o,useRef as i,useEffect as a}from"react";import{isEmpty as c,uniqBy as p}from"lodash";import{DEFAULT_ASSET_TYPE as l}from"../constants.js";import{formatAsset as u,isAssetOption as m,sortAsset as f,getRequestOptions as d}from"../utils/index.js";import"uuid";import"lodash/set";import"lodash/get";import"lodash/unset";import"moment";import{mapAssetGetRequest as j,getAssets as b}from"../../../clients/jsonApi/index.js";import"../../../clients/subscriptions/constants.js";import"../../../clients/subscriptions.v1.js";import"../../../clients/subscriptions/subscriptions-client.factory.js";import"../../../clients/api/apiCore.js";import"../../../clients/constants.js";import"../../../clients/sso/auth0.js";import"../../../clients/sso/oauth2.js";import"../../../clients/api/rateLimiter.js";import{PER_PAGE as y}from"../../AssetEditor/constants.js";import"../../../constants/goals.js";import"../../../constants/segment.js";import"../../../constants/alerts.js";import"../../../constants/apps.js";import"../../../constants/drillstring.js";import"../../../constants/completion.js";import"../../../constants/appPackages.js";import"../../../constants/notifications.js";import"../../../constants/feed.js";import"../../../constants/bha.js";import{ASSET_TYPES as v}from"../../../constants/assetTypes.js";import"../../../constants/corvaCompanyId.js";import"../../GradientManager/configuration/constants.js";import{deserializeAssetResponse as g,getFirstIncludedId as h,getResponseData as O}from"./assetResponse.js";function A(t,r){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable}))),e.push.apply(e,n)}return e}function P(r){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?A(Object(n),!0).forEach((function(e){t(r,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(n)):A(Object(n)).forEach((function(t){Object.defineProperty(r,t,Object.getOwnPropertyDescriptor(n,t))}))}return r}var w=function(t){var A=t.appKey,w=t.assetType,x=t.company,I=t.groups,k=t.isRequiredAssetId,D=t.parentAssetId,_=t.parentAssetType,C=t.searchValue,T=t.assetFields,E=void 0===T?[]:T,R=t.currentValue,q=t.setCurrentOption,G=t.scrollPage,S=t.onActiveAssetIdChange,V=t.isDrillingPlatformApp,W=o([]),F=n(W,2),K=F[0],L=F[1],M=o(!1),z=n(M,2),B=z[0],H=z[1],J=i(null),N=i(null),Q=i(null),U=i(null),X=w||l,Y=X===v.pad.type?[].concat(e(E),["pad.active","pad.parent_frac_fleet_id"]):E,Z=function(){var t=r(s.mark((function t(r){var n,o,i,a,c,l=arguments;return s.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=l.length>1&&void 0!==l[1]&&l[1],t.prev=1,o=(null==r?void 0:r.type)||X,H(!0),i={per_page:y,page:G},_&&D&&(i[_]=D),x&&"all"!==x&&(i.company=x),C&&(i.search=C),A&&(i.app_key=A),J.current=x,t.next=12,j(o)(P(P({},d(o,Y)),i));case 12:a=t.sent,c=g(a).map((function(t){return u({asset:t,group:null==r?void 0:r.name,isRequiredAssetId:k,isPrimaryAsset:!0,isDrillingPlatformApp:V})})).filter(m).sort(f),J.current===x&&L(n?function(t){return p([].concat(e(t),e(c)),"id")}:c),t.next=20;break;case 17:t.prev=17,t.t0=t.catch(1),console.error(t.t0);case 20:return t.prev=20,H(!1),t.finish(20);case 23:case"end":return t.stop()}}),t,null,[[1,17,20,23]])})));return function(r){return t.apply(this,arguments)}}(),$=function(){var t=r(s.mark((function t(){var r,e,n;return s.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,j(X)(P(P({},d(X,Y)),{},{ids:R}));case 2:if(r=t.sent,!c(O(r))){t.next=7;break}return t.next=6,b(P(P({},d(X,Y)),{},{ids:R}));case 6:r=t.sent;case 7:e=u({asset:g(r)[0],isPrimaryAsset:!0,isRequiredAssetId:k,isDrillingPlatformApp:V}),q(e),X===v.rig.type?(n=V?h(r):(null==e?void 0:e.activeWellId)||null,S(n)):X===v.intervention_unit.type&&S((null==e?void 0:e.activeWellId)||null);case 10:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}();return a((function(){x&&L([])}),[x]),a((function(){var t=Q.current!==C,r=U.current!==G,e=!t&&r&&G>1&&(U.current||0)<G;t&&(Q.current=C),r&&(U.current=G),I?I.forEach((function(t){Z(t,e)})):(N.current&&N.current!==X&&L([]),N.current=X,Z(null,e))}),[w,_,D,x,A,null==I?void 0:I.length,C,G]),a((function(){R&&$()}),[]),{assets:K,loading:B}};export{w as usePrimaryAssetSelectData};
|
|
2
2
|
//# sourceMappingURL=usePrimaryAssetSelectData.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePrimaryAssetSelectData.js","sources":["../../../../src/components/AssetEditorV2/effects/usePrimaryAssetSelectData.js"],"sourcesContent":["import { useEffect, useRef, useState } from 'react';\nimport { isEmpty, map, uniqBy } from 'lodash';\n\nimport { formatAsset, getRequestOptions, sortAsset } from '../utils';\n\nimport { jsonApi } from '~/clients';\nimport { jsonaDataFormatter } from '~/utils/jsonaDataFormatter';\nimport { PER_PAGE } from '~/components/AssetEditor/constants';\nimport { ASSET_TYPES } from '~/constants';\n\nexport function usePrimaryAssetSelectData({\n appKey,\n assetType,\n company,\n groups,\n isRequiredAssetId,\n parentAssetId,\n parentAssetType,\n searchValue,\n assetFields,\n currentValue,\n setCurrentOption,\n scrollPage,\n onActiveAssetIdChange,\n isDrillingPlatformApp,\n}) {\n const [assets, setAssets] = useState([]);\n const [loading, setLoading] = useState(false);\n const prevCompany = useRef(null);\n const prevAssetType = useRef(null);\n const prevSearchValue = useRef(null);\n const prevScrollPage = useRef(null);\n\n const assetFieldsByAssetType =\n assetType === ASSET_TYPES.pad.type\n ? [...assetFields, 'pad.active', 'pad.parent_frac_fleet_id']\n : assetFields;\n\n const loadAssets = async (group, shouldAppend = false) => {\n try {\n const currentAssetType = group?.type || assetType;\n setLoading(true);\n const requestParams = { per_page: PER_PAGE, page: scrollPage };\n if (parentAssetType && parentAssetId) requestParams[parentAssetType] = parentAssetId;\n if (company && company !== 'all') requestParams.company = company;\n if (searchValue) requestParams.search = searchValue;\n if (appKey) requestParams.app_key = appKey;\n\n prevCompany.current = company;\n const requestPromise = jsonApi.mapAssetGetRequest(currentAssetType)({\n ...getRequestOptions(currentAssetType, assetFieldsByAssetType),\n ...requestParams,\n });\n\n const response = await requestPromise;\n const deserializedResponse = jsonaDataFormatter.deserialize(response);\n\n const responseAssets = map(deserializedResponse, asset =>\n formatAsset({\n asset,\n group: group?.name,\n isRequiredAssetId,\n isPrimaryAsset: true,\n isDrillingPlatformApp,\n })\n ).sort(sortAsset);\n\n if (prevCompany.current === company) {\n if (shouldAppend) {\n setAssets(prevState => uniqBy([...prevState, ...responseAssets], 'id'));\n } else {\n setAssets(responseAssets);\n }\n }\n } catch (e) {\n console.error(e);\n } finally {\n setLoading(false);\n }\n };\n\n const loadCurrentOption = async () => {\n let response = await jsonApi.mapAssetGetRequest(assetType)({\n ...getRequestOptions(assetType, assetFieldsByAssetType),\n ids: currentValue,\n });\n if (isEmpty(response.data)) {\n // NOTE: Try fetch current option from v2/assets\n response = await jsonApi.getAssets({\n ...getRequestOptions(assetType, assetFieldsByAssetType),\n ids: currentValue,\n });\n }\n const deserializedResponse = jsonaDataFormatter.deserialize(response);\n\n const formattedAsset = formatAsset({\n asset: deserializedResponse[0],\n isPrimaryAsset: true,\n isRequiredAssetId,\n isDrillingPlatformApp,\n });\n\n setCurrentOption(formattedAsset);\n if (assetType === ASSET_TYPES.rig.type) {\n const activeWellId = isDrillingPlatformApp\n ? Number(response?.included?.[0]?.id)\n : formattedAsset?.activeWellId || null;\n onActiveAssetIdChange(activeWellId);\n } else if (assetType === ASSET_TYPES.intervention_unit.type) {\n const activeWellId = formattedAsset?.activeWellId || null;\n onActiveAssetIdChange(activeWellId);\n }\n };\n\n useEffect(() => {\n if (company) {\n setAssets([]);\n }\n }, [company]);\n\n useEffect(() => {\n // Check if searchValue changed - if so, reset assets and don't append\n const searchValueChanged = prevSearchValue.current !== searchValue;\n const scrollPageChanged = prevScrollPage.current !== scrollPage;\n // Only append for pagination: searchValue didn't change AND scrollPage increased\n const isPagination =\n !searchValueChanged &&\n scrollPageChanged &&\n scrollPage > 1 &&\n (prevScrollPage.current || 0) < scrollPage;\n\n if (searchValueChanged) {\n prevSearchValue.current = searchValue;\n }\n if (scrollPageChanged) {\n prevScrollPage.current = scrollPage;\n }\n\n if (groups) {\n groups.forEach(group => {\n loadAssets(group, isPagination);\n });\n return;\n }\n if (!!assetType && !!prevAssetType.current && prevAssetType.current !== assetType) {\n setAssets([]);\n }\n prevAssetType.current = assetType;\n loadAssets(null, isPagination);\n }, [\n assetType,\n parentAssetType,\n parentAssetId,\n company,\n appKey,\n groups?.length,\n searchValue,\n scrollPage,\n ]);\n\n useEffect(() => {\n if (currentValue) {\n loadCurrentOption();\n }\n }, []);\n\n return { assets, loading };\n}\n"],"names":["usePrimaryAssetSelectData","_ref","_ref2","_ref3","appKey","assetType","company","groups","isRequiredAssetId","parentAssetId","parentAssetType","searchValue","assetFields","currentValue","setCurrentOption","scrollPage","onActiveAssetIdChange","isDrillingPlatformApp","useState","_useState2","_slicedToArray","_useState","assets","setAssets","_useState4","_useState3","loading","setLoading","prevCompany","useRef","prevAssetType","prevSearchValue","prevScrollPage","assetFieldsByAssetType","ASSET_TYPES","pad","type","concat","_toConsumableArray","loadAssets","_asyncToGenerator","_regeneratorRuntime","mark","group","shouldAppend","currentAssetType","requestParams","requestPromise","response","deserializedResponse","responseAssets","_args","arguments","wrap","_context","prev","next","per_page","PER_PAGE","page","search","app_key","current","jsonApi","_objectSpread","getRequestOptions","sent","jsonaDataFormatter","deserialize","map","asset","formatAsset","name","isPrimaryAsset","sort","sortAsset","prevState","uniqBy","t0","console","error","finish","stop","_callee","_x","apply","this","loadCurrentOption","_callee2","formattedAsset","_response","_response$included","_response$included$","activeWellId","_activeWellId","_context2","ids","isEmpty","data","rig","Number","included","id","intervention_unit","useEffect","searchValueChanged","scrollPageChanged","isPagination","forEach","length"],"mappings":"8sEAUO,SAASA,EAebC,GAAA,IAaeC,EA2CUC,EAtE1BC,IAAAA,OACAC,IAAAA,UACAC,IAAAA,QACAC,IAAAA,OACAC,IAAAA,kBACAC,IAAAA,cACAC,IAAAA,gBACAC,IAAAA,YACAC,IAAAA,YACAC,IAAAA,aACAC,IAAAA,iB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AssetSelectData.js","sources":["../../../../src/components/AssetEditorV2/effects/usePrimaryAssetSelectData.ts"],"sourcesContent":["import { useEffect, useRef, useState } from 'react';\nimport { isEmpty, uniqBy } from 'lodash';\n\nimport { AssetGroup, AssetId, AssetOption, AssetSelection } from '../types';\nimport { DEFAULT_ASSET_TYPE } from '../constants';\nimport { formatAsset, getRequestOptions, isAssetOption, sortAsset } from '../utils';\n\nimport { jsonApi } from '~/clients';\nimport { PER_PAGE } from '~/components/AssetEditor/constants';\nimport { ASSET_TYPES } from '~/constants';\n\nimport { deserializeAssetResponse, getFirstIncludedId, getResponseData } from './assetResponse';\n\ntype QueryParams = Record<string, unknown>;\n\ntype UsePrimaryAssetSelectDataParams = {\n appKey?: string | null;\n assetType?: string | null;\n company?: AssetId | null;\n groups?: AssetGroup[];\n isRequiredAssetId?: boolean;\n parentAssetId?: AssetId | null;\n parentAssetType?: string | null;\n searchValue?: string;\n assetFields?: string[];\n currentValue?: AssetId | null;\n selectedGroup?: AssetGroup | null;\n setCurrentOption: (selection: AssetSelection) => void;\n scrollPage: number;\n onActiveAssetIdChange: (id: number | null) => void;\n isDrillingPlatformApp?: boolean;\n};\n\nexport const usePrimaryAssetSelectData = ({\n appKey,\n assetType,\n company,\n groups,\n isRequiredAssetId,\n parentAssetId,\n parentAssetType,\n searchValue,\n assetFields = [],\n currentValue,\n setCurrentOption,\n scrollPage,\n onActiveAssetIdChange,\n isDrillingPlatformApp,\n}: UsePrimaryAssetSelectDataParams): { assets: AssetOption[]; loading: boolean } => {\n const [assets, setAssets] = useState<AssetOption[]>([]);\n const [loading, setLoading] = useState(false);\n const prevCompany = useRef<AssetId | null | undefined>(null);\n const prevAssetType = useRef<string | null>(null);\n const prevSearchValue = useRef<string | null | undefined>(null);\n const prevScrollPage = useRef<number | null>(null);\n const requestAssetType = assetType || DEFAULT_ASSET_TYPE;\n\n const assetFieldsByAssetType =\n requestAssetType === ASSET_TYPES.pad.type\n ? [...assetFields, 'pad.active', 'pad.parent_frac_fleet_id']\n : assetFields;\n\n const loadAssets = async (group?: AssetGroup | null, shouldAppend = false) => {\n try {\n const currentAssetType = group?.type || requestAssetType;\n setLoading(true);\n\n const requestParams: QueryParams = { per_page: PER_PAGE, page: scrollPage };\n\n if (parentAssetType && parentAssetId) requestParams[parentAssetType] = parentAssetId;\n if (company && company !== 'all') requestParams.company = company;\n if (searchValue) requestParams.search = searchValue;\n if (appKey) requestParams.app_key = appKey;\n\n prevCompany.current = company;\n\n const response: unknown = await jsonApi.mapAssetGetRequest(currentAssetType)({\n ...getRequestOptions(currentAssetType, assetFieldsByAssetType),\n ...requestParams,\n });\n\n const responseAssets = deserializeAssetResponse(response)\n .map(asset =>\n formatAsset({\n asset,\n group: group?.name,\n isRequiredAssetId,\n isPrimaryAsset: true,\n isDrillingPlatformApp,\n })\n )\n .filter(isAssetOption)\n .sort(sortAsset);\n\n if (prevCompany.current === company) {\n if (shouldAppend) {\n setAssets(prevState => uniqBy([...prevState, ...responseAssets], 'id'));\n } else {\n setAssets(responseAssets);\n }\n }\n } catch (error) {\n console.error(error);\n } finally {\n setLoading(false);\n }\n };\n\n const loadCurrentOption = async () => {\n let response: unknown = await jsonApi.mapAssetGetRequest(requestAssetType)({\n ...getRequestOptions(requestAssetType, assetFieldsByAssetType),\n ids: currentValue,\n });\n\n if (isEmpty(getResponseData(response))) {\n // Try to fetch the current option from v2/assets.\n response = await jsonApi.getAssets({\n ...getRequestOptions(requestAssetType, assetFieldsByAssetType),\n ids: currentValue,\n });\n }\n\n const formattedAsset = formatAsset({\n asset: deserializeAssetResponse(response)[0],\n isPrimaryAsset: true,\n isRequiredAssetId,\n isDrillingPlatformApp,\n });\n\n setCurrentOption(formattedAsset);\n\n if (requestAssetType === ASSET_TYPES.rig.type) {\n const activeWellId = isDrillingPlatformApp\n ? getFirstIncludedId(response)\n : formattedAsset?.activeWellId || null;\n\n onActiveAssetIdChange(activeWellId);\n } else if (requestAssetType === ASSET_TYPES.intervention_unit.type) {\n onActiveAssetIdChange(formattedAsset?.activeWellId || null);\n }\n };\n\n useEffect(() => {\n if (company) {\n setAssets([]);\n }\n }, [company]);\n\n useEffect(() => {\n // Reset assets instead of appending when the search value changes.\n const isSearchValueChanged = prevSearchValue.current !== searchValue;\n const isScrollPageChanged = prevScrollPage.current !== scrollPage;\n const isPagination =\n !isSearchValueChanged &&\n isScrollPageChanged &&\n scrollPage > 1 &&\n (prevScrollPage.current || 0) < scrollPage;\n\n if (isSearchValueChanged) {\n prevSearchValue.current = searchValue;\n }\n\n if (isScrollPageChanged) {\n prevScrollPage.current = scrollPage;\n }\n\n if (groups) {\n groups.forEach(group => {\n loadAssets(group, isPagination);\n });\n\n return;\n }\n\n if (prevAssetType.current && prevAssetType.current !== requestAssetType) {\n setAssets([]);\n }\n\n prevAssetType.current = requestAssetType;\n loadAssets(null, isPagination);\n }, [\n assetType,\n parentAssetType,\n parentAssetId,\n company,\n appKey,\n groups?.length,\n searchValue,\n scrollPage,\n ]);\n\n useEffect(() => {\n if (currentValue) {\n loadCurrentOption();\n }\n }, []);\n\n return { assets, loading };\n};\n"],"names":["usePrimaryAssetSelectData","_ref","appKey","assetType","company","groups","isRequiredAssetId","parentAssetId","parentAssetType","searchValue","_ref$assetFields","assetFields","currentValue","setCurrentOption","scrollPage","onActiveAssetIdChange","isDrillingPlatformApp","useState","_useState2","_slicedToArray","_useState","assets","setAssets","_useState4","_useState3","loading","setLoading","prevCompany","useRef","prevAssetType","prevSearchValue","prevScrollPage","requestAssetType","DEFAULT_ASSET_TYPE","assetFieldsByAssetType","ASSET_TYPES","pad","type","concat","_toConsumableArray","loadAssets","_ref2","_asyncToGenerator","_regeneratorRuntime","mark","group","shouldAppend","currentAssetType","requestParams","response","responseAssets","_args","arguments","wrap","_context","prev","next","per_page","PER_PAGE","page","search","app_key","current","jsonApi","_objectSpread","getRequestOptions","sent","deserializeAssetResponse","map","asset","formatAsset","name","isPrimaryAsset","filter","isAssetOption","sort","sortAsset","prevState","uniqBy","t0","console","error","finish","stop","_callee","_x","apply","this","loadCurrentOption","_ref3","_callee2","formattedAsset","activeWellId","_context2","ids","isEmpty","getResponseData","rig","getFirstIncludedId","intervention_unit","useEffect","isSearchValueChanged","isScrollPageChanged","isPagination","forEach","length"],"mappings":"8yEAiCaA,IAAAA,EAA4B,SAe2CC,GAAA,IAdlFC,IAAAA,OACAC,IAAAA,UACAC,IAAAA,QACAC,IAAAA,OACAC,IAAAA,kBACAC,IAAAA,cACAC,IAAAA,gBACAC,IAAAA,YAAWC,EAAAT,EACXU,YAAAA,aAAc,GAAED,EAChBE,IAAAA,aACAC,IAAAA,iBACAC,IAAAA,WACAC,IAAAA,sBACAC,IAAAA,sBAE4BC,EAAAA,EAAwB,IAAGC,EAAAC,EAAAC,EAAA,GAAhDC,EAAMH,EAAA,GAAEI,EAASJ,EAAA,GACMD,EAAAA,GAAS,GAAMM,EAAAJ,EAAAK,EAAA,GAAtCC,EAAOF,EAAA,GAAEG,EAAUH,EAAA,GACpBI,EAAcC,EAAmC,MACjDC,EAAgBD,EAAsB,MACtCE,EAAkBF,EAAkC,MACpDG,EAAiBH,EAAsB,MACvCI,EAAmB7B,GAAa8B,EAEhCC,EACJF,IAAqBG,EAAYC,IAAIC,KAAI,GAAAC,OAAAC,EACjC5B,GAAa,CAAA,aAAc,6BAC/BA,EAEA6B,EAAU,WAAA,IAAAC,EAAAC,EAAAC,EAAAC,MAAG,WAAOC,GAAyB,IAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,UAAA,OAAAT,EAAAU,MAAA,SAAAC,GAAA,OAAA,OAAAA,EAAAC,KAAAD,EAAAE,MAAA,KAAA,EAYjB,OAZmBV,kCAAoBQ,EAAAC,KAAA,EAE/DR,GAAmBF,eAAAA,EAAOR,OAAQL,EACxCN,GAAW,GAELsB,EAA6B,CAAES,SAAUC,EAAUC,KAAM7C,GAE3DN,GAAmBD,IAAeyC,EAAcxC,GAAmBD,GACnEH,GAAuB,QAAZA,IAAmB4C,EAAc5C,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DpG,EACAK,EACAD,EACAH,EACAF,EACAG,aAAAA,EAAAA,EAAQoG,OACRhG,EACAK,IAGFsF,GAAU,WACJxF,GACF4E,GAEH,GAAE,IAEI,CAAEnE,OAAAA,EAAQI,QAAAA,EACnB"}
|
|
@@ -1,70 +1,39 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
isHiddenTitle
|
|
15
|
-
isNullable
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
defaultValue: undefined;
|
|
33
|
-
secondaryDefaultValue: undefined;
|
|
34
|
-
isHiddenTitle: boolean;
|
|
35
|
-
appKey: null;
|
|
36
|
-
isVisibleMultipleAssetsToggle: boolean;
|
|
37
|
-
isDisabledSecondaryAssetSelect: boolean;
|
|
38
|
-
primaryAssetFields: never[];
|
|
39
|
-
secondaryAssetFields: never[];
|
|
40
|
-
secondaryAssetHelpText: null;
|
|
41
|
-
onChange: (...args: any[]) => void;
|
|
42
|
-
elementsClassNames: {};
|
|
1
|
+
import { FC, ReactNode } from 'react';
|
|
2
|
+
import { AssetEditorAppType, AssetEditorChange, AssetId, AssetSettings, AssetSettingsChangeHandler } from './types';
|
|
3
|
+
export type { AssetEditorAppType, AssetEditorChange, AssetSettings, AssetSettingsChangeHandler, AssetSettingsPatch, } from './types';
|
|
4
|
+
type AppSettingsAssetEditorProps = {
|
|
5
|
+
appType: AssetEditorAppType;
|
|
6
|
+
settings: AssetSettings;
|
|
7
|
+
onSettingsChange: AssetSettingsChangeHandler;
|
|
8
|
+
appKey?: string | null;
|
|
9
|
+
className?: string;
|
|
10
|
+
company?: AssetId | null;
|
|
11
|
+
defaultValue?: AssetId | null;
|
|
12
|
+
secondaryDefaultValue?: AssetId | null;
|
|
13
|
+
disabled?: boolean;
|
|
14
|
+
isHiddenTitle?: boolean;
|
|
15
|
+
isNullable?: boolean;
|
|
16
|
+
label?: string;
|
|
17
|
+
primaryAssetFields?: string[];
|
|
18
|
+
secondaryAssetFields?: string[];
|
|
19
|
+
isExtendedSelect?: boolean;
|
|
20
|
+
isRequiredAssetId?: boolean;
|
|
21
|
+
isVisibleMultipleAssetsToggle?: boolean;
|
|
22
|
+
assetsLimit?: number | null;
|
|
23
|
+
isDisabledSecondaryAssetSelect?: boolean;
|
|
24
|
+
isDrillingPlatformApp?: boolean;
|
|
25
|
+
secondaryAssetHelpText?: ReactNode;
|
|
26
|
+
onChange?: (change: AssetEditorChange) => void;
|
|
27
|
+
elementsClassNames?: {
|
|
28
|
+
title?: string;
|
|
29
|
+
multiAssetSwitch?: string;
|
|
30
|
+
primaryAssetSelect?: string;
|
|
31
|
+
secondaryAssetSelect?: string;
|
|
43
32
|
};
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
secondaryDefaultValue: PropTypes.Requireable<any>;
|
|
50
|
-
onSettingsChange: PropTypes.Validator<(...args: any[]) => any>;
|
|
51
|
-
label: PropTypes.Requireable<string>;
|
|
52
|
-
isNullable: PropTypes.Requireable<boolean>;
|
|
53
|
-
isHiddenTitle: PropTypes.Requireable<boolean>;
|
|
54
|
-
appKey: PropTypes.Requireable<string>;
|
|
55
|
-
isVisibleMultipleAssetsToggle: PropTypes.Requireable<boolean>;
|
|
56
|
-
isDisabledSecondaryAssetSelect: PropTypes.Requireable<boolean>;
|
|
57
|
-
primaryAssetFields: PropTypes.Requireable<(PropTypes.InferProps<{}> | null | undefined)[]>;
|
|
58
|
-
secondaryAssetFields: PropTypes.Requireable<(PropTypes.InferProps<{}> | null | undefined)[]>;
|
|
59
|
-
secondaryAssetHelpText: PropTypes.Requireable<NonNullable<string | PropTypes.ReactElementLike | null | undefined>>;
|
|
60
|
-
onChange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
61
|
-
elementsClassNames: PropTypes.Requireable<PropTypes.InferProps<{
|
|
62
|
-
title: PropTypes.Requireable<string>;
|
|
63
|
-
multiAssetSwitch: PropTypes.Requireable<string>;
|
|
64
|
-
primaryAssetSelect: PropTypes.Requireable<string>;
|
|
65
|
-
secondaryAssetSelect: PropTypes.Requireable<string>;
|
|
66
|
-
}>>;
|
|
67
|
-
};
|
|
68
|
-
}
|
|
33
|
+
/** @deprecated Retained for WorkflowEditRow compatibility; has no effect. */
|
|
34
|
+
isWorkflowsEditModal?: boolean;
|
|
35
|
+
};
|
|
36
|
+
export type AppSettingsAssetEditorV2Props = AppSettingsAssetEditorProps;
|
|
37
|
+
declare const AppSettingsAssetEditor: FC<AppSettingsAssetEditorProps>;
|
|
69
38
|
export default AppSettingsAssetEditor;
|
|
70
39
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/AssetEditorV2/index.
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/AssetEditorV2/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,SAAS,EAA+B,MAAM,OAAO,CAAC;AAYnE,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EAEjB,OAAO,EAIP,aAAa,EACb,0BAA0B,EAI3B,MAAM,SAAS,CAAC;AAEjB,YAAY,EACV,kBAAkB,EAClB,iBAAiB,EACjB,aAAa,EACb,0BAA0B,EAC1B,kBAAkB,GACnB,MAAM,SAAS,CAAC;AAEjB,KAAK,2BAA2B,GAAG;IACjC,OAAO,EAAE,kBAAkB,CAAC;IAC5B,QAAQ,EAAE,aAAa,CAAC;IACxB,gBAAgB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
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import e from"@babel/runtime/helpers/toConsumableArray";import
|
|
1
|
+
import e from"@babel/runtime/helpers/toConsumableArray";import t from"@babel/runtime/helpers/defineProperty";import s from"@babel/runtime/helpers/slicedToArray";import{useState as r,useRef as n,useEffect as i}from"react";import{isEmpty as a,noop as l}from"lodash";import o from"classnames";import{makeStyles as d}from"@material-ui/core";import"../../constants/goals.js";import{PAD_GROUP as p,FRAC_FLEET_GROUP as c}from"../../constants/segment.js";import"../../constants/alerts.js";import"../../constants/apps.js";import"../../constants/drillstring.js";import"../../constants/completion.js";import"../../constants/appPackages.js";import"../../constants/notifications.js";import"../../constants/feed.js";import"../../constants/bha.js";import{ASSET_TYPES as u}from"../../constants/assetTypes.js";import"../../constants/corvaCompanyId.js";import"../GradientManager/configuration/constants.js";import m from"./components/PrimaryAssetSelect.js";import y from"./components/SecondaryAssetSelect.js";import"./components/SelectItem.js";import f from"./components/MultipleAssetsToggle.js";import v from"./components/PrimaryAssetSelectV2.js";import{ACTIVE_ASSETS_ID as A,ACTIVE_ASSET_ID as g}from"./constants.js";import{getPrimaryAssetFields as b}from"./utils/index.js";import{jsxs as j,jsx as h}from"react/jsx-runtime";function I(e,t){var s=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),s.push.apply(s,r)}return s}function O(e){for(var s=1;s<arguments.length;s++){var r=null!=arguments[s]?arguments[s]:{};s%2?I(Object(r),!0).forEach((function(s){t(e,s,r[s])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):I(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var P=d({title:{fontWeight:400,fontSize:20,margin:"24px 0 16px"}}),S=[],C={},N=function(d){var I,N=d.appKey,T=void 0===N?null:N,D=d.appType,F=d.className,w=d.company,V=d.defaultValue,_=void 0===V?null:V,x=d.secondaryDefaultValue,E=void 0===x?null:x,R=d.disabled,G=d.isHiddenTitle,W=void 0!==G&&G,k=d.isNullable,q=void 0!==k&&k,K=d.label,L=void 0===K?"Choose An Asset":K,M=d.onSettingsChange,H=d.primaryAssetFields,z=void 0===H?S:H,B=d.secondaryAssetFields,J=void 0===B?S:B,Q=d.isExtendedSelect,U=d.isRequiredAssetId,X=d.settings,Y=d.isVisibleMultipleAssetsToggle,Z=void 0!==Y&&Y,$=d.assetsLimit,ee=void 0===$?null:$,te=d.isDisabledSecondaryAssetSelect,se=void 0!==te&&te,re=d.isDrillingPlatformApp,ne=d.secondaryAssetHelpText,ie=void 0===ne?null:ne,ae=d.onChange,le=void 0===ae?l:ae,oe=d.elementsClassNames,de=void 0===oe?C:oe,pe=D.primaryAsset.assetType,ce=null===(I=D.secondaryAsset)||void 0===I?void 0:I.assetType,ue=null==pe?void 0:pe.type,me=null==pe?void 0:pe.id,ye=null==pe?void 0:pe.label,fe=D.primaryAsset.groups,ve=!!ce,Ae=null==ce?void 0:ce.type,ge=null==ce?void 0:ce.id,be=null==ce?void 0:ce.label,je=me?X[me]:null,he=ge?X[ge]:null,Ie=je?Number(je):null,Oe=he?Number(he):E||null,Pe=r({id:Ie||_}),Se=s(Pe,2),Ce=Se[0],Ne=Se[1],Te=r(Oe),De=s(Te,2),Fe=De[0],we=De[1],Ve=r(!1),_e=s(Ve,2),xe=_e[0],Ee=_e[1],Re=r(null),Ge=s(Re,2),We=Ge[0],ke=Ge[1],qe=r(!1),Ke=s(qe,2),Le=Ke[0],Me=Ke[1],He=n(!1),ze=function(e){M(e,He.current)},Be=P(),Je=ue===u.rig.type||ue===u.intervention_unit.type?v:m,Qe=Array.isArray(Ce)?null:Ce,Ue=re&&null!=Qe&&Qe.assetId?Qe.assetId:null==Qe?void 0:Qe.id,Xe=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:He.current;Ne(e?[]:null),we(null),Ee(!1);var t={assets:null};me&&(t[me]=null),ge&&(t[ge]=null),ze(t)},Ye=ve&&(Le?Array.isArray(Ce)&&!!Ce.length&&!xe:(null==Qe?void 0:Qe.id)&&!xe);return i((function(){a(X)&&Xe()}),[X]),j("div",{className:F,children:[!W&&h("div",{className:o(Be.title,de.title),children:"Asset"}),Z&&h(f,{onChange:function(e){He.current=!!e,Me(e),Xe(e)},className:de.multiAssetSwitch,checked:Le}),h("div",{className:de.primaryAssetSelect,children:h(Je,{appKey:T,assetType:ue,company:w,currentOption:Ce,currentValue:null==Qe?void 0:Qe.id,"data-testid":"".concat("DC_AppSettingsAssetEditor","_primaryAssetEditorAutocomplete"),isSecondaryAssetPresent:ve,defaultValue:_,disableClearable:!q,disabled:R,isNullable:q,isRequiredAssetId:U,label:L,multiple:Le,onChange:function(s){if(le({primary:s}),Le)Array.isArray(s)&&function(s){var r,n;if(!(s.length>Number(ee))){var i=(null===(r=s[0])||void 0===r?void 0:r.group)===p.name,a=(null===(n=s[0])||void 0===n?void 0:n.group)===c.name,l=1===s.length&&i,o=1===s.length&&a;if(l?(Ee(!0),ke(p)):o&&ke(c),i){Ne(s);var d=s.reduce((function(t,s){var r=s.parentFracFleetId,n=s.id,i={fracFleetId:r,padId:n};return Q&&(i.assetId=r,i.replacedPadId=n),r?[].concat(e(t),[i]):t}),[]);ze({assets:d})}else{Ne(s);var u=s.reduce((function(s,r){var n=t({},"".concat(r.type,"Id"),r.id);return U&&(n.assetId=r.assetId),Q&&(n.assetId=r.assetId||r.id),[].concat(e(s),[n])}),[]);ze({assets:u})}}}(s);else if(s&&!Array.isArray(s)&&me){var r=s.id,n=s.type,i=s.parentFracFleetId;if(r)if(n!==u.pad.type){Ne(s),we(null);var a=t({},me,r);U&&(a.assetId=s.assetId),ge&&(a[ge]=null),ze(a),Ee(!1)}else{var l;Ne(s),Ee(!0),we(r);var o=(t(l={},u.frac_fleet.id,Number(i)),t(l,u.pad.id,r),l);ze(o)}}},setCurrentOption:Ne,selectedGroup:We,onGroupChange:function(e){ke(e),Xe()},onGroupReset:function(){ke(null),Xe()},groups:fe,onInputReset:Xe,onActiveAssetIdChange:function(e){Ne((function(t){return Array.isArray(t)?t:O(O({},t),{},{activeWellId:e})}))},isDrillingPlatformApp:re,assetFields:b({primaryAssetType:ue,assetFields:z,isDrillingPlatformApp:re})})}),Ye&&j("div",{className:de.secondaryAssetSelect,children:[ie,h(y,{assetFields:Ae===u.pad.type?[].concat(e(J),["pad.active","pad.current"]):J,activeWellId:null==Qe?void 0:Qe.activeWellId,appKey:T,assetType:Ae,company:w,currentValue:Fe,"data-testid":"".concat("DC_AppSettingsAssetEditor","_secondaryAutoComplete"),defaultValue:Le?A:g,disabled:Le||se||R,isDrillingPlatformApp:re,isNullable:q,isRequiredAssetId:U,onChange:function(e){var s=e.id,r=e.assetId,n=e.name;if(ge){le({secondary:{name:n}}),we(s);var i=s===g?null:s,a=t({},ge,i);U&&Ae===u.well.type?ze(O(O({},a),{},{replacedAssetId:re?i:r})):ze(a)}},parentAssetId:Ue,parentAssetType:re?"parent_asset_id":ue,primaryAssetLabel:ye,secondaryAssetLabel:be})]})]})};export{N as default};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/components/AssetEditorV2/index.js"],"sourcesContent":["import { useEffect, useRef, useState } from 'react';\nimport PropTypes from 'prop-types';\nimport { get, isEmpty, noop } from 'lodash';\nimport classNames from 'classnames';\nimport { makeStyles } from '@material-ui/core';\n\nimport { PrimaryAssetSelect, PrimaryAssetSelectV2, SecondaryAssetSelect } from './components';\nimport { ACTIVE_ASSET_ID, ACTIVE_ASSETS_ID } from './constants';\nimport MultipleAssetsToggle from './components/MultipleAssetsToggle';\nimport { getPrimaryAssetFields } from './utils';\n\nimport { ASSET_TYPES } from '~/constants';\nimport { FRAC_FLEET_GROUP, PAD_GROUP } from '~/constants/segment';\n\nconst useStyles = makeStyles({\n title: { fontWeight: 400, fontSize: 20, margin: '24px 0 16px' },\n});\n\nconst PAGE_NAME = 'DC_AppSettingsAssetEditor';\nconst PARENT_ASSET_ID = 'parent_asset_id';\n\nconst AppSettingsAssetEditor = ({\n appKey,\n appType,\n className,\n company,\n defaultValue,\n secondaryDefaultValue,\n disabled,\n isHiddenTitle,\n isNullable,\n label,\n onSettingsChange: propsOnSettingsChange,\n primaryAssetFields,\n secondaryAssetFields,\n isExtendedSelect,\n isRequiredAssetId,\n settings,\n isVisibleMultipleAssetsToggle,\n assetsLimit,\n isDisabledSecondaryAssetSelect,\n isDrillingPlatformApp,\n secondaryAssetHelpText,\n onChange,\n elementsClassNames,\n}) => {\n const primaryAssetType = get(appType, ['primaryAsset', 'assetType', 'type']);\n const primaryAssetIdType = get(appType, ['primaryAsset', 'assetType', 'id']);\n const primaryAssetLabel = get(appType, ['primaryAsset', 'assetType', 'label']);\n const primaryAssetSelectGroups = get(appType, ['primaryAsset', 'groups']);\n\n const isSecondaryAssetPresent = get(appType, ['secondaryAsset'], false);\n\n const secondaryAssetType = get(appType, ['secondaryAsset', 'assetType', 'type']);\n const secondaryAssetIdType = get(appType, ['secondaryAsset', 'assetType', 'id']);\n const secondaryAssetLabel = get(appType, ['secondaryAsset', 'assetType', 'label']);\n\n const currentValue = get(settings, primaryAssetIdType);\n const initialPrimaryAssetId = currentValue ? Number(currentValue) : null;\n const initialSecondaryAssetId = get(settings, secondaryAssetIdType)\n ? Number(get(settings, secondaryAssetIdType))\n : secondaryDefaultValue || null;\n const [primaryAsset, setPrimaryAsset] = useState({ id: initialPrimaryAssetId || defaultValue });\n\n const [secondaryAssetId, setSecondaryAssetId] = useState(initialSecondaryAssetId);\n const [isPadSelectedAsPrimaryAsset, setIsPadSelectedAsPrimaryAsset] = useState(false);\n const [selectedGroup, setSelectedGroup] = useState();\n const [isMultipleAssets, setIsMultipleAssets] = useState(false);\n const isMultipleAssetsRef = useRef(false);\n const onSettingsChange = (...args) => {\n propsOnSettingsChange(...args, isMultipleAssetsRef.current);\n };\n\n const styles = useStyles();\n\n const PrimaryAssetSelectComponent =\n primaryAssetType === ASSET_TYPES.rig.type ||\n primaryAssetType === ASSET_TYPES.intervention_unit.type\n ? PrimaryAssetSelectV2\n : PrimaryAssetSelect;\n\n const parentAssetId =\n isDrillingPlatformApp && primaryAsset?.assetId ? primaryAsset?.assetId : primaryAsset?.id;\n\n const onSecondaryAssetChange = ({ id, assetId, name }) => {\n onChange({ secondary: { name } });\n setSecondaryAssetId(id);\n const secondaryAssetId = id === ACTIVE_ASSET_ID ? null : id;\n const assetSettings = { [secondaryAssetIdType]: secondaryAssetId };\n\n if (isRequiredAssetId && secondaryAssetType === ASSET_TYPES.well.type) {\n onSettingsChange({\n ...assetSettings,\n replacedAssetId: isDrillingPlatformApp ? secondaryAssetId : assetId,\n });\n return;\n }\n\n onSettingsChange(assetSettings);\n };\n\n const onMultipleAssetChange = selected => {\n if (selected.length > assetsLimit) return;\n\n const isPadSelected = selected[0]?.group === PAD_GROUP.name;\n const isFracFleetSelected = selected[0]?.group === FRAC_FLEET_GROUP.name;\n const isFirstPadSelected = selected.length === 1 && isPadSelected;\n const isFirstFracFleetSelected = selected.length === 1 && isFracFleetSelected;\n\n if (isFirstPadSelected) {\n setIsPadSelectedAsPrimaryAsset(true);\n setSelectedGroup(PAD_GROUP);\n } else if (isFirstFracFleetSelected) {\n setSelectedGroup(FRAC_FLEET_GROUP);\n }\n\n if (isPadSelected) {\n setPrimaryAsset(selected);\n const assetsSetting = selected?.reduce((acc, { parentFracFleetId, id }) => {\n const settings = {\n fracFleetId: parentFracFleetId,\n padId: id,\n };\n\n if (isExtendedSelect) {\n settings.assetId = parentFracFleetId;\n settings.replacedPadId = id;\n }\n return parentFracFleetId ? [...acc, settings] : acc;\n }, []);\n\n onSettingsChange({\n assets: assetsSetting,\n });\n return;\n }\n\n setPrimaryAsset(selected);\n const assetsSetting = selected.reduce((acc, asset) => {\n const settings = { [`${asset.type}Id`]: asset.id };\n if (isRequiredAssetId) {\n settings.assetId = asset.assetId;\n }\n if (isExtendedSelect) {\n settings.assetId = asset.assetId || asset.id;\n }\n return [...acc, settings];\n }, []);\n onSettingsChange({\n assets: assetsSetting,\n });\n };\n\n const onPrimaryAssetChange = selected => {\n onChange({ primary: selected });\n if (isMultipleAssets) {\n onMultipleAssetChange(selected);\n return;\n }\n const { id, type, parentFracFleetId } = selected;\n if (!id) return;\n if (type === ASSET_TYPES.pad.type) {\n setPrimaryAsset(selected);\n setIsPadSelectedAsPrimaryAsset(true);\n setSecondaryAssetId(id);\n const assetSetting = {\n [ASSET_TYPES.frac_fleet.id]: Number(parentFracFleetId),\n [ASSET_TYPES.pad.id]: id,\n };\n onSettingsChange(assetSetting);\n return;\n }\n\n setPrimaryAsset(selected);\n setSecondaryAssetId(null);\n const assetSetting = { [primaryAssetIdType]: id };\n if (isRequiredAssetId) assetSetting.assetId = selected.assetId;\n if (secondaryAssetIdType) assetSetting[secondaryAssetIdType] = null;\n onSettingsChange(assetSetting);\n setIsPadSelectedAsPrimaryAsset(false);\n };\n\n const handlePrimaryAssetReset = (defaultValue = {}) => {\n setPrimaryAsset(defaultValue);\n setSecondaryAssetId(null);\n\n setIsPadSelectedAsPrimaryAsset(false);\n const assetSetting = {\n [primaryAssetIdType]: null,\n [secondaryAssetIdType]: null,\n assets: null,\n };\n onSettingsChange(assetSetting);\n };\n\n const handleMultipleAssetsChange = checked => {\n isMultipleAssetsRef.current = !!checked;\n setIsMultipleAssets(checked);\n handlePrimaryAssetReset(checked && []);\n };\n\n const handleGroupChange = newGroup => {\n setSelectedGroup(newGroup);\n handlePrimaryAssetReset(isMultipleAssets && []);\n };\n\n const handleGroupReset = () => {\n setSelectedGroup(null);\n handlePrimaryAssetReset(isMultipleAssets && []);\n };\n\n const secondaryAssetSelectIsVisible =\n isSecondaryAssetPresent &&\n (isMultipleAssets\n ? Boolean(primaryAsset.length) && !isPadSelectedAsPrimaryAsset\n : primaryAsset?.id && !isPadSelectedAsPrimaryAsset);\n\n useEffect(() => {\n if (isEmpty(settings)) {\n handlePrimaryAssetReset(isMultipleAssets && []);\n }\n }, [settings]);\n\n return (\n <div className={classNames(styles.main, className)}>\n {!isHiddenTitle && (\n <div className={classNames(styles.title, elementsClassNames.title)}>Asset</div>\n )}\n {isVisibleMultipleAssetsToggle && (\n <MultipleAssetsToggle\n onChange={handleMultipleAssetsChange}\n className={elementsClassNames.multiAssetSwitch}\n checked={isMultipleAssets}\n />\n )}\n <div className={elementsClassNames.primaryAssetSelect}>\n <PrimaryAssetSelectComponent\n appKey={appKey}\n assetType={primaryAssetType}\n company={company}\n currentOption={primaryAsset}\n currentValue={primaryAsset?.id}\n data-testid={`${PAGE_NAME}_primaryAssetEditorAutocomplete`}\n isSecondaryAssetPresent={isSecondaryAssetPresent}\n defaultValue={defaultValue}\n disableClearable={!isNullable}\n disabled={disabled}\n isNullable={isNullable}\n isRequiredAssetId={isRequiredAssetId}\n label={label}\n multiple={isMultipleAssets}\n onChange={onPrimaryAssetChange}\n setCurrentOption={setPrimaryAsset}\n selectedGroup={selectedGroup}\n onGroupChange={handleGroupChange}\n onGroupReset={handleGroupReset}\n groups={primaryAssetSelectGroups}\n onInputReset={handlePrimaryAssetReset}\n onActiveAssetIdChange={activeAssetId => {\n setPrimaryAsset(primaryAsset => ({ ...primaryAsset, activeWellId: activeAssetId }));\n }}\n isDrillingPlatformApp={isDrillingPlatformApp}\n assetFields={getPrimaryAssetFields(\n primaryAssetType,\n primaryAssetFields,\n isDrillingPlatformApp\n )}\n />\n </div>\n {secondaryAssetSelectIsVisible && (\n <div className={elementsClassNames.secondaryAssetSelect}>\n {secondaryAssetHelpText}\n <SecondaryAssetSelect\n assetFields={\n secondaryAssetType === ASSET_TYPES.pad.type\n ? [...secondaryAssetFields, 'pad.active', 'pad.current']\n : secondaryAssetFields\n }\n activeWellId={primaryAsset?.activeWellId}\n appKey={appKey}\n assetType={secondaryAssetType}\n company={company}\n currentValue={secondaryAssetId}\n data-testid={`${PAGE_NAME}_secondaryAutoComplete`}\n defaultValue={isMultipleAssets ? ACTIVE_ASSETS_ID : ACTIVE_ASSET_ID}\n disabled={isMultipleAssets || isDisabledSecondaryAssetSelect || disabled}\n isDrillingPlatformApp={isDrillingPlatformApp}\n isNullable={isNullable}\n isRequiredAssetId={isRequiredAssetId}\n onChange={onSecondaryAssetChange}\n parentAssetId={parentAssetId}\n parentAssetType={isDrillingPlatformApp ? PARENT_ASSET_ID : primaryAssetType}\n primaryAssetLabel={primaryAssetLabel}\n secondaryAssetLabel={secondaryAssetLabel}\n />\n </div>\n )}\n </div>\n );\n};\n\nAppSettingsAssetEditor.defaultProps = {\n assetsLimit: null,\n label: 'Choose An Asset',\n isNullable: false,\n defaultValue: undefined,\n secondaryDefaultValue: undefined,\n isHiddenTitle: false,\n appKey: null,\n isVisibleMultipleAssetsToggle: false,\n isDisabledSecondaryAssetSelect: false,\n primaryAssetFields: [],\n secondaryAssetFields: [],\n secondaryAssetHelpText: null,\n onChange: noop,\n elementsClassNames: {},\n};\n\nAppSettingsAssetEditor.propTypes = {\n assetsLimit: PropTypes.number,\n settings: PropTypes.shape({}).isRequired,\n appType: PropTypes.shape({}).isRequired,\n defaultValue: PropTypes.any, // eslint-disable-line react/forbid-prop-types\n secondaryDefaultValue: PropTypes.any, // eslint-disable-line react/forbid-prop-types\n onSettingsChange: PropTypes.func.isRequired,\n label: PropTypes.string,\n isNullable: PropTypes.bool,\n isHiddenTitle: PropTypes.bool,\n appKey: PropTypes.string,\n isVisibleMultipleAssetsToggle: PropTypes.bool,\n isDisabledSecondaryAssetSelect: PropTypes.bool,\n primaryAssetFields: PropTypes.arrayOf(PropTypes.shape({})),\n secondaryAssetFields: PropTypes.arrayOf(PropTypes.shape({})),\n secondaryAssetHelpText: PropTypes.oneOfType([PropTypes.element, PropTypes.string]),\n onChange: PropTypes.func,\n elementsClassNames: PropTypes.shape({\n title: PropTypes.string,\n multiAssetSwitch: PropTypes.string,\n primaryAssetSelect: PropTypes.string,\n secondaryAssetSelect: PropTypes.string,\n }),\n};\n\nexport default AppSettingsAssetEditor;\n"],"names":["useStyles","makeStyles","title","fontWeight","fontSize","margin","AppSettingsAssetEditor","_ref","appKey","appType","className","company","defaultValue","secondaryDefaultValue","disabled","isHiddenTitle","isNullable","label","propsOnSettingsChange","onSettingsChange","primaryAssetFields","secondaryAssetFields","isExtendedSelect","isRequiredAssetId","settings","isVisibleMultipleAssetsToggle","assetsLimit","isDisabledSecondaryAssetSelect","isDrillingPlatformApp","secondaryAssetHelpText","onChange","elementsClassNames","primaryAssetType","get","primaryAssetIdType","primaryAssetLabel","primaryAssetSelectGroups","isSecondaryAssetPresent","secondaryAssetType","secondaryAssetIdType","secondaryAssetLabel","currentValue","initialPrimaryAssetId","Number","initialSecondaryAssetId","_useState","useState","id","_useState2","_slicedToArray","primaryAsset","setPrimaryAsset","_useState4","_useState3","secondaryAssetId","setSecondaryAssetId","_useState6","_useState5","isPadSelectedAsPrimaryAsset","setIsPadSelectedAsPrimaryAsset","_useState7","_useState8","selectedGroup","setSelectedGroup","_useState10","_useState9","isMultipleAssets","setIsMultipleAssets","isMultipleAssetsRef","useRef","_len","arguments","length","args","Array","_key","concat","current","styles","PrimaryAssetSelectComponent","ASSET_TYPES","rig","type","intervention_unit","PrimaryAssetSelectV2","PrimaryAssetSelect","parentAssetId","assetId","handlePrimaryAssetReset","_assetSetting4","undefined","assetSetting","_defineProperty","secondaryAssetSelectIsVisible","Boolean","useEffect","isEmpty","_jsxs","classNames","main","children","_jsx","MultipleAssetsToggle","checked","multiAssetSwitch","primaryAssetSelect","assetType","currentOption","disableClearable","multiple","selected","primary","_selected$","_selected$2","isPadSelected","group","PAD_GROUP","name","isFracFleetSelected","FRAC_FLEET_GROUP","isFirstPadSelected","isFirstFracFleetSelected","assetsSetting","reduce","acc","_ref3","parentFracFleetId","fracFleetId","padId","replacedPadId","assets","asset","onMultipleAssetChange","pad","_assetSetting2","frac_fleet","setCurrentOption","onGroupChange","newGroup","onGroupReset","groups","onInputReset","onActiveAssetIdChange","activeAssetId","_objectSpread","activeWellId","assetFields","getPrimaryAssetFields","secondaryAssetSelect","SecondaryAssetSelect","_toConsumableArray","ACTIVE_ASSETS_ID","ACTIVE_ASSET_ID","_ref2","secondary","assetSettings","well","replacedAssetId","parentAssetType","defaultProps","noop","propTypes","PropTypes","number","shape","isRequired","any","func","string","bool","arrayOf","oneOfType","element"],"mappings":"83DAcA,IAAMA,EAAYC,EAAW,CAC3BC,MAAO,CAAEC,WAAY,IAAKC,SAAU,GAAIC,OAAQ,iBAM5CC,EAAyB,SAwBzBC,GAAA,IAvBJC,IAAAA,OACAC,IAAAA,QACAC,IAAAA,UACAC,IAAAA,QACAC,IAAAA,aACAC,IAAAA,sBACAC,IAAAA,SACAC,IAAAA,cACAC,IAAAA,WACAC,IAAAA,MACkBC,IAAlBC,iBACAC,IAAAA,mBACAC,IAAAA,qBACAC,IAAAA,iBACAC,IAAAA,kBACAC,IAAAA,SACAC,IAAAA,8BACAC,IAAAA,YACAC,IAAAA,+BACAC,IAAAA,sBACAC,IAAAA,uBACAC,IAAAA,SACAC,IAAAA,mBAEMC,EAAmBC,EAAIxB,EAAS,CAAC,eAAgB,YAAa,SAC9DyB,EAAqBD,EAAIxB,EAAS,CAAC,eAAgB,YAAa,OAChE0B,EAAoBF,EAAIxB,EAAS,CAAC,eAAgB,YAAa,UAC/D2B,EAA2BH,EAAIxB,EAAS,CAAC,eAAgB,WAEzD4B,EAA0BJ,EAAIxB,EAAS,CAAC,mBAAmB,GAE3D6B,EAAqBL,EAAIxB,EAAS,CAAC,iBAAkB,YAAa,SAClE8B,EAAuBN,EAAIxB,EAAS,CAAC,iBAAkB,YAAa,OACpE+B,GAAsBP,EAAIxB,EAAS,CAAC,iBAAkB,YAAa,UAEnEgC,GAAeR,EAAIT,EAAUU,GAC7BQ,GAAwBD,GAAeE,OAAOF,IAAgB,KAC9DG,GAA0BX,EAAIT,EAAUe,GAC1CI,OAAOV,EAAIT,EAAUe,IACrB1B,GAAyB,KAC7Bg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CAChBE,gBAAiBjI,EAAwB0B,EAAmBiC,KAKhEpE,GAAiBwI,IAgMTrE,cAAeA,GACfwE,gBAAiBlI,EAhRL,kBAgR+CI,EAC3DG,kBAAmBA,EACnBK,oBAAqBA,UAMjC,EAEAlC,EAAuByJ,aAAe,CACpCrI,YAAa,KACbT,MAAO,kBACPD,YAAY,EACZJ,kBAAc8E,EACd7E,2BAAuB6E,EACvB3E,eAAe,EACfP,OAAQ,KACRiB,+BAA+B,EAC/BE,gCAAgC,EAChCP,mBAAoB,GACpBC,qBAAsB,GACtBQ,uBAAwB,KACxBC,SAAUkI,EACVjI,mBAAoB,CAAC,GAGvBzB,EAAuB2J,UAAY,CACjCvI,YAAawI,EAAUC,OACvB3I,SAAU0I,EAAUE,MAAM,CAAA,GAAIC,WAC9B5J,QAASyJ,EAAUE,MAAM,CAAA,GAAIC,WAC7BzJ,aAAcsJ,EAAUI,IACxBzJ,sBAAuBqJ,EAAUI,IACjCnJ,iBAAkB+I,EAAUK,KAAKF,WACjCpJ,MAAOiJ,EAAUM,OACjBxJ,WAAYkJ,EAAUO,KACtB1J,cAAemJ,EAAUO,KACzBjK,OAAQ0J,EAAUM,OAClB/I,8BAA+ByI,EAAUO,KACzC9I,+BAAgCuI,EAAUO,KAC1CrJ,mBAAoB8I,EAAUQ,QAAQR,EAAUE,MAAM,CAAE,IACxD/I,qBAAsB6I,EAAUQ,QAAQR,EAAUE,MAAM,CAAE,IAC1DvI,uBAAwBqI,EAAUS,UAAU,CAACT,EAAUU,QAASV,EAAUM,SAC1E1I,SAAUoI,EAAUK,KACpBxI,mBAAoBmI,EAAUE,MAAM,CAClClK,MAAOgK,EAAUM,OACjBhE,iBAAkB0D,EAAUM,OAC5B/D,mBAAoByD,EAAUM,OAC9BpB,qBAAsBc,EAAUM"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/components/AssetEditorV2/index.tsx"],"sourcesContent":["import { FC, ReactNode, useEffect, useRef, useState } from 'react';\nimport { isEmpty, noop } from 'lodash';\nimport classNames from 'classnames';\nimport { makeStyles } from '@material-ui/core';\n\nimport { ASSET_TYPES } from '~/constants';\nimport { FRAC_FLEET_GROUP, PAD_GROUP } from '~/constants/segment';\n\nimport { PrimaryAssetSelect, PrimaryAssetSelectV2, SecondaryAssetSelect } from './components';\nimport { ACTIVE_ASSET_ID, ACTIVE_ASSETS_ID } from './constants';\nimport MultipleAssetsToggle from './components/MultipleAssetsToggle';\nimport { getPrimaryAssetFields } from './utils';\nimport {\n AssetEditorAppType,\n AssetEditorChange,\n AssetGroup,\n AssetId,\n AssetOption,\n AssetSelection,\n AssetSelectionSettings,\n AssetSettings,\n AssetSettingsChangeHandler,\n AssetSettingsPatch,\n PrimaryAssetChange,\n SecondaryAssetChange,\n} from './types';\n\nexport type {\n AssetEditorAppType,\n AssetEditorChange,\n AssetSettings,\n AssetSettingsChangeHandler,\n AssetSettingsPatch,\n} from './types';\n\ntype AppSettingsAssetEditorProps = {\n appType: AssetEditorAppType;\n settings: AssetSettings;\n onSettingsChange: AssetSettingsChangeHandler;\n appKey?: string | null;\n className?: string;\n company?: AssetId | null;\n defaultValue?: AssetId | null;\n secondaryDefaultValue?: AssetId | null;\n disabled?: boolean;\n isHiddenTitle?: boolean;\n isNullable?: boolean;\n label?: string;\n primaryAssetFields?: string[];\n secondaryAssetFields?: string[];\n isExtendedSelect?: boolean;\n isRequiredAssetId?: boolean;\n isVisibleMultipleAssetsToggle?: boolean;\n assetsLimit?: number | null;\n isDisabledSecondaryAssetSelect?: boolean;\n isDrillingPlatformApp?: boolean;\n secondaryAssetHelpText?: ReactNode;\n onChange?: (change: AssetEditorChange) => void;\n elementsClassNames?: {\n title?: string;\n multiAssetSwitch?: string;\n primaryAssetSelect?: string;\n secondaryAssetSelect?: string;\n };\n /** @deprecated Retained for WorkflowEditRow compatibility; has no effect. */\n isWorkflowsEditModal?: boolean;\n};\n\nexport type AppSettingsAssetEditorV2Props = AppSettingsAssetEditorProps;\n\nconst useStyles = makeStyles({\n title: { fontWeight: 400, fontSize: 20, margin: '24px 0 16px' },\n});\n\nconst PAGE_NAME = 'DC_AppSettingsAssetEditor';\nconst PARENT_ASSET_ID = 'parent_asset_id';\nconst DEFAULT_ASSET_FIELDS: string[] = [];\nconst DEFAULT_ELEMENT_CLASS_NAMES: NonNullable<AppSettingsAssetEditorProps['elementsClassNames']> =\n {};\n\nconst AppSettingsAssetEditor: FC<AppSettingsAssetEditorProps> = ({\n appKey = null,\n appType,\n className,\n company,\n defaultValue = null,\n secondaryDefaultValue = null,\n disabled,\n isHiddenTitle = false,\n isNullable = false,\n label = 'Choose An Asset',\n onSettingsChange: propsOnSettingsChange,\n primaryAssetFields = DEFAULT_ASSET_FIELDS,\n secondaryAssetFields = DEFAULT_ASSET_FIELDS,\n isExtendedSelect,\n isRequiredAssetId,\n settings,\n isVisibleMultipleAssetsToggle = false,\n assetsLimit = null,\n isDisabledSecondaryAssetSelect = false,\n isDrillingPlatformApp,\n secondaryAssetHelpText = null,\n onChange = noop,\n elementsClassNames = DEFAULT_ELEMENT_CLASS_NAMES,\n}) => {\n const primaryDescriptor = appType.primaryAsset.assetType;\n const secondaryDescriptor = appType.secondaryAsset?.assetType;\n const primaryAssetType = primaryDescriptor?.type;\n const primaryAssetIdType = primaryDescriptor?.id;\n const primaryAssetLabel = primaryDescriptor?.label;\n const primaryAssetSelectGroups = appType.primaryAsset.groups;\n const isSecondaryAssetPresent = !!secondaryDescriptor;\n const secondaryAssetType = secondaryDescriptor?.type;\n const secondaryAssetIdType = secondaryDescriptor?.id;\n const secondaryAssetLabel = secondaryDescriptor?.label;\n\n const currentValue = primaryAssetIdType ? settings[primaryAssetIdType] : null;\n const currentSecondaryValue = secondaryAssetIdType ? settings[secondaryAssetIdType] : null;\n const initialPrimaryAssetId = currentValue ? Number(currentValue) : null;\n const initialSecondaryAssetId = currentSecondaryValue\n ? Number(currentSecondaryValue)\n : secondaryDefaultValue || null;\n const [primaryAsset, setPrimaryAsset] = useState<AssetSelection>({\n id: initialPrimaryAssetId || defaultValue,\n });\n const [secondaryAssetId, setSecondaryAssetId] = useState<AssetId | null>(initialSecondaryAssetId);\n const [isPadSelectedAsPrimaryAsset, setIsPadSelectedAsPrimaryAsset] = useState(false);\n const [selectedGroup, setSelectedGroup] = useState<AssetGroup | null>(null);\n const [isMultipleAssets, setIsMultipleAssets] = useState(false);\n const isMultipleAssetsRef = useRef(false);\n\n const onSettingsChange = (settingsPatch: AssetSettingsPatch) => {\n propsOnSettingsChange(settingsPatch, isMultipleAssetsRef.current);\n };\n\n const styles = useStyles();\n\n const PrimaryAssetSelectComponent =\n primaryAssetType === ASSET_TYPES.rig.type ||\n primaryAssetType === ASSET_TYPES.intervention_unit.type\n ? PrimaryAssetSelectV2\n : PrimaryAssetSelect;\n\n const primaryOption = Array.isArray(primaryAsset) ? null : primaryAsset;\n const parentAssetId =\n isDrillingPlatformApp && primaryOption?.assetId ? primaryOption.assetId : primaryOption?.id;\n\n const onSecondaryAssetChange = ({ id, assetId, name }: SecondaryAssetChange) => {\n if (!secondaryAssetIdType) return;\n\n onChange({ secondary: { name } });\n setSecondaryAssetId(id);\n const selectedAssetId = id === ACTIVE_ASSET_ID ? null : id;\n const assetSettings = { [secondaryAssetIdType]: selectedAssetId };\n\n if (isRequiredAssetId && secondaryAssetType === ASSET_TYPES.well.type) {\n onSettingsChange({\n ...assetSettings,\n replacedAssetId: isDrillingPlatformApp ? selectedAssetId : assetId,\n });\n return;\n }\n\n onSettingsChange(assetSettings);\n };\n\n const onMultipleAssetChange = (selected: AssetOption[]) => {\n // The legacy null limit allows no selections; explicit limits opt into multiple assets.\n if (selected.length > Number(assetsLimit)) return;\n\n const isPadSelected = selected[0]?.group === PAD_GROUP.name;\n const isFracFleetSelected = selected[0]?.group === FRAC_FLEET_GROUP.name;\n const isFirstPadSelected = selected.length === 1 && isPadSelected;\n const isFirstFracFleetSelected = selected.length === 1 && isFracFleetSelected;\n\n if (isFirstPadSelected) {\n setIsPadSelectedAsPrimaryAsset(true);\n setSelectedGroup(PAD_GROUP);\n } else if (isFirstFracFleetSelected) {\n setSelectedGroup(FRAC_FLEET_GROUP);\n }\n\n if (isPadSelected) {\n setPrimaryAsset(selected);\n const assetsSetting = selected.reduce<AssetSelectionSettings[]>(\n (acc, { parentFracFleetId, id }) => {\n const assetSettings: AssetSelectionSettings = {\n fracFleetId: parentFracFleetId,\n padId: id,\n };\n\n if (isExtendedSelect) {\n assetSettings.assetId = parentFracFleetId;\n assetSettings.replacedPadId = id;\n }\n return parentFracFleetId ? [...acc, assetSettings] : acc;\n },\n []\n );\n\n onSettingsChange({\n assets: assetsSetting,\n });\n return;\n }\n\n setPrimaryAsset(selected);\n const assetsSetting = selected.reduce<AssetSelectionSettings[]>((acc, asset) => {\n const assetSettings: AssetSelectionSettings = { [`${asset.type}Id`]: asset.id };\n if (isRequiredAssetId) {\n assetSettings.assetId = asset.assetId;\n }\n if (isExtendedSelect) {\n assetSettings.assetId = asset.assetId || asset.id;\n }\n return [...acc, assetSettings];\n }, []);\n onSettingsChange({\n assets: assetsSetting,\n });\n };\n\n const onPrimaryAssetChange = (selected: PrimaryAssetChange) => {\n onChange({ primary: selected });\n if (isMultipleAssets) {\n if (Array.isArray(selected)) onMultipleAssetChange(selected);\n return;\n }\n\n if (!selected || Array.isArray(selected) || !primaryAssetIdType) return;\n\n const { id, type, parentFracFleetId } = selected;\n if (!id) return;\n if (type === ASSET_TYPES.pad.type) {\n setPrimaryAsset(selected);\n setIsPadSelectedAsPrimaryAsset(true);\n setSecondaryAssetId(id);\n const assetSetting = {\n [ASSET_TYPES.frac_fleet.id]: Number(parentFracFleetId),\n [ASSET_TYPES.pad.id]: id,\n };\n onSettingsChange(assetSetting);\n return;\n }\n\n setPrimaryAsset(selected);\n setSecondaryAssetId(null);\n const assetSetting: AssetSettingsPatch = { [primaryAssetIdType]: id };\n if (isRequiredAssetId) assetSetting.assetId = selected.assetId;\n if (secondaryAssetIdType) assetSetting[secondaryAssetIdType] = null;\n onSettingsChange(assetSetting);\n setIsPadSelectedAsPrimaryAsset(false);\n };\n\n const handlePrimaryAssetReset = (isMultiple = isMultipleAssetsRef.current) => {\n setPrimaryAsset(isMultiple ? [] : null);\n setSecondaryAssetId(null);\n\n setIsPadSelectedAsPrimaryAsset(false);\n const assetSetting: AssetSettingsPatch = { assets: null };\n if (primaryAssetIdType) assetSetting[primaryAssetIdType] = null;\n if (secondaryAssetIdType) assetSetting[secondaryAssetIdType] = null;\n onSettingsChange(assetSetting);\n };\n\n const handleMultipleAssetsChange = (checked: boolean) => {\n isMultipleAssetsRef.current = !!checked;\n setIsMultipleAssets(checked);\n handlePrimaryAssetReset(checked);\n };\n\n const handleGroupChange = (newGroup: AssetGroup | null) => {\n setSelectedGroup(newGroup);\n handlePrimaryAssetReset();\n };\n\n const handleGroupReset = () => {\n setSelectedGroup(null);\n handlePrimaryAssetReset();\n };\n\n const secondaryAssetSelectIsVisible =\n isSecondaryAssetPresent &&\n (isMultipleAssets\n ? Array.isArray(primaryAsset) && !!primaryAsset.length && !isPadSelectedAsPrimaryAsset\n : primaryOption?.id && !isPadSelectedAsPrimaryAsset);\n\n useEffect(() => {\n if (isEmpty(settings)) {\n handlePrimaryAssetReset();\n }\n }, [settings]);\n\n return (\n <div className={className}>\n {!isHiddenTitle && (\n <div className={classNames(styles.title, elementsClassNames.title)}>Asset</div>\n )}\n {isVisibleMultipleAssetsToggle && (\n <MultipleAssetsToggle\n onChange={handleMultipleAssetsChange}\n className={elementsClassNames.multiAssetSwitch}\n checked={isMultipleAssets}\n />\n )}\n <div className={elementsClassNames.primaryAssetSelect}>\n <PrimaryAssetSelectComponent\n appKey={appKey}\n assetType={primaryAssetType}\n company={company}\n currentOption={primaryAsset}\n currentValue={primaryOption?.id}\n data-testid={`${PAGE_NAME}_primaryAssetEditorAutocomplete`}\n isSecondaryAssetPresent={isSecondaryAssetPresent}\n defaultValue={defaultValue}\n disableClearable={!isNullable}\n disabled={disabled}\n isNullable={isNullable}\n isRequiredAssetId={isRequiredAssetId}\n label={label}\n multiple={isMultipleAssets}\n onChange={onPrimaryAssetChange}\n setCurrentOption={setPrimaryAsset}\n selectedGroup={selectedGroup}\n onGroupChange={handleGroupChange}\n onGroupReset={handleGroupReset}\n groups={primaryAssetSelectGroups}\n onInputReset={handlePrimaryAssetReset}\n onActiveAssetIdChange={activeAssetId => {\n setPrimaryAsset(current =>\n Array.isArray(current) ? current : { ...current, activeWellId: activeAssetId }\n );\n }}\n isDrillingPlatformApp={isDrillingPlatformApp}\n assetFields={getPrimaryAssetFields({\n primaryAssetType,\n assetFields: primaryAssetFields,\n isDrillingPlatformApp,\n })}\n />\n </div>\n {secondaryAssetSelectIsVisible && (\n <div className={elementsClassNames.secondaryAssetSelect}>\n {secondaryAssetHelpText}\n <SecondaryAssetSelect\n assetFields={\n secondaryAssetType === ASSET_TYPES.pad.type\n ? [...secondaryAssetFields, 'pad.active', 'pad.current']\n : secondaryAssetFields\n }\n activeWellId={primaryOption?.activeWellId}\n appKey={appKey}\n assetType={secondaryAssetType}\n company={company}\n currentValue={secondaryAssetId}\n data-testid={`${PAGE_NAME}_secondaryAutoComplete`}\n defaultValue={isMultipleAssets ? ACTIVE_ASSETS_ID : ACTIVE_ASSET_ID}\n disabled={isMultipleAssets || isDisabledSecondaryAssetSelect || disabled}\n isDrillingPlatformApp={isDrillingPlatformApp}\n isNullable={isNullable}\n isRequiredAssetId={isRequiredAssetId}\n onChange={onSecondaryAssetChange}\n parentAssetId={parentAssetId}\n parentAssetType={isDrillingPlatformApp ? PARENT_ASSET_ID : primaryAssetType}\n primaryAssetLabel={primaryAssetLabel}\n secondaryAssetLabel={secondaryAssetLabel}\n />\n </div>\n )}\n </div>\n );\n};\n\nexport default AppSettingsAssetEditor;\n"],"names":["useStyles","makeStyles","title","fontWeight","fontSize","margin","DEFAULT_ASSET_FIELDS","DEFAULT_ELEMENT_CLASS_NAMES","AppSettingsAssetEditor","_ref","_appType$secondaryAss","_ref$appKey","appKey","appType","className","company","_ref$defaultValue","defaultValue","_ref$secondaryDefault","secondaryDefaultValue","disabled","_ref$isHiddenTitle","isHiddenTitle","_ref$isNullable","isNullable","_ref$label","label","propsOnSettingsChange","onSettingsChange","_ref$primaryAssetFiel","primaryAssetFields","_ref$secondaryAssetFi","secondaryAssetFields","isExtendedSelect","isRequiredAssetId","settings","_ref$isVisibleMultipl","isVisibleMultipleAssetsToggle","_ref$assetsLimit","assetsLimit","_ref$isDisabledSecond","isDisabledSecondaryAssetSelect","isDrillingPlatformApp","_ref$secondaryAssetHe","secondaryAssetHelpText","_ref$onChange","onChange","noop","_ref$elementsClassNam","elementsClassNames","primaryDescriptor","primaryAsset","assetType","secondaryDescriptor","secondaryAsset","primaryAssetType","type","primaryAssetIdType","id","primaryAssetLabel","primaryAssetSelectGroups","groups","isSecondaryAssetPresent","secondaryAssetType","secondaryAssetIdType","secondaryAssetLabel","currentValue","currentSecondaryValue","initialPrimaryAssetId","Number","initialSecondaryAssetId","_useState","useState","_useState2","_slicedToArray","setPrimaryAsset","_useState4","_useState3","secondaryAssetId","setSecondaryAssetId","_useState6","_useState5","isPadSelectedAsPrimaryAsset","setIsPadSelectedAsPrimaryAsset","_useState8","_useState7","selectedGroup","setSelectedGroup","_useState10","_useState9","isMultipleAssets","setIsMultipleAssets","isMultipleAssetsRef","useRef","settingsPatch","current","styles","PrimaryAssetSelectComponent","ASSET_TYPES","rig","intervention_unit","PrimaryAssetSelectV2","PrimaryAssetSelect","primaryOption","Array","isArray","parentAssetId","assetId","handlePrimaryAssetReset","isMultiple","arguments","length","undefined","assetSetting","assets","secondaryAssetSelectIsVisible","useEffect","isEmpty","_jsxs","children","_jsx","classNames","MultipleAssetsToggle","checked","multiAssetSwitch","primaryAssetSelect","currentOption","concat","disableClearable","multiple","selected","primary","_selected$","_selected$2","isPadSelected","group","PAD_GROUP","name","isFracFleetSelected","FRAC_FLEET_GROUP","isFirstPadSelected","isFirstFracFleetSelected","assetsSetting","reduce","acc","_ref3","parentFracFleetId","assetSettings","fracFleetId","padId","replacedPadId","asset","onMultipleAssetChange","pad","_defineProperty","_assetSetting2","frac_fleet","setCurrentOption","onGroupChange","newGroup","onGroupReset","onInputReset","onActiveAssetIdChange","activeAssetId","_objectSpread","activeWellId","assetFields","getPrimaryAssetFields","secondaryAssetSelect","SecondaryAssetSelect","_toConsumableArray","ACTIVE_ASSETS_ID","ACTIVE_ASSET_ID","_ref2","secondary","selectedAssetId","well","replacedAssetId","parentAssetType"],"mappings":"21DAsEA,IAAMA,EAAYC,EAAW,CAC3BC,MAAO,CAAEC,WAAY,IAAKC,SAAU,GAAIC,OAAQ,iBAK5CC,EAAiC,GACjCC,EACJ,CAAA,EAEIC,EAA0D,SAwB1DC,GAAA,IAAAC,EAAAC,EAAAF,EAvBJG,OAAAA,aAAS,KAAID,EACbE,IAAAA,QACAC,IAAAA,UACAC,IAAAA,QAAOC,EAAAP,EACPQ,aAAAA,aAAe,KAAID,EAAAE,EAAAT,EACnBU,sBAAAA,aAAwB,KAAID,EAC5BE,IAAAA,SAAQC,EAAAZ,EACRa,cAAAA,cAAqBD,EAAAE,EAAAd,EACrBe,WAAAA,cAAkBD,EAAAE,EAAAhB,EAClBiB,MAAAA,aAAQ,kBAAiBD,EACPE,IAAlBC,iBAAgBC,EAAApB,EAChBqB,mBAAAA,aAAqBxB,EAAoBuB,EAAAE,EAAAtB,EACzCuB,qBAAAA,aAAuB1B,EAAoByB,EAC3CE,IAAAA,iBACAC,IAAAA,kBACAC,IAAAA,SAAQC,EAAA3B,EACR4B,8BAAAA,cAAqCD,EAAAE,EAAA7B,EACrC8B,YAAAA,cAAc,KAAID,EAAAE,GAAA/B,EAClBgC,+BAAAA,gBAAsCD,GACtCE,KAAAA,sBAAqBC,GAAAlC,EACrBmC,uBAAAA,eAAyB,KAAID,GAAAE,GAAApC,EAC7BqC,SAAAA,eAAWC,EAAIF,GAAAG,GAAAvC,EACfwC,mBAAAA,eAAqB1C,EAA2ByC,GAE1CE,GAAoBrC,EAAQsC,aAAaC,U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WW,GACXhD,QAASA,EACTmD,aAAcY,GACd,cAAA,GAAAiD,OAzRM,4BAyR4C,0BAClD9G,aAAcyE,GAAmBiF,EAAmBC,EACpDxJ,SAAUsE,IAAoBjD,IAAkCrB,EAChEsB,sBAAuBA,GACvBlB,WAAYA,EACZU,kBAAmBA,EACnBY,SAtNqB,SAAiD+H,GAAA,IAA9CnH,IAAAA,GAAIiD,IAAAA,QAAS8B,IAAAA,KAC7C,GAAKzE,GAAL,CAEAlB,GAAS,CAAEgI,UAAW,CAAErC,KAAAA,KACxB1D,GAAoBrB,GACpB,IAAMqH,EAAkBrH,IAAOkH,EAAkB,KAAOlH,EAClDyF,EAAaO,EAAA,CAAA,EAAM1F,GAAuB+G,GAE5C7I,GAAqB6B,KAAuBmC,EAAY8E,KAAKxH,KAC/D5B,UACKuH,GAAa,CAAA,EAAA,CAChB8B,gBAAiBvI,GAAwBqI,EAAkBpE,KAK/D/E,GAAiBuH,EAfU,GAsNnBzC,cAAeA,GACfwE,gBAAiBxI,GAhSL,kBAgS+Ca,GAC3DI,kBAAmBA,GACnBM,oBAAqBA,UAMjC"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/** Both persisted string IDs and numeric API IDs are accepted at input boundaries. */
|
|
2
|
+
export type AssetId = number | string;
|
|
3
|
+
export type AssetGroup = {
|
|
4
|
+
id: string;
|
|
5
|
+
name: string;
|
|
6
|
+
type: string;
|
|
7
|
+
};
|
|
8
|
+
export type AssetDescriptor = {
|
|
9
|
+
id: string;
|
|
10
|
+
type: string;
|
|
11
|
+
label: string;
|
|
12
|
+
};
|
|
13
|
+
export type AssetEditorAppType = {
|
|
14
|
+
primaryAsset: {
|
|
15
|
+
assetType: AssetDescriptor | null;
|
|
16
|
+
groups?: AssetGroup[];
|
|
17
|
+
};
|
|
18
|
+
secondaryAsset?: {
|
|
19
|
+
assetType: AssetDescriptor | null;
|
|
20
|
+
} | null;
|
|
21
|
+
};
|
|
22
|
+
/** Normalized option returned by the asset selectors. */
|
|
23
|
+
export type AssetOption = {
|
|
24
|
+
id: number;
|
|
25
|
+
name?: string;
|
|
26
|
+
type?: string;
|
|
27
|
+
assetId?: number;
|
|
28
|
+
group?: string;
|
|
29
|
+
status?: string | null;
|
|
30
|
+
activeWellId?: number | null;
|
|
31
|
+
parentFracFleetId?: AssetId | null;
|
|
32
|
+
};
|
|
33
|
+
/** A persisted/default selection may not have its option data loaded yet. */
|
|
34
|
+
export type AssetOptionState = Omit<Partial<AssetOption>, 'id'> & {
|
|
35
|
+
id?: AssetId | null;
|
|
36
|
+
};
|
|
37
|
+
export type AssetSelection = AssetOptionState | AssetOption[] | null;
|
|
38
|
+
export type PrimaryAssetChange = AssetOption | AssetOption[] | null;
|
|
39
|
+
export type SecondaryAssetChange = {
|
|
40
|
+
id: AssetId;
|
|
41
|
+
name?: string;
|
|
42
|
+
assetId?: number;
|
|
43
|
+
};
|
|
44
|
+
export type AssetSelectionSettings = {
|
|
45
|
+
[field: string]: AssetId | null | undefined;
|
|
46
|
+
};
|
|
47
|
+
/** The editor receives complete app settings but emits only the fields it changes. */
|
|
48
|
+
export type AssetSettings = {
|
|
49
|
+
rigId?: AssetId | null;
|
|
50
|
+
wellId?: AssetId | null;
|
|
51
|
+
fracFleetId?: AssetId | null;
|
|
52
|
+
padId?: AssetId | null;
|
|
53
|
+
interventionUnitId?: AssetId | null;
|
|
54
|
+
drilloutUnitId?: AssetId | null;
|
|
55
|
+
assetId?: AssetId | null;
|
|
56
|
+
replacedAssetId?: AssetId | null;
|
|
57
|
+
replacedPadId?: AssetId | null;
|
|
58
|
+
assets?: AssetSelectionSettings[] | null;
|
|
59
|
+
} & Record<string, unknown>;
|
|
60
|
+
export type AssetSettingsPatch = {
|
|
61
|
+
rigId?: AssetId | null;
|
|
62
|
+
wellId?: AssetId | null;
|
|
63
|
+
fracFleetId?: AssetId | null;
|
|
64
|
+
padId?: AssetId | null;
|
|
65
|
+
interventionUnitId?: AssetId | null;
|
|
66
|
+
drilloutUnitId?: AssetId | null;
|
|
67
|
+
assetId?: AssetId | null;
|
|
68
|
+
replacedAssetId?: AssetId | null;
|
|
69
|
+
replacedPadId?: AssetId | null;
|
|
70
|
+
assets?: AssetSelectionSettings[] | null;
|
|
71
|
+
} & Record<string, AssetId | AssetSelectionSettings[] | null | undefined>;
|
|
72
|
+
export type AssetEditorChange = {
|
|
73
|
+
primary: PrimaryAssetChange;
|
|
74
|
+
secondary?: never;
|
|
75
|
+
} | {
|
|
76
|
+
secondary: {
|
|
77
|
+
name?: string;
|
|
78
|
+
};
|
|
79
|
+
primary?: never;
|
|
80
|
+
};
|
|
81
|
+
export type AssetSettingsChangeHandler = (settings: AssetSettingsPatch, isMultipleAssets: boolean) => void;
|
|
82
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/AssetEditorV2/types.ts"],"names":[],"mappings":"AAAA,sFAAsF;AACtF,MAAM,MAAM,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC;AAEtC,MAAM,MAAM,UAAU,GAAG;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,YAAY,EAAE;QACZ,SAAS,EAAE,eAAe,GAAG,IAAI,CAAC;QAClC,MAAM,CAAC,EAAE,UAAU,EAAE,CAAC;KACvB,CAAC;IACF,cAAc,CAAC,EAAE;QACf,SAAS,EAAE,eAAe,GAAG,IAAI,CAAC;KACnC,GAAG,IAAI,CAAC;CACV,CAAC;AAEF,yDAAyD;AACzD,MAAM,MAAM,WAAW,GAAG;IACxB,EAAE,EAAE,MAA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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.test.d.ts","sourceRoot":"","sources":["../../../../../src/components/AssetEditorV2/utils/__tests__/utils.test.
|
|
1
|
+
{"version":3,"file":"utils.test.d.ts","sourceRoot":"","sources":["../../../../../src/components/AssetEditorV2/utils/__tests__/utils.test.ts"],"names":[],"mappings":""}
|