Add optional activity experience on leads and people with form mapping and filters.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -81,6 +81,7 @@ const discFilter = computed(() => {
|
||||
return /^[DISC](\/[DISC]){0,3}$/.test(value) ? value : '';
|
||||
});
|
||||
const sourceFilters = computed(() => queryList('source'));
|
||||
const activityExperienceFilters = computed(() => queryList('activityExperience'));
|
||||
const groupFilters = computed(() => queryList('group'));
|
||||
const { groups: customerGroups, load: loadCustomerGroups } = useCustomerGroups();
|
||||
/** گروههای فیلتر — با شمارش scoped بر اساس دسترسی کاربر */
|
||||
@@ -93,9 +94,15 @@ const filterValue = computed<ContactsFilterValue>(() => ({
|
||||
sources: sourceFilters.value,
|
||||
moods: moodFilters.value,
|
||||
disc: discFilter.value,
|
||||
activityExperiences: activityExperienceFilters.value,
|
||||
}));
|
||||
|
||||
type FilterTag = { kind: 'group' | 'source' | 'mood' | 'disc'; value: string; label: string; color?: string };
|
||||
type FilterTag = {
|
||||
kind: 'group' | 'source' | 'mood' | 'disc' | 'activityExperience';
|
||||
value: string;
|
||||
label: string;
|
||||
color?: string;
|
||||
};
|
||||
const activeTags = computed<FilterTag[]>(() => {
|
||||
const tags: FilterTag[] = groupFilters.value.map((id) => {
|
||||
const g =
|
||||
@@ -110,6 +117,9 @@ const activeTags = computed<FilterTag[]>(() => {
|
||||
for (const m of moodFilters.value) {
|
||||
tags.push({ kind: 'mood', value: m, label: moodLabel(m) });
|
||||
}
|
||||
for (const exp of activityExperienceFilters.value) {
|
||||
tags.push({ kind: 'activityExperience', value: exp, label: `سابقه: ${exp}` });
|
||||
}
|
||||
if (discFilter.value) tags.push({ kind: 'disc', value: discFilter.value, label: `DISC: ${discFilter.value}` });
|
||||
return tags;
|
||||
});
|
||||
@@ -208,6 +218,8 @@ const peopleSavedFilters = computed(() => {
|
||||
if (mood) out.mood = mood;
|
||||
const source = csv(sourceFilters.value);
|
||||
if (source) out.source = source;
|
||||
const activityExperience = csv(activityExperienceFilters.value);
|
||||
if (activityExperience) out.activityExperience = activityExperience;
|
||||
if (discFilter.value) out.disc = discFilter.value;
|
||||
const group = csv(groupFilters.value);
|
||||
if (group) out.group = group;
|
||||
@@ -230,7 +242,7 @@ function applyPeopleSavedFilters(filters: Record<string, unknown>) {
|
||||
// کلیدهای فیلتر را از نو میسازیم تا فیلتر قبلی روی صفحه نماند
|
||||
const query: Record<string, string | string[]> = {};
|
||||
for (const [key, value] of Object.entries(route.query)) {
|
||||
if (['q', 'sort', 'mood', 'source', 'disc', 'group', 'page', 'tab'].includes(key)) continue;
|
||||
if (['q', 'sort', 'mood', 'source', 'activityExperience', 'disc', 'group', 'page', 'tab'].includes(key)) continue;
|
||||
if (value == null || value === '') continue;
|
||||
if (Array.isArray(value)) {
|
||||
const list = value.filter((v): v is string => typeof v === 'string' && v !== '');
|
||||
@@ -245,6 +257,8 @@ function applyPeopleSavedFilters(filters: Record<string, unknown>) {
|
||||
if (mood) query.mood = mood;
|
||||
const source = savedCsv(filters.source);
|
||||
if (source) query.source = source;
|
||||
const activityExperience = savedCsv(filters.activityExperience);
|
||||
if (activityExperience) query.activityExperience = activityExperience;
|
||||
const disc = savedCsv(filters.disc);
|
||||
if (disc) query.disc = disc;
|
||||
const group = savedCsv(filters.group);
|
||||
@@ -317,6 +331,7 @@ async function load() {
|
||||
sort: sort.value,
|
||||
mood: csv(moodFilters.value),
|
||||
importSource: csv(sourceFilters.value),
|
||||
activityExperience: csv(activityExperienceFilters.value),
|
||||
disc: discFilter.value || undefined,
|
||||
groupId: csv(groupFilters.value),
|
||||
},
|
||||
@@ -391,7 +406,12 @@ function applyFilters(next: ContactsFilterValue, nextSort?: string) {
|
||||
patchQuery({
|
||||
group: csv(next.groups),
|
||||
...(people
|
||||
? { source: csv(next.sources), mood: csv(next.moods), disc: next.disc || undefined }
|
||||
? {
|
||||
source: csv(next.sources),
|
||||
mood: csv(next.moods),
|
||||
activityExperience: csv(next.activityExperiences),
|
||||
disc: next.disc || undefined,
|
||||
}
|
||||
: {}),
|
||||
// در موبایل مرتبسازی داخل همان شیت فیلتر است؛ یک patch تا query قبلی overwrite نشود
|
||||
...(nextSort !== undefined
|
||||
@@ -421,13 +441,25 @@ function removeTag(tag: FilterTag) {
|
||||
if (tag.kind === 'group') patchQuery({ group: without(groupFilters.value), page: undefined });
|
||||
else if (tag.kind === 'source') patchQuery({ source: without(sourceFilters.value), page: undefined });
|
||||
else if (tag.kind === 'mood') patchQuery({ mood: without(moodFilters.value), page: undefined });
|
||||
else patchQuery({ disc: undefined, page: undefined });
|
||||
else if (tag.kind === 'activityExperience') {
|
||||
patchQuery({
|
||||
activityExperience: without(activityExperienceFilters.value),
|
||||
page: undefined,
|
||||
});
|
||||
} else patchQuery({ disc: undefined, page: undefined });
|
||||
}
|
||||
|
||||
function clearFilters() {
|
||||
patchQuery({
|
||||
group: undefined,
|
||||
...(tab.value === 'people' ? { source: undefined, mood: undefined, disc: undefined } : {}),
|
||||
...(tab.value === 'people'
|
||||
? {
|
||||
source: undefined,
|
||||
mood: undefined,
|
||||
activityExperience: undefined,
|
||||
disc: undefined,
|
||||
}
|
||||
: {}),
|
||||
page: undefined,
|
||||
});
|
||||
}
|
||||
@@ -923,6 +955,7 @@ onMounted(load);
|
||||
<th>شرکت</th>
|
||||
<th>تلفن</th>
|
||||
<th>ایمیل</th>
|
||||
<th>سابقه فعالیت</th>
|
||||
<th>تاریخ ثبت</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
@@ -978,6 +1011,7 @@ onMounted(load);
|
||||
<UiIcon v-if="p.email" name="mail" :size="14" />
|
||||
</span>
|
||||
</td>
|
||||
<td>{{ p.activityExperience || '—' }}</td>
|
||||
<td>{{ formatDate(p.createdAt) }}</td>
|
||||
<td class="ops" @click.stop>
|
||||
<UiDropdownMenu
|
||||
|
||||
Reference in New Issue
Block a user