feat(contacts): keep Tahesab honorifics with person gender
Male and female names can store the title when requested, and Tahesab import and export use the same gender. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,11 +1,12 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, nextTick, onMounted, ref } from 'vue';
|
||||
import { computed, nextTick, onMounted, ref, watch } from 'vue';
|
||||
import { RouterLink, useRoute, useRouter } from 'vue-router';
|
||||
import axios from 'axios';
|
||||
import {
|
||||
Alert as AAlert,
|
||||
Button as AButton,
|
||||
Card as ACard,
|
||||
Checkbox as ACheckbox,
|
||||
Col as ACol,
|
||||
Divider as ADivider,
|
||||
Flex as AFlex,
|
||||
@@ -34,7 +35,8 @@ import {
|
||||
SearchOutlined,
|
||||
} from '@ant-design/icons-vue';
|
||||
import { api } from '@/lib/api';
|
||||
import type { CompanyDto, CreatePersonRequest, PersonDto, PersonMood } from '@mento/shared';
|
||||
import type { CompanyDto, CreatePersonRequest, PersonDto, PersonGender, PersonMood } from '@mento/shared';
|
||||
import { PERSON_GENDER_LABELS, PERSON_GENDERS, splitPersonHonorific } from '@mento/shared';
|
||||
import { PERSON_MOOD_LABELS, PERSON_MOODS } from '@/lib/person-mood';
|
||||
import { formatLocalDateInput, toFaDigits } from '@/lib/jalali';
|
||||
import JalaliDateInput from '@/components/JalaliDateInput.vue';
|
||||
@@ -85,6 +87,8 @@ const companies = ref<CompanyDto[]>([]);
|
||||
|
||||
const firstName = ref('');
|
||||
const lastName = ref('');
|
||||
const gender = ref<PersonGender>('none');
|
||||
const showGenderInName = ref(false);
|
||||
const email = ref('');
|
||||
const phone = ref('');
|
||||
const mobile = ref('');
|
||||
@@ -125,6 +129,15 @@ const companyOptions = computed(() => [
|
||||
...companies.value.map((c) => ({ value: c.id, label: c.name })),
|
||||
]);
|
||||
|
||||
const genderOptions = PERSON_GENDERS.map((key) => ({
|
||||
value: key,
|
||||
label: PERSON_GENDER_LABELS[key],
|
||||
}));
|
||||
|
||||
watch(gender, (value) => {
|
||||
if (value === 'none') showGenderInName.value = false;
|
||||
});
|
||||
|
||||
const backTo = computed(() =>
|
||||
isNew.value ? { name: 'contacts' as const } : { name: 'person-detail' as const, params: { id: id.value } },
|
||||
);
|
||||
@@ -249,8 +262,12 @@ function pickFromVcf() {
|
||||
}
|
||||
|
||||
function fill(p: PersonDto) {
|
||||
firstName.value = p.firstName;
|
||||
lastName.value = p.lastName;
|
||||
const bare = splitPersonHonorific(p.firstName, p.lastName);
|
||||
firstName.value = bare.firstName;
|
||||
lastName.value = bare.lastName;
|
||||
gender.value = p.gender && p.gender !== 'none' ? p.gender : (bare.gender ?? 'none');
|
||||
showGenderInName.value =
|
||||
gender.value !== 'none' && (p.showGenderInName || bare.gender != null);
|
||||
email.value = p.email ?? '';
|
||||
phone.value = p.phone ?? '';
|
||||
mobile.value = p.mobile ?? '';
|
||||
@@ -330,6 +347,8 @@ function payload(): CreatePersonRequest {
|
||||
return {
|
||||
firstName: firstName.value,
|
||||
lastName: lastName.value,
|
||||
gender: gender.value,
|
||||
showGenderInName: gender.value !== 'none' && showGenderInName.value,
|
||||
email: email.value || undefined,
|
||||
phone: phone.value || undefined,
|
||||
mobile: mobile.value || undefined,
|
||||
@@ -462,6 +481,21 @@ onMounted(load);
|
||||
<a-input v-model:value="lastName" />
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :xs="24" :md="12">
|
||||
<a-form-item label="جنسیت">
|
||||
<a-select v-model:value="gender" :options="genderOptions" />
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :xs="24" :md="12">
|
||||
<a-form-item
|
||||
label="نمایش در نام"
|
||||
extra="مرد «جناب آقای» و زن «سرکار خانم» ابتدای نام ذخیره میشود و به تهحساب هم همینطور میرود."
|
||||
>
|
||||
<a-checkbox v-model:checked="showGenderInName" :disabled="gender === 'none'">
|
||||
نمایش در نام
|
||||
</a-checkbox>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :xs="24" :md="12">
|
||||
<a-form-item label="موبایل">
|
||||
<a-space-compact block style="width: 100%">
|
||||
|
||||
Reference in New Issue
Block a user