function onPurityChanged()

in ui/src/app/common/components/indigo-components/directives/stoich-table/services/reagents/reagents-calculation.service.js [331:366]


    function onPurityChanged(row) {
        var prevPurity = row.stoicPurity.prevValue;
        var currentPurity = row.stoicPurity.value;

        if (!row.isPurityPresent()) {
            row.stoicPurity.value = row.stoicPurity.prevValue;

            return;
        }

        row.stoicPurity.prevValue = row.stoicPurity.value;

        // Mol and Weight Empty
        if (!row.isMolPresent() && !row.isWeightPresent()) {
            return;
        }

        // should Update Mol
        if (row.isWeightManuallyEntered() && row.isMolPresent()) {
            var mol = mathCalculation.computeMolByPurity(row.mol.value, currentPurity, prevPurity);
            row.setComputedMol(mol, updateDependencies);

            if (row.isLimiting()) {
                updateRows();
            }

            return;
        }

        // should Update Weight
        var shouldUpdateWeight = row.isMolManuallyEntered() ? row.isWeightPresent() : !row.isWeightManuallyEntered();
        if (shouldUpdateWeight) {
            var weight = mathCalculation.computeWeightByPurity(row.weight.value, currentPurity, prevPurity);
            row.setComputedWeight(weight, updateDependencies);
        }
    }