added controls for remove and duplicate criteria

This commit is contained in:
Joel McKinnon 2020-02-20 07:23:38 -08:00
parent d425bd564c
commit fa6dd84945
3 changed files with 37 additions and 1 deletions

View File

@ -96,6 +96,7 @@
:criterion="criterion" :criterion="criterion"
:index="index" :index="index"
:trigger="trigger" :trigger="trigger"
:is-default="domainObject.configuration.criteria.length === 1"
@persist="persist" @persist="persist"
/> />
</ul> </ul>
@ -214,7 +215,7 @@ export default {
this.domainObject.configuration.criteria.push(criteriaObject); this.domainObject.configuration.criteria.push(criteriaObject);
}, },
dragStart(e) { dragStart(e) {
this.$emit('set-move-index', Number(e.target.getAttribute('data-condition-index'))); this.$emit('setMoveIndex', Number(e.target.getAttribute('data-condition-index')));
}, },
destroy() { destroy() {
if (this.conditionClass) { if (this.conditionClass) {

View File

@ -46,6 +46,15 @@
> >
</span> </span>
</span> </span>
<div class="temp">
<span class="is-enabled c-c__duplicate"
@click="cloneCriterion"
></span>
<span v-if="!isDefault"
class="is-enabled c-c__trash"
@click="removeCriterion"
></span>
</div>
</li> </li>
</template> </template>
@ -72,6 +81,10 @@ export default {
trigger: { trigger: {
type: String, type: String,
required: true required: true
},
isDefault: {
type: Boolean,
default: false
} }
}, },
data() { data() {
@ -91,6 +104,7 @@ export default {
mounted() { mounted() {
this.updateMetadataOptions(); this.updateMetadataOptions();
this.updateOperationInputVisibility(); this.updateOperationInputVisibility();
console.log('this.isDefault', this.isDefault);
}, },
methods: { methods: {
updateMetadataOptions() { updateMetadataOptions() {
@ -113,6 +127,18 @@ export default {
updateMetadataSelection() { updateMetadataSelection() {
this.updateOperationInputVisibility(); this.updateOperationInputVisibility();
}, },
removeCriterion(ev) {
console.log('removeCriterion', this.index);
// this.$emit('removeCondition', this.conditionIdentifier);
},
cloneCriterion(ev) {
console.log('cloneCriterion')
// this.$emit('cloneCondition', {
// identifier: this.conditionIdentifier,
// index: Number(ev.target.closest('.widget-condition').getAttribute('data-condition-index'))
// });
},
persist() { persist() {
this.$emit('persist', this.criterion); this.$emit('persist', this.criterion);
} }

View File

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