hotfix (dashboard): display allow email contact in card box client

- Added the `allowEmailContact` property to the `CardBoxClient` component to display the email contact status.
- Added the `allowEmailContact` computed property to the `Person` model to determine if email contact is allowed based on the related datasets.
- Preloaded the datasets relation in the `AuthorsController` to access the pivot attributes.
- Updated the `Dashboard.vue` to pass the `allowEmailContact` prop to the `CardBoxClient` component.
- Updated the `array_contains_types` validation rule to correct the error message for descriptions.
- Updated the `FormCheckRadio.vue` to correctly handle the radio button and checkbox components.
This commit is contained in:
Kaimbacher 2025-03-31 15:14:34 +02:00
parent 09f65359f9
commit f89b119b18
6 changed files with 31 additions and 49 deletions

View file

@ -39,6 +39,10 @@ const props = defineProps({
type: String,
default: null,
},
allowEmailContact: {
type: Boolean,
default: false,
}
});
const pillType = computed(() => {
@ -81,9 +85,8 @@ const pillType = computed(() => {
<h4 class="text-xl text-ellipsis">
{{ name }}
</h4>
<p class="text-gray-500 dark:text-slate-400">
<!-- {{ date }} @ {{ login }} -->
{{ email }}
<p class="text-gray-500 dark:text-slate-400">
<div v-if="props.allowEmailContact"> {{ email }}</div>
</p>
</div>
</BaseLevel>

View file

@ -1,7 +1,6 @@
<script setup lang="ts">
import { computed } from 'vue';
interface Props {
name: string;
type?: 'checkbox' | 'radio' | 'switch';
@ -10,58 +9,27 @@ interface Props {
inputValue: string | number | boolean;
}
const props = defineProps({
name: {
type: String,
required: true,
},
type: {
type: String,
default: 'checkbox',
validator: (value: string) => ['checkbox', 'radio', 'switch'].includes(value),
},
label: {
type: String,
default: null,
},
modelValue: {
type: [Array, String, Number, Boolean],
default: null,
},
inputValue: {
type: [String, Number, Boolean],
required: true,
},
});// const props = defineProps<Props>();
const props = defineProps<Props>();
// const emit = defineEmits(['update:modelValue']);
const emit = defineEmits<{ (e: 'update:modelValue', value: Props['modelValue']): void }>();
const computedValue = computed({
get: () => props.modelValue,
set: (value) => {
// If type is radio, wrap the new value inside an array.
if (props.type === 'radio') {
emit('update:modelValue', [value]);
} else {
emit('update:modelValue', value);
}
emit('update:modelValue', props.type === 'radio' ? [value] : value);
},
});
const inputType = computed(() => (props.type === 'radio' ? 'radio' : 'checkbox'));
// Define isChecked for radio inputs: it's true when the current modelValue equals the inputValue
const isChecked = computed(() => {
if (props.type === 'radio') {
return Array.isArray(computedValue.value) &&
computedValue.value.length > 0 &&
computedValue.value[0] === props.inputValue;
} else if (props.type === 'checkbox') {
return Array.isArray(computedValue.value) &&
computedValue.value.length > 0 &&
computedValue.value.includes(props.inputValue);
}
return computedValue.value === props.inputValue;
if (Array.isArray(computedValue.value) && computedValue.value.length > 0) {
return props.type === 'radio'
? computedValue.value[0] === props.inputValue
: computedValue.value.includes(props.inputValue);
}
return computedValue.value === props.inputValue;
});
</script>

View file

@ -113,6 +113,7 @@ const userHasRoles = (roleNames: Array<string>): boolean => {
:date="client.created_at"
:text="client.identifier_orcid"
:count="client.dataset_count"
/>
</div>
<div class="flex flex-col justify-between">