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

Apply condition sets to drawing objects in a layout + Static styling for objects. #2767

Merged
merged 88 commits into from
Mar 24, 2020

Conversation

shefalijoshi
Copy link
Contributor

@shefalijoshi shefalijoshi commented Mar 23, 2020

Static styles for drawing objects Resolves #2762
Conditional styles for drawing objects
Static Styles for domain objects
Control visibility for domain objects and drawing objects in a layout Resolves #2766
Add condition sets (one or more) to inspector view Resolves #2644
Default style for domain objects Resolves #2643

Author Checklist

  • Changes address original issue? Yes
  • Unit tests included and/or updated with changes? Yes
  • Command line build passes? Yes
  • Changes have been smoke-tested? Yes

shefalijoshi and others added 30 commits February 25, 2020 22:12
…tor domain objects only.

Needs Architectural review
Removes hardcoded conditionSet work used for prototype
Change variable name for better readability and clarity
Remove unused code
- Tweaks for layout/overflow issues;
- Better header alignment;
- Much better approach to "accordion" spacing;
- New `.c-selector` class;
- Markup added to tree-item.vue to fix missing `c-object-label` wrapper;
Copy link
Contributor

@JoelMcKinnon JoelMcKinnon left a comment

Choose a reason for hiding this comment

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

looks good

