PowerShell / ConsoleGuiTools

Modules that mix PowerShell and GUIs/CUIs!
https://www.powershellgallery.com/packages/Microsoft.PowerShell.ConsoleGuiTools
MIT License
790 stars 60 forks source link

OCGV:Different Filter will "forget" all selected before #174

Closed MrFly72 closed 1 year ago

MrFly72 commented 2 years ago

Prerequisites

Steps to reproduce

When a filter is active at the end of choosing elements, only the elements that are included in the active filter will be returned. eg.: Get-Process | Out-ConsoleGridView Check one process, eg. Word Filter by eg.Notepad, check Notepad When you now hit enter with the active filter for notepad, only notepad will be returned

There is only one workaround this, you have to remove the filter before hitting enter.

This bug is introduced in the newer version, as before, hitting enter in a filtered list, would gather all elements that have been checked.

Expected behavior

Word + Notepad should be returned

Actual behavior

Only notepad is returned

Error details

No Error ourput

Environment data

Name                           Value
----                           -----
PSVersion                      7.2.6
PSEdition                      Core
GitCommitId                    7.2.6
OS                             Linux 5.15.56-v8+ #1575 SMP PREEMPT Fri Jul 22 20:31:26 BST 2022
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Version

0.7.2

Visuals

No response

tig commented 2 years ago

This is caused by https://github.com/PowerShell/GraphicalTools/pull/163

I agree this is a change in behavior and it's a bummer it impacted you.

I think it's too late to revert/fix this for 0.7.2 as @andschwa notes.

We can definitely fix for 0.7.3.

The question is, how do I fix it?

See #121 for more background.

MrFly72 commented 2 years ago

I want to describe my impact on this a little bit more in detail. I am using OCGV on a Raspberry Pi for a script I wrote to automate Media Download from State TV. Basically it filters series etc. by rest-api from a source-page, then displays them with OCGV to check for shows to be downloaded. To easier check them, as it is usually a list of 1800 shows, I filter them, eg. "Show 1", then check the ones to download, then filter by "show 2" and mark others to download and so on. at the end, i press enter to accept all shows and then the script will add download jobs on my NAS by rest-api. it will wait for all shows to download and rename them by defined pattern (eg. Date-Series.Title-Episode-Title.mp4). I know, that the Windows Version of OGV, also does not "keep" marked entries by "CTRL", but on the other end there are no checkboxes, so totally different approach.

For me it would be valuable, for the checkmarks to be persistent through filters. At the moment, the workaround for me is, to remove the filter before "enter", as the checkmarks will persist. The only bummer is, that you really have to clear filter by "backspace" character by character

BDisp commented 2 years ago

The only bummer is, that you really have to clear filter by "backspace" character by character

The Filter has a ContextMenu with a Delete All where you can delete all text at once.

MrFly72 commented 2 years ago

How do I reach the context menu on Linux shell? Did not find any possibility in an ssh shell

BDisp commented 2 years ago

How do I reach the context menu on Linux shell? Did not find any possibility in an ssh shell

By mouse right clicking on the TextField or by pressing Ctrl+Shift+D. But I see that this isn't working on the current build. I submitted this pr https://github.com/gui-cs/Terminal.Gui/pull/1968 to allow pressing Ctrl+R, because Linux don't differentiate Ctrl+alfa from Ctrl+Shift+alfa.

MrFly72 commented 2 years ago

Mouse? Hehe. Don't use one on my iPad which connects via SSH to the raspian shell and then use the shell to start pwsh. So keyboard is essential for this.

BDisp commented 2 years ago

Mouse? Hehe. Don't use one on my iPad which connects via SSH to the raspian shell and then use the shell to start pwsh. So keyboard is essential for this.

I forgot to mention that the context menu can be opened with the keyboard by pressing Shift+F10, but I don't know why it isn't opening with the current build.

MrFly72 commented 2 years ago

Ok. I mean I can understand that some people want it this way (Filter will forget all previously checked). As in the thread which changed this was mentioned, there are people who want his behavior and some don't. This is a typical area for a switch. Default could be "drop selections" and a switch like -keepselectsonfilter could keep them.

MrFly72 commented 2 years ago

I must realize, that I more then once walked into this issue, even after knowing that it changed. HAd this great way before:

tznind commented 2 years ago

Would a solution be to 'pin' selected items regardless of filter? So if an item is checked then it doesn't disappear even when the filter is changed? That should make clear that the ticked items are going to be confirmed even if they don't match the filter?

Sort of like this: pinningmultiselect Ignore the random reorder of items as they are ticked ;)

Apologies if I have misunderstood the issue.

MrFly72 commented 2 years ago

Would also be ok in my eyes. And I think the counter of how many are selected is also not a bad idea.

BDisp commented 2 years ago

That is the best solution. Maintaining a track on each new filter to the ID of all the available items from the empty filter.

MrFly72 commented 1 year ago

Is someone actively working on this? I must really admit that I really often "pitfall" into this. Filter, check some element, filter something else, check some additional and then forget to delete filters and will only have the elements with the checked ones in the second filter. Btw. I use this in a list with about 2000items, where without filtering, it is not really nice to select. A solution would be very welcome!

tig commented 1 year ago

I def want to fix this!

I will get to it asap.

MrFly72 commented 1 year ago

Any news? Meanwhile i get used to

tig commented 1 year ago

No update at this time. On my list to work on but been super busy. Sorry.

MrFly72 commented 1 year ago

Any news on this?

tig commented 1 year ago

@MrFly72, whatcha think of this?

xsK3sKz 1

The model is now:

Thanks to @tznind for the suggestion.

MrFly72 commented 1 year ago

Looks great. Can tell you how it feels when able to try.

tig commented 1 year ago

Putting @MrFly72's question in right thread:

One first question. How does it behave if the screen eg. Only shows 20 elements and I have already selected 18. is the scrolling area then still 20 and the pinned elements will "walk up" in the list or are place 1-18 fix with the pinned elements and only the lines 19-20 will move?

The pinned elements currently are just the top elements in the filtered list. They scroll with the list.

Making them actually be pinned (so they don't scroll) would be a big change...

MrFly72 commented 1 year ago

Hi. I am testing in every day usage and found out, that the elements will not be on top of list, they will be in the same order, that they would have been in the "no-filtered" list: image Would be "nicer" if they would really be at the top. Or what do you think ?

tig commented 1 year ago

That was my intent. I'll look to see what I did wrong.

MrFly72 commented 1 year ago

It is a large objectlist I am using (2600 rows).Don't know if that matters. It takes a while to load (about 10 secs) from pipeline.

tig commented 1 year ago

188 should fix this! Let me know (in that PR comments).