Skip to content
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

Merged
merged 489 commits into from
Mar 31, 2020
Merged

Conditionals feature #2830

merged 489 commits into from
Mar 31, 2020

Conversation

shefalijoshi
Copy link
Contributor

No description provided.

davetsay and others added 30 commits February 25, 2020 17:27
Condition clone name persistance
Removes console log statements
Fixes import paths
davetsay and others added 15 commits March 30, 2020 09:40
…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
src/MCT.js Outdated Show resolved Hide resolved
src/plugins/condition/components/condition.scss Outdated Show resolved Hide resolved
@@ -0,0 +1,81 @@
/*****************************************************************************
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo in the filename

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

charlesh88 and others added 2 commits March 31, 2020 15:36
- 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;
@akhenry akhenry merged commit ee4a81b into master Mar 31, 2020
Copy link
Contributor

@akhenry akhenry left a 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 {
Copy link
Contributor

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) {
Copy link
Contributor

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);
Copy link
Contributor

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.

Copy link
Contributor Author

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);
Copy link
Contributor

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.

Copy link
Contributor Author

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) {
Copy link
Contributor

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.

Copy link
Contributor Author

@shefalijoshi shefalijoshi Apr 16, 2020

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];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cast to Number

Copy link
Contributor Author

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',
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

}
},
{
name: 'valueIsNot',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above

Copy link
Contributor Author

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()));
Copy link
Contributor

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.

Copy link
Contributor Author

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()));
Copy link
Contributor

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.

Copy link
Contributor

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).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@akhenry akhenry mentioned this pull request Apr 8, 2020
13 tasks
@shefalijoshi shefalijoshi deleted the topic-conditionals branch September 3, 2020 17:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants