Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for legacy Imulus.TableEditor formatted data #29

Open
wants to merge 2 commits into
base: v13/main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 25 additions & 5 deletions src/Limbo.Umbraco.Tables/Models/TableModel.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Linq;
Expand Down Expand Up @@ -73,16 +74,35 @@ public class TableModel : TableObject, IHtmlContent {
UseFirstColumnAsHeader = json.GetBoolean("useFirstColumnAsHeader") && config.AllowUseFirstColumnAsHeader;
UseLastRowAsFooter = json.GetBoolean("useLastRowAsFooter") && config.AllowUseLastRowAsFooter;

JArray rows = json.GetArrayOrNew("rows");
//var jobString = json.ToString(Formatting.Indented);

Rows = json.GetArrayOrNew("rows")
.ForEach((i, x) => new TableRow(i, x, rows.Count, this))
JArray cells = json.GetArrayOrNew("cells");
var maxCell = cells.Last.Last;

//Construct rows
var rowsCount = maxCell.Value<int>("rowIndex") + 1;
var rowArray = new JArray();
for (int j = 0; j < rowsCount; j++) {
rowArray.Add("{}");
}

Rows = rowArray
.ForEach((i, x) => new TableRow(i, x, rowsCount, this))
.ToList();

Columns = json.GetArrayOrNew("columns")

//Construct columns
var columnsCount = maxCell.Value<int>("columnIndex") + 1;
var columnsArray = new JArray();
for (int j = 0; j < columnsCount; j++) {
columnsArray.Add("{}");
}
Columns = columnsArray
.ForEach((i, x) => new TableColumn(i, x, this))
.ToList();


//Process actual cells
Cells = json
.GetArrayOrNew("cells")
.ForEach((i, x) => ParseCellRow(i, x, htmlParser, preview))
Expand Down