Skip to content

Commit f7c66c2

Browse files
entrotechHyMike
andauthored
1992 edit tooltips page 2 (#2641)
* store procedure for admin update description tooltip * create router, controller, service: Add a endpoint with put request to execute store procedure to update description for tooltips * create a new method in the calculation.service module called updateDescription in the server * implement tooltip editing for admin and add feature where "i" and "+" icons toggle base on tooltip availability * add feature of editing to disabled tooltips also and add editing feature and toggle "+" and "i" to rulestrategy allowing page 4 to exhibit the same behaviors like page 1 * fix linting errors * Get tooltip editing working on page 2 --------- Co-authored-by: Michael Hy <hymike88@gmail.com>
1 parent 584865b commit f7c66c2

2 files changed

Lines changed: 55 additions & 1 deletion

File tree

client/src/components/ProjectWizard/RuleInput/ProjectLevelRuleInput.jsx

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import PropTypes from "prop-types";
33
import { createUseStyles, useTheme } from "react-jss";
44
import clsx from "clsx";
55
import RuleLabel from "../Common/RuleLabel";
6+
import AccordionToolTip from "../../ToolTip/AccordionToolTip";
67

78
const useStyles = createUseStyles(theme => ({
89
rowContainer: {
@@ -82,6 +83,14 @@ const ProjectLevelRuleInput = ({
8283
// user first touches the input field to display the text of the error message.
8384
const [showValidationErrors, setShowValidationErrors] = useState(false);
8485
const [showDescription, setShowDescription] = useState(false);
86+
const [isEditing, setIsEditing] = useState(false);
87+
const [localDescription, setLocalDescription] = useState(description);
88+
89+
// Add callback to handle description updates
90+
const handleDescriptionUpdate = newDescription => {
91+
setLocalDescription(newDescription);
92+
setIsEditing(false); // Close editing mode
93+
};
8594

8695
const onInputChange = e => {
8796
setShowValidationErrors(true);
@@ -108,6 +117,7 @@ const ProjectLevelRuleInput = ({
108117
name={name}
109118
setShowDescription={setShowDescription}
110119
showDescription={showDescription}
120+
setIsEditing={setIsEditing}
111121
/>
112122
</div>
113123
<div className={classes.rowItem2}>
@@ -155,8 +165,9 @@ const ProjectLevelRuleInput = ({
155165
required={required}
156166
link={link}
157167
name={name}
158-
className={classes.rowItem1}
159168
setShowDescription={setShowDescription}
169+
showDescription={showDescription}
170+
setIsEditing={setIsEditing}
160171
/>
161172
<div
162173
className={classes.rowItem2}
@@ -190,6 +201,15 @@ const ProjectLevelRuleInput = ({
190201
</div>
191202
</div>
192203
) : null}
204+
{(showDescription && localDescription) || isEditing ? (
205+
<AccordionToolTip
206+
description={localDescription || ""}
207+
setShowDescription={setShowDescription}
208+
id={id}
209+
forceEditMode={isEditing}
210+
onEditDescription={handleDescriptionUpdate}
211+
/>
212+
) : null}
193213
</React.Fragment>
194214
);
195215
};
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
CREATE or ALTER PROCEDURE [dbo].[CalculationRule_UpdateDescription]
2+
(@id INT,
3+
@loginId INT,
4+
@description NVARCHAR(MAX)
5+
)
6+
AS
7+
BEGIN
8+
SET NOCOUNT ON;
9+
10+
IF NOT EXISTS (
11+
SELECT 1
12+
FROM [dbo].[Login]
13+
WHERE [id] = @loginId
14+
AND [isAdmin] = 1
15+
)
16+
BEGIN
17+
RAISERROR('Access denied. User must have admin privileges to update calculation rule description.', 16, 1);
18+
RETURN;
19+
END
20+
IF NOT EXISTS (
21+
SELECT 1
22+
FROM [dbo].[CalculationRule]
23+
WHERE [id] = @id
24+
)
25+
BEGIN
26+
RAISERROR('Calculation rule with ID %d does not exist.', 16, 1, @id);
27+
RETURN;
28+
END
29+
UPDATE [dbo].[CalculationRule]
30+
SET [description] = @description
31+
WHERE [id] = @id;
32+
33+
SELECT 'Description updated successfully' AS Result;
34+
END

0 commit comments

Comments
 (0)