-
Notifications
You must be signed in to change notification settings - Fork 7
GitHub Issue 947, 955 & 988 #7518
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,10 +16,18 @@ Ext4.define('LABKEY.internal.ViewDesigner.field.FilterTextValueUtil', { | |
| // convert the filter value into a user-editable string using filter.getURLParameterValue() | ||
| var valueString = filter.getURLParameterValue(); | ||
|
|
||
| // replace ; with \n on UI | ||
| // Display multi-valued filters with one value per line in the textarea. | ||
| // getURLParameterValue() returns {json:[...]} when values contain the ';' separator, | ||
| // so we need to parse that format before converting to newline-separated display. | ||
| if (filterType.isMultiValued() && (urlSuffix !== 'notbetween' && urlSuffix !== 'between')) { | ||
| if (typeof valueString === 'string' && valueString.indexOf('\n') === -1 && valueString.indexOf(';') > 0) | ||
| valueString = valueString.replaceAll(';', '\n'); | ||
| if (typeof valueString === 'string') { | ||
| var parsed = this._parseJsonFilterValue(valueString); | ||
| if (parsed !== null) { | ||
| valueString = parsed.join('\n'); | ||
| } else if (valueString.indexOf('\n') === -1 && valueString.indexOf(';') > 0) { | ||
| valueString = valueString.replaceAll(';', '\n'); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| this.setValue(valueString); | ||
|
|
@@ -48,15 +56,55 @@ Ext4.define('LABKEY.internal.ViewDesigner.field.FilterTextValueUtil', { | |
|
|
||
| setRecordValue : function (valueString) { | ||
| // parse the value string into parts for multi-value filters | ||
| var filterValue; | ||
| try { | ||
| // For multi-valued filters (excluding between/notbetween), values are displayed | ||
| // one per line in the textarea. When saving, split by newline only and encode | ||
| // using {json:[...]} if any value contains the separator character (e.g. ';') | ||
| // to prevent parseValue from incorrectly splitting those values. | ||
| var op = this.record.get("items")[this.clauseIndex].op; | ||
| var filterType = LABKEY.Filter.getFilterTypeForURLSuffix(op); | ||
| var urlSuffix = filterType ? filterType.getURLSuffix() : null; | ||
|
|
||
| if (filterType && filterType.isMultiValued() && typeof valueString === 'string' | ||
| && urlSuffix !== 'notbetween' && urlSuffix !== 'between') { | ||
| var sep = filterType.getMultiValueSeparator(); | ||
| var values = valueString.split('\n'); | ||
| if (sep && values.some(function(v) { return v.indexOf(sep) !== -1; })) { | ||
| valueString = '{json:' + JSON.stringify(values) + '}'; | ||
| } else { | ||
| valueString = values.join(sep); | ||
| } | ||
| } | ||
|
|
||
| var filter = this.createFilter(valueString); | ||
| var filterValue = filter.getValue(); | ||
| filterValue = filter.getValue(); | ||
| } | ||
| catch (e) { | ||
| console.warn("Error parsing filter value: " + valueString); | ||
| filterValue = valueString; | ||
| } | ||
|
|
||
| this.record.get("items")[this.clauseIndex].value = filterValue; | ||
| }, | ||
|
|
||
| /** | ||
| * GitHub Issue 947: Multi value text choice values with semicolon mangled in LKS grid view editor | ||
| * Parse a {json:[...]} encoded filter value string. | ||
| * Returns the parsed array, or null if the string is not in {json:...} format. | ||
| */ | ||
| _parseJsonFilterValue : function (valueString) { | ||
| if (typeof valueString === 'string' | ||
| && valueString.indexOf('{json:') === 0 | ||
| && valueString.lastIndexOf('}') === valueString.length - 1) { | ||
| try { | ||
| var parsed = JSON.parse(valueString.substring('{json:'.length, valueString.length - 1)); | ||
| if (Array.isArray(parsed)) | ||
| return parsed; | ||
| } catch (e) { | ||
| // Not valid JSON, return null to fall through to default handling | ||
| } | ||
| } | ||
| return null; | ||
|
Contributor
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. not sure where this comment belongs, but if I go to the LKS grid filter modal for a MVTC field that has values like: "a, b" and "a;b". When I put them both in the filter modal or have multiple lines, it works as expected, but If I just try to include "a;b", it doesn't work. It turns that into an array of "a" and "b"
Contributor
Author
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. Could you please file a separate issue for this, unless this is newly introduced? We were not prioritizing LKS scenarios but might want this fixed before the LKS bug bash. This seems the same behavior as regular text field filtering.
Contributor
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. new issue added here: https://github.com/LabKey/internal-issues/issues/998 |
||
| } | ||
| }); | ||

Uh oh!
There was an error while loading. Please reload this page.