Skip to content

Commit ca5302d

Browse files
committed
name_of_type -> type, transform -> value
1 parent 3276d1b commit ca5302d

File tree

4 files changed

+46
-9
lines changed

4 files changed

+46
-9
lines changed

cypress/integration/main_spec.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -595,11 +595,22 @@ module.exports = (index) => {
595595
});
596596
});
597597

598-
describe("readme Example4: tweaking row_settings, without changing html", function () {
598+
describe("readme Example4: changing the type", function () {
599599
it("visit test page", function () {
600600
setViewportAndVisitUrl(url + "/Plugins/Example1/?test=5");
601601
});
602602
it_unaffectedValuesAreUnchanged();
603+
it("Displays updated 'my_type' type instead of original 'object'", function () {
604+
const type = 10;
605+
nthSelectorEqualsText(type, "span.type", "my_type");
606+
});
607+
});
608+
609+
describe("readme Example5: tweaking row_settings, without changing html", function () {
610+
it("visit test page", function () {
611+
setViewportAndVisitUrl(url + "/Plugins/Example1/?test=6");
612+
});
613+
it_unaffectedValuesAreUnchanged();
603614
it("Updates key to 'mykey'", function () {
604615
const key = 10;
605616
nthSelectorEqualsText(key, "span.key", "mykey");
@@ -628,9 +639,9 @@ module.exports = (index) => {
628639
});
629640
});
630641

631-
describe.only("readme Example2a: multiple overrides - of the value of an existing 'String' Type", function () {
642+
describe("readme Example2a: multiple overrides - of the value of an existing 'String' Type", function () {
632643
it("visit test page", function () {
633-
setViewportAndVisitUrl(url + "/Plugins/Example1/?test=6");
644+
setViewportAndVisitUrl(url + "/Plugins/Example1/?test=7");
634645
});
635646
it_unaffectedValuesAreUnchanged();
636647
const first = 12;

src/Examples/ExamplePlugins.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const customType1a = {
22
type_parser: (v) => v && v.specific_key1 && v.value_key_a, // defined as an object with these 2 keys
3-
transform: (v) => `${v.specific_key1} [${v.value_key_a}]`, // displays as string with 2 keys joined
3+
value: (v) => `${v.specific_key1} [${v.value_key_a}]`, // displays as string with 2 keys joined
44
row_render: (row_settings, globals) => {
55
const { level } = row_settings;
66
return {
@@ -13,7 +13,7 @@ const customType1a = {
1313

1414
const customType1b = {
1515
type_parser: (v) => v && v.specific_key1 && v.value_key_a && v.value_key_b, // defined as an object with these 3 keys
16-
transform: (v) => `${v.specific_key1} [${v.value_key_a}${v.value_key_b}]`, // displays as string with 3 keys joined
16+
value: (v) => `${v.specific_key1} [${v.value_key_a}${v.value_key_b}]`, // displays as string with 3 keys joined
1717
row_render: (row_settings, globals) => {
1818
//renders multiple rows
1919
const { level } = row_settings;
@@ -40,12 +40,12 @@ const customType1b = {
4040

4141
const customType2 = {
4242
type_parser: (v) => v && typeof v === "string" && v.includes("string:"), // defined as string containing "string:"
43-
//transform: undefined // displays as string, no transformation needed
43+
//value: undefined // displays as string, no transformation needed
4444
};
4545

4646
const customType3 = {
4747
type_parser: (v) => v && v.specific_key2 && v.value_key_b && v.value_key_c, // defined as an object with these 3 keys
48-
transform: (v) => {
48+
value: (v) => {
4949
const { specific_key2, ...rest } = v;
5050
return rest; // displays as an object, and for some reason we want to display only 2 of it's keys
5151
},

src/Examples/SvelteComponent/Plugins/Example1/fixtures.js

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,32 @@ const test4 = {
6565
};
6666

6767
const test5 = {
68+
value: {
69+
...value,
70+
test_object: {
71+
key1: "test1",
72+
key2: "test2",
73+
key3: "test3",
74+
key4: "test4",
75+
key5: "test5",
76+
key6: "test6",
77+
key7: "test7",
78+
key8: "test8",
79+
key9: "test9",
80+
key10: "test10",
81+
},
82+
},
83+
settings: {
84+
rows: [
85+
{
86+
match: (v) => typeof v === "object" && "key1" in v && "key10" in v,
87+
type: "my_type",
88+
},
89+
],
90+
},
91+
};
92+
93+
const test6 = {
6894
value: { ...value, test_string: "valuecontainingabc" },
6995
settings: {
7096
rows: [
@@ -87,7 +113,7 @@ const test5 = {
87113
},
88114
};
89115

90-
const test6 = {
116+
const test7 = {
91117
value: {
92118
...value,
93119
test_string1: "valuecontainingabc",

src/lib/codeFormat.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ function getUpdatedTypeAndValue(row_settings) {
6969
if (matching_row_overrides.length) {
7070
matching_row_overrides.forEach((override) => {
7171
if (override.value) val = override.value(val);
72-
type = override.type_name || getNullOrOtherType(val);
72+
type = override.type || getNullOrOtherType(val);
7373
if (override.row_render) row_render = override.row_render;
7474
if (override.row_html) row_html = override.row_html;
7575
});

0 commit comments

Comments
 (0)