Unify the web UI on shared controls and let pipeline columns be managed on the board.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -8,10 +8,22 @@ import CustomFieldsSection from '@/components/CustomFieldsSection.vue';
|
||||
import EntityTimeline from '@/components/EntityTimeline.vue';
|
||||
import UiIcon from '@/components/UiIcon.vue';
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
embedded?: boolean;
|
||||
entityId?: string;
|
||||
}>(),
|
||||
{ embedded: false },
|
||||
);
|
||||
const emit = defineEmits<{ saved: []; cancel: [] }>();
|
||||
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
const id = computed(() => (typeof route.params.id === 'string' ? route.params.id : ''));
|
||||
const isNew = computed(() => route.name === 'company-new');
|
||||
const id = computed(() => {
|
||||
if (props.embedded) return props.entityId ?? '';
|
||||
return typeof route.params.id === 'string' ? route.params.id : '';
|
||||
});
|
||||
const isNew = computed(() => (props.embedded ? !props.entityId : route.name === 'company-new'));
|
||||
const pageTitle = computed(() => (isNew.value ? 'شرکت جدید' : 'ویرایش شرکت'));
|
||||
|
||||
const loading = ref(false);
|
||||
@@ -71,9 +83,17 @@ async function submit() {
|
||||
try {
|
||||
if (isNew.value) {
|
||||
const { data } = await api.post<CompanyDto>('/companies', payload());
|
||||
if (props.embedded) {
|
||||
emit('saved');
|
||||
return;
|
||||
}
|
||||
await router.replace({ name: 'company-detail', params: { id: data.id } });
|
||||
} else {
|
||||
await api.patch(`/companies/${id.value}`, payload());
|
||||
if (props.embedded) {
|
||||
emit('saved');
|
||||
return;
|
||||
}
|
||||
await router.push({ name: 'contacts', query: { tab: 'companies' } });
|
||||
}
|
||||
} catch (e) {
|
||||
@@ -103,6 +123,10 @@ async function remove() {
|
||||
}
|
||||
|
||||
function cancel() {
|
||||
if (props.embedded) {
|
||||
emit('cancel');
|
||||
return;
|
||||
}
|
||||
void router.push({ name: 'contacts', query: { tab: 'companies' } });
|
||||
}
|
||||
|
||||
@@ -110,8 +134,14 @@ onMounted(load);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section class="page">
|
||||
<header class="desktop-head">
|
||||
<section class="page" :class="{ embedded }">
|
||||
<div v-if="embedded" class="embed-actions">
|
||||
<button class="btn primary" type="button" :disabled="saving" @click="submit">
|
||||
{{ saving ? 'در حال ذخیره…' : 'ذخیره' }}
|
||||
</button>
|
||||
<button class="btn cancel" type="button" :disabled="saving" @click="cancel">انصراف</button>
|
||||
</div>
|
||||
<header v-if="!embedded" class="desktop-head">
|
||||
<div class="title-block">
|
||||
<span class="doc-ico"><UiIcon name="building" :size="22" /></span>
|
||||
<div>
|
||||
@@ -135,7 +165,7 @@ onMounted(load);
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<header class="mobile-head">
|
||||
<header v-if="!embedded" class="mobile-head">
|
||||
<button class="icon-btn" type="button" aria-label="ذخیره" :disabled="saving" @click="submit">
|
||||
<UiIcon name="check-plain" :size="22" />
|
||||
</button>
|
||||
@@ -206,6 +236,17 @@ onMounted(load);
|
||||
padding-bottom: 1.5rem;
|
||||
}
|
||||
|
||||
.page.embedded {
|
||||
max-width: none;
|
||||
padding-bottom: 0;
|
||||
}
|
||||
|
||||
.embed-actions {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.desktop-head {
|
||||
display: none;
|
||||
justify-content: space-between;
|
||||
|
||||
Reference in New Issue
Block a user