- Added new $glyph-icon-eye-disabled font symbol and related class;
- Modded glyphs used for visibility toggle button;
- Modded StyleEditor thumb preview to reflect visibility setting;
- Tweaked `is-style-invisible` opacity property;
- Code cleanup;
- Display disabled toolbar for Inspector styles in Browse mode;
- Better approach to 'is-style-invisible' `c-style-thumb` with new
bgCheckerboard mixin;
- Moved `$controlDisabledOpacity` into a theme constant;
- Refined spacing in Inspector grid;
} else {
if (this.currentStyle) {
Object.keys(this.currentStyle).forEach(key => {
this.currentStyle[key] = 'transparent';
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like this is used later on to identify which styles should be deleted from the element's style definition. If so, can we use something other than transparent? This is a valid CSS value for some style rules, so it may not be clear to developers that this will result in the subsequent deletion of this style rule. Could use a distinct value save in a named constant instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. Will do.


<script>
import {TRIGGER} from "@/plugins/condition/utils/constants";
import { OPERATIONS } from "@/plugins/condition/utils/operations";
Copy link
Contributor

Choose a reason for hiding this comment

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

Inconsistent spacing here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

});
if (this.condition.isDefault) {
this.criterionDescriptions.splice(0, 0, {
description: 'all else fails'
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is criterionDescriptions an array of objects rather than an array of Strings?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah! initially i was using the same component to show errors but then I moved errors into its own component. I've changed this to be strings.

});
},
getOperatorText(operationName, values) {
const found = OPERATIONS.find((operation) => operation.name === operationName);
Copy link
Contributor

Choose a reason for hiding this comment

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

OPERATIONS should be an object keyed on the value of name to avoid an O(n) array scan.

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 change will affect a lot of things. I'll create an issue for it and fix later.
#2771

data() {
return {
conditionErrors: [],
ERROR: {
Copy link
Contributor

@akhenry akhenry Mar 24, 2020

Choose a reason for hiding this comment

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

Doesn't need to be returned by data. Vue will make it reactive unnecessarily. Let's just make it a const.

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.

}
},
getCriterionErrors(criterion, index) {
this.openmct.objects.get(criterion.telemetry).then((telemetryObject) => {
Copy link
Contributor

@akhenry akhenry Mar 24, 2020

Choose a reason for hiding this comment

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

There's way too much getting of objects. This is already an issue that users complain about. Criterion objects should evaluate a description and an error message only once - when the telemetry property changes and then store them.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK.

}
},
mounted() {
// TODO: should update on mutation.
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think any of these todo items are relevant in this context?

Copy link
Contributor Author

@shefalijoshi shefalijoshi Mar 24, 2020

Choose a reason for hiding this comment

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

Removed.

@akhenry
Copy link
Contributor

akhenry commented Mar 24, 2020

@shefalijoshi Won't be able to get through this today, code diff is huge. So that testing is not blocked, could you please just fix the code style issues reported by Circle CI, then I'll merge and file a followup with any changes necessary.

},
// mixins: [ObjectLink],
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 remove this commented code.

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.

</span>
</template>
<span v-else>
<condition-description :show-label="false"
Copy link
Contributor

Choose a reason for hiding this comment

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

good choice to make as its own component. we just need to be sure the styling remains the same. the description component is inline in read-only mode and as a block element in edit mode.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@charlesh88 Can you take a look at the CSS here?

Copy link
Contributor

Choose a reason for hiding this comment

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

And I'm not trying to say its not working. Just making sure this was verified. The markup was slightly different. One block used divs and one used spans. Maybe the container elements take care of the proper displays.

@@ -36,7 +36,7 @@ export default {
},
methods: {
onClick(event) {
if (this.options.dialog) {
if ((this.options.isEditing === undefined || this.options.isEditing) && this.options.dialog) {
Copy link
Contributor

Choose a reason for hiding this comment

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

i see (this.options.isEditing === undefined) || this.options.isEditing) several times. i know it'd be extra code but i wonder if this should be in a computed with a descriptive name so that someone doesn't come along and mistakenly stomp over this thinking it can be a simple truthy check.

Copy link
Contributor Author

@shefalijoshi shefalijoshi Mar 24, 2020

Choose a reason for hiding this comment

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

OK. Why a computed property? Could it be a regular method? like

showDialog() {
            return (this.options.isEditing === undefined || this.options.isEditing);
        }

Copy link
Contributor

Choose a reason for hiding this comment

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

Method would work fine if used for pure js logic. The computed would allow vue to cache the result if this is to be used in templates.

<div v-for="(error, index) in conditionErrors"
:key="index"
class="u-alert u-alert--block u-alert--with-icon"
>{{ error.message.errorText }} <template v-if="error.additionalInfo">{{ error.additionalInfo }}</template>
Copy link
Contributor

Choose a reason for hiding this comment

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

do you need the v-if? if error.additionalInfo is undefined then nothing will be rendered

Copy link
Contributor Author

@shefalijoshi shefalijoshi Mar 24, 2020

Choose a reason for hiding this comment

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

Removed.

@akhenry akhenry merged commit 57a68a2 into topic-conditionals Mar 24, 2020
Copy link
Contributor

@davetsay davetsay left a comment

Choose a reason for hiding this comment

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

I don't have anything major to report. Just suggestions. Andrews comments are much more critical to address.

},
data() {
return {
hasChildren: false,
Copy link
Contributor

Choose a reason for hiding this comment

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

can we have this as a computed based on children.length or is this a way to get around an async call for children?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. To avoid additional calls.

computed: {
navigated() {
const itemId = this.selectedItem && this.selectedItem.itemId;
const isSelectedObject = itemId && this.openmct.objects.areIdsEqual(this.node.object.identifier, itemId);
Copy link
Contributor

Choose a reason for hiding this comment

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

i think areIdsEqual would not be true if itemId is undefined so I think you are safe removing itemId check

Copy link
Contributor Author

Choose a reason for hiding this comment

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

True. I can check how it behaves without that.

removeChild(identifier) {
let removeId = this.openmct.objects.makeKeyString(identifier);
this.children = this.children
.filter(c => c.id !== removeId);
Copy link
Contributor

Choose a reason for hiding this comment

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

uncharacteristic non-descriptive var name for you @shefalijoshi , 😉

} else {
this.styleItem.style[item.property] = value;
}
this.$emit('persist', this.styleItem);
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe rename to reflect it has updated style. whatever is listening to this is going to be persisting i think.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure. I can rename the event to persistUpdatedStyle

this.openmct.objects.getOriginalPath(this.conditionSetDomainObject.identifier).then(
(objectPath) => {
this.objectPath = objectPath;
this.navigateToPath = '#/browse/' + this.objectPath
Copy link
Contributor

Choose a reason for hiding this comment

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

should this use a call to get root path instead of hardcoding?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually I think I can get rid of that property altogether.

@akhenry
Copy link
Contributor

akhenry commented Mar 24, 2020

Merged to unblock testing. Will continue review and file followups.

@akhenry akhenry mentioned this pull request Mar 28, 2020
13 tasks
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