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) {
return {
id: uuid(),
id: criterionConfiguration.id || uuid(),
telemetry: criterionConfiguration.telemetry || '',
telemetryObject: this.conditionManager.telemetryObjects[this.openmct.objects.makeKeyString(criterionConfiguration.telemetry)],
operation: criterionConfiguration.operation || '',

View File

@ -122,6 +122,7 @@ export default class ConditionManager extends EventEmitter {
output: 'false',
trigger: 'all',
criteria: [{
id: uuid(),
telemetry: '',
operation: '',
input: [],
@ -140,7 +141,9 @@ export default class ConditionManager extends EventEmitter {
}
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) {

View File

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