Skip to content

Commit

Permalink
starting to adjust formula to row add
Browse files Browse the repository at this point in the history
  • Loading branch information
tnrich committed Jan 31, 2024
1 parent 215d93e commit 8b6bc38
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 11 deletions.
2 changes: 1 addition & 1 deletion packages/bounce-loader/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"command": "cd packages/bounce-loader && npx playwright test --ui"
},
"launch-e2e2": {
"command": "npx concurrently -k \"wait-on tcp:4200 && cd packages/bounce-loader && yarn cypress open --e2e --browser chrome\" \"nx run bounce-loader:start\""
"command": "npx concurrently -k \"wait-on tcp:4200 && cd packages/bounce-loader && yarn cypress open --e2e --browser electron\" \"nx run bounce-loader:start\""
},
"e2e-playwright": {
"command": "cd packages/bounce-loader && npx playwright test"
Expand Down
2 changes: 1 addition & 1 deletion packages/ove/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
"options": {
"watch": true,
"headed": true,
"browser": "chrome",
"browser": "electron",
"cypressConfig": "packages/ove/cypress.config.ts",
"devServerTarget": "ove:start:ci",
"testingType": "e2e"
Expand Down
1 change: 0 additions & 1 deletion packages/ui/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@
"options": {
"watch": true,
"headed": true,
"browser": "chrome",
"cypressConfig": "packages/ui/cypress.config.ts",
"devServerTarget": "ui:start:ci",
"testingType": "e2e"
Expand Down
1 change: 0 additions & 1 deletion packages/ui/src/DataTable/editCellHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,6 @@ export const editCellHelper = ({
}
// console.log(`evaluate deps`, cellDepGraph, `for cell`, cellAlphaNum);
const [depColLetter, depRowIndex] = depCellAlphaNum.split(/(\d+)/);

const depEntity = entities[depRowIndex - 1];
const depColIndex = depColLetter.charCodeAt(0) - 65;
const depColSchema = schema.fields[depColIndex];
Expand Down
37 changes: 30 additions & 7 deletions packages/ui/src/DataTable/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -402,9 +402,8 @@ class DataTable extends React.Component {
};
formatAndValidateEntities = (
entities,
{ useDefaultValues, indexToStartAt } = {}
{ useDefaultValues, indexToStartAt, depGraphToUse } = {}
) => {
console.log(`entities:`, entities)
const { schema } = this.props;
const editableFields = schema.fields.filter(f => !f.isNotEditable);
let validationErrors = {};
Expand All @@ -426,7 +425,7 @@ class DataTable extends React.Component {
//mutative
const { errors } = editCellHelper({
updateGroup,
depGraph: this.depGraph,
depGraph: depGraphToUse || this.depGraph,
entities,
entity: e,
schema,
Expand Down Expand Up @@ -3248,19 +3247,43 @@ class DataTable extends React.Component {
newEntities,
{
useDefaultValues: true,
indexToStartAt: insertIndexToUse
indexToStartAt: insertIndexToUse,
depGraphToUse: {}
}
);

console.log(`jarr`)

newEnts = newEnts.map(e => ({
...e,
_isClean: true
}));

entities.forEach(e => {
if (e.formula) {
console.log(`e.formula:`, e.formula);
}
Object.values(e).forEach((v) => {
if (v?.formula) {
console.log(`v.formula:`,v.formula)
// update the formula to shift the row numbers up or down as needed
v.formula = v.formula.replace(/([A-Z]+[0-9]+)/gi, (match, p1) => {
console.log(`p1:`, p1)
console.log(`match:`, match)
// update the match number
const num = Number(match.replace(/[A-Z]+/gi, ''));
console.log(`num:`, num)
console.log(`insertIndexToUse:`, insertIndexToUse)
if (insertIndexToUse < num) {
console.log(`newEnts.length:`,newEnts.length)
const newNum = num + newEnts.length
console.log(`newNum:`, newNum)
// if the insert index is above the match number then we need to add 1 to the row number
return `${p1}${newNum}`;
}
})
console.log(`v.formula:`,v.formula)


}
})
});
this.updateValidation(entities, {
...reduxFormCellValidation,
Expand Down

0 comments on commit 8b6bc38

Please sign in to comment.