mirror of
https://github.com/nasa/openmct.git
synced 2024-12-21 22:17:49 +00:00
duplicate condition complete
This commit is contained in:
parent
bc9cadaa77
commit
01b1d66bea
@ -45,6 +45,7 @@
|
||||
:condition-index="index"
|
||||
@update-current-condition="updateCurrentCondition"
|
||||
@remove-condition="removeCondition"
|
||||
@clone-condition="cloneCondition"
|
||||
@condition-result-updated="handleConditionResult"
|
||||
@set-move-index="setMoveIndex"
|
||||
/>
|
||||
@ -168,17 +169,36 @@ export default {
|
||||
addTelemetry(telemetryDomainObject) {
|
||||
this.telemetryObjs.push(telemetryDomainObject);
|
||||
},
|
||||
addCondition(event, isDefault) {
|
||||
let conditionDO = this.getConditionDomainObject(!!isDefault);
|
||||
/*
|
||||
Adds a condition to list via programatic creation of default for initial list, manual
|
||||
creation via Add Condition button, or duplication via button in title bar of condition.
|
||||
Params:
|
||||
event: always null,
|
||||
idDefault (boolean): true if conditionList is empty
|
||||
isClone (boolean): true if duplicating a condition
|
||||
name (string): name of condition being duplicated
|
||||
index (number): index of condition being duplicated
|
||||
*/
|
||||
addCondition(event, isDefault, isClone, name, index) {
|
||||
let conditionDO = this.getConditionDomainObject(!!isDefault, isClone, name, index);
|
||||
//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());
|
||||
if (!isClone) {
|
||||
this.conditionCollection.unshift(conditionDO.identifier);
|
||||
} else {
|
||||
this.conditionCollection.splice(index + 1, 0, conditionDO.identifier);
|
||||
}
|
||||
this.persist();
|
||||
},
|
||||
updateCurrentCondition(identifier) {
|
||||
this.currentConditionIdentifier = identifier;
|
||||
},
|
||||
getConditionDomainObject(isDefault) {
|
||||
getConditionDomainObject(isDefault, isClone, name) {
|
||||
if (isClone) {
|
||||
name = 'Copy of ' + name;
|
||||
} else {
|
||||
name = isDefault ? 'Default' : 'Unnamed Condition';
|
||||
}
|
||||
let conditionObj = {
|
||||
isDefault: isDefault,
|
||||
identifier: {
|
||||
@ -186,7 +206,7 @@ export default {
|
||||
key: uuid()
|
||||
},
|
||||
definition: {
|
||||
name: isDefault ? 'Default' : 'Unnamed Condition',
|
||||
name: name,
|
||||
output: 'false',
|
||||
trigger: 'any',
|
||||
criteria: isDefault ? [] : [{
|
||||
@ -203,11 +223,6 @@ export default {
|
||||
|
||||
return newDO.useCapability('adapter');
|
||||
},
|
||||
updateCondition(updatedCondition) {
|
||||
//TODO: this should only happen for reordering
|
||||
let index = _.findIndex(this.conditions, (condition) => condition.id === updatedCondition.id);
|
||||
this.conditions[index] = updatedCondition;
|
||||
},
|
||||
removeCondition(identifier) {
|
||||
let index = _.findIndex(this.conditionCollection, (condition) => {
|
||||
let conditionId = this.openmct.objects.makeKeyString(condition);
|
||||
@ -219,12 +234,17 @@ export default {
|
||||
this.updateCurrentConditionId();
|
||||
},
|
||||
reorder(reorderPlan) {
|
||||
let oldConditions = this.conditionCollection.slice();
|
||||
let oldConditions = Array.from(this.conditionCollection);
|
||||
reorderPlan.forEach((reorderEvent) => {
|
||||
this.$set(this.conditionCollection, reorderEvent.newIndex, oldConditions[reorderEvent.oldIndex]);
|
||||
});
|
||||
this.persist();
|
||||
},
|
||||
cloneCondition(condition) {
|
||||
this.openmct.objects.get(condition.identifier).then((obj) => {
|
||||
this.addCondition(null, false, true, obj.definition.name, condition.index);
|
||||
});
|
||||
},
|
||||
persist() {
|
||||
this.openmct.objects.mutate(this.domainObject, 'configuration.conditionCollection', this.conditionCollection);
|
||||
}
|
||||
|
@ -23,6 +23,7 @@
|
||||
</div>
|
||||
<span v-if="!condition.isDefault"
|
||||
class="is-enabled c-c__duplicate"
|
||||
@click="cloneCondition"
|
||||
></span>
|
||||
<span v-if="!condition.isDefault"
|
||||
class="is-enabled c-c__trash"
|
||||
@ -218,15 +219,20 @@ export default {
|
||||
this.$emit('set-move-index', Number(e.target.getAttribute('data-condition-index')));
|
||||
},
|
||||
handleConditionResult(args) {
|
||||
// console.log('ConditionEdit::Result', args);
|
||||
this.$emit('condition-result-updated', {
|
||||
id: this.conditionIdentifier,
|
||||
result: args.data.result
|
||||
})
|
||||
},
|
||||
removeCondition(ev) { //move this to conditionCollection
|
||||
removeCondition(ev) {
|
||||
this.$emit('remove-condition', this.conditionIdentifier);
|
||||
},
|
||||
cloneCondition(ev) {
|
||||
this.$emit('clone-condition', {
|
||||
identifier: this.conditionIdentifier,
|
||||
index: Number(ev.target.closest('.widget-condition').getAttribute('data-condition-index'))
|
||||
});
|
||||
},
|
||||
setOutput() {
|
||||
if (this.condition.definition.output !== 'false' && this.condition.definition.output !== 'true') {
|
||||
this.selectedOutputKey = this.outputOptions[2].key;
|
||||
@ -252,7 +258,6 @@ export default {
|
||||
this.openmct.objects.get(this.condition.definition.criteria[0].key).then((obj) => {
|
||||
this.telemetryObject = obj;
|
||||
this.telemetryMetadata = this.openmct.telemetry.getMetadata(this.telemetryObject).values();
|
||||
// this.selectedMetaDataKey = this.telemetryMetadata[0].key;
|
||||
this.selectedMetaDataKey = '';
|
||||
this.selectedTelemetryKey = this.telemetryObject.identifier;
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user