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

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

View File

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

View File

@ -65,10 +65,12 @@
export default { export default {
inject: ['openmct', 'domainObject'], inject: ['openmct', 'domainObject'],
props: { props: {
condition: Object condition: {
type: Object,
required: true
}
}, },
data() { data() {
return { return {
expanded: true, expanded: true,
name: this.condition.name, name: this.condition.name,
@ -76,9 +78,6 @@ export default {
}; };
}, },
mounted() { mounted() {
console.log(`this.condition.name: ${this.condition.name}`);
// console.log(`currentObjectPath: ${this.currentObjectPath.name}`);
// console.log(this.domainObject);
}, },
methods: { methods: {
removeCondition(ev) { removeCondition(ev) {