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

198 Include user's card labels when generating the report #219

Merged
merged 11 commits into from
Oct 3, 2023

Conversation

m7pr
Copy link
Contributor

@m7pr m7pr commented Sep 26, 2023

Closes #198 and accompanied by insightsengineering/teal.modules.clinical#835

The problem

Currently most of the teal modules, that wrap up teal.reporter in their UI, have titles of the ReportCard hardcoded in their body. For example check out below 2 modules

https://github.com/insightsengineering/teal.modules.clinical/blob/2b20a85b22f25f15f6808f745b4d1d5333b123f3/R/tm_g_ci.R#L484-L503

https://github.com/insightsengineering/teal.modules.clinical/blob/2b20a85b22f25f15f6808f745b4d1d5333b123f3/R/tm_g_km.R#L774-L793

Such hardcoded content in card$set_name() and card$append_text() has a great impact on the final ReportCard.
If label in the Add Card module UI is not provided, then the card name is set to the one passed in card$set_name(). This is fine for cards that had empty labels - they will have a name populated by the developer of the teal module.

image

However card$append_text() like this
https://github.com/insightsengineering/teal.modules.clinical/blob/2b20a85b22f25f15f6808f745b4d1d5333b123f3/R/tm_g_km.R#L778
and this
https://github.com/insightsengineering/teal.modules.clinical/blob/2b20a85b22f25f15f6808f745b4d1d5333b123f3/R/tm_g_ci.R#L489
appends a content to the card. The card gets a hardcoded title, no matter what user specifies as a card label.

The solution

add_card_button_srv allows to specify card_fun with label parameter for card's title & content customization. This means, that you are able to use label shiny input and use it in your card_fun to pass the title. We are able to rewrite teal modules, so that they have default titles, if label is empty in Add Card module UI. When it is not empty, then the label is used as a name and as a title of the card - like in this commit insightsengineering/teal.modules.clinical@5833c6c

With label

image
image

Without the label

image
so the default teal module name and title are used
image

@m7pr m7pr added the core label Sep 26, 2023
@m7pr m7pr marked this pull request as ready for review September 26, 2023 13:05
@github-actions
Copy link
Contributor

github-actions bot commented Sep 26, 2023

badge

Code Coverage Summary

Filename              Stmts    Miss  Cover    Missing
------------------  -------  ------  -------  ----------------------------------------------------------------------------------
R/AddCardModule.R       144       2  98.61%   162, 199
R/Archiver.R             25       0  100.00%
R/ContentBlock.R         18       2  88.89%   38-44
R/DownloadModule.R      207      49  76.33%   89-95, 138, 163-168, 177-181, 184-188, 196-200, 203-207, 214-218, 221-225, 262-266
R/FileBlock.R            13       0  100.00%
R/NewpageBlock.R          2       0  100.00%
R/PictureBlock.R         30       2  93.33%   15, 79
R/Previewer.R           295      56  81.02%   183, 197, 199-202, 205, 208-216, 325-369
R/RcodeBlock.R           15       0  100.00%
R/Renderer.R            115      22  80.87%   61, 122, 130, 139, 141-162
R/ReportCard.R           77       4  94.81%   180, 219, 224, 245
R/Reporter.R             94       1  98.94%   254
R/ResetModule.R          55       0  100.00%
R/SimpleReporter.R       29       0  100.00%
R/TableBlock.R            9       0  100.00%
R/TextBlock.R            13       0  100.00%
R/utils.R               161      70  56.52%   7, 38-97, 99, 102-109, 163, 175-177
R/yaml_utils.R           81       2  97.53%   41, 239
TOTAL                  1383     210  84.82%

Diff against main

Filename             Stmts    Miss  Cover
-----------------  -------  ------  -------
R/AddCardModule.R       +4      +1  -0.67%
TOTAL                   +4      +1  -0.03%

Results for commit: 29be0e6

Minimum allowed coverage is 80%

♻️ This comment has been updated with latest results

@github-actions
Copy link
Contributor

github-actions bot commented Sep 26, 2023

Unit Tests Summary

    1 files    18 suites   23s ⏱️
204 tests 204 ✔️ 0 💤 0
346 runs  346 ✔️ 0 💤 0

