diff --git a/src/components/floor-plan/CanvasMenu.jsx b/src/components/floor-plan/CanvasMenu.jsx index 515ff459..b52b4a91 100644 --- a/src/components/floor-plan/CanvasMenu.jsx +++ b/src/components/floor-plan/CanvasMenu.jsx @@ -408,7 +408,7 @@ export default function CanvasMenu(props) { const checkMenuState = (menu) => { return ( (['2', '3'].includes(canvasSetting?.roofSizeSet) && menu.type === 'outline') || - (selectedMenu === 'module' && ['drawing', 'placement'].includes(menu.type)) || + (selectedMenu === 'module' && ['placement', 'outline', 'surface'].includes(menu.type)) || (isExistModule() && ['placement', 'outline'].some((num) => num === menu.type)) || (['estimate', 'simulation'].includes(selectedMenu) && ['placement', 'outline', 'surface'].includes(menu.type)) ) diff --git a/src/components/floor-plan/modal/circuitTrestle/CircuitTrestleSetting.jsx b/src/components/floor-plan/modal/circuitTrestle/CircuitTrestleSetting.jsx index 681a425d..981201ec 100644 --- a/src/components/floor-plan/modal/circuitTrestle/CircuitTrestleSetting.jsx +++ b/src/components/floor-plan/modal/circuitTrestle/CircuitTrestleSetting.jsx @@ -521,6 +521,15 @@ export default function CircuitTrestleSetting({ id }) { const handlePassivityAllocationCkeck = () => { let pcsCount = {} let result = {} + const notAllocationModules = canvas.getObjects().filter((obj) => obj.name === POLYGON_TYPE.MODULE && !obj.circuit) + if (notAllocationModules.length > 0) { + swalFire({ + text: getMessage('not.allocation.exist.module'), + type: 'alert', + icon: 'warning', + }) + return + } canvas .getObjects() .filter((obj) => obj.name === POLYGON_TYPE.MODULE) diff --git a/src/components/floor-plan/modal/dimensionLine/DimensionLineSetting.jsx b/src/components/floor-plan/modal/dimensionLine/DimensionLineSetting.jsx index a49c9ad6..e08bc839 100644 --- a/src/components/floor-plan/modal/dimensionLine/DimensionLineSetting.jsx +++ b/src/components/floor-plan/modal/dimensionLine/DimensionLineSetting.jsx @@ -31,6 +31,7 @@ export default function DimensionLineSetting(props) { useEffect(() => { if (canvas) { const dimensionObject = canvas.getActiveObject() + console.log(dimensionObject) const id = dimensionObject.groupId const textObj = dimensionObject._objects.filter((obj) => obj.name === 'dimensionLineText' && obj.group.groupId === id)[0] if (!textObj) return @@ -38,6 +39,7 @@ export default function DimensionLineSetting(props) { setBasicLength(+dimensionObject.length) setSelectedSlope1(dimensionObject.angle1) setSelectedSlope2(dimensionObject.angle2) + setSlopeAble(dimensionObject.slopeAble) } if (basicSetting.roofAngleSet === 'slope') { @@ -65,13 +67,13 @@ export default function DimensionLineSetting(props) { }, []) useEffect(() => { - if (!slopeAble) { - const dimensionObject = canvas.getActiveObject() - dimensionObject.set({ - angle1: null, - angle2: null, - }) - } + // if (!slopeAble) { + // const dimensionObject = canvas.getActiveObject() + // dimensionObject.set({ + // angle1: null, + // angle2: null, + // }) + // } }, [slopeAble]) const handleChangeLength = () => { @@ -79,19 +81,24 @@ export default function DimensionLineSetting(props) { const dimensionObject = canvas.getActiveObject() const id = dimensionObject.groupId const textObj = dimensionObject._objects.filter((obj) => obj.name === 'dimensionLineText' && obj.group.groupId === id)[0] - let resultText = +changeLength > 0 ? +changeLength : '0' - console.log(changeLength) + let resultText = +changeLength > 0 ? +changeLength : dimensionObject.length + if (slopeAble) { resultText = !selectedSlope2 - ? calculateLength(basicLength, selectedSlope1.value).toFixed(0) - : calculateLength(basicLength, selectedSlope1.value, selectedSlope2.value).toFixed(0) + ? calculateLength(resultText, selectedSlope1.value).toFixed(0) + : calculateLength(resultText, selectedSlope1.value, selectedSlope2.value).toFixed(0) } textObj.set({ text: String(resultText), }) - dimensionObject.set({ length: +resultText }) + dimensionObject.set({ + length: +changeLength > 0 ? +changeLength : dimensionObject.length, + slopeAble: slopeAble, + angle1: selectedSlope1, + angle2: selectedSlope2, + }) setBasicLength(resultText) setChangeLength('') canvas.renderAll() @@ -153,7 +160,7 @@ export default function DimensionLineSetting(props) {
- setSlopeAble(!slopeAble)} /> + setSlopeAble(!slopeAble)} />
diff --git a/src/components/floor-plan/modal/placementShape/PlacementShapeSetting.jsx b/src/components/floor-plan/modal/placementShape/PlacementShapeSetting.jsx index a7decdb7..ccf6ed4b 100644 --- a/src/components/floor-plan/modal/placementShape/PlacementShapeSetting.jsx +++ b/src/components/floor-plan/modal/placementShape/PlacementShapeSetting.jsx @@ -428,7 +428,7 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, pla )} - {currentRoof && ( + {/* {currentRoof && (
- )} + )} */} diff --git a/src/hooks/common/useCommonUtils.js b/src/hooks/common/useCommonUtils.js index 538ee8c5..dbad7a88 100644 --- a/src/hooks/common/useCommonUtils.js +++ b/src/hooks/common/useCommonUtils.js @@ -282,6 +282,10 @@ export function useCommonUtils() { originY: 'center', lineDirection: lineDirection, groupId: uuid, + length: distance * 10, + slopeAble: false, + angle1: null, + angle2: null, }) canvas.add(group) diff --git a/src/hooks/module/useModule.js b/src/hooks/module/useModule.js index f3fc0348..50e8e091 100644 --- a/src/hooks/module/useModule.js +++ b/src/hooks/module/useModule.js @@ -536,14 +536,7 @@ export function useModule() { const moduleRowRemove = (type) => { const activeModule = canvas.getObjects().filter((obj) => canvas.getActiveObjects()[0].id === obj.id)[0] - if (activeModule.circuit) { - swalFire({ - title: getMessage('can.not.remove.module'), - icon: 'error', - type: 'alert', - }) - return - } + c const rowModules = getRowModules(activeModule) const otherModules = getOtherModules(rowModules) const objects = getObjects() @@ -671,6 +664,9 @@ export function useModule() { const moduleSetupSurface = canvas .getObjects() .filter((obj) => obj.name === POLYGON_TYPE.MODULE_SETUP_SURFACE && obj.id === activeModule.surfaceId)[0] + if (moduleSetupSurface.modules.filter((module) => module.circuit).length > 0) { + return + } let width = -1 let isWarning = false if (targetModules.length === 0) { @@ -776,6 +772,9 @@ export function useModule() { const moduleSetupSurface = canvas .getObjects() .filter((obj) => obj.name === POLYGON_TYPE.MODULE_SETUP_SURFACE && obj.id === activeModule.surfaceId)[0] + if (moduleSetupSurface.modules.filter((module) => module.circuit).length > 0) { + return + } let height = -1 let isWarning = false canvas.discardActiveObject() @@ -855,6 +854,14 @@ export function useModule() { } const alignModule = (type, surfaceArray) => { + if (activeModule.circuit) { + swalFire({ + title: getMessage('can.not.remove.module'), + icon: 'error', + type: 'alert', + }) + return + } surfaceArray.forEach((surface) => { const modules = surface.modules @@ -939,6 +946,7 @@ export function useModule() { .getObjects() .filter((module) => module.name === POLYGON_TYPE.MODULE && module.surfaceId === surface.id) .forEach((module) => { + canvas.remove(module.circuit) canvas.remove(module) }) }) diff --git a/src/hooks/useContextMenu.js b/src/hooks/useContextMenu.js index 842cad28..f1cb43e4 100644 --- a/src/hooks/useContextMenu.js +++ b/src/hooks/useContextMenu.js @@ -706,12 +706,68 @@ export function useContextMenu() { { id: 'moduleVerticalCenterAlign', name: getMessage('contextmenu.module.vertical.align'), - fn: () => alignModule(MODULE_ALIGN_TYPE.VERTICAL, currentObject.arrayData ?? [currentObject]), + fn: () => { + if (currentObject.arrayData) { + let existCircuit = false + currentObject.arrayData.forEach((surface) => { + surface.modules.forEach((module) => { + if (module.circuit) existCircuit = true + }) + }) + if (existCircuit) { + swalFire({ + title: getMessage('can.not.move.module'), + icon: 'error', + type: 'alert', + }) + return + } + } else { + const allocatedModules = currentObject.modules.filter((module) => module.circuit !== null) + if (allocatedModules.length > 0) { + swalFire({ + title: getMessage('can.not.move.module'), + icon: 'error', + type: 'alert', + }) + return + } + } + alignModule(MODULE_ALIGN_TYPE.VERTICAL, currentObject.arrayData ?? [currentObject]) + }, }, { id: 'moduleHorizonCenterAlign', name: getMessage('contextmenu.module.horizon.align'), - fn: () => alignModule(MODULE_ALIGN_TYPE.HORIZONTAL, currentObject.arrayData ?? [currentObject]), + fn: () => { + if (currentObject.arrayData) { + let existCircuit = false + currentObject.arrayData.forEach((surface) => { + surface.modules.forEach((module) => { + if (module.circuit) existCircuit = true + }) + }) + if (existCircuit) { + swalFire({ + title: getMessage('can.not.move.module'), + icon: 'error', + type: 'alert', + }) + return + } + } else { + const allocatedModules = currentObject.modules.filter((module) => module.circuit !== null) + if (allocatedModules.length > 0) { + swalFire({ + title: getMessage('can.not.move.module'), + icon: 'error', + type: 'alert', + }) + return + } + } + alignModule(MODULE_ALIGN_TYPE.HORIZONTAL, currentObject.arrayData ?? [currentObject]) + }, }, { id: 'moduleRemove',