/
SpreadsheetCoreRecursiveClick.js
171 lines (159 loc) · 5.23 KB
/
SpreadsheetCoreRecursiveClick.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
// okconcept0 SpreadsheetCoreRecursiveClick copyright 2017-2018
// SpreadsheetCoreRecursiveClick.js
// mlBench & danmckeown.info
import React, { Component } from "react";
import Link from "next/link";
let lastkey = null;
class SpreadsheetCoreRecursiveClick extends Component {
table = null;
render(props) {
let theStore = this.props.store;
let theTable = this.props.table;
var g;
if (this.props.spreadsheetdata[0] !== undefined) {
g = [{}, ...this.props.spreadsheetdata];
} else {
g = [this.props.spreadsheetdata];
}
return (
<div id="desk" className="mlBench-content">
<section className="keylibrary">
{g.map(function (interVal) {
let valArr = Object.keys(interVal);
let retSet = [];
for (let i = 0; i < valArr.length; i++) {
if (typeof valArr[i] === "object") {
// do nothing
} else {
retSet.push(
<span key={valArr[i]} className="valHeaderRow">
{valArr[i] + " "}
</span>
);
}
}
})}
</section>
<section className="datalibrary">
{g.map(function (interVal) {
let keyArr = Object.keys(interVal);
let valArr = Object.values(interVal);
let retSet = [];
for (let i = 0; i < keyArr.length; i++) {
if (keyArr[i] === "locator") {
lastkey = valArr[i];
}
if (typeof keyArr[i] === "object") {
// do nothing
} else {
retSet.push(
<span key={keyArr[i]} className="valHeaderRow">
{keyArr[i] + " "}
</span>
);
}
if (i === keyArr.length - 1) {
retSet.push(<div key={i + keyArr[i] + valArr[i] + `header`} className="endDividerHead" />);
}
}
for (let i = 0; i < valArr.length; i++) {
if (typeof valArr[i] === "object") {
retSet.push(
<span key={valArr[i]} className="valSheetRow">
<SpreadsheetCoreRecursiveClick
spreadsheetdata={valArr[i]}
table={theTable}
store={theStore}
/>
</span>
);
} else {
let newdata = encodeURIComponent(JSON.stringify(valArr[i]));
let newdataString = newdata.toString();
retSet.push(
<span key={valArr[i]} className="valSheetRow">
<Link
href={{
pathname: "/Edit2",
query: {
tuple: lastkey,
val: newdataString,
store: theStore,
table: theTable,
objprop: keyArr[i]
}
}}
>
<a>{valArr[i] + " "}</a>
</Link>{" "}
<Link
href={{
pathname: "/View",
query: {
tuple: lastkey,
store: theStore,
table: theTable
}
}}
>
<a>🏤</a>
</Link>{" "}
<Link
href={{
pathname: "/Delete",
query: {
tuple: lastkey,
store: theStore,
table: theTable
}
}}
>
<a>❌</a>
</Link>
</span>
);
}
if (i === keyArr.length - 1) {
retSet.push(<div key={i + keyArr[i] + valArr[i] + `valz`} className="endDivider" />);
}
}
return [...retSet];
})}
</section>
<style jsx>{`
.spread {
font-family: "Ubuntu Mono", "Inconsolata", "Hack", "Fira Code",
Menlo, monospace;
}
.keylibrary {
display: flex;
flex-direction: row;
}
span.valHeaderRow {
background-color: lightblue;
margin-top: 12px;
margin-right: 10px;
margin-bottom: 0.6rem;
line-height: 1.3;
text-align: left;
padding-right: calc(1rem + 2.1vw);
}
span.valSheetRow {
background-color: lightgray;
margin-top: 12px;
margin-right: 10px;
margin-bottom: 0.6rem;
line-height: 1.3;
text-align: left;
padding-right: calc(1rem);
}
span.valSheetRow a {
text-decoration: none;
color: black;
}
`}</style>
</div>
);
}
}
export default SpreadsheetCoreRecursiveClick;