mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-10-25 22:52:48 +00:00
Refactor entity handling in TypeUser.vue and PickEntity.vue for improved consistency and type safety.
- Adjusted `TypeUser.vue` to correctly reference `props.item.result` and removed unused `hasParent` logic. - Updated `PickEntity.vue` to include handling for households with new `isEntityHousehold` utility. - Added `isEntityHousehold` function to `types.ts` for reusable type checks.
This commit is contained in:
@@ -12,13 +12,20 @@
|
||||
>{{ trans(USER_CURRENT_USER) }}</span
|
||||
>
|
||||
<span
|
||||
v-else
|
||||
v-else-if="!isEntityHousehold(p)"
|
||||
:class="getBadgeClass(p)"
|
||||
class="chill_denomination"
|
||||
:style="getBadgeStyle(p)"
|
||||
>
|
||||
{{ p.text }}
|
||||
</span>
|
||||
<span v-else
|
||||
:class="getBadgeClass(p)"
|
||||
class="chill_denomination"
|
||||
:style="getBadgeStyle(p)"
|
||||
>
|
||||
Ménage n°{{ p.id }}
|
||||
</span>
|
||||
</li>
|
||||
</ul>
|
||||
<ul class="record_actions mb-0">
|
||||
@@ -54,9 +61,12 @@
|
||||
@click="addNewSuggested(s)"
|
||||
style="margin: 0"
|
||||
>
|
||||
<span :class="getBadgeClass(s)" :style="getBadgeStyle(s)">
|
||||
<span v-if="!isEntityHousehold(s)" :class="getBadgeClass(s)" :style="getBadgeStyle(s)">
|
||||
{{ s.text }}
|
||||
</span>
|
||||
<span v-else>
|
||||
Ménage n°{{ s.id }}
|
||||
</span>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
@@ -75,7 +85,7 @@ import AddPersons from "ChillPersonAssets/vuejs/_components/AddPersons.vue";
|
||||
import {
|
||||
Entities,
|
||||
EntitiesOrMe,
|
||||
EntityType,
|
||||
EntityType, isEntityHousehold,
|
||||
SearchOptions,
|
||||
Suggestion,
|
||||
} from "ChillPersonAssets/types";
|
||||
|
||||
@@ -392,6 +392,10 @@ export type EntityType =
|
||||
|
||||
export type Entities = (UserGroup | User | Person | Thirdparty | Household);
|
||||
|
||||
export function isEntityHousehold(e: Entities): e is Household {
|
||||
return e.type === "household";
|
||||
}
|
||||
|
||||
export type EntitiesOrMe = "me" | Entities;
|
||||
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
<template>
|
||||
<div class="container usercontainer">
|
||||
<div class="user-identification">
|
||||
<UserRenderBoxBadge :user="item.result" />
|
||||
<UserRenderBoxBadge :user="props.item.result" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="right_actions">
|
||||
<BadgeEntity :entity="item.result" :options="{ displayLong: true }" />
|
||||
<BadgeEntity :entity="props.item.result" :options="{ displayLong: true }" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -22,11 +22,6 @@ interface TypeUserProps {
|
||||
|
||||
const props = defineProps<TypeUserProps>();
|
||||
|
||||
const hasParent = computed(() => props.item.result.parent !== null);
|
||||
|
||||
defineExpose({
|
||||
hasParent,
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
||||
Reference in New Issue
Block a user