Merge branch 'conditionSet-view' of https://github.com/nasa/openmct into conditionSet-with-classes

This commit is contained in:
Joshi 2020-01-14 10:27:10 -08:00
commit 31736fa194
3 changed files with 21 additions and 71 deletions

View File

@ -5,15 +5,15 @@
>
<div class="title-bar">
<span class="condition-name">
{{condition.name}}
{{ condition.name }}
</span>
<span class="condition-output">
Output: {{condition.output}}
Output: {{ condition.output }}
</span>
</div>
<div class="condition-config">
<span class="condition-description">
{{ condition.description}}
{{ condition.description }}
</span>
</div>
</div>
@ -23,7 +23,10 @@
export default {
inject: ['openmct'],
props: {
condition: Object
condition: {
type: Object,
required: true
}
},
data() {
return {

View File

@ -34,9 +34,7 @@
class="conditionArea"
>
<div v-if="isEditing">
<ConditionEdit :condition="condition"
@persist="persist"
/>
<ConditionEdit :condition="condition" />
</div>
<div v-else>
<Condition :condition="condition" />
@ -74,31 +72,18 @@ export default {
},
mounted() {
this.instantiate = this.openmct.$injector.get('instantiate');
this.conditionCollection = this.domainObject.configuration ? this.domainObject.configuration.conditionCollection : [];
this.addDefaultCondition();
this.conditionCollection = this.domainObject.configuration.conditionCollection || this.conditionCollection;
if (!this.conditionCollection.length) {this.addCondition(true)}
},
methods: {
added(conditionDO) {
this.conditionCollection.unshift(conditionDO);
},
addCondition() {
// let conditionObjId = uuid();
// let conditionObj = {
// isDefault: false,
// composition: [],
// name: "Unnamed Condition",
// type: "condition",
// id: conditionObjId,
// location: this.parentKeyString,
// identifier: {
// namespace: "",
// key: conditionObjId
// },
// output: 'test'
// };
addCondition(isDefault) {
if (isDefault !== true) {isDefault = false}
let conditionObj = {
isDefault: true,
name: 'Unnamed Condition',
name: isDefault ? 'Default' : 'Unnamed Condition',
trigger: 'any',
criteria: [{
operation: '',
@ -116,39 +101,6 @@ export default {
let conditionDO = new ConditionClass(conditionObj, this.openmct);
this.conditionCollection.unshift(conditionDO);
this.$set(this.conditionCollection, 0, conditionDO);
console.log(conditionDO, this.conditionCollection);
this.persist();
},
addDefaultCondition() {
this.conditionCollection = [];
// let conditionObjId = uuid();
// this.conditionCollection.push({
// description: 'when all fails',
// isDefault: true,
// composition: [],
// name: "Default",
// type: "condition",
// id: conditionObjId,
// location: this.parentKeyString,
// identifier: {
// namespace: "",
// key: conditionObjId
// },
// output: 'Default test'
// });
this.conditionCollection.push({
isDefault: true,
name: 'Default',
description: 'when all fails - condition',
trigger: '',
criteria: [],
output: 'Default test'
});
},
removeCondition(identifier) {
let index = _.findIndex(this.conditionCollection, (condition) => this.openmct.objects.makeKeyString(identifier) === condition.identifier.key);
@ -160,13 +112,6 @@ export default {
reorderPlan.forEach((reorderEvent) => {
this.$set(this.conditionCollection, reorderEvent.newIndex, oldConditions[reorderEvent.oldIndex]);
});
},
persist(index) {
if (index) {
this.openmct.objects.mutate(this.domainObject, `configuration.conditionCollection[${index}]`, this.conditionCollection[index]);
} else {
this.openmct.objects.mutate(this.domainObject, 'configuration.conditionCollection', this.conditionCollection);
}
}
}
}

View File

@ -65,10 +65,12 @@
export default {
inject: ['openmct', 'domainObject'],
props: {
condition: Object
condition: {
type: Object,
required: true
}
},
data() {
return {
expanded: true,
name: this.condition.name,
@ -76,9 +78,10 @@ export default {
};
},
mounted() {
console.log(`this.condition.name: ${this.condition.name}`);
// console.log(`currentObjectPath: ${this.currentObjectPath.name}`);
// console.log(this.domainObject);
},
updated() {
console.log('updated');
this.persist()
},
methods: {
removeCondition(ev) {
@ -87,7 +90,6 @@ export default {
const index = Array.from(conditionCollectionDiv.children).indexOf(conditionDiv);
this.domainObject.configuration.conditionCollection.splice(index, 1);
this.persist()
},
persist(index) {
if (index) {