-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Conditionals feature #2830
Conditionals feature #2830
Conversation
Condition clone name persistance
Removes console log statements Fixes import paths
Clone condition, criteria issues
…2799) * Cast number inputs to a Number so that operations evaluate correctly
* New Condition Widget * Add new glyphs and symbols font files
* Adds XOR and NOT triggers for conditions * Adds unit tests and fixes linting issues
* Test Data * Persist testData and apply it to the conditionSet * Do not persist the applied flag, but persist test data Co-authored-by: charlesh88 <[email protected]>
Removed image properties button from display layouts toolbar
Any all telemetry option for conditions.
* Sisplay default condition output by... default
Topic conditionals master merge
@@ -0,0 +1,81 @@ | |||
/***************************************************************************** |
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.
Typo in the filename
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.
Done.
- Restore updated symbols font file for Condition Widget icon glyph; - Change "All telemetry | Any telemetry" to all lowercase; - Fix cursor styles for Condition Widget; - Fix Safari layout problems with Condition Set/section styles;
… commented out code
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.
Ok, I've got through the JS files, will hit the Vue files next.
This is looking really great, you guys have put in a tonne of work here in a short amount of time (even if it didn't feel like a short amount of time 😄 ).
There are a lot of comments here, but they are mostly small niggles. Happy to discuss any or all of these.
* ] | ||
* } | ||
*/ | ||
export default class ConditionClass extends EventEmitter { |
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.
Let's not have a class name suffixed with Class
. Condition
should be clear enough.
} | ||
|
||
handleBroadcastTelemetry(datum) { | ||
if (!datum || !datum.id) { |
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.
Why would this ever happen?
} | ||
this.criteria.forEach(criterion => { | ||
if (criterion.telemetry && (criterion.telemetry === 'all' || criterion.telemetry === 'any')) { | ||
criterion.handleSubscription(datum, this.conditionManager.telemetryObjects); |
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.
Let's name this something like "evaluateTelemetry" or something. As mentioned previously, naming it "handleSubscription" makes it sound as though it is handling subscription lifecycle events.
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.
This has been addressed and merged in #2904
|
||
updateTelemetry() { | ||
this.criteria.forEach((criterion) => { | ||
criterion.updateTelemetry(this.conditionManager.telemetryObjects); |
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.
This is very confusingly named. This function updates the telemetry object, not the telemetry itself.
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.
Done.
this.conditionManager.on('broadcastTelemetry', this.handleBroadcastTelemetry, this); | ||
} | ||
|
||
handleBroadcastTelemetry(datum) { |
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.
See comments I've made in the past about naming handlers. They should describe what they do, and not the event they handle. This should be something like processTelemetryDatum
.
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.
This has been addressed and merged in #2904
{ | ||
name: 'enumValueIsNot', | ||
operation: function (input) { | ||
return input[0] !== input[1]; |
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.
Cast to Number
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.
This was fixed and merged as part of #2898
} | ||
}, | ||
{ | ||
name: 'valueIs', |
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.
I keep getting confused by the name of this operation, and the fault lies with the people who wrote the requirements, but this operation should be isOneOf
.
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.
Done.
} | ||
}, | ||
{ | ||
name: 'valueIsNot', |
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.
See above
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.
Done.
operation: function (input) { | ||
if (input[1]) { | ||
const values = input[1].split(','); | ||
return values.find((value) => input[0].toString() === _.trim(value.toString())); |
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.
This function should strictly return boolean values. Truthiness is not a substitute for truth. Array.some()
might be better here as it returns a boolean.
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.
Done.
operation: function (input) { | ||
if (input[1]) { | ||
const values = input[1].split(','); | ||
const found = values.find((value) => input[0].toString() === _.trim(value.toString())); |
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.
Let's use native functions wherever possible.
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.
Also, Array.some()
might be better here as it returns a boolean (see previous comment about truthiness vs truth).
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.
Done.
No description provided.