This repository has been archived on 2024-07-22. You can view files and clone it, but cannot push or open issues or pull requests.
Zaimki/components/PropagateCheckbox.vue

38 lines
964 B
Vue
Raw Normal View History

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