Results for commit 8858d32.

♻️ This comment has been updated with latest results.

Copy link
Contributor

@kartikeyakirar kartikeyakirar left a comment

Choose a reason for hiding this comment

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

In the report, there is a blank header when Rcode is included. I previously added a blank header in teal.reporter to move content to another slide. This issue can be resolved by replacing ### with ---.

"### ",
.

image

@m7pr
Copy link
Contributor Author

m7pr commented Sep 27, 2023 via email

@kartikeyakirar
Copy link
Contributor

kartikeyakirar commented Sep 27, 2023

Is this in the scope of this feature?

Not exactly but it affects report with Rcode is created but I have included this change in PR. so no worries.

insightsengineering/teal.modules.clinical@5833c6c

The solution looks good and I recommend creating separate tasks for each package to facilitate easy tracking. This applies to teal.module.clinical, teal.modules.general, teal.modules.hermes, teal.osprey, and teal.goshawk. All these modules utilize the reporter.

R/AddCardModule.R Outdated Show resolved Hide resolved
Co-authored-by: kartikeya kirar <[email protected]>
Signed-off-by: Marcin <[email protected]>
@m7pr m7pr requested a review from kartikeyakirar September 27, 2023 10:42
@m7pr m7pr requested review from donyunardi and lcd2yyz September 27, 2023 11:02
@m7pr
Copy link
Contributor Author

m7pr commented Sep 27, 2023

Hey @lcd2yyz and @donyunardi - pinging you here to double check you are ok with the proposed changes?
In many teal modules that uses teal.reporter we had hardcoded card content titles. This PR allows the Card Name label to be passed as a title of Card Content. This is a big change, as this required so many modules to be changed in teal.modules.clinical - check this PR insightsengineering/teal.modules.clinical#835

Is this the desired behavior? If yes, I will proceed with this change in other packages listed by @kartikeyakirar above
teal.modules.general, teal.modules.hermes, teal.osprey, and teal.goshawk

@m7pr
Copy link
Contributor Author

m7pr commented Sep 29, 2023

Hey @lcd2yyz and @donyunardi - we are ready to merge. Just waiting for your final green light.

Copy link
Contributor

@donyunardi donyunardi left a comment

Choose a reason for hiding this comment

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

Thanks for working on this @m7pr
I think the solution is great and very subtle.

@m7pr m7pr dismissed kartikeyakirar’s stale review October 3, 2023 08:52

fixed in other issue

@m7pr m7pr merged commit 629f981 into main Oct 3, 2023
23 checks passed
@m7pr m7pr deleted the 198_card_labels@main branch October 3, 2023 08:52
kartikeyakirar added a commit to insightsengineering/teal.modules.general that referenced this pull request Oct 13, 2023
this PR fixes
#583

this is follow-up after
insightsengineering/teal.reporter#219

---------

Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
kartikeyakirar added a commit to insightsengineering/teal.modules.clinical that referenced this pull request Oct 13, 2023
This PR allows end user to use their Card Name (label) to be passed to
the Card Content. There are no more hardcoded titles. The hardcoded
titles will be only used if Card Name (label0) is empty.

A follow-up after
insightsengineering/teal.reporter#219

---------

Signed-off-by: André Veríssimo <[email protected]>
Co-authored-by: André Veríssimo <[email protected]>
Co-authored-by: unknown <[email protected]>
kartikeyakirar added a commit to insightsengineering/teal.modules.hermes that referenced this pull request Oct 13, 2023
this PR fixes
#335

this is follow-up after
insightsengineering/teal.reporter#219

---------

Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
kartikeyakirar added a commit to insightsengineering/teal.osprey that referenced this pull request Oct 13, 2023
this PR fixes
#228

this is follow-up after
insightsengineering/teal.reporter#219

---------

Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
kartikeyakirar added a commit to insightsengineering/teal.goshawk that referenced this pull request Oct 13, 2023
this PR fixes
#240

this is follow-up after
insightsengineering/teal.reporter#219

---------

Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: 27856297+dependabot-preview[bot]@users.noreply.github.com <27856297+dependabot-preview[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature Request]: Include user's card labels when generating the report
3 participants