-
Notifications
You must be signed in to change notification settings - Fork 6
Jhork/clear modifier field bug fix #168
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
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
6ca87af
remove check for selectedConditions.length
jonnyhork 4429d5c
adjust test for custom select component
jonnyhork 6531055
De-couple display field from condition model
jgellin-sf c7c143a
Explicitly clear inputs on X click
jgellin-sf e1a63bd
remove dead code
jonnyhork 786f25f
track selected field to re-render if cleared
jonnyhork ddf9b1d
simplify syntax
jonnyhork cb753a2
check all values are cleared with X click
jonnyhork 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -20,6 +20,10 @@ import { | |
| soqlStringLiteralToDisplayValue | ||
| } from '../services/soqlUtils'; | ||
|
|
||
| const DEFAULT_FIELD_INPUT_VALUE = ''; | ||
| const DEFAULT_OPERATOR_INPUT_VALUE = 'EQ'; | ||
| const DEFAULT_CRITERIA_INPUT_VALUE = ''; | ||
|
|
||
| export default class WhereModifierGroup extends LightningElement { | ||
| @api allFields: string[]; | ||
| @api isLoading = false; | ||
|
|
@@ -34,6 +38,8 @@ export default class WhereModifierGroup extends LightningElement { | |
| } | ||
| _condition: JsonMap; | ||
| _currentOperatorValue; | ||
| @track | ||
| _currentFieldSelection; | ||
| @track _criteriaDisplayValue; | ||
| _sobjectMetadata: any; | ||
| sobjectTypeUtils: SObjectTypeUtils; | ||
|
|
@@ -60,6 +66,8 @@ export default class WhereModifierGroup extends LightningElement { | |
| this._condition = condition; | ||
| this._criteriaDisplayValue = ''; | ||
|
|
||
| this._currentFieldSelection = this.getFieldName(); | ||
|
|
||
| const matchingOption = condition | ||
| ? operatorOptions.find( | ||
| (option) => option.modelValue === condition.operator | ||
|
|
@@ -122,18 +130,8 @@ export default class WhereModifierGroup extends LightningElement { | |
| } | ||
|
|
||
| /* --- FIELDS --- */ | ||
| get hasSelectedField() { | ||
| return !!this.getFieldName(); | ||
| } | ||
|
|
||
| get _selectedField() { | ||
| return this.getFieldName() ? [this.getFieldName()] : []; | ||
| } | ||
|
|
||
| get filteredFields() { | ||
| return this.allFields.filter((field) => { | ||
| return field !== this.getFieldName(); | ||
| }); | ||
| return this._currentFieldSelection ? [this._currentFieldSelection] : []; | ||
| } | ||
|
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. This is dead code, I forgot to remove this when we switched to the custom select |
||
|
|
||
| getFieldName(): string | undefined { | ||
|
|
@@ -205,6 +203,11 @@ export default class WhereModifierGroup extends LightningElement { | |
| /** end css class methods */ | ||
|
|
||
| handleConditionRemoved(e) { | ||
| // reset inputs to defaults | ||
| this._currentFieldSelection = DEFAULT_FIELD_INPUT_VALUE; | ||
| this._currentOperatorValue = DEFAULT_OPERATOR_INPUT_VALUE; | ||
| this._criteriaDisplayValue = DEFAULT_CRITERIA_INPUT_VALUE; | ||
|
|
||
| e.preventDefault(); | ||
| const conditionRemovedEvent = new CustomEvent('where__condition_removed', { | ||
| detail: { | ||
|
|
@@ -309,7 +312,7 @@ export default class WhereModifierGroup extends LightningElement { | |
| if (this.checkAllModifiersHaveValues()) { | ||
| this.resetErrorFlagsAndMessages(); | ||
|
|
||
| const fieldName = this.fieldEl.value[0]; | ||
| const fieldName = (this._currentFieldSelection = this.fieldEl.value[0]); | ||
| const op = (this._currentOperatorValue = this.operatorEl.value); | ||
| const opModelValue = this.toOperatorModelValue(op); | ||
|
|
||
|
|
||
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.
Do you think it is worth having a similar test but when there is an error state, like in
set error class on invalid operator inputThere 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.
Yes, i'm adding that now. It looks like the error state needs to be cleared as well in this case.
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.
That'll be in a separate PR. QAing this now.