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

[B5] Web Apps #34682

Merged
merged 101 commits into from
Jul 24, 2024
Merged

[B5] Web Apps #34682

merged 101 commits into from
Jul 24, 2024

Conversation

orangejenny
Copy link
Contributor

@orangejenny orangejenny commented May 28, 2024

Product Description

Turn on bootstrap 5 for web apps. Side by side comparisons are here, but the high level summary is: not much changed. Colors are a little brighter, borders are a little lighter, buttons are a little bigger.

Technical Summary

Review by commit. Most commits are small, except the cleanup commits, which are mechanical. Most of this work has been merged already, what remains in this PR is three major changes:

  • Updating the python views to use the B5 decorators and templates
  • Javascript changes that either depend on B5 libraries (bootstrap js or tempus dominus) or were annoying to wrap behind a window.USE_BOOTSTRAP5 check.
  • Deleting the B3 templates and diff files.

Safety Assurance

Safety story

High risk, as this is a high visibility area, there are a lot of changes (including changes made in previous PRs that will go live when this is merged), and our test coverage at the UI level is limited. We'll be going through the same QA/safety approach as for the web apps requirejs migration.

Automated test coverage

Not a whole lot.

QA Plan

https://dimagi.atlassian.net/browse/QA-6550

Rollback instructions

This can be rolled back if needed. Due to its size, it may get difficult to automatically roll back relatively soon, although it looks like there hasn't been that much activity in the web apps front end in the past few weeks.

Sentry can be monitored for javascript errors using this filter.

  • This PR can be reverted after deploy with no further considerations

Labels & Review

  • Risk label is set correctly
  • The set of people pinged as reviewers is appropriate for the level of risk of the change

@orangejenny orangejenny added awaiting QA QA in progress. Do not merge product/all-users-all-environments Change impacts all users on all environments Risk: High Change affects files that have been flagged as high risk. labels May 28, 2024
@orangejenny orangejenny requested review from a team May 28, 2024 18:03
@orangejenny orangejenny removed the request for review from a team May 28, 2024 18:03
@orangejenny orangejenny requested a review from nospame as a code owner May 28, 2024 18:03
@dimagimon dimagimon added dependencies Pull requests that update a dependency file Risk: Medium Change affects files that have been flagged as medium risk. and removed Risk: High Change affects files that have been flagged as high risk. labels May 28, 2024
corehq/apps/cloudcare/static/cloudcare/js/utils.js Outdated Show resolved Hide resolved
@@ -0,0 +1,7 @@
---
+++
Copy link
Contributor

Choose a reason for hiding this comment

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

why are these not unsplit?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

They're still used here:

<link type="text/less"
rel="stylesheet"
media="all"
href="{% static 'cloudcare/less/font-formplayer.less' %}" />
<link type="text/less"
rel="stylesheet"
media="all"
href="{% static 'cloudcare/less/formplayer-common.less' %}"/>
<link type="text/less"
rel="stylesheet"
media="all"
href="{% static 'cloudcare/less/formplayer-webapp.less' %}"/>

This is basically the result of running the bootstrap migration tool.
- dateTimePickerTooltips are already handled by by defaultTranslations in the HQ tempus dominus module
- Several callbacks/handlers were no longer needed
- It's annoying that showing the clear button is handled through initial page data, but updating that is out of scope
The migration tool doesn't check js files for CSS class names,
and some of these aren't greppable anyway.
This completes changes that were started in 845d9ff
Just following bootstrap convention here
@MartinRiese MartinRiese force-pushed the jls/b5-web-apps branch 2 times, most recently from 41345f6 to 12daf60 Compare July 3, 2024 17:16
In Bootstrap 3 we were able to have and intermediate tag as parent
of the apps. This is not allowed anymore in Bootstrap 5. The order
classes previously used only change the visual order, not the tab
order. Adding a hidden reference div and inserting the apps before
it results in the right order that also keeps the tab order in place.
Comment on lines +117 to +120
attachHtml: function attachHtml(els, $container) {
let childElement = $container.find("#put-apps-here");
$container[0].insertBefore(els, childElement[0]);
},
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't love this solution but I looked at it for a while and couldn't come up with anything better.

Copy link
Contributor

Choose a reason for hiding this comment

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

same here

MartinRiese and others added 8 commits July 9, 2024 06:52
The relative position is needed to place the hover circle
around the delete/audio icon correctly. But it interfers
with the focus outline of the row.

* Remove it from the row related class
* Add bootstrap class to add the property to the direct
  parent of the icon
