Calculation/Form: disable elements when Calculate || CreateKP

This commit is contained in:
vchikalkin 2023-05-31 11:02:03 +03:00
parent 05ed1b6aef
commit 2d0117bc4c
6 changed files with 24 additions and 6 deletions

View File

@ -35,7 +35,7 @@ const FinGAP = observer(() => {
const dataSource = toJS(fingap.risks);
const selectedRowKeys = [...toJS(fingap.selectedKeys)];
const disabled = $process.has('LoadKP');
const disabled = $process.has('LoadKP') || $process.has('Calculate') || $process.has('CreateKP');
return (
<Table

View File

@ -8,7 +8,9 @@ const errorMessage = 'Ошибка во время создания КП!';
const successMessage = 'КП создано!';
export function action({ store, trpcClient, apolloClient }: ProcessContext) {
const { $calculation, $tables, $results } = store;
const { $calculation, $tables, $results, $process } = store;
$process.add('CreateKP');
$calculation.$status.setStatus('btnCalculate', 'Loading');
$calculation.$status.setStatus('btnCreateKP', 'Loading');
@ -72,5 +74,7 @@ export function action({ store, trpcClient, apolloClient }: ProcessContext) {
$calculation.$status.setStatus('btnCalculate', 'Default');
$calculation.$status.setStatus('btnCreateKP', 'Default');
$calculation.$status.setStatus('btnCreateKPMini', 'Default');
$process.delete('CreateKP');
});
}

View File

@ -26,7 +26,11 @@ export default class StatusStore {
return 'Default';
}
if (this.root.$process.has('LoadKP')) {
if (
this.root.$process.has('LoadKP') ||
this.root.$process.has('Calculate') ||
this.root.$process.has('CreateKP')
) {
return 'Disabled';
}

View File

@ -1,7 +1,7 @@
import type { ObservableSet } from 'mobx';
import { observable } from 'mobx';
export type Process = 'Calculate' | 'ELT' | 'LoadKP' | 'Unlimited';
export type Process = 'Calculate' | 'CreateKP' | 'ELT' | 'LoadKP' | 'Unlimited';
export type ProcessStore = ObservableSet<Process>;
export default function createProcessStore() {

View File

@ -105,7 +105,12 @@ export default class InsuranceTable {
getStatus: (valueName: Insurance.Values) => {
if (this.root.$process.has('Unlimited')) return 'Default';
if (this.root.$process.has('LoadKP')) return 'Disabled';
if (
this.root.$process.has('LoadKP') ||
this.root.$process.has('Calculate') ||
this.root.$process.has('CreateKP')
)
return 'Disabled';
return this.statuses[key][valueName];
},

View File

@ -74,7 +74,12 @@ export default class PaymentsTable {
public getStatus(index: number) {
if (this.root.$process.has('Unlimited')) return 'Default';
if (this.root.$process.has('LoadKP')) return 'Disabled';
if (
this.root.$process.has('LoadKP') ||
this.root.$process.has('Calculate') ||
this.root.$process.has('CreateKP')
)
return 'Disabled';
return this.overridedStatus.get() ?? this.statuses[index];
}