1. Persist the condition domain object — done

2. Persist the condition identifier only in configuration.conditionCollection array, not the domain object — done
3. WIP - Retrieve the condition domain object and instantiate the condition classes on load
This commit is contained in:
Joshi 2020-01-16 16:11:23 -08:00
parent bf1efaf912
commit 7b7c7b528a
4 changed files with 33 additions and 15 deletions

View File

@ -98,7 +98,7 @@ export default class ConditionClass extends EventEmitter {
addCriterion(criterionDefinition) {
let criterionDefinitionWithId = this.generateCriterion(criterionDefinition || null);
let criterion = new TelemetryCriterion(criterionDefinitionWithId, this.openmct);
criterion.on('criterionUpdated', (obj) => this.this.handleCriterionUpdated(obj));
criterion.on('criterionUpdated', (obj) => this.handleCriterionUpdated(obj));
if (!this.criteria) {
this.criteria = [];
}

View File

@ -23,16 +23,24 @@
export default {
inject: ['openmct'],
props: {
condition: {
conditionIdentifier: {
type: Object,
required: true
}
},
data() {
return {
conditionData: {}
conditionData: {},
condition: this.condition
};
},
mounted() {
this.condition = {};
this.openmct.objects.get(this.conditionIdentifier).then((obj => {
console.log('ConditionEdit obj', obj);
this.condition = obj;
}));
},
methods: {
}
}

View File

@ -29,15 +29,15 @@
</button>
</div>
<div class="condition-collection">
<div v-for="condition in conditionCollection"
:key="condition.identifier.key"
<div v-for="conditionIdentifier in conditionCollection"
:key="conditionIdentifier.key"
class="conditionArea"
>
<div v-if="isEditing">
<ConditionEdit :condition="condition" />
<ConditionEdit :conditionIdentifier="conditionIdentifier" />
</div>
<div v-else>
<Condition :condition="condition" />
<Condition :conditionIdentifier="conditionIdentifier" />
</div>
</div>
</div>
@ -86,7 +86,10 @@ export default {
},
addCondition(event, isDefault) {
let conditionDO = this.getConditionDomainObject(!!isDefault);
this.conditionCollection.unshift(conditionDO);
//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.conditionCollection.unshift(conditionDO.identifier);
let condition = new ConditionClass(conditionDO, this.openmct);
this.conditions.push(condition);
@ -96,7 +99,7 @@ export default {
isDefault: isDefault,
isCurrent: true,
identifier: {
namespace: "",
namespace: this.domainObject.identifier.namespace,
key: uuid()
},
name: isDefault ? 'Default' : 'Unnamed Condition',
@ -112,6 +115,7 @@ export default {
};
let conditionDOKeyString = this.openmct.objects.makeKeyString(conditionObj.identifier);
let newDO = this.instantiate(conditionObj, conditionDOKeyString);
return newDO.useCapability('adapter');
},
updateCondition(updatedCondition) {

View File

@ -133,7 +133,7 @@ import { OPERATIONS } from '../utils/operations';
export default {
inject: ['openmct', 'domainObject'],
props: {
condition: {
conditionIdentifier: {
type: Object,
required: true
}
@ -141,6 +141,7 @@ export default {
data() {
let conditionCollection = this.domainObject.configuration.conditionCollection;
return {
condition: this.condition,
expanded: true,
name: this.condition.name,
description: this.condition.description,
@ -155,11 +156,16 @@ export default {
};
},
mounted() {
if (this.condition.output !== 'false' && this.condition.output !== 'true') {
this.$refs.outputSelect.value = 'string';
this.stringOutputField = true;
}
this.updateTelemetry();
this.condition = {};
this.openmct.objects.get(this.conditionIdentifier).then((obj => {
console.log('ConditionEdit obj', obj);
this.condition = obj;
if (this.condition.output !== 'false' && this.condition.output !== 'true') {
this.$refs.outputSelect.value = 'string';
this.stringOutputField = true;
}
this.updateTelemetry();
}));
},
updated() {
this.updateCurrentCondition();