* Add separate column for icons to improve the code structure.
* Button bar should be there independent of screen size
* break point for SSCS is lg not md
Copy link
Contributor

@nospame nospame left a comment

Choose a reason for hiding this comment

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

Just reviewed the changes since last review of "new changes look good". Couple clarifying questions, looks good on the whole.

@@ -4,7 +4,7 @@
<i class="fa fa-user module-icon" aria-hidden="true"></i>
</div>
</td>
<td class="module-column">
<td class="module-column module-column-name">
Copy link
Contributor

Choose a reason for hiding this comment

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

The module-column-name class gets added here but it looks like the css class was removed, is that right? Or does it serve some other purpose as well?

Copy link
Contributor

Choose a reason for hiding this comment

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

I had removed it to get rid of the relative positioning that caused issues. With this commit I am adding it back in because it missing caused some other issue in app preview. Instead I removed the property from the css class and added it to the direct parent of the icon tags that needed the relative position.

@@ -380,7 +380,7 @@ hqDefine('cloudcare/js/utils', [
let picker = hqTempusDominus.createDatePicker($el.get(0), options);

$el.attr("placeholder", dateFormat);
$el.attr("pattern", "[0-9\-/]+"); // eslint-disable-line no-useless-escape
// $el.attr("pattern", "[0-9\-/]+"); // eslint-disable-line no-useless-escape
Copy link
Contributor

Choose a reason for hiding this comment

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

What was this used for, and why comment out rather than delete?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it is used for validation but it caused and error with each validation because it is malformed regex. I was not sure what the correct regex should be. So I commented it out for now.

Copy link
Contributor

@nospame nospame Jul 10, 2024

Choose a reason for hiding this comment

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

@esoergel do you have any context on what this is meant to be? I know you did work with the datepicker a while back and it looks like one of your commits moved this pattern here initially.

Copy link
Contributor

Choose a reason for hiding this comment

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

@nospame changed it to $el.attr("pattern", "\\d{1,2}/\\d{1,2}/\\d{4}"); since the format is hard coded to 'M/D/YYYY'.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is meant to be "integers, dashes, or slashes" - IIRC, users were sometimes typing out "July 1st" or whatever, and this would mark that as an error. The existing datepicker actually accepts string input in a variety of formats, defined here. I believe it starts from left to right and uses the first format that matches:

var dateFormats = ['MM/DD/YYYY', 'YYYY-MM-DD', 'M/D/YYYY', 'M/D/YY', 'M-D-YYYY', 'M-D-YY', moment.defaultFormat];

Copy link
Contributor

@esoergel esoergel Jul 11, 2024

Choose a reason for hiding this comment

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

Some more context and discussion on that here: #32738 and here: #32628

Copy link
Contributor

Choose a reason for hiding this comment

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

that makes more sense. In the HTML it should end up looking like this pattern="[0-9\-\/]+" because we the dash and forward slash are inside the [] we need to escape them. But since we are in JS land we need two \ each to get there. so $el.attr("pattern", "[0-9\\-\\/]+");

Copy link
Contributor

@nospame nospame left a comment

Choose a reason for hiding this comment

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

Think it'll be good to find an answer to #34682 (comment) but not considering it blocking. Approving the changes made here by @MartinRiese in the time @orangejenny has been offline.

@@ -18,12 +18,19 @@ body {
font-size: 1.5rem;
text-transform: uppercase;
color: $cc-neutral-mid;
padding-left: 1.5rem;
padding-left: 12px;
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a relative padding that could be used here instead (e.g. 1rem)?

Copy link
Contributor

Choose a reason for hiding this comment

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

There's also $spacer, though I'm not certain when you'd use that over rem (I believe $spacer: 2rem)

Copy link
Contributor

Choose a reason for hiding this comment

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

I used px because because .module-column-icon does too and I did not want to mix two units.

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this needs to block, but another option would be to use a common reference variable, if the two items need to line up. Can you explain the connection between .page-header > h1 and .module-column-icon? I see one is set to 12px and the other to 20px, is there an 8px element in the mix somewhere too?

@MartinRiese MartinRiese removed the awaiting QA QA in progress. Do not merge label Jul 24, 2024
Copy link
Contributor

@esoergel esoergel left a comment

Choose a reason for hiding this comment

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

Approving commits since Evan's last approval

@MartinRiese MartinRiese merged commit 3a885ff into master Jul 24, 2024
13 checks passed
@esoergel esoergel deleted the jls/b5-web-apps branch August 28, 2024 18:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file product/all-users-all-environments Change impacts all users on all environments Risk: Medium Change affects files that have been flagged as medium risk.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants