-
Notifications
You must be signed in to change notification settings - Fork 174
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
[Raisinbread] Fixing help_editor module to display RB instrument instructions #6907
[Raisinbread] Fixing help_editor module to display RB instrument instructions #6907
Conversation
205bd9f
to
ee3f055
Compare
great, can you also comment in one line on whether the help editor seems to work in terms of editing help text? |
@christinerogers The Help Editor does not correctly save changes made in the frontend to the file contents. I made changes and hit Another issue is that the button |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi Alex, see my comment below, the topic column is probably trying to match a valid test name value.
Can you dig further into the code to find out?
Dave's question on the issue here isn't actually addressed until we know that part.
@ridz1208 -- care to review otherwise?
raisinbread/RB_files/RB_help.sql
Outdated
@@ -1,5 +1,6 @@ | |||
SET FOREIGN_KEY_CHECKS=0; | |||
TRUNCATE TABLE `help`; | |||
LOCK TABLES `help` WRITE; | |||
INSERT INTO `help` (`helpID`, `parentID`, `hash`, `topic`, `content`, `created`, `updated`) VALUES (123,12,'hash','BMI Instructions','The BMI calculator instrument can calculate the BMI and BMI Classification of a visitor. The two required fields for this instrument are the Date of Administration of the instrument and the Examiner name. The height and weight of the visitor must then be entered in either standard or metric units. The instrument will not accept an entry where the height and weight are given in both units. After this information is given, the instrument will calculate the BMI and BMI Classification of the visitor.',NULL,NULL); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alex, since this doesn't actually render for the BMI -- per your comment here
I think it might be because of the value in the topic
column. If you change this to bmi
(which i think would be the relevant test_name value for this instrument) -- what happens?
Could you also take another step here towards resolving it by verifying in the code how the Help display/dropdown actually trying to locate relevant help text? If it's not trying to match the topic
column against a valid test_name
value -- then what is it trying to match/look for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes I can definitely look into this :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@christinerogers @driusan So after some digging:
The help file is handled by helpHandler.js. This then calls the modules/help_editor/ajax/help.php file with a GET request.
In THAT file, it first tries to render the help file by either using the module name (which is given by the request parameter testName
or using the subtest
parameter (in this case "bmi" or "aosi"). If it's not a module, it instead tries to load data from the help
table using the request parameter subtest
as the identifier. But when I went to an instrument data entry page and used the Developer Tool, I saw that when the GET request is sent to help.php
, it only provides the testName
parameter in the request and doesn't provide a subtest
value, so it never checks if there's a file in the help table and instead just looks for the markdown help file for the Instruments module.
Let me know if this makes sense, I can explain it in more detail if necessary. I don't know how to fix this as of now. I can keep looking to see how to edit the GET request to provide the subtest
parameter, but I haven't figured out where to do that yet.
@zaliqarosli can you team up with @AlexandraLivadas to figure out what is happening in this module ? our options would be to either fix it if it doesnt work as intended or remove the module entirely |
@ridz1208 yeah sure @AlexandraLivadas wanna slack me or get on a call to explain what's going on? |
@zaliqarosli @AlexandraLivadas have you guys firgured it out ? is it working for bmi specifically now ? |
fixes #5691 |
@ridz1208 yeah i fixed it - sent a PR to this PR branch. @AlexandraLivadas can you merge the changes? |
@@ -1,5 +1,3 @@ | |||
import swal from 'sweetalert2'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this downgrading from swal2 to swal1?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When @zaliqarosli was making the changes, she said that this statement threw an error. However, when I added this line back on my local version, I did not get the same error. I'm not sure why this was causing issues for her but not me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it should be downgraded.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
undoing the changes on this file is still giving me the error:
@laemtl also reported seeing this error in #6940. (Laetitia, any chance you could give this PR a test, with and without these changes to this file?)
this PR as is fixes all issues. @driusan @HenriRabalais @maltheism any of you know how to properly fix this without downgrading to swal1?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes sure! I'm also working on #7018 so it might be helpful to fix this problem with swal.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I understand why the file can't just be moved from the js
directory to jsx
and added to the webpack config so that webpack compiles it and it can use swal2?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@driusan Eslint fails with /var/www/html/loris/modules/help_editor/jsx/help_editor_helper.js
33:13 error A function with a name starting with an uppercase letter should only be used as a constructor new-cap
markdownContent = document.createElement('div');
ReactDOM.render(
RMarkdown({content: content}),
markdownContent
);
I pushed a commit which fixes the pb with the fix found here which changes the eslint rules.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wouldn't it be kind of against our repo standard that we're calling a non-react non-jsx file a jsx file and putting it under that directory? help_editor_helper.js isn't a component and doesn't need to be compiled. there's a way to call sweetalert2 with normal JS:
but using require() also throws an error. surely just making the file a jsx file isn't the right move?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zaliqarosli nodejs, browserify, or webpack supports require() but not javascript on the browser. The browser shouldn't have access to node_modules on the server anyways.
I think it's not great that we cannot use import
in the js directory as well. It would be nice to keep helper code away from the component directory. Although, I do like the thought of js directory just having compiled js code from jsx with nothing else.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zaliqarosli You are right, I migrated my fix to #7018. I'm not sure the way I tackled it is the best. I kind of agree that it is weird to have this file under jsx/. I wonder if reactifying it should be preferable? Isn't the plan to completely remove the jQuery dependencies in the future?
7ce172c
to
bca66c8
Compare
is discussion still required here? |
@zaliqarosli No, I don't think so. I think this was approved a while ago and just needed to be tested and reviewed again on the 23.0 branch |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
everything else looks good. just wondering about one leftover comment. i am happy to approve this PR as is though
could someone test this? i'm having trouble with my dev VM. @jstirling91 would you be interested? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
everything else looks good! will test now
Co-authored-by: Zaliqa <zaliqa.rosli@mcin.ca>
@AlexandraLivadas any chance you could edit the help_editor .md help file to say "This module displays existing help content for LORIS instrument pages" instead of what's there? |
…AlexandraLivadas/Loris into 2020-08-12-addDataForHelpEditor
@driusan this one is in your hands, it's going to 23 since it's a bugfix requested by IBIS |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!!
@driusan i think this one is yours as well |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ill approve again since the last commit. also retested
Edited
This PR aimed to add data to the
help
table in Raisinbread so that the data would generate in the Help Editor module. This will allow theHelp Editor
module to be manually tested.It was found that there is a bug in this module that causes it not to save/display this information. This issue is resolved in this PR.
Here is a screenshot of the
Help Editor
module with the new data:Testing instructions (if applicable)
With a fresh RB install:
Help Editor
in the frontend and see that data loads for instructions for the BMI instrument.Link to related issue