Co-authored-by: gorbenko.pavel <gorbenko.pavel@tansu.kz> Reviewed-on: http://git.tnsu.kz/timur.gorodetskiy/request-portal/pulls/9
This commit was merged in pull request #9.
This commit is contained in:
@@ -2,6 +2,7 @@ import * as React from 'react';
|
||||
import type { WebPartContext } from '@microsoft/sp-webpart-base';
|
||||
import styles from './ApproveFeature.module.scss';
|
||||
import { getViewComponent } from '../../forms/viewRegistry';
|
||||
import { isConfirmedStaleListId } from '../../shared/approval';
|
||||
|
||||
export interface IApproveFeatureProps {
|
||||
context: WebPartContext;
|
||||
@@ -9,18 +10,29 @@ export interface IApproveFeatureProps {
|
||||
formKey: string;
|
||||
/** RowID заявки из URL. */
|
||||
itemId: number;
|
||||
/** Партиция, где лежит заявка (см. IRoute.listId) — не задана у ссылок старого формата. */
|
||||
listId?: string;
|
||||
}
|
||||
|
||||
// Фича «Согласование»: открывается по ссылке из потока (mode=approve&type=&id=).
|
||||
// Показывает заявку в режиме чтения; панель решения добавим следующим шагом.
|
||||
const ApproveFeature: React.FC<IApproveFeatureProps> = ({ context, formKey, itemId }) => {
|
||||
const ApproveFeature: React.FC<IApproveFeatureProps> = ({ context, formKey, itemId, listId }) => {
|
||||
const ViewComponent = getViewComponent(formKey);
|
||||
|
||||
// Партиция указана и реестр ТОЧНО знает, что её там нет — см. тот же
|
||||
// комментарий в EditFeature (isConfirmedStaleListId).
|
||||
const partitionError =
|
||||
listId && isConfirmedStaleListId(formKey, listId)
|
||||
? `Не удалось открыть заявку: список «${listId}» не найден в реестре партиций. Ссылка могла устареть — попробуйте открыть заявку заново из списка.`
|
||||
: undefined;
|
||||
|
||||
return (
|
||||
<div className={styles.content}>
|
||||
{ViewComponent ? (
|
||||
{partitionError ? (
|
||||
<div className={styles.state}>{partitionError}</div>
|
||||
) : ViewComponent ? (
|
||||
<React.Suspense fallback={<div className={styles.state}>Загрузка…</div>}>
|
||||
<ViewComponent context={context} itemId={itemId} formKey={formKey} />
|
||||
<ViewComponent context={context} itemId={itemId} formKey={formKey} listId={listId} />
|
||||
</React.Suspense>
|
||||
) : (
|
||||
<div className={styles.state}>Для формы «{formKey}» режим согласования пока не настроен.</div>
|
||||
|
||||
Reference in New Issue
Block a user