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

HTML-555: JavaScript functions like setValue() should have access to … #161

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

Am-Coder
Copy link
Member

@Am-Coder Am-Coder commented Feb 6, 2020

….date and .accessionNumber even if the fields are not displayed

Description of what I changed

Link to the issue - https://issues.openmrs.org/browse/HTML-555

To solve this issue I created a generateHiddenHTML method in Date Widget and TextFieldWidget which will be called whenever the date widget, comment widget and accession number widget are left null for obs tag. In order to make these widgets accessible via js an additional attribute "enableParamJS" needs to be set to "true". After setting this attribute these widgets become accessible via java script.

Issue I worked on

see https://issues.openmrs.org/browse/HTML-555

Checklist: I completed these to help reviewers :)

  • My pull request only contains ONE single commit
    (the number above, next to the 'Commits' tab is 1).

    No? -> read here on how to squash multiple commits into one

  • My IDE is configured to follow the code style of this project.

    No? Unsure? -> configure your IDE, format the code and add the changes with git add . && git commit --amend

  • I have added tests to cover my changes. (If you refactored
    existing code that was well tested you do not have to add tests)

    No? -> write tests and add them to this commit git add . && git commit --amend

  • I ran mvn clean package right before creating this pull request and
    added all formatting changes to my commit.

    No? -> execute above command

  • All new and existing tests passed.

    No? -> figure out why and add the fix to your commit. It is your responsibility to make sure your code works.

  • My pull request is based on the latest changes of the master branch.

    No? Unsure? -> execute command git pull --rebase upstream master

@HerbertYiga
Copy link
Contributor

we have some failing checks here

@Am-Coder
Copy link
Member Author

Working on them

Copy link

@CaptainDaVinci CaptainDaVinci left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There appear to be some issues with indentation and formatting of the data members declared in the class.

@Am-Coder
Copy link
Member Author

The original repo too has this issue. That's why I didn't bother to check the formatting.

@dkayiwa
Copy link
Member

dkayiwa commented Feb 21, 2020

Is this still a draft?

@Am-Coder Am-Coder marked this pull request as ready for review February 21, 2020 09:52
@Am-Coder
Copy link
Member Author

ready for review

@@ -1028,6 +1031,11 @@ else if (parameters.containsKey("commentFieldCode")) {
} else {
context.addFieldToActiveSection(field);
}

//if enableParamJS is true
if( "true".equals(parameters.get("enableParamJS")) ) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can perhaps inline this statement to

enableParamJS = parameters.get("enableParamJS").equals("true");

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pointing out, just that it should be

enableParamJS = "true".equals(parameters.get("enableParamJS"));

This way there won't be any case of null pointer exception.

context.registerPropertyAccessorInfo(id + ".date", context.getFieldNameIfRegistered(dateWidget),
"dateFieldGetterFunction", null, "dateSetterFunction");
ret.append(" ");
String str = dateWidget.generateHiddenHtml(context);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since, str isn't used anywhere else, I think it would be better to pass the generated html to ret direclty.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah my bad. Thanks again.

….date and .accessionNumber even if the fields are not displayed
sb.append(" maxlength=\"" + textFieldMaxLength.intValue() + "\"");
}
if (placeholder != null) {
// TODO escape
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When do you plan to work on the above TODO?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These TODO's were present in generateHtml method at similar positions so I added them here as well. I couldn't understand their meaning that why they were added and what is to be done.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dkayiwa Sorry for late reply. These TODO's were present in generateHtml method at similar condition so I added them here as well. I couldn't understand their meaning that why they were added and what is to be done.

sb.append(" maxlength=\"" + textFieldMaxLength.intValue() + "\"");
}
if (placeholder != null) {
// TODO escape
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When do you plan to work on the above TODO?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same case as previous is here as well.

@gitcliff
Copy link

gitcliff commented Aug 4, 2020

@Am-Coder kindly look into the merge conflicts ,,,
Thanks

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

Successfully merging this pull request may close these issues.

5 participants