Параллельные шаги (#3)
Co-authored-by: gorbenko.pavel <gorbenko.pavel@tansu.kz> Reviewed-on: http://git.tnsu.kz/timur.gorodetskiy/request-portal/pulls/3
This commit was merged in pull request #3.
This commit is contained in:
@@ -8,6 +8,7 @@ import { getRequestsByCategory, REQUEST_TYPES } from '../../data/requests';
|
||||
import { getFormComponent } from '../../forms/registry';
|
||||
import { IRequestType } from '../../models/types';
|
||||
import { emitRequestsChanged } from '../../shared/requestEvents';
|
||||
import { confirmDiscardFormChanges, markFormClean } from '../../shared/unsavedChanges';
|
||||
|
||||
export interface ISubmitFeatureProps {
|
||||
context: WebPartContext;
|
||||
@@ -43,7 +44,15 @@ const SubmitFeature: React.FC<ISubmitFeatureProps> = ({ context, activeCategoryI
|
||||
|
||||
const requests = getRequestsByCategory(activeCategoryId);
|
||||
|
||||
const handleBack = (): void => setSelectedRequest(null);
|
||||
// Возврат к плиткам закрывает форму и теряет введённое (раздел остаётся
|
||||
// смонтированным, но состояние формы живёт в самом FormComponent). Спрашиваем,
|
||||
// если правки есть и они не сохранены; после согласия флаг снимаем — терять
|
||||
// уже нечего.
|
||||
const handleBack = (): void => {
|
||||
if (!confirmDiscardFormChanges()) return;
|
||||
markFormClean();
|
||||
setSelectedRequest(null);
|
||||
};
|
||||
|
||||
const renderSelected = (request: IRequestType): React.ReactNode => {
|
||||
const FormComponent = getFormComponent(request.id);
|
||||
|
||||
Reference in New Issue
Block a user