admin-panel: convert city create form into a modal (pilot)
Establishes the pattern the remaining 15 add/edit forms will follow: - The form component accepts open?/id? props. When open is defined it's used as-is; asModal is fixed at mount (not reactive) since the parent decides once whether this instance is a modal or a route page. - As a modal it renders through BaseFormModal (header=title, footer= buttons, body=form) and emits success + update:open instead of navigating; as a route page (the old /city/create still exists and still works) it falls back to the original <a-card> + button layout unchanged. - The list page gets a ListPageHeader add button above the list, gated on the exact rid the route used to gate on (cities.create), opening the modal instead of navigating. Verified: pnpm build passes. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
a6d8993d01
commit
12c8195090
@@ -6,6 +6,8 @@
|
||||
-->
|
||||
<div id="page-user-list">
|
||||
<a-card title="لیست شهر ها">
|
||||
<ListPageHeader rid="cities.create" add-label="افزودن شهر" @add="addOpen = true" />
|
||||
|
||||
<XTable ref="citiesTable" :model="model">
|
||||
<template #percent="{ text }">
|
||||
{{ text ?? '-' }}
|
||||
@@ -47,6 +49,8 @@
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
</a-modal>
|
||||
|
||||
<CreateCity :open="addOpen" @update:open="addOpen = $event" @success="citiesTable?.fetch()" />
|
||||
</a-card>
|
||||
</div>
|
||||
</template>
|
||||
@@ -56,6 +60,8 @@ import { reactive, ref } from 'vue';
|
||||
import { message } from 'ant-design-vue';
|
||||
import { DeleteOutlined, EditOutlined } from '@ant-design/icons-vue';
|
||||
import XTable from '../../components/x-table/XTable.vue';
|
||||
import ListPageHeader from '../../components/common/ListPageHeader.vue';
|
||||
import CreateCity from './createCity.vue';
|
||||
import { buildCityListModel } from './CityListModel';
|
||||
import { useUsersStore } from '../../stores/users';
|
||||
import { useDeleteHandler } from '../../composables/useDeleteHandler';
|
||||
@@ -66,6 +72,7 @@ const hasPermission = (rid: string) => Boolean(users.hasPermission(rid));
|
||||
|
||||
const model = buildCityListModel();
|
||||
const citiesTable = ref<{ fetch: () => Promise<void> } | null>(null);
|
||||
const addOpen = ref(false);
|
||||
const visible = ref(false);
|
||||
const tempRow = ref<Record<string, any> | undefined>(undefined);
|
||||
const form = reactive<Record<string, any>>({ title: '', percent: null, percent_aux: null });
|
||||
|
||||
Reference in New Issue
Block a user