Skip to content

Commit

Permalink
Merge pull request #648 from rojasadrian012/601-Add-editable-title-to…
Browse files Browse the repository at this point in the history
…-modal-dialog

Feature/#601 Add editable title to modal dialog
  • Loading branch information
brauliodiez authored Jan 4, 2025
2 parents 1f4c4f2 + 10ad433 commit 25c2ad1
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { ShapeSizeRestrictions, ShapeType } from '@/core/model';
import { ShapeProps } from '../shape.model';
import { fitSizeToShapeSizeRestrictions } from '@/common/utils/shapes/shape-restrictions';
import { useGroupShapeProps } from '../mock-components.utils';
import { BASIC_SHAPE } from '../front-components/shape.const';

const modalDialogShapeSizeRestrictions: ShapeSizeRestrictions = {
minWidth: 250,
Expand All @@ -21,14 +22,14 @@ const shapeType: ShapeType = 'modalDialog';

export const ModalDialogContainer = forwardRef<any, ShapeProps>(
(props, ref) => {
const { x, y, width, height, id, onSelected, ...shapeProps } = props;
const { x, y, width, height, id, onSelected, text, ...shapeProps } = props;
const restrictedSize = fitSizeToShapeSizeRestrictions(
modalDialogShapeSizeRestrictions,
width,
height
);
const { width: restrictedWidth, height: restrictedHeight } = restrictedSize;

const margin = 10;
const titleBarHeight = 50;

const commonGroupProps = useGroupShapeProps(
Expand Down Expand Up @@ -61,6 +62,16 @@ export const ModalDialogContainer = forwardRef<any, ShapeProps>(
strokeWidth={2}
fill="lightgray"
/>
<Text
x={margin * 3}
y={margin * 2}
text={text}
fontFamily={BASIC_SHAPE.DEFAULT_FONT_FAMILY}
fontSize={12}
fill="black"
ellipsis={true}
wrap="none"
/>

{/* (X) */}
<Group x={restrictedWidth - 40} y={10}>
Expand Down
3 changes: 3 additions & 0 deletions src/pods/canvas/model/inline-editable.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ const inlineEditableShapes = new Set<ShapeType>([
'timepickerinput',
'datepickerinput',
'browser',
'modalDialog',
]);

// Check if a shape type allows inline editing
Expand Down Expand Up @@ -74,6 +75,7 @@ const shapeTypesWithDefaultText = new Set<ShapeType>([
'timepickerinput',
'datepickerinput',
'browser',
'modalDialog',
]);

// Map of ShapeTypes to their default text values
Expand Down Expand Up @@ -110,6 +112,7 @@ const defaultTextValueMap: Partial<Record<ShapeType, string>> = {
timepickerinput: 'hh:mm',
datepickerinput: new Date().toLocaleDateString(),
browser: 'https://example.com',
modalDialog: 'Title here...',
};

export const generateDefaultTextValue = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ export const renderModalDialogContainer = (
onDragEnd={handleDragEnd(shape.id)}
onTransform={handleTransform}
onTransformEnd={handleTransform}
isEditable={shape.allowsInlineEdition}
text={shape.text}
/>
);
};

0 comments on commit 25c2ad1

Please sign in to comment.