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:
@@ -22,11 +22,21 @@ const CATEGORIES = [
|
||||
|
||||
const UNITS = ['عدد', 'گرم', 'مثقال', 'سوت', 'کیلوگرم', 'ساعت', 'بسته'];
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
embedded?: boolean;
|
||||
entityId?: string;
|
||||
}>(),
|
||||
{ embedded: false },
|
||||
);
|
||||
const emit = defineEmits<{ saved: []; cancel: [] }>();
|
||||
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
const editId = computed(() =>
|
||||
typeof route.params.id === 'string' ? route.params.id : '',
|
||||
);
|
||||
const editId = computed(() => {
|
||||
if (props.embedded) return props.entityId ?? '';
|
||||
return typeof route.params.id === 'string' ? route.params.id : '';
|
||||
});
|
||||
const isEdit = computed(() => Boolean(editId.value));
|
||||
|
||||
const loading = ref(false);
|
||||
@@ -148,6 +158,10 @@ async function submit() {
|
||||
} else {
|
||||
await api.post('/products', payload);
|
||||
}
|
||||
if (props.embedded) {
|
||||
emit('saved');
|
||||
return;
|
||||
}
|
||||
await router.push({ name: 'products' });
|
||||
} catch (e) {
|
||||
if (axios.isAxiosError(e)) {
|
||||
@@ -164,6 +178,10 @@ async function submit() {
|
||||
}
|
||||
|
||||
function cancel() {
|
||||
if (props.embedded) {
|
||||
emit('cancel');
|
||||
return;
|
||||
}
|
||||
void router.push({ name: 'products' });
|
||||
}
|
||||
|
||||
@@ -178,8 +196,14 @@ onMounted(async () => {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section class="page">
|
||||
<header class="page-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="page-head">
|
||||
<button type="button" class="back mob-only" aria-label="بازگشت" @click="cancel">
|
||||
<UiIcon name="chevron" :size="20" />
|
||||
</button>
|
||||
@@ -401,6 +425,16 @@ onMounted(async () => {
|
||||
gap: 1rem;
|
||||
max-width: 1100px;
|
||||
}
|
||||
|
||||
.page.embedded {
|
||||
max-width: none;
|
||||
}
|
||||
|
||||
.embed-actions {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
.page-head {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
|
||||
Reference in New Issue
Block a user