Hello there!
I have a form controlling some entity for edition and creation. That entity (“activity”) has multiple boolean properties, such as “isPlace” and “isEvent”. Those two properties are mutually exclusive: no activity can be both.
So in my form, I want my user to switch on for example the “activity.isPlace” switch, turning off automatically the “activity.isEvent” switch. And the opposite. What is the best way to do that? Through computed properties? Or watchers?
Thank you.
Furthermore, I’m using Vuetify. Does anyone know how to apply a “success” class on a switch label? We can put a color on the switch when it’s on, but on the label too? Is it possible?
Thank you again
EDIT:
The following seems to be ok, but it’s verbose and ugly-ish
watch: {
//If isPlace switch is ON, isEvent Switch is OFF
//And vice-versa
'activity.isPlace'(newValue) {
if (newValue === true) {
this.activity.isPlace = true;
this.activity.isEvent = false;
}
else {
this.activity.isPlace = false;
this.activity.isEvent = true;
}
},
'activity.isEvent'(newValue) {
if (newValue === true) {
this.activity.isPlace = false;
this.activity.isEvent = true;
}
else {
this.activity.isPlace = true;
this.activity.isEvent = false;
}
}
}
And for the style:
<style>
.v-selection-control--dirty label {
color: rgb(76, 175, 80) !important;
font-weight: bold;
}
</style>
So If anyone better than me comes around, don’t hesitate