From 05ed1b6aefd44e019087e8ab682c3f37affec524 Mon Sep 17 00:00:00 2001 From: vchikalkin Date: Wed, 31 May 2023 10:26:50 +0300 Subject: [PATCH] Calculation/Form: disable elements when LoadKP --- .../Calculation/Form/Insurance/FinGAPTable/index.jsx | 5 ++++- apps/web/stores/calculation/statuses/index.ts | 6 +++++- apps/web/stores/tables/insurance/index.ts | 2 ++ apps/web/stores/tables/payments/index.ts | 2 ++ 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/apps/web/Components/Calculation/Form/Insurance/FinGAPTable/index.jsx b/apps/web/Components/Calculation/Form/Insurance/FinGAPTable/index.jsx index a22f6b0..d7bd22b 100644 --- a/apps/web/Components/Calculation/Form/Insurance/FinGAPTable/index.jsx +++ b/apps/web/Components/Calculation/Form/Insurance/FinGAPTable/index.jsx @@ -29,17 +29,20 @@ const Validation = observer(() => { }); const FinGAP = observer(() => { - const { $tables } = useStore(); + const { $tables, $process } = useStore(); const { fingap } = $tables; const dataSource = toJS(fingap.risks); const selectedRowKeys = [...toJS(fingap.selectedKeys)]; + const disabled = $process.has('LoadKP'); + return ( ({ disabled }), onChange: (_, selectedRows) => { const selectedKeys = selectedRows.reduce((acc, row) => { acc.push(row.key); diff --git a/apps/web/stores/calculation/statuses/index.ts b/apps/web/stores/calculation/statuses/index.ts index 2bead74..30d8bb7 100644 --- a/apps/web/stores/calculation/statuses/index.ts +++ b/apps/web/stores/calculation/statuses/index.ts @@ -22,10 +22,14 @@ export default class StatusStore { public getStatus(elementName: ElementsActions | ElementsValues) { const status = this.overrided[elementName] || this.statuses[elementName]; - if (this.root.$process.has('Unlimited') && status === 'Disabled') { + if (this.root.$process.has('Unlimited')) { return 'Default'; } + if (this.root.$process.has('LoadKP')) { + return 'Disabled'; + } + return status; } diff --git a/apps/web/stores/tables/insurance/index.ts b/apps/web/stores/tables/insurance/index.ts index 461225b..6c3d8f2 100644 --- a/apps/web/stores/tables/insurance/index.ts +++ b/apps/web/stores/tables/insurance/index.ts @@ -105,6 +105,8 @@ export default class InsuranceTable { getStatus: (valueName: Insurance.Values) => { if (this.root.$process.has('Unlimited')) return 'Default'; + if (this.root.$process.has('LoadKP')) return 'Disabled'; + return this.statuses[key][valueName]; }, diff --git a/apps/web/stores/tables/payments/index.ts b/apps/web/stores/tables/payments/index.ts index e11a103..289b033 100644 --- a/apps/web/stores/tables/payments/index.ts +++ b/apps/web/stores/tables/payments/index.ts @@ -74,6 +74,8 @@ export default class PaymentsTable { public getStatus(index: number) { if (this.root.$process.has('Unlimited')) return 'Default'; + if (this.root.$process.has('LoadKP')) return 'Disabled'; + return this.overridedStatus.get() ?? this.statuses[index]; }