mirror of
https://github.com/nasa/openmct.git
synced 2025-03-11 06:54:01 +00:00
duplicate condition complete
This commit is contained in:
parent
bc9cadaa77
commit
01b1d66bea
@ -45,6 +45,7 @@
|
|||||||
:condition-index="index"
|
:condition-index="index"
|
||||||
@update-current-condition="updateCurrentCondition"
|
@update-current-condition="updateCurrentCondition"
|
||||||
@remove-condition="removeCondition"
|
@remove-condition="removeCondition"
|
||||||
|
@clone-condition="cloneCondition"
|
||||||
@condition-result-updated="handleConditionResult"
|
@condition-result-updated="handleConditionResult"
|
||||||
@set-move-index="setMoveIndex"
|
@set-move-index="setMoveIndex"
|
||||||
/>
|
/>
|
||||||
@ -168,17 +169,36 @@ export default {
|
|||||||
addTelemetry(telemetryDomainObject) {
|
addTelemetry(telemetryDomainObject) {
|
||||||
this.telemetryObjs.push(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
|
//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.openmct.objects.mutate(conditionDO, 'created', new Date());
|
||||||
|
if (!isClone) {
|
||||||
this.conditionCollection.unshift(conditionDO.identifier);
|
this.conditionCollection.unshift(conditionDO.identifier);
|
||||||
|
} else {
|
||||||
|
this.conditionCollection.splice(index + 1, 0, conditionDO.identifier);
|
||||||
|
}
|
||||||
this.persist();
|
this.persist();
|
||||||
},
|
},
|
||||||
updateCurrentCondition(identifier) {
|
updateCurrentCondition(identifier) {
|
||||||
this.currentConditionIdentifier = identifier;
|
this.currentConditionIdentifier = identifier;
|
||||||
},
|
},
|
||||||
getConditionDomainObject(isDefault) {
|
getConditionDomainObject(isDefault, isClone, name) {
|
||||||
|
if (isClone) {
|
||||||
|
name = 'Copy of ' + name;
|
||||||
|
} else {
|
||||||
|
name = isDefault ? 'Default' : 'Unnamed Condition';
|
||||||
|
}
|
||||||
let conditionObj = {
|
let conditionObj = {
|
||||||
isDefault: isDefault,
|
isDefault: isDefault,
|
||||||
identifier: {
|
identifier: {
|
||||||
@ -186,7 +206,7 @@ export default {
|
|||||||
key: uuid()
|
key: uuid()
|
||||||
},
|
},
|
||||||
definition: {
|
definition: {
|
||||||
name: isDefault ? 'Default' : 'Unnamed Condition',
|
name: name,
|
||||||
output: 'false',
|
output: 'false',
|
||||||
trigger: 'any',
|
trigger: 'any',
|
||||||
criteria: isDefault ? [] : [{
|
criteria: isDefault ? [] : [{
|
||||||
@ -203,11 +223,6 @@ export default {
|
|||||||
|
|
||||||
return newDO.useCapability('adapter');
|
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) {
|
removeCondition(identifier) {
|
||||||
let index = _.findIndex(this.conditionCollection, (condition) => {
|
let index = _.findIndex(this.conditionCollection, (condition) => {
|
||||||
let conditionId = this.openmct.objects.makeKeyString(condition);
|
let conditionId = this.openmct.objects.makeKeyString(condition);
|
||||||
@ -219,12 +234,17 @@ export default {
|
|||||||
this.updateCurrentConditionId();
|
this.updateCurrentConditionId();
|
||||||
},
|
},
|
||||||
reorder(reorderPlan) {
|
reorder(reorderPlan) {
|
||||||
let oldConditions = this.conditionCollection.slice();
|
let oldConditions = Array.from(this.conditionCollection);
|
||||||
reorderPlan.forEach((reorderEvent) => {
|
reorderPlan.forEach((reorderEvent) => {
|
||||||
this.$set(this.conditionCollection, reorderEvent.newIndex, oldConditions[reorderEvent.oldIndex]);
|
this.$set(this.conditionCollection, reorderEvent.newIndex, oldConditions[reorderEvent.oldIndex]);
|
||||||
});
|
});
|
||||||
this.persist();
|
this.persist();
|
||||||
},
|
},
|
||||||
|
cloneCondition(condition) {
|
||||||
|
this.openmct.objects.get(condition.identifier).then((obj) => {
|
||||||
|
this.addCondition(null, false, true, obj.definition.name, condition.index);
|
||||||
|
});
|
||||||
|
},
|
||||||
persist() {
|
persist() {
|
||||||
this.openmct.objects.mutate(this.domainObject, 'configuration.conditionCollection', this.conditionCollection);
|
this.openmct.objects.mutate(this.domainObject, 'configuration.conditionCollection', this.conditionCollection);
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<span v-if="!condition.isDefault"
|
<span v-if="!condition.isDefault"
|
||||||
class="is-enabled c-c__duplicate"
|
class="is-enabled c-c__duplicate"
|
||||||
|
@click="cloneCondition"
|
||||||
></span>
|
></span>
|
||||||
<span v-if="!condition.isDefault"
|
<span v-if="!condition.isDefault"
|
||||||
class="is-enabled c-c__trash"
|
class="is-enabled c-c__trash"
|
||||||
@ -218,15 +219,20 @@ export default {
|
|||||||
this.$emit('set-move-index', Number(e.target.getAttribute('data-condition-index')));
|
this.$emit('set-move-index', Number(e.target.getAttribute('data-condition-index')));
|
||||||
},
|
},
|
||||||
handleConditionResult(args) {
|
handleConditionResult(args) {
|
||||||
// console.log('ConditionEdit::Result', args);
|
|
||||||
this.$emit('condition-result-updated', {
|
this.$emit('condition-result-updated', {
|
||||||
id: this.conditionIdentifier,
|
id: this.conditionIdentifier,
|
||||||
result: args.data.result
|
result: args.data.result
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
removeCondition(ev) { //move this to conditionCollection
|
removeCondition(ev) {
|
||||||
this.$emit('remove-condition', this.conditionIdentifier);
|
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() {
|
setOutput() {
|
||||||
if (this.condition.definition.output !== 'false' && this.condition.definition.output !== 'true') {
|
if (this.condition.definition.output !== 'false' && this.condition.definition.output !== 'true') {
|
||||||
this.selectedOutputKey = this.outputOptions[2].key;
|
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.openmct.objects.get(this.condition.definition.criteria[0].key).then((obj) => {
|
||||||
this.telemetryObject = obj;
|
this.telemetryObject = obj;
|
||||||
this.telemetryMetadata = this.openmct.telemetry.getMetadata(this.telemetryObject).values();
|
this.telemetryMetadata = this.openmct.telemetry.getMetadata(this.telemetryObject).values();
|
||||||
// this.selectedMetaDataKey = this.telemetryMetadata[0].key;
|
|
||||||
this.selectedMetaDataKey = '';
|
this.selectedMetaDataKey = '';
|
||||||
this.selectedTelemetryKey = this.telemetryObject.identifier;
|
this.selectedTelemetryKey = this.telemetryObject.identifier;
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user