fix: в заголовке заявковк на чтение теперь показывает правильный номер
This commit is contained in:
@@ -70,6 +70,16 @@ const RequestPortal: React.FC<IRequestPortalProps> = ({ hasTeamsContext, context
|
||||
const [mobileNavOpen, setMobileNavOpen] = React.useState<boolean>(false);
|
||||
const [navCounts, setNavCounts] = React.useState<INavCounts | undefined>(undefined);
|
||||
|
||||
// Уникальный код заявки для заголовка Drawer (approve/edit) — сама форма
|
||||
// узнаёт его только после загрузки (см. onCodeLoaded в ApproveFeature/
|
||||
// EditFeature), поэтому не берём route.itemId (это RowID в SharePoint, а не
|
||||
// видимый пользователю код). Сбрасываем при переходе на другую заявку —
|
||||
// иначе при быстрой смене итемов в заголовке на миг мелькнёт код ПРЕДЫДУЩЕЙ.
|
||||
const [drawerCode, setDrawerCode] = React.useState<string>('');
|
||||
React.useEffect(() => {
|
||||
setDrawerCode('');
|
||||
}, [route.itemId, route.mode]);
|
||||
|
||||
const [activeCategoryId, setActiveCategoryId] = React.useState<string>(() => {
|
||||
if (route.mode === 'create' && route.formKey) {
|
||||
const found = REQUEST_TYPES.filter((r) => r.id === route.formKey)[0];
|
||||
@@ -386,15 +396,21 @@ const RequestPortal: React.FC<IRequestPortalProps> = ({ hasTeamsContext, context
|
||||
</div>
|
||||
|
||||
{route.mode === 'approve' && route.formKey && route.itemId && (
|
||||
<Drawer title={`Заявка №${route.itemId}`} onClose={closeDrawer}>
|
||||
<ApproveFeature context={context} formKey={route.formKey} itemId={route.itemId} listId={route.listId} />
|
||||
<Drawer title={drawerCode ? `Заявка №${drawerCode}` : 'Заявка'} onClose={closeDrawer}>
|
||||
<ApproveFeature
|
||||
context={context}
|
||||
formKey={route.formKey}
|
||||
itemId={route.itemId}
|
||||
listId={route.listId}
|
||||
onCodeLoaded={setDrawerCode}
|
||||
/>
|
||||
</Drawer>
|
||||
)}
|
||||
|
||||
{/* Своя незавершённая заявка — та же панель, но с формой. Ввод здесь тоже
|
||||
помечает состояние изменённым, поэтому обёртка ловит input/change. */}
|
||||
{route.mode === 'edit' && route.formKey && route.itemId && (
|
||||
<Drawer title={`Заявка №${route.itemId}`} onClose={closeEditDrawer}>
|
||||
<Drawer title={drawerCode ? `Заявка №${drawerCode}` : 'Заявка'} onClose={closeEditDrawer}>
|
||||
<div onInput={markFormDirty} onChange={markFormDirty}>
|
||||
<EditFeature
|
||||
context={context}
|
||||
@@ -402,6 +418,7 @@ const RequestPortal: React.FC<IRequestPortalProps> = ({ hasTeamsContext, context
|
||||
itemId={route.itemId}
|
||||
listId={route.listId}
|
||||
onClose={closeDrawer}
|
||||
onCodeLoaded={setDrawerCode}
|
||||
/>
|
||||
</div>
|
||||
</Drawer>
|
||||
|
||||
Reference in New Issue
Block a user