PronounsPage/components/PropagateCheckbox.vue
2025-01-31 21:49:08 +01:00

43 lines
941 B
Vue

<template>
<div v-if="hasChanges" class="form-check form-switch my-2">
<label>
<input v-model="propagate" class="form-check-input" type="checkbox" role="switch">
<T>profile.editor.propagate</T>
</label>
</div>
</template>
<script>
export default {
props: {
field: { required: true },
before: { required: true },
after: { required: true },
},
emits: ['change'],
data() {
return {
propagate: false,
};
},
computed: {
hasChanges() {
return JSON.stringify(this.before) !== JSON.stringify(this.after);
},
},
watch: {
hasChanges() {
this.emit();
},
propagate() {
this.emit();
},
},
methods: {
emit() {
this.$emit('change', this.field, this.hasChanges && this.propagate);
},
},
};
</script>