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 #835

Merged
merged 18 commits into from
Oct 13, 2023

Conversation

m7pr
Copy link
Contributor

@m7pr m7pr commented Sep 26, 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

@m7pr m7pr changed the title 98 Include user's card labels when generating the report 198 Include user's card labels when generating the report Sep 26, 2023
@m7pr m7pr added the core label Sep 26, 2023
@m7pr m7pr marked this pull request as ready for review September 27, 2023 11:00
@github-actions
Copy link
Contributor

github-actions bot commented Sep 27, 2023

Unit Tests Summary

    1 files    33 suites   4s ⏱️
149 tests 149 ✔️     0 💤 0
280 runs  168 ✔️ 112 💤 0

Results for commit 4a7e361.

♻️ This comment has been updated with latest results.

R/tm_a_gee.R Outdated Show resolved Hide resolved
R/utils.R Outdated Show resolved Hide resolved
R/tm_a_gee.R Outdated Show resolved Hide resolved
@m7pr m7pr requested review from chlebowa and averissimo September 29, 2023 09:54
@chlebowa
Copy link
Contributor

Yay, indentation linter 🥳

Corrects SuperLinter errors that were already in `main` and unrelated to
#835

They were caught by SuperLinter because we changed the files.

---------

Co-authored-by: m7pr <[email protected]>
@kartikeyakirar
Copy link
Contributor

This looks good, @m7pr. Could you also add a unit test for card_template?

m7pr added a commit to insightsengineering/teal.reporter that referenced this pull request Oct 3, 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](https://github.com/insightsengineering/teal.reporter/assets/133694481/b5d3656b-b61f-450f-ba69-b9db14889a24)

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](https://github.com/insightsengineering/teal.reporter/assets/133694481/2c96ba72-19eb-41c8-82a6-bd89bcaa02cc)

![image](https://github.com/insightsengineering/teal.reporter/assets/133694481/5ab17ab9-e2a9-40fc-96ee-068be0c34b42)


## Without the label


![image](https://github.com/insightsengineering/teal.reporter/assets/133694481/c318d90b-4518-4839-bf5a-5189e771c6bb)
**so the default `teal` module name and title are used**

![image](https://github.com/insightsengineering/teal.reporter/assets/133694481/7c313c1c-adf6-4cdd-afba-d23791144dbd)

---------

Signed-off-by: Marcin <[email protected]>
Co-authored-by: kartikeya kirar <[email protected]>
Co-authored-by: 27856297+dependabot-preview[bot]@users.noreply.github.com <27856297+dependabot-preview[bot]@users.noreply.github.com>
Co-authored-by: Dony Unardi <[email protected]>
@m7pr
Copy link
Contributor Author

m7pr commented Oct 4, 2023

@kartikeyakirar while working on other packages, can you create a test function in this PR as well? you will need to create it in other packages anyway

This looks good, @m7pr. Could you also add a unit test for card_template?

Thanks

Copy link
Contributor Author

@m7pr m7pr left a comment

Choose a reason for hiding this comment

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

@kartikeyakirar please take out card_template and move it to teal.reporter.
insightsengineering/teal.modules.general#584 (comment)

.lintr Show resolved Hide resolved
@m7pr
Copy link
Contributor Author

m7pr commented Oct 13, 2023

Hey @kartikeyakirar looks like this staged deps cyclic error does not appear on this PR anymore. You are good to merge

kartikeyakirar added a commit to insightsengineering/teal that referenced this pull request Oct 13, 2023
#933)

this PR is extension to
insightsengineering/teal.reporter#198

Here I have added card_template() function that generates a report card
with a title,
an optional description, and the option to append the filter state list.
and is been used in
insightsengineering/teal.modules.general#584
insightsengineering/teal.modules.clinical#835
insightsengineering/teal.modules.hermes#336
insightsengineering/teal.osprey#229
insightsengineering/teal.goshawk#241

ref issues and discussion:
insightsengineering/teal.reporter#226

---------

Signed-off-by: kartikeya kirar <[email protected]>
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Marcin <[email protected]>
Co-authored-by: 27856297+dependabot-preview[bot]@users.noreply.github.com <27856297+dependabot-preview[bot]@users.noreply.github.com>
@kartikeyakirar kartikeyakirar merged commit e5e8dae into main Oct 13, 2023
20 checks passed
@kartikeyakirar kartikeyakirar deleted the 198_card_labels@main branch October 13, 2023 09:45
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.

4 participants