mirror of
https://github.com/nasa/openmct.git
synced 2025-01-20 03:36:44 +00:00
persist data changes on update
This commit is contained in:
parent
c8abc45e25
commit
94305ed82c
@ -34,14 +34,10 @@
|
|||||||
class="conditionArea"
|
class="conditionArea"
|
||||||
>
|
>
|
||||||
<div v-if="isEditing">
|
<div v-if="isEditing">
|
||||||
<ConditionEdit :condition="condition"
|
<ConditionEdit :condition="condition" />
|
||||||
@persist="persist"
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
<div v-else>
|
<div v-else>
|
||||||
<Condition :condition="condition"
|
<Condition :condition="condition" />
|
||||||
@persist="persist"
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -76,18 +72,19 @@ 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;
|
||||||
if (!this.conditionCollection.length) {this.addDefaultCondition()}
|
if (!this.conditionCollection.length) {this.addCondition(true)}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
added(conditionDO) {
|
added(conditionDO) {
|
||||||
this.conditionCollection.unshift(conditionDO);
|
this.conditionCollection.unshift(conditionDO);
|
||||||
},
|
},
|
||||||
addCondition() {
|
addCondition(isDefault) {
|
||||||
|
if (isDefault !== true) {isDefault = false}
|
||||||
let conditionObjId = uuid();
|
let conditionObjId = uuid();
|
||||||
let conditionObj = {
|
let conditionObj = {
|
||||||
isDefault: false,
|
isDefault: isDefault,
|
||||||
composition: [],
|
composition: [],
|
||||||
name: "Unnamed Condition",
|
name: isDefault ? 'Default': 'Unnamed Condition',
|
||||||
type: "condition",
|
type: "condition",
|
||||||
id: conditionObjId,
|
id: conditionObjId,
|
||||||
location: this.parentKeyString,
|
location: this.parentKeyString,
|
||||||
@ -104,27 +101,6 @@ export default {
|
|||||||
let conditionDO = newDO.useCapability('adapter');
|
let conditionDO = newDO.useCapability('adapter');
|
||||||
|
|
||||||
this.conditionCollection.unshift(conditionDO);
|
this.conditionCollection.unshift(conditionDO);
|
||||||
|
|
||||||
this.persist();
|
|
||||||
},
|
|
||||||
addDefaultCondition() {
|
|
||||||
this.conditionCollection = [];
|
|
||||||
|
|
||||||
let conditionObjId = uuid();
|
|
||||||
this.conditionCollection.push({
|
|
||||||
description: 'When all else fails',
|
|
||||||
isDefault: true,
|
|
||||||
composition: [],
|
|
||||||
name: "Default",
|
|
||||||
type: "condition",
|
|
||||||
id: conditionObjId,
|
|
||||||
location: this.parentKeyString,
|
|
||||||
identifier: {
|
|
||||||
namespace: "",
|
|
||||||
key: conditionObjId
|
|
||||||
},
|
|
||||||
output: 'Default test'
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
removeCondition(identifier) {
|
removeCondition(identifier) {
|
||||||
let index = _.findIndex(this.conditionCollection, (condition) => this.openmct.objects.makeKeyString(identifier) === condition.identifier.key);
|
let index = _.findIndex(this.conditionCollection, (condition) => this.openmct.objects.makeKeyString(identifier) === condition.identifier.key);
|
||||||
@ -136,13 +112,6 @@ export default {
|
|||||||
reorderPlan.forEach((reorderEvent) => {
|
reorderPlan.forEach((reorderEvent) => {
|
||||||
this.$set(this.conditionCollection, reorderEvent.newIndex, oldConditions[reorderEvent.oldIndex]);
|
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -79,6 +79,10 @@ export default {
|
|||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
},
|
},
|
||||||
|
updated() {
|
||||||
|
console.log('updated');
|
||||||
|
this.persist()
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
removeCondition(ev) {
|
removeCondition(ev) {
|
||||||
const conditionDiv = ev.target.closest('.conditionArea');
|
const conditionDiv = ev.target.closest('.conditionArea');
|
||||||
@ -86,7 +90,6 @@ export default {
|
|||||||
const index = Array.from(conditionCollectionDiv.children).indexOf(conditionDiv);
|
const index = Array.from(conditionCollectionDiv.children).indexOf(conditionDiv);
|
||||||
|
|
||||||
this.domainObject.configuration.conditionCollection.splice(index, 1);
|
this.domainObject.configuration.conditionCollection.splice(index, 1);
|
||||||
this.persist()
|
|
||||||
},
|
},
|
||||||
persist(index) {
|
persist(index) {
|
||||||
if (index) {
|
if (index) {
|
||||||
|
Loading…
Reference in New Issue
Block a user