pc2ccs / pc2v9

Version 9 of the PC^2 Programming Contest Control System
Eclipse Public License 2.0
46 stars 23 forks source link

Filter incorrectly sets all items in list #368

Open johnbrvc opened 2 years ago

johnbrvc commented 2 years ago

Describe the issue: On panes that have a Filter button that allows filtering by accounts or teams (Accounts, Runs, Clarifications, etc), selecting a single team or account can cause all teams/accounts to be selected in that list.

To Reproduce: From Admin, select Run Contest->Clarifications (make sure there are clarifications present) Click on the Filter button along bottom. Under Teams, pick a single team, say, team1. Press Ok button (DO NOT SELECT "Filter On") Press the Filter button again. Note that all teams are now selected.

Expected behavior: Only the team(s) or item(s) that were previously selected should be selected, not the entire list.

Actual behavior: All teams are selected.

Environment:

OS : Windows 11 Java Version : 17.0.1

Today's Date : Tue Apr 05 13:27:27 EDT 2022

Version 9.2 20220312 (Saturday, March 12th 2022 02:48 UTC) Java ver 17.0.1 build 91 Windows 10 10.0 (amd64)

Log Info:
N/A

Screenshots: Not necessary

Additional context: It appears this is a problem with pc2.core.model.Filter and pc2.ui.EditFilterPane in routine loadTeamName (and loadAccountNames). The inFilter "isFilteringAccounts()" routine returns true because there is a single item in the hash table (Filter.filteringAccounts == true). setSelected for the checkbox checks if the filter matches the account by calling matches(Account account). This in turn calls FIlter.matches(ClientId). Since "Filter.filterEnabled" is false, "matches(ClientId)" returns true all the time. Hence, all boxes become checked. This only occurs with Teams/Accounts.

Possible solution: There seems to be confusion about the different between filteringXXXXX and filterEnabled. The former (eg filteringAccounts) is used to indicate that there are specific accounts selected in the hash table for accounts (Really, clientId's: Filter.clientIdHash). The latter indicates that the entire filter is "in effect". At the point this occurs, "filterEnabled" should not be the criteria tested. A separate routine that simply checks if something is in the specific hashtable as opposed to being both IN the hashtable AND filteringEnabled. Basically, matchesAccount(ClientId clientId) does this. In EditFIlterPane.java, If calls to "matches(Account)" are changed to "matchesAccount(Account.getClientId())" in the 2 places (loadTeamNames, loadAccountNames), the issue is resolved. Not sure if there is a better or more correct solution.

lane55 commented 1 year ago

There was a report of select all teams filter problem. A user selected all (Ctrl-A) then unselect all then selected one team, click Filter on then Ok. All teams showed up. edit filter again and all teams selected. -- shown to me by Tom R pacnw contest