stores/calculation: add syntax sugar methods
This commit is contained in:
parent
7a10d72408
commit
26f6149b39
@ -17,11 +17,11 @@ export default function calculateValidationReactions(
|
||||
},
|
||||
(hasErrors) => {
|
||||
if (hasErrors) {
|
||||
$calculation.$status.setStatus('btnCalculate', 'Disabled');
|
||||
$calculation.$status.setStatus('btnCreateKP', 'Disabled');
|
||||
$calculation.blockElement('btnCalculate');
|
||||
$calculation.blockElement('btnCreateKP');
|
||||
} else {
|
||||
$calculation.$status.resetStatus('btnCalculate');
|
||||
$calculation.$status.resetStatus('btnCreateKP');
|
||||
$calculation.unblockElement('btnCalculate');
|
||||
$calculation.unblockElement('btnCreateKP');
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
@ -43,8 +43,11 @@ export default function leadOpportunityUrlsReactions(
|
||||
reaction(
|
||||
() => $calculation.$values.getElementValue(linkElementName),
|
||||
(url) => {
|
||||
const status = url ? 'Default' : 'Disabled';
|
||||
$calculation.$status.setStatus(linkElementName, status);
|
||||
if (!url) {
|
||||
$calculation.blockElement(linkElementName);
|
||||
} else {
|
||||
$calculation.unblockElement(linkElementName);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
/* eslint-disable import/no-cycle */
|
||||
import type { Elements } from 'Components/Calculation/config/map/values';
|
||||
import type { Elements as ElementsActions } from 'Components/Calculation/config/map/actions';
|
||||
import type { Elements as ElementsValues } from 'Components/Calculation/config/map/values';
|
||||
import type RootStore from 'stores/root';
|
||||
import OptionsStore from './options';
|
||||
import StatusStore from './statuses';
|
||||
@ -19,10 +20,18 @@ export default class CalculationStore {
|
||||
this.$validation = new ValidationStore(rootStore);
|
||||
}
|
||||
|
||||
resetElement = (elementName: Elements) => {
|
||||
resetElement = (elementName: ElementsValues) => {
|
||||
this.$values.resetElementValue(elementName);
|
||||
this.$options.resetOption(elementName);
|
||||
this.$status.resetStatus(elementName);
|
||||
this.$validation.clearErrors(elementName);
|
||||
};
|
||||
|
||||
blockElement = (elementName: ElementsValues | ElementsActions) => {
|
||||
this.$status.setStatus(elementName, 'Disabled');
|
||||
};
|
||||
|
||||
unblockElement = (elementName: ElementsValues | ElementsActions) => {
|
||||
this.$status.setStatus(elementName, 'Default');
|
||||
};
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user