@@ -65,7 +69,8 @@ export default {
expanded: true,
parentKeyString: this.openmct.objects.makeKeyString(this.domainObject.identifier),
conditionCollection: [],
- conditions: []
+ conditions: [],
+ currentConditionIdentifier: this.currentConditionIdentifier || {}
};
},
destroyed() {
@@ -78,7 +83,10 @@ export default {
this.composition.on('add', this.addTelemetry);
this.composition.load();
this.conditionCollection = this.domainObject.configuration ? this.domainObject.configuration.conditionCollection : [];
- if (!this.conditionCollection.length) {this.addCondition(null, true)}
+ if (!this.conditionCollection.length) {
+ this.addCondition(null, true);
+ }
+
},
methods: {
addTelemetry(telemetryDomainObject) {
@@ -89,11 +97,29 @@ export default {
//persist the condition DO so that we can do an openmct.objects.get on it and only persist the identifier in the conditionCollection of conditionSet
this.openmct.objects.mutate(conditionDO, 'created', new Date());
+ this.currentConditionIdentifier = conditionDO.identifier;
this.conditionCollection.unshift(conditionDO.identifier);
let condition = new ConditionClass(conditionDO, this.openmct);
this.conditions.push(condition);
},
+ updateCurrentCondition(identifier) {
+ console.log('updateCurrentCondition from ConditionCollection', identifier);
+ this.currentConditionIdentifier = identifier;
+ // this.openmct.objects.get(identifier).then((obj) => {
+ // if (this.conditionCollection.length > 1) {
+ // console.log(this.conditionCollection.length)
+ // this.conditionCollection.forEach((condition, index) => {
+ // index === 0 ? condition.isCurrent = true : condition.isCurrent = false
+ // console.log('conditionEdit', condition)
+ // });
+ // } else {
+ // this.conditionCollection[0].isCurrent = true;
+ // }
+ // });
+ // this.conditionCollection = collection;
+ // this.$set(this.conditionCollection, , post)
+ },
getConditionDomainObject(isDefault) {
let conditionObj = {
isDefault: isDefault,
diff --git a/src/plugins/condition/components/ConditionEdit.vue b/src/plugins/condition/components/ConditionEdit.vue
index 85a796d63e..72c3b6f64b 100644
--- a/src/plugins/condition/components/ConditionEdit.vue
+++ b/src/plugins/condition/components/ConditionEdit.vue
@@ -1,7 +1,7 @@
import { OPERATIONS } from '../utils/operations';
+// import { EventBus } from '../utils/eventbus.js';
+
export default {
inject: ['openmct', 'domainObject'],
props: {
conditionIdentifier: {
type: Object,
required: true
+ },
+ isCurrent: {
+ type: Object,
+ required: true
}
},
data() {
return {
condition: this.condition,
expanded: true,
- conditionCollection: this.conditionCollection,
telemetryObject: this.telemetryObject,
telemetryMetadata: this.telemetryMetadata,
operations: OPERATIONS,
@@ -154,9 +159,8 @@ export default {
};
},
mounted() {
- this.conditionCollection = this.domainObject.configuration.conditionCollection;
this.openmct.objects.get(this.conditionIdentifier).then((obj => {
- console.log('ConditionEdit obj', obj);
+ // console.log('ConditionEdit obj', obj);
this.condition = obj;
if (this.condition.output !== 'false' && this.condition.output !== 'true') {
this.$refs.outputSelect.value = 'string';
@@ -164,18 +168,23 @@ export default {
}
this.updateTelemetry();
}));
+ this.updateCurrentCondition();
},
updated() {
- this.updateCurrentCondition();
+ console.log('updated');
+ if (this.isCurrent && this.isCurrent.key === this.condition.key) {
+ this.updateCurrentCondition();
+ }
this.persist();
},
methods: {
removeCondition(ev) {
- const conditionDiv = ev.target.closest('.conditionArea');
- const conditionCollectionDiv = conditionDiv.closest('.condition-collection');
- const index = Array.from(conditionCollectionDiv.children).indexOf(conditionDiv);
+ // const conditionDiv = ev.target.closest('.conditionArea');
+ // const conditionCollectionDiv = conditionDiv.closest('.condition-collection');
+ // const index = Array.from(conditionCollectionDiv.children).indexOf(conditionDiv);
- this.domainObject.configuration.conditionCollection.splice(index, 1);
+ // this.domainObject.configuration.conditionCollection.splice(index, 1);
+ // this.updateCurrentCondition();
},
updateTelemetry() {
if (this.hasTelemetry()) {
@@ -183,7 +192,7 @@ export default {
this.telemetryObject = obj;
this.telemetryMetadata = this.openmct.telemetry.getMetadata(this.telemetryObject).values();
this.selectedMetaDataKey = this.telemetryMetadata[0].key;
- console.log('ConditionEdit', this.telemetryObject, this.telemetryMetadata);
+ // console.log('ConditionEdit', this.telemetryObject, this.telemetryMetadata);
});
} else {
this.telemetryObject = null;
@@ -192,27 +201,32 @@ export default {
hasTelemetry() {
return this.condition.criteria.length && this.condition.criteria[0].key;
},
- persist(index) {
- if (index) {
- this.openmct.objects.mutate(this.domainObject, `configuration.conditionCollection[${index}]`, this.domainObject.configuration.conditionCollection[index]);
- } else {
- this.openmct.objects.mutate(this.domainObject, 'configuration.conditionCollection', this.domainObject.configuration.conditionCollection);
- }
+ persist() {
+ this.openmct.objects.mutate(this.domainObject, 'isCurrent', this.condition.isCurrent);
},
updateCurrentCondition() {
+ // console.log('updateCurrentCondition called')
//mutate / persist the condition domainObject
//persist the condition DO so that we can do an openmct.objects.get on it and only persist the identifier in the conditionCollection of conditionSet
- this.openmct.objects.mutate(this.condition, 'created', new Date());
+ // console.log('before mutate output',this.condition.output)
+ // this.openmct.objects.mutate(this.condition, "output", this.condition.output);
+ // console.log('after mutate output',this.condition.output)
//
// // TODO: replace based on telemetry
// if (this.conditionCollection.length > 1) {
+ // console.log(this.conditionCollection.length)
// this.conditionCollection.forEach((condition, index) => {
// index === 0 ? condition.isCurrent = true : condition.isCurrent = false
+ // console.log('conditionEdit', condition)
// });
// } else {
// this.conditionCollection[0].isCurrent = true;
// }
- // console.log(this.condition);
+ //console.log('this.conditionCollection', this.conditionCollection);
+ // console.log('this.conditionIdentifier', this.conditionIdentifier);
+ this.$emit('update-current-condition', this.conditionIdentifier);
+ // this.openmct.objects.mutate(this.condition, "isCurrent", this.condition.isCurrent);
+ // console.log('this.conditionCollection', this.conditionCollection);
// console.log(this.conditionCollection);
},
getOutputBinary(ev) {
@@ -220,14 +234,15 @@ export default {
this.condition.output = ev.target.value;
this.stringOutputField = false;
} else {
- this.stringOutputField = true;
+ this.stringOutputField = true
}
+ this.updateCurrentCondition();
},
getOutputString(ev) {
this.condition.output = ev.target.value;
},
getOperationKey(ev) {
- console.log(ev.target.value)
+ // console.log(ev.target.value)
if (ev.target.value !== 'isUndefined' && ev.target.value !== 'isDefined') {
this.comparisonValueField = true;
} else {
diff --git a/src/plugins/condition/components/ConditionSet.vue b/src/plugins/condition/components/ConditionSet.vue
index 9f6758f52b..9640856fcc 100644
--- a/src/plugins/condition/components/ConditionSet.vue
+++ b/src/plugins/condition/components/ConditionSet.vue
@@ -2,9 +2,11 @@
@@ -15,6 +17,7 @@ import CurrentOutput from './CurrentOutput.vue';
import TestData from './TestData.vue';
import ConditionCollection from './ConditionCollection.vue';
+
export default {
inject: ["openmct", "domainObject"],
components: {
@@ -32,12 +35,18 @@ export default {
}
},
mounted() {
- let conditionCollection = this.domainObject.configuration.conditionCollection;
- this.currentConditionIdentifier = conditionCollection.length ? conditionCollection[0] : null;
- if (this.currentConditionIdentifier) {
+ },
+ methods: {
+ updateCurrentcondition(identifier) {
+ this.currentConditionIdentifier = identifier;
+ console.log('identifier', identifier)
this.openmct.objects.get(this.currentConditionIdentifier).then((obj) => {
this.currentCondition = obj;
+ console.log(`this.currentCondition`, this.currentCondition);
});
+ // console.log('updateCurrentCondition from ConditionCollection', name);
+ // this.conditionCollection = collection;
+ // this.$set(this.conditionCollection, , post)
}
}
};
diff --git a/src/plugins/condition/components/CurrentOutput.vue b/src/plugins/condition/components/CurrentOutput.vue
index 84114f3c8b..8d48ba7fda 100644
--- a/src/plugins/condition/components/CurrentOutput.vue
+++ b/src/plugins/condition/components/CurrentOutput.vue
@@ -36,7 +36,7 @@ export default {
}
},
mounted() {
-
+ console.log('this.condition', this.condition);
},
methods: {
diff --git a/src/plugins/condition/event b/src/plugins/condition/event
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/src/plugins/condition/utils/eventbus.js b/src/plugins/condition/utils/eventbus.js
new file mode 100644
index 0000000000..50e9f894c8
--- /dev/null
+++ b/src/plugins/condition/utils/eventbus.js
@@ -0,0 +1,2 @@
+import Vue from 'vue';
+export const EventBus = new Vue();