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

turn off on panel #91

Closed
wants to merge 19 commits into from
Closed

turn off on panel #91

wants to merge 19 commits into from

Conversation

Polkas
Copy link
Contributor

@Polkas Polkas commented Aug 22, 2022

closes #84

Global toggle for Filter Panel, where the hidden state is recovered when turn on.
The PR is taken into account the filter_panel_api which is linked with it.

@nikolas-burkoff
Copy link
Contributor

nikolas-burkoff commented Aug 23, 2022

Does this close #84 - I guess you also need the trigger in FilteredDataAPI

R/FilteredData.R Outdated Show resolved Hide resolved
@nikolas-burkoff
Copy link
Contributor

We also need to correctly (whatever that means) handle the case where the filter panel is disabled but the module developer calls the filter panel api to set states

@Polkas
Copy link
Contributor Author

Polkas commented Aug 23, 2022

Does this close #84 - I guess you also need the trigger in FilteredDataAPI

No, this is a button in the global scope not local.

@nikolas-burkoff
Copy link
Contributor

  • Do you think there's a way of linking all these together (i.e. some panel with light shading to show that the whole of this is the filter panel?) - and maybe a title "filtering"

image

  • Also I don't like the word "Turn" there maybe An inline label "Filtering:" then the switch you have with labels "Enabled" + "Disabled"

  • There's a picture of the filter panel in the teal vignette which I think should be updated (or a ticket added to update it)

I'm aware there is a big filter panel UI change coming so not sure whether these should be done here or not

@Polkas Polkas requested a review from gogonzo August 29, 2022 07:20
Copy link
Contributor

@gogonzo gogonzo left a comment

Choose a reason for hiding this comment

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

tests are missing, besides looks good to me

@@ -891,6 +945,12 @@ FilteredData <- R6::R6Class( # nolint
# private attributes ----
filtered_datasets = list(),

# turn on / off filter panel
filter_turn = TRUE,
Copy link
Contributor

@pawelru pawelru Sep 2, 2022

Choose a reason for hiding this comment

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

  1. I dislike the "turn" term here. You can turn left/right or on/off. It's a verb whereas you are looking for a noun. I propose state / status / active instead. Please change other places as well including method docs.

  2. What's the point of this field? I ask from the class simplicity point of view.
    I can see that it's used in the api class - there is a check whether it's active and if yes then you can do set/get/etc. Is that needed? The functionality would be anyway disabled from the GUI perspective (vide: disabling inputs). What I am suggesting here is that the big disable/enable button would just propagate this action to all relevant inputs + save/restore action and that's it. An object would not store its state as this opens a door for unnecessary complexity I believe. I am happy to discuss it further if needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

By default shinyWidgets::switchInput use the logical(1) for value so this should not be surprising I stay with this type.

filter_turn variable is needed only for filter_panel_api, so we could provide a proper warning if sb want to update the state when filter panel is turn off.

I like the Turn Off/On naming, although I see you agree with Nik in this area so please update to the one you are preferring.

R/FilteredData.R Outdated
Comment on lines 807 to 812
handlerExpr = {
if (isTRUE(input[["filter_turn_onoff"]])) {
self$filter_panel_enable()
} else {
self$filter_panel_disable()
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I would suggest to put all of shinyjs::disable/enable calls here and use save/restore methods. This would keep shiny functionalities nicely decoupled - methods relates only to data fields and shiny parts lives inside the modules.
Moreover, I do not see (and I couldn't imagine) other place where we would call self$filter_panel_enable/disable().

Copy link
Contributor Author

Choose a reason for hiding this comment

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

"other place where we would call" - DRY rule is not the only reason to separate the code. Nice that you are raising it, please check how overcrowded is the server of filter panel now. WE should work to make it more clear and readable.

Copy link
Contributor

Choose a reason for hiding this comment

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

DRY rule is not the only reason to separate the code

Yes you are definitely right here but my first point remains.
Long time ago we have a lengthy discussions with @gogonzo and Konrad about decoupling shiny-related parts from the class definitions. Unfortunately there is no good design pattern and we decided to still keep it inside the class definition but only inside one module method or two ui/server methods. This indeed means that those the method(s) definitions would be lengthy but it also assures nice decoupling of class' methods from the shiny part which should serve just as an add-on which calls those methods. Separate shiny-methods would break that and make the code less separated.

R/FilteredData.R Outdated
Comment on lines 623 to 633
div(
id = ns("switch-button"),
class = "inline-block",
shinyWidgets::switchInput(
ns("filter_turn_onoff"),
label = "TURN",
value = TRUE,
inline = FALSE,
handleWidth = "80px"
)
),
Copy link
Contributor

Choose a reason for hiding this comment

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

Please spend more time on UX here. IMO right now it is too maximal

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I like the current UI as is obvious and the functionality important, please give me your idea then.

Copy link
Contributor

Choose a reason for hiding this comment

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

It's not about the importance of the feature - it's more how it fits into the overall GUI. Right now it doesn't fit well.
Maybe something like below? It's a minimal switch with decreased opacity.
image

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 the button that @Polkas proposed could work if we label it properly:

Screen Shot 2022-09-22 at 10 44 40 PM

But I also think the button that @pawelru proposed looks good too.

@kumamiao do you have any opinion on how which button that makes the most sense to the user?

Copy link
Contributor

@donyunardi donyunardi Sep 23, 2022

Choose a reason for hiding this comment

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

Also, @kumamiao, can I also get your opinion on the wording 'On/Off' or 'Enabled/Disabled' for the button toggle? Which one do you think user will prefer?

Choose a reason for hiding this comment

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

I am a fan of Pawel's proposition of the On/Off switch for Active filtering which is quite straightforward
image
The current button can be a bit misleading and takes more space

@insightsengineering insightsengineering deleted a comment from pawelru Sep 2, 2022
@Polkas
Copy link
Contributor Author

Polkas commented Oct 17, 2022

Finally the idea from @kumamiao and @pawelru looks most preferable so I apply the shinyWidgets::prettySwitch. The implementation is very straightforward and equally easy to maintain.

Screenshot 2022-10-17 at 14 13 25

@pawelru
Copy link
Contributor

pawelru commented Oct 17, 2022

Thank you - this is much better now!

The screenshot you provided made me think about yet another idea - how about placing the switch next to the show/hide button (hamburger one). Those are conceptually functionalities affecting the same object - filter. WDYT?

@Polkas
Copy link
Contributor Author

Polkas commented Oct 17, 2022

@pawelru very interesting proposition.
So the hamburger button is a part of teal::init not the filtering panel by itself.
Currently we are adding the activate button directly to the filter panel, so under current design I could not bind them together directly. I could make the switch button to align right by itself.

I apply your proposition and I remove the text and leave it only as a title which will be printed on hover. I very like this scenario.

Screenshot 2022-10-17 at 18 00 49

with regular text:

Screenshot 2022-10-17 at 18 05 01

@Polkas Polkas closed this Nov 8, 2022
@gogonzo gogonzo deleted the 26_new_chunks@main branch January 13, 2023 10:58
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.

Introduce disable filters in FilterPanelApi/FilteredData
7 participants