Merge pull request #2687 from nasa/remove-criteria

Added controls for remove and duplicate criteria
This commit is contained in:
Shefali Joshi 2020-02-28 09:53:53 -08:00 committed by GitHub
commit 28255dce01
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 44 additions and 13 deletions

View File

@ -112,14 +112,27 @@
<ul v-if="telemetry.length"
class="t-widget-condition-config"
>
<Criterion v-for="(criterion, index) in domainObject.configuration.criteria"
:key="index"
:telemetry="telemetry"
:criterion="criterion"
:index="index"
:trigger="trigger"
@persist="persist"
/>
<li v-for="(criterion, index) in domainObject.configuration.criteria"
:key="index"
class="has-local-controls t-condition"
>
<Criterion :telemetry="telemetry"
:criterion="criterion"
:index="index"
:trigger="trigger"
:is-default="domainObject.configuration.criteria.length === 1"
@persist="persist"
/>
<div class="c-c__criterion-controls">
<span class="is-enabled c-c__duplicate"
@click="cloneCriterion(index)"
></span>
<span v-if="!(domainObject.configuration.criteria.length === 1)"
class="is-enabled c-c__trash"
@click="removeCriterion(index)"
></span>
</div>
</li>
</ul>
<div class="holder c-c-button-wrapper align-left">
<span class="c-c-label-spacer"></span>
@ -201,7 +214,8 @@ export default {
trigger: 'all',
selectedOutputKey: '',
stringOutputField: false,
outputOptions: ['false', 'true', 'string']
outputOptions: ['false', 'true', 'string'],
criterionIndex: 0
};
},
computed: {
@ -264,6 +278,16 @@ export default {
index: Number(ev.target.closest('.widget-condition').getAttribute('data-condition-index'))
});
},
removeCriterion(index) {
this.domainObject.configuration.criteria.splice(index, 1);
this.persist()
},
cloneCriterion(index) {
const clonedCriterion = {...this.domainObject.configuration.criteria[index]};
this.domainObject.configuration.criteria.splice(index + 1, 0, clonedCriterion);
this.persist()
},
setOutput() {
let conditionOutput = this.domainObject.configuration.output;
if (conditionOutput) {

View File

@ -84,7 +84,6 @@
import Condition from '../../condition/components/Condition.vue';
import uuid from 'uuid';
export default {
inject: ['openmct', 'domainObject'],
components: {

View File

@ -1,5 +1,5 @@
<template>
<li class="has-local-controls t-condition">
<div>
<label>{{ setRowLabel }}</label>
<span class="t-configuration">
<span class="controls">
@ -46,8 +46,7 @@
>
</span>
</span>
</li>
</div>
</template>
<script>

View File

@ -197,3 +197,12 @@
border-radius: 2px;
}
}
.c-c__criterion-controls {
width: 28px;
.c-c__duplicate,
.c-c__trash {
display: inline-block;
}
}