Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question template edit not working properly #530

Open
DMCarrajola opened this issue Feb 25, 2025 · 2 comments
Open

Question template edit not working properly #530

DMCarrajola opened this issue Feb 25, 2025 · 2 comments

Comments

@DMCarrajola
Copy link

Bug Report

Question Template edit zone doesn't work properly.

Description

When editing a question, it asks for input in a different insert box.

Steps to Reproduce

1- Go to Question Template.

2- Click the + Create button.

3- Insert information in both fields (Question template * and Company *).

4- Choose a Question Type (doesn't matter which type).

5- Insert the name of the Question and the specifics of the Question Type.

6- Hit Add Question.

7- Click Edit.

8- Edit the data you need to edit.

9- Hit Save.
Now it's when it goes wrong. Once you hit Save, it shows you a reminder behind the question input in the Add A Question zone.

10- (If you) fill in the question in the Add A Question zone.

11- Hit Save. Now it saves properly and the info is OK, but the information in the Add A Question input is lost.

Expected Behavior

After hitting Save when editing the needed data, it just saves.

Actual Behavior

After hitting Save when editing the needed data, it asks for unnecessary input, and then allows to save.

Screenshots

Bug.Edit.Template.mp4

Environment

  • Django Version: 4.2.11
  • Python Version: 3.11.0
  • Operating System: Windows 11 up to date.
  • Browser: Brave/Edge/Chrome

Additional Information

The error might be between question_template_detailed_view.html and question_all.html and their Javascript associated files.

Priority

medium

@horilla-opensource
Copy link
Owner

horilla-opensource commented Feb 26, 2025

Hi @DMCarrajola ,

Thank you for reporting this issue and for providing detailed insights!.

We'll test these fixes thoroughly and update accordingly.

Thanks again for your valuable report.

Best Regards,
Team Horilla

DMCarrajola added a commit to DMCarrajola/horilla that referenced this issue Feb 26, 2025
Hi, i opened that issue (issue horilla-opensource#530), and I am here showing a possible fix I found.

📌 Changes in question_all.html

Line 89: Replaced data-target with onclick to call JavaScript functions for handling the edit button’s expected behavior.
Lines 98-100: Changed {% trans %} to {% blocktrans %} to resolve a VSCode warning. (I didn't notice any functional difference, so feel free to remove it if unnecessary.)
Lines 104-105: Replaced data-id-save with onclick to ensure the save button triggers the required function.
Lines 115-156: Added JavaScript for handling the edit/save process. Not sure if this is the best place for it. If wanna change tell me where, im open to suggestions!

📌 Changes in views.py

Updated how edited data is passed to the backend using Ajax. This was the best solution I found.

🛠 General Notes

Got some help from AI, so if anything seems off, let me know! 😅
Open to feedback — hope this all makes sense!
Cheers!
DMCarrajola added a commit to DMCarrajola/horilla that referenced this issue Feb 27, 2025
The issue was caused by the overly broad scope of the conditional statements in the script at the end of question_template_detailed_view.html. These conditions unintentionally affected the input fields in question_all.html, leading to validation being applied incorrectly when editing a question.

This fix ensures that the validation logic is properly scoped, applying only to the intended form elements without interfering with the editing functionality.

This fix was aided by AI and may not be perfect, since im a begginer and as I don't have full knowledge of the entire project. Further testing and review are recommended.
@horilla-opensource
Copy link
Owner

Hi @DMCarrajola,

We've updated the source code and resolved this issue.

Please pull the latest code from the repository and let us know if you encounter any further issues.

Thank you for your valuable feedback!

Best Regards,
Team Horilla

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants