mirror of
https://github.com/nasa/openmct.git
synced 2024-12-21 14:07:50 +00:00
Merge branch 'condition-from-identifier' of https://github.com/nasa/openmct into conditionSet-ui-merge
This commit is contained in:
commit
e88ead30dc
@ -1,8 +1,8 @@
|
||||
<template>
|
||||
<div id="conditionArea"
|
||||
v-if="condition && condition.definition"
|
||||
<div v-if="condition"
|
||||
id="conditionArea"
|
||||
class="c-cs-ui__conditions"
|
||||
:class="['widget-condition', { 'widget-condition--current': condition.isCurrent }]"
|
||||
:class="['widget-condition', { 'widget-condition--current': isCurrent && (isCurrent.key === conditionIdentifier.key) }]"
|
||||
>
|
||||
<div class="title-bar">
|
||||
<span class="condition-name">
|
||||
@ -27,11 +27,14 @@ export default {
|
||||
conditionIdentifier: {
|
||||
type: Object,
|
||||
required: true
|
||||
},
|
||||
isCurrent: {
|
||||
type: Object,
|
||||
required: true
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
conditionData: {},
|
||||
condition: this.condition
|
||||
};
|
||||
},
|
||||
@ -39,8 +42,6 @@ export default {
|
||||
this.openmct.objects.get(this.conditionIdentifier).then((obj => {
|
||||
this.condition = obj;
|
||||
}));
|
||||
},
|
||||
methods: {
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
@ -35,11 +35,16 @@
|
||||
>
|
||||
<div v-if="isEditing">
|
||||
<ConditionEdit :condition-identifier="conditionIdentifier"
|
||||
:is-current="currentConditionIdentifier"
|
||||
@update-current-condition="updateCurrentCondition"
|
||||
@remove-condition="removeCondition"
|
||||
@condition-result-updated="handleConditionResult"
|
||||
/>
|
||||
</div>
|
||||
<div v-else>
|
||||
<Condition :condition-identifier="conditionIdentifier" />
|
||||
<Condition :condition-identifier="conditionIdentifier"
|
||||
:is-current="currentConditionIdentifier"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -66,7 +71,8 @@ export default {
|
||||
expanded: true,
|
||||
parentKeyString: this.openmct.objects.makeKeyString(this.domainObject.identifier),
|
||||
conditionCollection: [],
|
||||
conditions: []
|
||||
conditions: [],
|
||||
currentConditionIdentifier: this.currentConditionIdentifier || {}
|
||||
};
|
||||
},
|
||||
destroyed() {
|
||||
@ -79,11 +85,7 @@ 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)
|
||||
} else {
|
||||
console.log(this.conditionCollection.length, this.conditionCollection);
|
||||
}
|
||||
if (!this.conditionCollection.length) {this.addCondition(null, true)}
|
||||
},
|
||||
methods: {
|
||||
handleConditionResult(args) {
|
||||
@ -96,10 +98,12 @@ export default {
|
||||
let conditionDO = this.getConditionDomainObject(!!isDefault);
|
||||
//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);
|
||||
this.persist();
|
||||
},
|
||||
updateCurrentCondition(identifier) {
|
||||
this.currentConditionIdentifier = identifier;
|
||||
},
|
||||
getConditionDomainObject(isDefault) {
|
||||
let conditionObj = {
|
||||
isDefault: isDefault,
|
||||
@ -131,8 +135,12 @@ export default {
|
||||
this.conditions[index] = updatedCondition;
|
||||
},
|
||||
removeCondition(identifier) {
|
||||
let index = _.findIndex(this.conditionCollection, (condition) => this.openmct.objects.makeKeyString(identifier) === condition.identifier.key);
|
||||
this.conditionCollection.splice(index, 1);
|
||||
console.log('this.conditions', this.conditions);
|
||||
let index = _.findIndex(this.conditionCollection, (condition) => {
|
||||
identifier.key === condition.key
|
||||
});
|
||||
this.conditionCollection.splice(index + 1, 1);
|
||||
this.persist();
|
||||
},
|
||||
reorder(reorderPlan) {
|
||||
let oldConditions = this.conditionCollection.slice();
|
||||
|
@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<div v-if="condition"
|
||||
class="c-cs-editui__conditions"
|
||||
:class="['widget-condition', { 'widget-condition--current': condition.isCurrent }]"
|
||||
:class="['widget-condition', { 'widget-condition--current': isCurrent && (isCurrent.key === conditionIdentifier.key) }]"
|
||||
>
|
||||
<div class="title-bar">
|
||||
<span
|
||||
@ -16,7 +16,7 @@
|
||||
></span>
|
||||
<div class="condition-summary">
|
||||
<span class="condition-name">{{ condition.definition.name }}</span>
|
||||
<span class="condition-description">{{ condition.definition.description }}</span>
|
||||
<span class="condition-description">{{ condition.definition.name }}</span>
|
||||
</div>
|
||||
<span v-if="!condition.isDefault"
|
||||
class="is-enabled c-c__duplicate"
|
||||
@ -139,19 +139,23 @@
|
||||
<script>
|
||||
import { OPERATIONS } from '../utils/operations';
|
||||
import ConditionClass from "@/plugins/condition/Condition";
|
||||
|
||||
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,
|
||||
@ -175,6 +179,7 @@ export default {
|
||||
text: 'String'
|
||||
}
|
||||
]
|
||||
|
||||
};
|
||||
},
|
||||
destroyed() {
|
||||
@ -194,6 +199,9 @@ export default {
|
||||
}));
|
||||
},
|
||||
updated() {
|
||||
if (this.isCurrent && this.isCurrent.key === this.condition.key) {
|
||||
this.updateCurrentCondition();
|
||||
}
|
||||
this.persist();
|
||||
},
|
||||
methods: {
|
||||
@ -205,11 +213,7 @@ export default {
|
||||
})
|
||||
},
|
||||
removeCondition(ev) { //move this to conditionCollection
|
||||
// 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.$emit('remove-condition', this.conditionIdentifier);
|
||||
},
|
||||
setOutput() {
|
||||
if (this.condition.definition.output !== 'false' && this.condition.definition.output !== 'true') {
|
||||
|
@ -4,7 +4,9 @@
|
||||
<div class="c-sw-edit__ui holder">
|
||||
<CurrentOutput :condition="currentCondition" />
|
||||
<TestData :is-editing="isEditing" />
|
||||
<ConditionCollection :is-editing="isEditing"/>
|
||||
<ConditionCollection :is-editing="isEditing"
|
||||
@update-current-condition="updateCurrentcondition"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -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: {
|
||||
@ -27,18 +30,26 @@ export default {
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
// conditionCollection: this.conditionCollection,
|
||||
currentCondition: this.currentCondition
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
let conditionCollection = this.domainObject.configuration.conditionCollection;
|
||||
this.currentConditionIdentifier = conditionCollection.length ? conditionCollection[0] : null;
|
||||
this.currentConditionIdentifier = conditionCollection.length ? this.domainObject.configuration.conditionCollection[0] : null;
|
||||
if (this.currentConditionIdentifier) {
|
||||
this.openmct.objects.get(this.currentConditionIdentifier).then((obj) => {
|
||||
this.currentCondition = obj;
|
||||
});
|
||||
}
|
||||
|
||||
},
|
||||
methods: {
|
||||
updateCurrentcondition(identifier) {
|
||||
this.currentConditionIdentifier = identifier;
|
||||
this.openmct.objects.get(this.currentConditionIdentifier).then((obj) => {
|
||||
this.currentCondition = obj;
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
@ -36,7 +36,6 @@ export default {
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
|
||||
},
|
||||
methods: {
|
||||
|
||||
|
0
src/plugins/condition/event
Normal file
0
src/plugins/condition/event
Normal file
2
src/plugins/condition/utils/eventbus.js
Normal file
2
src/plugins/condition/utils/eventbus.js
Normal file
@ -0,0 +1,2 @@
|
||||
import Vue from 'vue';
|
||||
export const EventBus = new Vue();
|
Loading…
Reference in New Issue
Block a user