@saltcorn/builder 0.9.4-beta.1 → 0.9.4-beta.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/builder_bundle.js +15 -11
- package/package.json +2 -1
- package/src/components/Builder.js +59 -13
- package/src/components/Library.js +34 -19
- package/src/components/Toolbox.js +112 -163
- package/src/components/elements/BoxModelEditor.js +8 -8
- package/src/components/elements/Columns.js +4 -4
- package/src/components/elements/Container.js +26 -2
- package/src/components/elements/DropMenu.js +31 -2
- package/src/components/elements/Link.js +1 -0
- package/src/components/elements/RelationBadges.js +53 -44
- package/src/components/elements/Tabs.js +118 -40
- package/src/components/elements/View.js +86 -40
- package/src/components/elements/ViewLink.js +80 -34
- package/src/components/elements/utils.js +139 -76
- package/src/components/storage.js +6 -0
- package/tests/relations_finder.test.js +57 -92
- package/tests/test_data.js +0 -163
|
@@ -200,6 +200,7 @@ const layoutToNodes = (layout, query, actions, parent = "ROOT") => {
|
|
|
200
200
|
minHeight={segment.minHeight}
|
|
201
201
|
height={segment.height}
|
|
202
202
|
width={segment.width}
|
|
203
|
+
click_action={segment.click_action}
|
|
203
204
|
url={segment.url}
|
|
204
205
|
hoverColor={segment.hoverColor}
|
|
205
206
|
minHeightUnit={segment.minHeightUnit || "px"}
|
|
@@ -253,10 +254,12 @@ const layoutToNodes = (layout, query, actions, parent = "ROOT") => {
|
|
|
253
254
|
<Tabs
|
|
254
255
|
key={ix}
|
|
255
256
|
titles={segment.titles}
|
|
257
|
+
showif={segment.showif}
|
|
256
258
|
ntabs={segment.ntabs}
|
|
257
259
|
independent={segment.independent}
|
|
258
260
|
startClosed={segment.startClosed}
|
|
259
261
|
deeplink={segment.deeplink}
|
|
262
|
+
acc_init_opens={segment.acc_init_opens}
|
|
260
263
|
disable_inactive={segment.disable_inactive}
|
|
261
264
|
serverRendered={segment.serverRendered}
|
|
262
265
|
tabId={segment.tabId}
|
|
@@ -457,6 +460,7 @@ const craftToSaltcorn = (nodes, startFrom = "ROOT") => {
|
|
|
457
460
|
gradStartColor: node.props.gradStartColor,
|
|
458
461
|
gradEndColor: node.props.gradEndColor,
|
|
459
462
|
gradDirection: node.props.gradDirection,
|
|
463
|
+
click_action: node.props.click_action,
|
|
460
464
|
rotate: node.props.rotate,
|
|
461
465
|
style: node.props.style,
|
|
462
466
|
};
|
|
@@ -529,10 +533,12 @@ const craftToSaltcorn = (nodes, startFrom = "ROOT") => {
|
|
|
529
533
|
type: "tabs",
|
|
530
534
|
contents,
|
|
531
535
|
titles: node.props.titles,
|
|
536
|
+
showif: node.props.showif,
|
|
532
537
|
tabsStyle: node.props.tabsStyle,
|
|
533
538
|
field: node.props.field,
|
|
534
539
|
independent: node.props.independent,
|
|
535
540
|
startClosed: node.props.startClosed,
|
|
541
|
+
acc_init_opens: node.props.acc_init_opens,
|
|
536
542
|
deeplink: node.props.deeplink,
|
|
537
543
|
disable_inactive: node.props.disable_inactive,
|
|
538
544
|
serverRendered: node.props.serverRendered,
|
|
@@ -9,7 +9,16 @@ import {
|
|
|
9
9
|
withKeyFromLayerTwo,
|
|
10
10
|
withKeyFromLayerThree,
|
|
11
11
|
withSimplePostTopicrelation,
|
|
12
|
-
} from "
|
|
12
|
+
} from "@saltcorn/common-code/tests/test_data";
|
|
13
|
+
|
|
14
|
+
import {
|
|
15
|
+
expectedOne,
|
|
16
|
+
expectedTwo,
|
|
17
|
+
expectedThree,
|
|
18
|
+
expectedFour,
|
|
19
|
+
expectedFive,
|
|
20
|
+
expectedSix,
|
|
21
|
+
} from "@saltcorn/common-code/tests/expected_relations";
|
|
13
22
|
import { ViewSettings } from "../src/components/elements/View";
|
|
14
23
|
import { ViewLinkSettings } from "../src/components/elements/ViewLink";
|
|
15
24
|
|
|
@@ -60,43 +69,47 @@ const doTest = (
|
|
|
60
69
|
renderer.create(<ViewSettings></ViewSettings>);
|
|
61
70
|
expect(spy).toBeCalled();
|
|
62
71
|
const vCallArgs = spy.mock.calls[0];
|
|
63
|
-
expect(vCallArgs[0].
|
|
64
|
-
expect(vCallArgs[0].
|
|
65
|
-
expect(vCallArgs[0].
|
|
72
|
+
expect(vCallArgs[0].relations).toBeDefined();
|
|
73
|
+
expect(vCallArgs[0].relations).toHaveLength(expected.length);
|
|
74
|
+
expect(vCallArgs[0].relations.map((rel) => rel.relationString)).toEqual(
|
|
75
|
+
expect.arrayContaining(expected)
|
|
76
|
+
);
|
|
66
77
|
|
|
67
78
|
renderer.create(<ViewLinkSettings></ViewLinkSettings>);
|
|
68
79
|
expect(spy.mock.calls).toHaveLength(4);
|
|
69
80
|
const vLinkcallArgs = spy.mock.calls[2];
|
|
70
|
-
expect(vLinkcallArgs[0].
|
|
71
|
-
expect(vLinkcallArgs[0].
|
|
72
|
-
expect(vLinkcallArgs[0].
|
|
81
|
+
expect(vLinkcallArgs[0].relations).toBeDefined();
|
|
82
|
+
expect(vLinkcallArgs[0].relations).toHaveLength(expected.length);
|
|
83
|
+
expect(vLinkcallArgs[0].relations.map((rel) => rel.relationString)).toEqual(
|
|
84
|
+
expect.arrayContaining(expected)
|
|
85
|
+
);
|
|
73
86
|
};
|
|
74
87
|
|
|
75
88
|
describe("relations tests", () => {
|
|
76
|
-
beforeAll(() => {
|
|
77
|
-
// inject relationHelpers (normally it's a script tag)
|
|
78
|
-
global.relationHelpers = {
|
|
79
|
-
...require("../../server/public/relation_helpers.js"),
|
|
80
|
-
};
|
|
81
|
-
});
|
|
82
89
|
beforeEach(() => {
|
|
83
90
|
jest.restoreAllMocks();
|
|
84
91
|
});
|
|
85
92
|
describe("single relations", () => {
|
|
86
|
-
it("parent relations",
|
|
87
|
-
const { tables, views } = fixturesData();
|
|
93
|
+
it("parent relations", () => {
|
|
94
|
+
const { tables, views } = fixturesData(__dirname);
|
|
88
95
|
const expected = [".fan_club.artist"];
|
|
89
96
|
doTest(tables, views, "fan_club", "show_artist", expected);
|
|
90
97
|
});
|
|
91
98
|
|
|
92
|
-
it("
|
|
93
|
-
const { tables, views } = fixturesData();
|
|
99
|
+
it("parent relations with layers", () => {
|
|
100
|
+
const { tables, views } = fixturesData(__dirname);
|
|
101
|
+
const expected = [".patients.favbook.publisher"];
|
|
102
|
+
doTest(tables, views, "patients", "show_publisher", expected);
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
it("one to one relations", () => {
|
|
106
|
+
const { tables, views } = fixturesData(__dirname);
|
|
94
107
|
const expected = [".covers.albums$cover"];
|
|
95
108
|
doTest(tables, views, "covers", "show_album", expected);
|
|
96
109
|
});
|
|
97
110
|
|
|
98
|
-
it("employee department relation",
|
|
99
|
-
const { tables, views } = fixturesData();
|
|
111
|
+
it("employee department relation", () => {
|
|
112
|
+
const { tables, views } = fixturesData(__dirname);
|
|
100
113
|
const expected = [".employee", ".employee.department.manager"];
|
|
101
114
|
doTest(tables, views, "employee", "show_manager", expected);
|
|
102
115
|
});
|
|
@@ -104,85 +117,37 @@ describe("relations tests", () => {
|
|
|
104
117
|
|
|
105
118
|
describe("multi relations", () => {
|
|
106
119
|
describe("inbound relations", () => {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
".users.user_interested_in_topic$user.topic.blog_in_topic$topic",
|
|
110
|
-
".users.user_interested_in_topic$user.topic.inbound_inbound$topic.bp_inbound.post.blog_in_topic$post",
|
|
111
|
-
".users.messages$user.room.participants$room.user.user_interested_in_topic$user.topic.blog_in_topic$topic",
|
|
112
|
-
];
|
|
113
|
-
it("single keys to source and rel table", async () => {
|
|
114
|
-
const { tables, views } = fixturesData();
|
|
120
|
+
it("single keys to source and rel table", () => {
|
|
121
|
+
const { tables, views } = fixturesData(__dirname);
|
|
115
122
|
doTest(tables, views, "users", "blog_in_topic_feed", expectedOne);
|
|
116
123
|
});
|
|
117
124
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
".users.user_interested_in_topic$another_user.topic.blog_in_topic$topic",
|
|
121
|
-
".users.user_interested_in_topic$another_user.topic.inbound_inbound$topic.bp_inbound.post.blog_in_topic$post",
|
|
122
|
-
".users.messages$user.room.participants$room.user.user_interested_in_topic$another_user.topic.blog_in_topic$topic",
|
|
123
|
-
];
|
|
124
|
-
it("multiple keys to source and single key to rel table", async () => {
|
|
125
|
-
const { tables, views } = withAnotherUserField();
|
|
125
|
+
it("multiple keys to source and single key to rel table", () => {
|
|
126
|
+
const { tables, views } = withAnotherUserField(__dirname);
|
|
126
127
|
doTest(tables, views, "users", "blog_in_topic_feed", expectedTwo);
|
|
127
128
|
});
|
|
128
129
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
".users.user_interested_in_topic$user.topic.blog_in_topic$second_topic",
|
|
132
|
-
".users.user_interested_in_topic$another_user.topic.blog_in_topic$second_topic",
|
|
133
|
-
".users.messages$user.room.participants$room.user.user_interested_in_topic$user.topic.blog_in_topic$second_topic",
|
|
134
|
-
".users.messages$user.room.participants$room.user.user_interested_in_topic$another_user.topic.blog_in_topic$second_topic",
|
|
135
|
-
];
|
|
136
|
-
it("multiple keys to source and rel table", async () => {
|
|
137
|
-
const { tables, views } = withSecondTopicField();
|
|
130
|
+
it("multiple keys to source and rel table", () => {
|
|
131
|
+
const { tables, views } = withSecondTopicField(__dirname);
|
|
138
132
|
doTest(tables, views, "users", "blog_in_topic_feed", expectedThree);
|
|
139
133
|
});
|
|
140
134
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
".users.user_interested_in_topic$user.another_user.second_inbound$user.topic.blog_in_topic$topic",
|
|
144
|
-
".users.user_interested_in_topic$user.another_user.second_inbound$user.topic.blog_in_topic$second_topic",
|
|
145
|
-
".users.second_inbound$user.topic.blog_in_topic$topic",
|
|
146
|
-
".users.second_inbound$user.topic.blog_in_topic$second_topic",
|
|
147
|
-
".users.second_inbound$user.topic.inbound_inbound$topic.bp_inbound.post.blog_in_topic$post",
|
|
148
|
-
".users.messages$user.room.participants$room.user.second_inbound$user.topic.blog_in_topic$topic",
|
|
149
|
-
".users.messages$user.room.participants$room.user.second_inbound$user.topic.blog_in_topic$second_topic",
|
|
150
|
-
];
|
|
151
|
-
it("multiple inbound tables", async () => {
|
|
152
|
-
const { tables, views } = withMultipleInbounds();
|
|
135
|
+
it("multiple inbound tables", () => {
|
|
136
|
+
const { tables, views } = withMultipleInbounds(__dirname);
|
|
153
137
|
doTest(tables, views, "users", "blog_in_topic_feed", expectedFour);
|
|
154
138
|
});
|
|
155
139
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
".users.user_interested_in_topic$user.topic.inbound_inbound$topic.post_from_layer_two.blog_in_topic$post",
|
|
159
|
-
".users.user_interested_in_topic$another_user.topic.inbound_inbound$topic.post_from_layer_two.blog_in_topic$post",
|
|
160
|
-
".users.second_inbound$user.topic.inbound_inbound$topic.post_from_layer_two.blog_in_topic$post",
|
|
161
|
-
".users.user_interested_in_topic$user.topic.blog_in_topic$topic.post.inbound_inbound$post_from_layer_two.topic.blog_in_topic$second_topic",
|
|
162
|
-
".users.user_interested_in_topic$user.another_user.second_inbound$user.topic.inbound_inbound$topic.post_from_layer_two.blog_in_topic$post",
|
|
163
|
-
".users.user_interested_in_topic$another_user.topic.blog_in_topic$topic.post.inbound_inbound$post_from_layer_two.topic.blog_in_topic$second_topic",
|
|
164
|
-
".users.second_inbound$user.topic.blog_in_topic$topic.post.inbound_inbound$post_from_layer_two.topic.blog_in_topic$second_topic",
|
|
165
|
-
];
|
|
166
|
-
it("key to source from layer two", async () => {
|
|
167
|
-
const { tables, views } = withKeyFromLayerTwo();
|
|
140
|
+
it("key to source from layer two", () => {
|
|
141
|
+
const { tables, views } = withKeyFromLayerTwo(__dirname);
|
|
168
142
|
doTest(tables, views, "users", "blog_in_topic_feed", expectedFive);
|
|
169
143
|
});
|
|
170
144
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
".users.user_interested_in_topic$user.topic.inbound_level_three$topic.inbound_level_two.bp_inbound.post.blog_in_topic$post",
|
|
174
|
-
".users.user_interested_in_topic$user.topic.inbound_level_three$topic.inbound_level_two.post_from_layer_two.blog_in_topic$post",
|
|
175
|
-
".users.user_interested_in_topic$another_user.topic.inbound_level_three$topic.inbound_level_two.bp_inbound.post.blog_in_topic$post",
|
|
176
|
-
".users.user_interested_in_topic$another_user.topic.inbound_level_three$topic.inbound_level_two.post_from_layer_two.blog_in_topic$post",
|
|
177
|
-
".users.second_inbound$user.topic.inbound_level_three$topic.inbound_level_two.bp_inbound.post.blog_in_topic$post",
|
|
178
|
-
".users.second_inbound$user.topic.inbound_level_three$topic.inbound_level_two.post_from_layer_two.blog_in_topic$post",
|
|
179
|
-
];
|
|
180
|
-
it("three levels inbound", async () => {
|
|
181
|
-
const { tables, views } = withKeyFromLayerThree();
|
|
145
|
+
it("three levels inbound", () => {
|
|
146
|
+
const { tables, views } = withKeyFromLayerThree(__dirname);
|
|
182
147
|
doTest(tables, views, "users", "blog_in_topic_feed", expectedSix);
|
|
183
148
|
});
|
|
184
149
|
|
|
185
|
-
it("simple post topic relation",
|
|
150
|
+
it("simple post topic relation", () => {
|
|
186
151
|
const expected = [
|
|
187
152
|
".",
|
|
188
153
|
".users.favsimpletopic.simple_posts$topic",
|
|
@@ -190,20 +155,20 @@ describe("relations tests", () => {
|
|
|
190
155
|
".users.messages$user.room.participants$room.user.favsimpletopic.simple_posts$topic",
|
|
191
156
|
".users.messages$user.room.participants$room.user.favsimpletopic.simple_post_inbound$topic.post",
|
|
192
157
|
];
|
|
193
|
-
const { tables, views } = withSimplePostTopicrelation();
|
|
158
|
+
const { tables, views } = withSimplePostTopicrelation(__dirname);
|
|
194
159
|
doTest(tables, views, "users", "simple_posts_list", expected);
|
|
195
160
|
});
|
|
196
161
|
});
|
|
197
162
|
|
|
198
163
|
describe("many to many relations", () => {
|
|
199
|
-
it("artist_plays_on_album",
|
|
200
|
-
const { tables, views } = fixturesData();
|
|
164
|
+
it("artist_plays_on_album", () => {
|
|
165
|
+
const { tables, views } = fixturesData(__dirname);
|
|
201
166
|
const expected = [".", ".artists.artist_plays_on_album$artist.album"];
|
|
202
167
|
doTest(tables, views, "artists", "albums_feed", expected);
|
|
203
168
|
});
|
|
204
169
|
|
|
205
|
-
it("tracks on album",
|
|
206
|
-
const { tables, views } = fixturesData();
|
|
170
|
+
it("tracks on album", () => {
|
|
171
|
+
const { tables, views } = fixturesData(__dirname);
|
|
207
172
|
const expected = [
|
|
208
173
|
".",
|
|
209
174
|
".artists.artist_plays_on_album$artist.album.tracks_on_album$album",
|
|
@@ -211,8 +176,8 @@ describe("relations tests", () => {
|
|
|
211
176
|
doTest(tables, views, "artists", "tracks_on_album_feed", expected);
|
|
212
177
|
});
|
|
213
178
|
|
|
214
|
-
it("show pressing_job with embedded fan club feed",
|
|
215
|
-
const { tables, views } = fixturesData();
|
|
179
|
+
it("show pressing_job with embedded fan club feed", () => {
|
|
180
|
+
const { tables, views } = fixturesData(__dirname);
|
|
216
181
|
const expected = [
|
|
217
182
|
".",
|
|
218
183
|
".pressing_job.album.artist_plays_on_album$album.artist.fan_club$artist",
|
|
@@ -222,8 +187,8 @@ describe("relations tests", () => {
|
|
|
222
187
|
});
|
|
223
188
|
|
|
224
189
|
describe("excluded viewtemplates", () => {
|
|
225
|
-
it("excluded viewtemplates",
|
|
226
|
-
const { tables, views } = fixturesData();
|
|
190
|
+
it("excluded viewtemplates", () => {
|
|
191
|
+
const { tables, views } = fixturesData(__dirname);
|
|
227
192
|
const expected = [];
|
|
228
193
|
const excluded = ["Room"];
|
|
229
194
|
doTest(tables, views, "participants", "rooms_view", expected, excluded);
|
|
@@ -232,7 +197,7 @@ describe("relations tests", () => {
|
|
|
232
197
|
|
|
233
198
|
describe("open legacy relations", () => {
|
|
234
199
|
it("ChildList", async () => {
|
|
235
|
-
const { tables, views } = fixturesData();
|
|
200
|
+
const { tables, views } = fixturesData(__dirname);
|
|
236
201
|
const expected = [".", ".books.discusses_books$book"];
|
|
237
202
|
doTest(
|
|
238
203
|
tables,
|
|
@@ -247,7 +212,7 @@ describe("relations tests", () => {
|
|
|
247
212
|
});
|
|
248
213
|
|
|
249
214
|
it("Independent", async () => {
|
|
250
|
-
const { tables, views } = fixturesData();
|
|
215
|
+
const { tables, views } = fixturesData(__dirname);
|
|
251
216
|
const expected = [
|
|
252
217
|
".",
|
|
253
218
|
".blog_posts",
|
|
@@ -266,7 +231,7 @@ describe("relations tests", () => {
|
|
|
266
231
|
});
|
|
267
232
|
|
|
268
233
|
it("Own", async () => {
|
|
269
|
-
const { tables, views } = fixturesData();
|
|
234
|
+
const { tables, views } = fixturesData(__dirname);
|
|
270
235
|
const expected = [".books"];
|
|
271
236
|
doTest(
|
|
272
237
|
tables,
|
package/tests/test_data.js
DELETED
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
import { readFileSync } from "fs";
|
|
2
|
-
import { join } from "path";
|
|
3
|
-
|
|
4
|
-
export const fixturesData = () => {
|
|
5
|
-
const { tables, views } = JSON.parse(
|
|
6
|
-
readFileSync(join(__dirname, "schema_data.json"))
|
|
7
|
-
);
|
|
8
|
-
return { tables, views };
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
let nextFieldId = 3000;
|
|
12
|
-
|
|
13
|
-
export const withAnotherUserField = () => {
|
|
14
|
-
const { tables, views } = JSON.parse(JSON.stringify(fixturesData()));
|
|
15
|
-
const uiit = tables.find(({ name }) => name === "user_interested_in_topic");
|
|
16
|
-
uiit.foreign_keys.push({
|
|
17
|
-
name: "another_user",
|
|
18
|
-
id: nextFieldId++,
|
|
19
|
-
table_id: uiit.id,
|
|
20
|
-
reftable_name: "users",
|
|
21
|
-
is_unique: false,
|
|
22
|
-
});
|
|
23
|
-
return { tables, views };
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
export const withSecondTopicField = () => {
|
|
27
|
-
const { tables, views } = JSON.parse(JSON.stringify(withAnotherUserField()));
|
|
28
|
-
const bit = tables.find(({ name }) => name === "blog_in_topic");
|
|
29
|
-
bit.foreign_keys.push({
|
|
30
|
-
name: "second_topic",
|
|
31
|
-
id: nextFieldId++,
|
|
32
|
-
table_id: bit.id,
|
|
33
|
-
reftable_name: "topics",
|
|
34
|
-
is_unique: false,
|
|
35
|
-
});
|
|
36
|
-
return { tables, views };
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
export const withMultipleInbounds = () => {
|
|
40
|
-
const { tables, views } = JSON.parse(JSON.stringify(withSecondTopicField()));
|
|
41
|
-
const nextTableId = tables.length + 1;
|
|
42
|
-
tables.push({
|
|
43
|
-
name: "second_inbound",
|
|
44
|
-
id: nextTableId,
|
|
45
|
-
foreign_keys: [
|
|
46
|
-
{
|
|
47
|
-
name: "topic",
|
|
48
|
-
id: nextFieldId++,
|
|
49
|
-
table_id: nextTableId,
|
|
50
|
-
reftable_name: "topics",
|
|
51
|
-
is_unique: false,
|
|
52
|
-
},
|
|
53
|
-
{
|
|
54
|
-
name: "user",
|
|
55
|
-
id: nextFieldId++,
|
|
56
|
-
table_id: nextTableId,
|
|
57
|
-
reftable_name: "users",
|
|
58
|
-
is_unique: false,
|
|
59
|
-
},
|
|
60
|
-
],
|
|
61
|
-
});
|
|
62
|
-
return { tables, views };
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
export const withKeyFromLayerTwo = () => {
|
|
66
|
-
const { tables, views } = JSON.parse(JSON.stringify(withMultipleInbounds()));
|
|
67
|
-
const inboundInbound = tables.find(({ name }) => name === "inbound_inbound");
|
|
68
|
-
inboundInbound.foreign_keys.push({
|
|
69
|
-
name: "post_from_layer_two",
|
|
70
|
-
id: nextFieldId++,
|
|
71
|
-
table_id: inboundInbound.id,
|
|
72
|
-
reftable_name: "blog_posts",
|
|
73
|
-
is_unique: false,
|
|
74
|
-
});
|
|
75
|
-
return { tables, views };
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
export const withKeyFromLayerThree = () => {
|
|
79
|
-
const { tables, views } = JSON.parse(JSON.stringify(withKeyFromLayerTwo()));
|
|
80
|
-
const nextTableId = tables.length + 1;
|
|
81
|
-
tables.push({
|
|
82
|
-
name: "inbound_level_three",
|
|
83
|
-
id: nextTableId,
|
|
84
|
-
foreign_keys: [
|
|
85
|
-
{
|
|
86
|
-
name: "inbound_level_two",
|
|
87
|
-
id: nextFieldId++,
|
|
88
|
-
table_id: nextTableId,
|
|
89
|
-
reftable_name: "inbound_inbound",
|
|
90
|
-
is_unique: false,
|
|
91
|
-
},
|
|
92
|
-
{
|
|
93
|
-
name: "topic",
|
|
94
|
-
id: nextFieldId++,
|
|
95
|
-
table_id: nextTableId,
|
|
96
|
-
reftable_name: "topics",
|
|
97
|
-
is_unique: false,
|
|
98
|
-
},
|
|
99
|
-
],
|
|
100
|
-
});
|
|
101
|
-
return { tables, views };
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
export const withSimplePostTopicrelation = () => {
|
|
105
|
-
const { tables, views } = JSON.parse(JSON.stringify(fixturesData()));
|
|
106
|
-
const simpleTopicsId = tables.length + 1;
|
|
107
|
-
const simplePostsId = simpleTopicsId + 1;
|
|
108
|
-
const simplePostInboundId = simplePostsId + 1;
|
|
109
|
-
tables.push({
|
|
110
|
-
name: "simple_posts",
|
|
111
|
-
id: simplePostsId,
|
|
112
|
-
foreign_keys: [
|
|
113
|
-
{
|
|
114
|
-
name: "topic",
|
|
115
|
-
table_id: simplePostsId,
|
|
116
|
-
id: nextFieldId++,
|
|
117
|
-
reftable_name: "simple_topics",
|
|
118
|
-
is_unique: false,
|
|
119
|
-
},
|
|
120
|
-
],
|
|
121
|
-
});
|
|
122
|
-
tables.push({
|
|
123
|
-
name: "simple_topics",
|
|
124
|
-
id: simpleTopicsId,
|
|
125
|
-
foreign_keys: [],
|
|
126
|
-
});
|
|
127
|
-
tables.push({
|
|
128
|
-
name: "simple_post_inbound",
|
|
129
|
-
id: simplePostInboundId,
|
|
130
|
-
foreign_keys: [
|
|
131
|
-
{
|
|
132
|
-
name: "post",
|
|
133
|
-
table_id: simplePostInboundId,
|
|
134
|
-
id: nextFieldId++,
|
|
135
|
-
reftable_name: "simple_posts",
|
|
136
|
-
is_unique: false,
|
|
137
|
-
},
|
|
138
|
-
{
|
|
139
|
-
name: "topic",
|
|
140
|
-
table_id: simplePostInboundId,
|
|
141
|
-
id: nextFieldId++,
|
|
142
|
-
reftable_name: "simple_topics",
|
|
143
|
-
is_unique: false,
|
|
144
|
-
},
|
|
145
|
-
],
|
|
146
|
-
});
|
|
147
|
-
const users = tables.find(({ name }) => name === "users");
|
|
148
|
-
users.foreign_keys.push({
|
|
149
|
-
name: "favsimpletopic",
|
|
150
|
-
table_id: users.id,
|
|
151
|
-
id: nextFieldId++,
|
|
152
|
-
reftable_name: "simple_topics",
|
|
153
|
-
is_unique: false,
|
|
154
|
-
});
|
|
155
|
-
|
|
156
|
-
views.push({
|
|
157
|
-
name: "simple_posts_list",
|
|
158
|
-
table_id: simplePostsId,
|
|
159
|
-
display_type: "NO_ROW_LIMIT",
|
|
160
|
-
});
|
|
161
|
-
|
|
162
|
-
return { tables, views };
|
|
163
|
-
};
|