Addresses comments

This commit is contained in:
Joshi 2020-03-13 14:24:47 -07:00
parent 76e7fec1a0
commit 83c648cc26
3 changed files with 33 additions and 43 deletions

View File

@ -124,7 +124,7 @@ export default class ConditionManager extends EventEmitter {
this.persistConditions();
}
removeCondition(conditionConfiguration, index) {
removeCondition(index) {
let condition = this.conditionClassCollection[index];
condition.destroyCriteria();
condition.off('conditionResultUpdated', this.handleConditionResult.bind(this));

View File

@ -28,8 +28,8 @@
<div class="c-condition__header">
<span class="c-condition__drag-grippy c-grippy c-grippy--vertical-drag"
title="Drag to reorder conditions"
:class="[{ 'is-enabled': !domainObject.isDefault }, { 'hide-nice': domainObject.isDefault }]"
:draggable="!domainObject.isDefault"
:class="[{ 'is-enabled': !condition.isDefault }, { 'hide-nice': condition.isDefault }]"
:draggable="!condition.isDefault"
@dragstart="dragStart"
@dragstop="dragStop"
@dragover.stop
@ -40,20 +40,20 @@
@click="expanded = !expanded"
></span>
<span class="c-condition__name">{{ domainObject.configuration.name }}</span>
<span class="c-condition__name">{{ condition.configuration.name }}</span>
<!-- TODO: description should be derived from criteria -->
<span class="c-condition__summary">
Description/summary goes here {{ domainObject.configuration.description }}
Description/summary goes here {{ condition.configuration.description }}
</span>
<div class="c-condition__buttons">
<button v-if="!domainObject.isDefault"
<button v-if="!condition.isDefault"
class="c-click-icon c-condition__duplicate-button icon-duplicate"
title="Duplicate this condition"
@click="cloneCondition"
></button>
<button v-if="!domainObject.isDefault"
<button v-if="!condition.isDefault"
class="c-click-icon c-condition__delete-button icon-trash"
title="Delete this condition"
@click="removeCondition"
@ -66,7 +66,7 @@
<span class="c-cdef__separator c-row-separator"></span>
<span class="c-cdef__label">Condition Name</span>
<span class="c-cdef__controls">
<input v-model="domainObject.configuration.name"
<input v-model="condition.configuration.name"
class="t-condition-input__name"
type="text"
@blur="persist"
@ -87,20 +87,20 @@
</option>
</select>
<input v-if="selectedOutputSelection === outputOptions[2]"
v-model="domainObject.configuration.output"
v-model="condition.configuration.output"
class="t-condition-name-input"
type="text"
@blur="persist"
>
</span>
<div v-if="!domainObject.isDefault"
<div v-if="!condition.isDefault"
class="c-cdef__match-and-criteria"
>
<span class="c-cdef__separator c-row-separator"></span>
<span class="c-cdef__label">Match</span>
<span class="c-cdef__controls">
<select v-model="domainObject.configuration.trigger"
<select v-model="condition.configuration.trigger"
@change="persist"
>
<option value="all">when all criteria are met</option>
@ -109,15 +109,15 @@
</span>
<template v-if="telemetry.length">
<div v-for="(criterion, index) in domainObject.configuration.criteria"
<div v-for="(criterion, index) in condition.configuration.criteria"
:key="index"
class="c-cdef__criteria"
>
<Criterion :telemetry="telemetry"
:criterion="criterion"
:index="index"
:trigger="domainObject.configuration.trigger"
:is-default="domainObject.configuration.criteria.length === 1"
:trigger="condition.configuration.trigger"
:is-default="condition.configuration.criteria.length === 1"
@persist="persist"
/>
<div class="c-cdef__criteria__buttons">
@ -125,7 +125,7 @@
title="Duplicate this criteria"
@click="cloneCriterion(index)"
></button>
<button v-if="!(domainObject.configuration.criteria.length === 1)"
<button v-if="!(condition.configuration.criteria.length === 1)"
class="c-click-icon c-cdef__criteria-duplicate-button icon-trash"
title="Delete this criteria"
@click="removeCriterion(index)"
@ -153,14 +153,14 @@
<!-- Browse view -->
<div class="c-condition__header">
<span class="c-condition__name">
{{ domainObject.configuration.name }}
{{ condition.configuration.name }}
</span>
<span class="c-condition__output">
Output: {{ domainObject.configuration.output }}
Output: {{ condition.configuration.output }}
</span>
</div>
<div class="c-condition__summary">
Description/summary goes here {{ domainObject.configuration.description }}
Description/summary goes here {{ condition.configuration.description }}
</div>
</div>
</template>
@ -194,9 +194,6 @@ export default {
},
data() {
return {
domainObject: {
configuration: {}
},
currentCriteria: this.currentCriteria,
expanded: true,
trigger: 'all',
@ -209,15 +206,11 @@ export default {
this.destroy();
},
mounted() {
this.domainObject = this.condition;
this.initialize();
this.setOutputSelection();
},
methods: {
initialize() {
this.setOutputSelection();
},
setOutputSelection() {
let conditionOutput = this.domainObject.configuration.output;
let conditionOutput = this.condition.configuration.output;
if (conditionOutput) {
if (conditionOutput !== 'false' && conditionOutput !== 'true') {
this.selectedOutputSelection = 'string';
@ -228,9 +221,9 @@ export default {
},
setOutputValue() {
if (this.selectedOutputSelection === 'string') {
this.domainObject.configuration.output = '';
this.condition.configuration.output = '';
} else {
this.domainObject.configuration.output = this.selectedOutputSelection;
this.condition.configuration.output = this.selectedOutputSelection;
}
this.persist();
},
@ -241,7 +234,7 @@ export default {
input: '',
metadata: ''
};
this.domainObject.configuration.criteria.push(criteriaObject);
this.condition.configuration.criteria.push(criteriaObject);
},
dragStart(e) {
e.dataTransfer.setData('dragging', e.target); // required for FF to initiate drag
@ -255,10 +248,7 @@ export default {
destroy() {
},
removeCondition(ev) {
this.$emit('removeCondition', {
condition: this.condition,
index: this.conditionIndex
});
this.$emit('removeCondition', this.conditionIndex);
},
cloneCondition(ev) {
this.$emit('cloneCondition', {
@ -267,26 +257,26 @@ export default {
});
},
removeCriterion(index) {
this.domainObject.configuration.criteria.splice(index, 1);
this.condition.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);
const clonedCriterion = {...this.condition.configuration.criteria[index]};
this.condition.configuration.criteria.splice(index + 1, 0, clonedCriterion);
this.persist()
},
hasTelemetry(identifier) {
// TODO: check parent domainObject.composition.hasTelemetry
// TODO: check parent condition.composition.hasTelemetry
return this.currentCriteria && identifier;
},
persist() {
this.$emit('updateCondition', {
condition: this.domainObject,
condition: this.condition,
index: this.conditionIndex
});
},
initCap: function (value) {
return value.charAt(0).toUpperCase() + value.slice(1)
initCap: function (str) {
return str.charAt(0).toUpperCase() + str.slice(1)
}
}
}

View File

@ -193,8 +193,8 @@ export default {
updateCondition(data) {
this.conditionManager.updateCondition(data.condition, data.index);
},
removeCondition(data) {
this.conditionManager.removeCondition(data.condition, data.index);
removeCondition(index) {
this.conditionManager.removeCondition(index);
},
reorder(reorderPlan) {
this.conditionManager.reorderConditions(reorderPlan);