add default condition only when none present

This commit is contained in:
Joel McKinnon 2020-01-14 08:38:12 -08:00
parent ea6f8c9a50
commit c8abc45e25
3 changed files with 16 additions and 18 deletions

View File

@ -23,7 +23,10 @@
export default {
inject: ['openmct'],
props: {
condition: Object
condition: {
type: Object,
required: true
}
},
data() {
return {

View File

@ -39,7 +39,9 @@
/>
</div>
<div v-else>
<Condition :condition="condition" />
<Condition :condition="condition"
@persist="persist"
/>
</div>
</div>
</div>
@ -74,9 +76,7 @@ export default {
mounted() {
this.instantiate = this.openmct.$injector.get('instantiate');
this.conditionCollection = this.domainObject.configuration.conditionCollection || this.conditionCollection;
this.addDefaultCondition();
console.log(this.conditionCollection);
if (!this.conditionCollection.length) {this.addDefaultCondition()}
},
methods: {
added(conditionDO) {
@ -105,10 +105,6 @@ export default {
this.conditionCollection.unshift(conditionDO);
this.$set(this.conditionCollection, 0, conditionDO);
console.log(this.conditionCollection);
this.persist();
},
addDefaultCondition() {
@ -116,7 +112,7 @@ export default {
let conditionObjId = uuid();
this.conditionCollection.push({
description: 'when all fails',
description: 'When all else fails',
isDefault: true,
composition: [],
name: "Default",

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,6 @@ export default {
};
},
mounted() {
console.log(`this.condition.name: ${this.condition.name}`);
// console.log(`currentObjectPath: ${this.currentObjectPath.name}`);
// console.log(this.domainObject);
},
methods: {
removeCondition(ev) {