-
-
Notifications
You must be signed in to change notification settings - Fork 152
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
Unable to select or deselect columns to be displayed in lists #410
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
3d8d688
Display the columns in lists in accordance with the toogle_cols cookie
xispa 4cbb97f
changelog
xispa abfbd9c
Don't use a local columns var, prevent issues with global var
xispa 6606df9
Merge remote-tracking branch 'senaite/master' into i360
xispa 1941619
Merge branch 'master' into i360
ramonski 6de13d6
Merge branch 'master' into i360
ramonski File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -723,10 +723,7 @@ def _process_request(self): | |
# and modify self.columns[]['toggle'] to match. | ||
toggle_cols = self.get_toggle_cols() | ||
for col in self.columns.keys(): | ||
if col in toggle_cols: | ||
self.columns[col]['toggle'] = True | ||
else: | ||
self.columns[col]['toggle'] = False | ||
self.columns[col]['toggle'] = col in toggle_cols | ||
|
||
def _set_sorting_criteria(self): | ||
""" | ||
|
@@ -822,25 +819,28 @@ def get_columns_indexes(self): | |
return indexes | ||
|
||
def get_toggle_cols(self): | ||
_form = self.request.form | ||
toggles = {} | ||
try: | ||
default_toggles = _form.get("toggle_cols", "{}") | ||
_key = self.form_id + "_toggle_cols" | ||
form_toggles = _form.get(_key, default_toggles) | ||
toggles = json.loads(form_toggles) | ||
except (ValueError, TypeError): | ||
pass | ||
finally: | ||
if not toggles: | ||
toggles = {} | ||
cookie_key = "%s%s" % (self.context.portal_type, self.form_id) | ||
toggle_cols = toggles.get( | ||
cookie_key, [col for col in self.columns.keys() | ||
if col in self.review_state['columns'] and | ||
('toggle' not in self.columns[col] or | ||
self.columns[col]['toggle'] is True)]) | ||
return toggle_cols | ||
""" | ||
Returns the list of column ids to be displayed for the current list. | ||
:return: list of column ids to be displayed | ||
:rtype: list of str | ||
""" | ||
# Get the toggle configuration from the cookie | ||
cookie_toggle = self.request.get('toggle_cols', '{}') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't be that value in Reminder: We have to consolidate all the different places in the system where cookies get set, because these cookies make caching by Varnish impossible. |
||
cookie_toggle = json.loads(cookie_toggle) | ||
|
||
# Load the toggling configuration for the current list | ||
list_toggle_key = "%s%s" % (self.context.portal_type, self.form_id) | ||
list_toggle = cookie_toggle.get(list_toggle_key, []) | ||
|
||
# If there is no stored configuration re toggle for the current list | ||
# in the cookie (or if there is no cookie for toggle config), use the | ||
# default configuration based on the initial column settings | ||
if not list_toggle: | ||
columns_ids = self.review_state['columns'] | ||
list_toggle = [col_id for col_id in columns_ids if | ||
self.columns[col_id].get('toggle', True) is True] | ||
|
||
return list_toggle | ||
|
||
def GET_url(self, include_current=True, **kwargs): | ||
url = self.request['URL'].split("?")[0] | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!