Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)

Paste

Pasted as JavaScript by Brendan ( 3 years ago )
const updateStatisticalInformation = (state, payload) => {
  const { value, sectionIndex, valIndex } = payload;
  const originalValue =
    state.form.tabs[state.activeTab].sections[sectionIndex].fieldDetails[
      valIndex
    ].value;
  const nRows = Object.keys(
    state.form.tabs[state.activeTab].sections[sectionIndex].rowHeaders
  ).length;
  const nCols = Object.keys(
    state.form.tabs[state.activeTab].sections[sectionIndex].columnHeaders
  ).length;
  const curRow = parseInt(valIndex / nCols);
  const curCol = valIndex - parseInt(valIndex / nCols) * nCols;

  const numValue = Number.isNaN(Number(value)) ? 0 : Number(value);
  const numOriginalValue = Number.isNaN(Number(originalValue))
    ? 0
    : Number(originalValue);
  const effectiveValue = numValue - numOriginalValue;
  switch (sectionIndex) {
    case 0:
    case 1:
      return updateStatisticalSection(
        nCols,
        curRow,
        curCol,
        nRows,
        effectiveValue,
        state,
        payload
      );
    default:
      const required = [0, 1, 2];
      const totalIndexs = [(nRows - 1) * nCols + (valIndex % nCols)];
      let flag = 0;
      const annualTotalTabIndexs = [];
      if (sectionIndex === 2 && required.includes(valIndex)) {
        totalIndexs[1] = 0 * nCols + (valIndex % nCols);
        flag = 1;
      } else if (sectionIndex === 2 && !required.includes(valIndex)) {
        flag = 2;
      }
      annualTotalTabIndexs.push(parseInt(valIndex / nCols));
      annualTotalTabIndexs.push(2);
      state = updateStatisticalTabFields(
        state,
        payload,
        effectiveValue,
        totalIndexs,
        flag
      );
      return updateFieldsOfStatisticalTotalTab(
        state,
        effectiveValue,
        flag,
        annualTotalTabIndexs
      );
  }
};

 

Revise this Paste

Parent: 125270
Your Name: Code Language: