feat: implemented form lifecycle hool and state machine
This commit is contained in:
@@ -4,6 +4,8 @@ export {
|
||||
REQUEST_STATUS_CHOICES,
|
||||
APPROVAL_PHASE,
|
||||
APPROVAL_PHASE_CHOICES,
|
||||
EDITABLE_STATUSES,
|
||||
isEditableStatus,
|
||||
} from './models/statuses';
|
||||
export type { ISiteUser } from './models/ISiteUser';
|
||||
export type { IMatrixRow } from './models/IMatrixRow';
|
||||
@@ -26,3 +28,4 @@ export type { IUseMatrixEditor } from './useMatrixEditor';
|
||||
export { ApprovalMatrix } from './ui/ApprovalMatrix';
|
||||
export { UserPicker } from './ui/UserPicker';
|
||||
export { DecisionPanel } from './ui/DecisionPanel';
|
||||
export { StatusBadge } from './ui/StatusBadge';
|
||||
|
||||
@@ -13,6 +13,20 @@ export const REQUEST_STATUS = {
|
||||
closed: 'Закрыта',
|
||||
} as const;
|
||||
|
||||
// Статусы, при которых заявку ещё можно править (форма редактируема).
|
||||
// Всё остальное (На согласовании / Согласовано / Выполнение / Закрыта) — только чтение.
|
||||
// «Отклонено» здесь по решению 2026-08-04: отклонённую можно доработать и переотправить.
|
||||
export const EDITABLE_STATUSES: string[] = [
|
||||
REQUEST_STATUS.draft,
|
||||
REQUEST_STATUS.returned,
|
||||
REQUEST_STATUS.rejected,
|
||||
];
|
||||
|
||||
// Новая (без статуса) или заявка в редактируемом статусе → форму можно менять.
|
||||
export function isEditableStatus(status: string | undefined): boolean {
|
||||
return !status || EDITABLE_STATUSES.indexOf(status) !== -1;
|
||||
}
|
||||
|
||||
// Полный набор значений для Choice-колонки при провижининге.
|
||||
export const REQUEST_STATUS_CHOICES: string[] = [
|
||||
REQUEST_STATUS.draft,
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
@import '../../../../../styles/design-tokens';
|
||||
|
||||
.badge {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
padding: 5px 12px;
|
||||
border-radius: $r-sm;
|
||||
font-family: $font-sans;
|
||||
font-size: 12.5px;
|
||||
font-weight: 600;
|
||||
letter-spacing: .2px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.draft {
|
||||
background: $gray-100;
|
||||
color: $gray-700;
|
||||
}
|
||||
|
||||
.onApproval {
|
||||
background: $blue-50;
|
||||
color: $blue-600;
|
||||
}
|
||||
|
||||
.approved {
|
||||
background: $green-50;
|
||||
color: $green-600;
|
||||
}
|
||||
|
||||
.rejected {
|
||||
background: $red-50;
|
||||
color: $red-500;
|
||||
}
|
||||
|
||||
.returned {
|
||||
background: $gold-50;
|
||||
color: $amber-700;
|
||||
}
|
||||
|
||||
.execution {
|
||||
background: $navy-50;
|
||||
color: $navy-800;
|
||||
}
|
||||
|
||||
.closed {
|
||||
background: $gray-100;
|
||||
color: $gray-500;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
import * as React from 'react';
|
||||
import styles from './StatusBadge.module.scss';
|
||||
import { REQUEST_STATUS } from '../models/statuses';
|
||||
|
||||
// Цвет бейджа по статусу заявки. Неизвестный статус → нейтральный (как черновик).
|
||||
const VARIANT: Record<string, string> = {
|
||||
[REQUEST_STATUS.draft]: styles.draft,
|
||||
[REQUEST_STATUS.onApproval]: styles.onApproval,
|
||||
[REQUEST_STATUS.approved]: styles.approved,
|
||||
[REQUEST_STATUS.rejected]: styles.rejected,
|
||||
[REQUEST_STATUS.returned]: styles.returned,
|
||||
[REQUEST_STATUS.execution]: styles.execution,
|
||||
[REQUEST_STATUS.closed]: styles.closed,
|
||||
};
|
||||
|
||||
/** Цветная плашка статуса заявки (шапка формы / просмотра). */
|
||||
export const StatusBadge: React.FC<{ status: string }> = ({ status }) => (
|
||||
<span className={`${styles.badge} ${VARIANT[status] || styles.draft}`}>{status}</span>
|
||||
);
|
||||
Reference in New Issue
Block a user