Skip to content

Commit

Permalink
fix: Remove sub element parsing as it causes problems with long forms (
Browse files Browse the repository at this point in the history
…#2626)

* Comment out root id parsing code for now

* Skip test

* skip more tests
  • Loading branch information
dsamojlenko authored Sep 7, 2023
1 parent 34d0e75 commit 8e7e9e5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
12 changes: 6 additions & 6 deletions components/form-builder/getPath.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { parseRootId, getElementIndexes, indexesToPath, getPath, getPathString } from "./getPath";

describe("Parse root ID", () => {
it("parses root id", () => {
it.skip("parses root id", () => {
expect(parseRootId(1)).toEqual(1);
expect(parseRootId(9)).toEqual(9);
expect(parseRootId(12)).toEqual(12);
Expand All @@ -14,12 +14,12 @@ describe("Parse root ID", () => {
});

describe("Get array indexes for path by element ID", () => {
it("parses elIndex", () => {
it.skip("parses elIndex", () => {
const elements = [{ id: 1 }, { id: 2 }, { id: 3 }, { id: 12 }];
expect(getElementIndexes(1210, elements)).toEqual([3, null]);
});

it("parses 3 digit elIndex and subIndex", () => {
it.skip("parses 3 digit elIndex and subIndex", () => {
const elements = [
{ id: 1 },
{ id: 2, properties: { subElements: [{ id: 201 }, { id: 202 }, { id: 203 }] } },
Expand All @@ -31,7 +31,7 @@ describe("Get array indexes for path by element ID", () => {
expect(subIndex).toEqual(0);
});

it("parses 4 digit elIndex and subIndex", () => {
it.skip("parses 4 digit elIndex and subIndex", () => {
const elements = [
{ id: 1 },
{ id: 2 },
Expand Down Expand Up @@ -71,7 +71,7 @@ describe("Get path string by id", () => {
expect(path).toEqual("form.elements[1].properties");
});

it("gets subPath", async () => {
it.skip("gets subPath", async () => {
const elements = [
{ id: 1 },
{ id: 2 },
Expand All @@ -97,7 +97,7 @@ describe("Get path string by id", () => {
expect(path).toEqual(form.elements[3]);
});

it("gets sub element path", async () => {
it.skip("gets sub element path", async () => {
const form = {
elements: [
{ id: 1 },
Expand Down
11 changes: 6 additions & 5 deletions components/form-builder/getPath.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
export const parseRootId = (id: number) => {
// @TODO: Revisit for sub elements. Note that the following will break if we have more than 99 sub elements
// split 3 or 4 digit id into first 1 or 2 digits
const idStr = id.toString();
const sliceAt = idStr.length == 3 ? 1 : 2;
const idArr = idStr.split("");
const first = idArr.slice(0, sliceAt).join("");
return Number(first);
// const idStr = id.toString();
// const sliceAt = idStr.length == 3 ? 1 : 2;
// const idArr = idStr.split("");
// const first = idArr.slice(0, sliceAt).join("");
return Number(id);
};

interface Form {
Expand Down

0 comments on commit 8e7e9e5

Please sign in to comment.