Skip to content

Commit

Permalink
migrate mt-inheritance-switch to custom i18n
Browse files Browse the repository at this point in the history
  • Loading branch information
Haberkamp committed Nov 6, 2024
1 parent a0fb1b7 commit ad42e43
Showing 1 changed file with 26 additions and 31 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
<template>
<div
class="mt-inheritance-switch"
:class="{
'mt-inheritance-switch--disabled': disabled,
'mt-inheritance-switch--is-inherited': isInherited,
'mt-inheritance-switch--is-not-inherited': !isInherited,
}"
:class="[
'mt-inheritance-switch',
{
'mt-inheritance-switch--disabled': disabled,
'mt-inheritance-switch--is-inherited': isInherited,
'mt-inheritance-switch--is-not-inherited': !isInherited,
},
]"
>
<mt-icon
v-if="isInherited"
Expand All @@ -20,14 +22,17 @@
size="14"
@click="onClickRemoveInheritance"
/>

<mt-icon
v-else
key="uninherit-icon"
v-tooltip="{
message: t('tooltipRestoreInheritance'),
disabled: disabled,
}"
:class="unInheritClasses"
:class="{
'is--clickable': !disabled,
}"
:multicolor="true"
name="regular-link-horizontal-slash"
size="14"
Expand Down Expand Up @@ -67,29 +72,7 @@ export default defineComponent({
},
},
computed: {
unInheritClasses(): { "is--clickable": boolean } {
return { "is--clickable": !this.disabled };
},
},
methods: {
onClickRestoreInheritance() {
if (this.disabled) {
return;
}
this.$emit("inheritance-restore");
},
onClickRemoveInheritance() {
if (this.disabled) {
return;
}
this.$emit("inheritance-remove");
},
},
setup() {
setup(props, { emit }) {
const { t } = useI18n({
messages: {
en: {
Expand All @@ -103,7 +86,19 @@ export default defineComponent({
},
});
return { t };
function onClickRestoreInheritance() {
if (props.disabled) return;
emit("inheritance-restore");
}
function onClickRemoveInheritance() {
if (props.disabled) return;
emit("inheritance-remove");
}
return { t, onClickRemoveInheritance, onClickRestoreInheritance };
},
});
</script>
Expand Down

0 comments on commit ad42e43

Please sign in to comment.