Skip to content

Commit

Permalink
Disable bot settings if team member filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
gaspergrom committed Oct 20, 2023
1 parent ded1213 commit b2cf226
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<p class="text-xs font-semibold leading-5 mb-3">
Bot contacts visibility
</p>
<el-radio-group v-model="value">
<el-radio-group v-model="value" :disabled="props.settings?.teamMember === 'filter'">
<el-radio :label="IncludeEnum.EXCLUDE" class="!h-5">
<span class="text-xs">Exclude bot contacts</span>
</el-radio>
Expand All @@ -16,22 +16,37 @@
<script setup lang="ts">
import { IncludeEnum } from '@/modules/member/config/saved-views/settings/common/types/IncludeEnum';
import { computed } from 'vue';
import { computed, ref, watch } from 'vue';
const props = defineProps<{
modelValue: IncludeEnum,
modelValue: IncludeEnum | '',
settings: Record<string, string>,
}>();
const emit = defineEmits<{(e: 'update:modelValue', value: IncludeEnum): any }>();
const emit = defineEmits<{(e: 'update:modelValue', value: IncludeEnum | ''): any }>();
const value = computed<IncludeEnum>({
const value = computed<IncludeEnum | ''>({
get() {
return props.modelValue;
},
set(val: IncludeEnum) {
set(val: IncludeEnum | '') {
emit('update:modelValue', val);
},
});
const previousSettings = ref<Record<string, string> | null>(null);
watch(() => props.settings, (current) => {
if (current?.teamMember === 'filter') {
if (!previousSettings.value || previousSettings.value.teamMember !== 'filter') {
value.value = '';
}
}
if (previousSettings.value?.teamMember === 'filter' && current?.teamMember !== 'filter') {
value.value = IncludeEnum.EXCLUDE;
}
previousSettings.value = { ...current };
}, { deep: true, immediate: true });
</script>
<script lang="ts">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
<section v-if="Object.keys(settings).length > 0" class="px-6">
<div class="border-b border-gray-200 pb-1">
<div v-for="(setting, settingsKey) in settings" :key="settingsKey" class="pb-3">
<component :is="setting.settingsComponent" v-model="form.settings[settingsKey]" />
<component :is="setting.settingsComponent" v-model="form.settings[settingsKey]" :settings="form.settings" />
</div>
</div>
</section>
Expand Down

0 comments on commit b2cf226

Please sign in to comment.