Merge pull request #2865 from nasa/criterion-delete

Criterion delete
This commit is contained in:
Joel McKinnon 2020-04-02 10:51:12 -07:00 committed by GitHub
commit 469e93d916
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 5 deletions

View File

@ -95,7 +95,7 @@ export default class ConditionClass extends EventEmitter {
generateCriterion(criterionConfiguration) { generateCriterion(criterionConfiguration) {
return { return {
id: uuid(), id: criterionConfiguration.id || uuid(),
telemetry: criterionConfiguration.telemetry || '', telemetry: criterionConfiguration.telemetry || '',
telemetryObject: this.conditionManager.telemetryObjects[this.openmct.objects.makeKeyString(criterionConfiguration.telemetry)], telemetryObject: this.conditionManager.telemetryObjects[this.openmct.objects.makeKeyString(criterionConfiguration.telemetry)],
operation: criterionConfiguration.operation || '', operation: criterionConfiguration.operation || '',

View File

@ -122,6 +122,7 @@ export default class ConditionManager extends EventEmitter {
output: 'false', output: 'false',
trigger: 'all', trigger: 'all',
criteria: [{ criteria: [{
id: uuid(),
telemetry: '', telemetry: '',
operation: '', operation: '',
input: [], input: [],
@ -140,7 +141,9 @@ export default class ConditionManager extends EventEmitter {
} }
cloneCondition(conditionConfiguration, index) { cloneCondition(conditionConfiguration, index) {
this.createAndSaveCondition(index, JSON.parse(JSON.stringify(conditionConfiguration))); let clonedConfig = JSON.parse(JSON.stringify(conditionConfiguration));
clonedConfig.configuration.criteria.forEach((criterion) => criterion.id = uuid());
this.createAndSaveCondition(index, clonedConfig);
} }
createAndSaveCondition(index, conditionConfiguration) { createAndSaveCondition(index, conditionConfiguration) {

View File

@ -41,7 +41,6 @@
></span> ></span>
<span class="c-condition__name">{{ condition.configuration.name }}</span> <span class="c-condition__name">{{ condition.configuration.name }}</span>
<!-- TODO: description should be derived from criteria -->
<span class="c-condition__summary"> <span class="c-condition__summary">
<template v-if="!canEvaluateCriteria"> <template v-if="!canEvaluateCriteria">
Define criteria Define criteria
@ -122,7 +121,7 @@
<template v-if="telemetry.length || condition.configuration.criteria.length"> <template v-if="telemetry.length || condition.configuration.criteria.length">
<div v-for="(criterion, index) in condition.configuration.criteria" <div v-for="(criterion, index) in condition.configuration.criteria"
:key="index" :key="criterion.id"
class="c-cdef__criteria" class="c-cdef__criteria"
> >
<Criterion :telemetry="telemetry" <Criterion :telemetry="telemetry"
@ -183,6 +182,7 @@
import Criterion from './Criterion.vue'; import Criterion from './Criterion.vue';
import ConditionDescription from "./ConditionDescription.vue"; import ConditionDescription from "./ConditionDescription.vue";
import { TRIGGER, TRIGGER_LABEL } from "@/plugins/condition/utils/constants"; import { TRIGGER, TRIGGER_LABEL } from "@/plugins/condition/utils/constants";
import uuid from 'uuid';
export default { export default {
inject: ['openmct'], inject: ['openmct'],
@ -275,6 +275,7 @@ export default {
}, },
addCriteria() { addCriteria() {
const criteriaObject = { const criteriaObject = {
id: uuid(),
telemetry: '', telemetry: '',
operation: '', operation: '',
input: '', input: '',
@ -308,6 +309,7 @@ export default {
}, },
cloneCriterion(index) { cloneCriterion(index) {
const clonedCriterion = JSON.parse(JSON.stringify(this.condition.configuration.criteria[index])); const clonedCriterion = JSON.parse(JSON.stringify(this.condition.configuration.criteria[index]));
clonedCriterion.id = uuid();
this.condition.configuration.criteria.splice(index + 1, 0, clonedCriterion); this.condition.configuration.criteria.splice(index + 1, 0, clonedCriterion);
this.persist(); this.persist();
}, },
@ -317,7 +319,7 @@ export default {
index: this.conditionIndex index: this.conditionIndex
}); });
}, },
initCap: function (str) { initCap(str) {
return str.charAt(0).toUpperCase() + str.slice(1) return str.charAt(0).toUpperCase() + str.slice(1)
} }
} }