The Cognitive Distortion Journal (CDJ) is a smart journaling tool that helps remedy distorted thinking. It can feel impossible to follow the CBT technique of labeling and reframing distorted thinking when you've been thinking this way your whole life. The CDJ can help with that 🧠✨ -- v2 is in development!
Entry titles may now be updated by clicking on the title, entering data in the TextField that appears, then pressing enter or clicking away (or hitting escape) to submit or exit. It uses the same logic and components as update entry content. To do this, updates to the backend's updateEntry controller were made so that it could be reused. This was done by checking the req body and uses conditionals to update the title or entry content, whichever is in the req body. Since updateEntry can have a req body without entry content, content requirement from joi entrySchema validation had to be removed.
Note that this is a the quick solution. It simply copies existing code that provides the functionality. This provides a refactoring opportunity. To reduce duplication, the edit functionality in the Analysis component can be abstracted using callbacks. This will remove much of the duplication, but be mindful of state that is affected only by changes made to the title or the entry content such as, the conditionals for LinearProgress components and the key down functionalities.
Additionally, the updateEntry controller can also be improved by simply passing the req body to the update method that can parse it and update all fields after being validated. This will be a little more involved because anytime the content of an entry is updated the associated analysis_content is also updated. It might be worth looking into mongoose middleware for the chosen update method that can be triggered and run the request for a new analysis.
Entry titles may now be updated by clicking on the title, entering data in the TextField that appears, then pressing enter or clicking away (or hitting escape) to submit or exit. It uses the same logic and components as update entry content. To do this, updates to the backend's
updateEntry
controller were made so that it could be reused. This was done by checking thereq
body and uses conditionals to update thetitle
or entrycontent
, whichever is in thereq
body. SinceupdateEntry
can have areq
body without entry content, content requirement from joientrySchema
validation had to be removed.Note that this is a the quick solution. It simply copies existing code that provides the functionality. This provides a refactoring opportunity. To reduce duplication, the edit functionality in the
Analysis
component can be abstracted using callbacks. This will remove much of the duplication, but be mindful of state that is affected only by changes made to thetitle
or the entrycontent
such as, the conditionals forLinearProgress
components and the key down functionalities.Additionally, the
updateEntry
controller can also be improved by simply passing thereq
body to the update method that can parse it and update all fields after being validated. This will be a little more involved because anytime thecontent
of anentry
is updated the associatedanalysis_content
is also updated. It might be worth looking into mongoose middleware for the chosen update method that can be triggered and run the request for a new analysis.closes #122