Skip to content

Commit

Permalink
Improve table row names
Browse files Browse the repository at this point in the history
  • Loading branch information
grassick committed Jun 22, 2020
1 parent 5fc4b98 commit f1629a1
Show file tree
Hide file tree
Showing 10 changed files with 18 additions and 20 deletions.
2 changes: 1 addition & 1 deletion lib/widgets/blocks.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ test("findBlockAncestry with queryTable", function () {
var ancestry = blocks.findBlockAncestry(blockDef, createBlock, rootContextVars, "c1");
expect(ancestry).toEqual([
{ blockDef: blockDef, contextVars: rootContextVars },
{ blockDef: blockDef.contents[0], contextVars: rootContextVars.concat({ id: "qt1_row", name: "Table row", type: "row", table: "t1" }) },
{ blockDef: blockDef.contents[0], contextVars: rootContextVars.concat({ id: "qt1_row", name: "Table row of CV1", type: "row", table: "t1" }) },
]);
});
test("getBlockTree", function () {
Expand Down
2 changes: 1 addition & 1 deletion lib/widgets/blocks/queryRepeat/queryRepeat.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ var QueryRepeatBlock = /** @class */ (function (_super) {
};
/** Create the context variable used */
QueryRepeatBlock.prototype.createRowContextVar = function (rowsetCV) {
return { id: this.getRowContextVarId(), name: "Table row", type: "row", table: rowsetCV.table };
return { id: this.getRowContextVarId(), name: "Table row of " + rowsetCV.name, type: "row", table: rowsetCV.table };
};
QueryRepeatBlock.prototype.getRowContextVarId = function () {
return this.blockDef.id + "_row";
Expand Down
4 changes: 2 additions & 2 deletions lib/widgets/blocks/queryRepeat/queryRepeat.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ var queryRepeat_1 = require("./queryRepeat");
var schema_1 = __importDefault(require("../../../__fixtures__/schema"));
var BlockFactory_1 = __importDefault(require("../../BlockFactory"));
// Outer context vars
var rowsetCV = { id: "cv1", type: "rowset", name: "", table: "t1" };
var rowsetCV = { id: "cv1", type: "rowset", name: "CV1", table: "t1" };
var contextVars = [rowsetCV];
var qrbd = {
id: "123",
Expand All @@ -36,7 +36,7 @@ var schema = schema_1.default();
test("gets row cv", function () {
expect(qrb.createRowContextVar(rowsetCV)).toEqual({
id: "123_row",
name: "Table row",
name: "Table row of CV1",
type: "row",
table: "t1"
});
Expand Down
4 changes: 2 additions & 2 deletions lib/widgets/blocks/queryTable/queryTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ var QueryTableBlock = /** @class */ (function (_super) {
QueryTableBlock.prototype.createRowContextVar = function (rowsetCV) {
switch (this.blockDef.mode) {
case "singleRow":
return { id: this.getRowContextVarId(), name: "Table row", type: "row", table: rowsetCV.table };
return { id: this.getRowContextVarId(), name: "Table row of " + rowsetCV.name, type: "row", table: rowsetCV.table };
case "multiRow":
return { id: this.getRowContextVarId(), name: "Table row rowset", type: "rowset", table: rowsetCV.table };
return { id: this.getRowContextVarId(), name: "Table row rowset of " + rowsetCV.name, type: "rowset", table: rowsetCV.table };
}
throw new Error("Unknown mode");
};
Expand Down
6 changes: 3 additions & 3 deletions lib/widgets/blocks/queryTable/queryTable.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ var schema_1 = __importDefault(require("../../../__fixtures__/schema"));
var BlockFactory_1 = __importDefault(require("../../BlockFactory"));
var ActionLibrary_1 = require("../../ActionLibrary");
// Outer context vars
var rowsetCV = { id: "cv1", type: "rowset", name: "", table: "t1" };
var rowsetCV = { id: "cv1", type: "rowset", name: "CV1", table: "t1" };
var contextVars = [rowsetCV];
var qtbdSingle = {
id: "123",
Expand Down Expand Up @@ -52,15 +52,15 @@ var schema = schema_1.default();
test("gets single row cv", function () {
expect(qtbSingle.createRowContextVar(rowsetCV)).toEqual({
id: "123_row",
name: "Table row",
name: "Table row of CV1",
type: "row",
table: "t1"
});
});
test("gets multiple row cv", function () {
expect(qtbMultiple.createRowContextVar(rowsetCV)).toEqual({
id: "123_rowset",
name: "Table row rowset",
name: "Table row rowset of CV1",
type: "rowset",
table: "t1"
});
Expand Down
2 changes: 1 addition & 1 deletion src/widgets/blocks.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ test("findBlockAncestry with queryTable", () => {
const ancestry = blocks.findBlockAncestry(blockDef, createBlock, rootContextVars, "c1")
expect(ancestry).toEqual([
{ blockDef: blockDef, contextVars: rootContextVars },
{ blockDef: blockDef.contents[0], contextVars: rootContextVars.concat({ id: "qt1_row", name: "Table row", type: "row", table: "t1" }) },
{ blockDef: blockDef.contents[0], contextVars: rootContextVars.concat({ id: "qt1_row", name: "Table row of CV1", type: "row", table: "t1" }) },
])
})

Expand Down
6 changes: 2 additions & 4 deletions src/widgets/blocks/queryRepeat/queryRepeat.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@ import { QueryRepeatBlockDef, QueryRepeatBlock } from "./queryRepeat";
import { ContextVar } from "../../blocks";
import simpleSchema from "../../../__fixtures__/schema";
import BlockFactory from "../../BlockFactory";
import { WidgetLibrary } from "../../../designer/widgetLibrary";
import { ActionLibrary } from "../../ActionLibrary";
import { InstanceCtx } from "../../../contexts";

// Outer context vars
const rowsetCV: ContextVar = { id: "cv1", type: "rowset", name: "", table: "t1" }
const rowsetCV: ContextVar = { id: "cv1", type: "rowset", name: "CV1", table: "t1" }
const contextVars: ContextVar[] = [rowsetCV]

const qrbd: QueryRepeatBlockDef = {
Expand All @@ -30,7 +28,7 @@ const schema = simpleSchema()
test("gets row cv", () => {
expect(qrb.createRowContextVar(rowsetCV)).toEqual({
id: "123_row",
name: "Table row",
name: "Table row of CV1",
type: "row",
table: "t1"
})
Expand Down
2 changes: 1 addition & 1 deletion src/widgets/blocks/queryRepeat/queryRepeat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export class QueryRepeatBlock extends Block<QueryRepeatBlockDef> {

/** Create the context variable used */
createRowContextVar(rowsetCV: ContextVar): ContextVar {
return { id: this.getRowContextVarId(), name: "Table row", type: "row", table: rowsetCV.table }
return { id: this.getRowContextVarId(), name: `Table row of ${rowsetCV.name}`, type: "row", table: rowsetCV.table }
}

getRowContextVarId() {
Expand Down
6 changes: 3 additions & 3 deletions src/widgets/blocks/queryTable/queryTable.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { InstanceCtx } from "../../../contexts";
import { ActionLibrary } from "../../ActionLibrary";

// Outer context vars
const rowsetCV: ContextVar = { id: "cv1", type: "rowset", name: "", table: "t1" }
const rowsetCV: ContextVar = { id: "cv1", type: "rowset", name: "CV1", table: "t1" }
const contextVars: ContextVar[] = [rowsetCV]

const qtbdSingle: QueryTableBlockDef = {
Expand Down Expand Up @@ -47,7 +47,7 @@ const schema = simpleSchema()
test("gets single row cv", () => {
expect(qtbSingle.createRowContextVar(rowsetCV)).toEqual({
id: "123_row",
name: "Table row",
name: "Table row of CV1",
type: "row",
table: "t1"
})
Expand All @@ -56,7 +56,7 @@ test("gets single row cv", () => {
test("gets multiple row cv", () => {
expect(qtbMultiple.createRowContextVar(rowsetCV)).toEqual({
id: "123_rowset",
name: "Table row rowset",
name: "Table row rowset of CV1",
type: "rowset",
table: "t1"
})
Expand Down
4 changes: 2 additions & 2 deletions src/widgets/blocks/queryTable/queryTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,9 @@ export class QueryTableBlock extends Block<QueryTableBlockDef> {
createRowContextVar(rowsetCV: ContextVar): ContextVar {
switch (this.blockDef.mode) {
case "singleRow":
return { id: this.getRowContextVarId(), name: "Table row", type: "row", table: rowsetCV.table }
return { id: this.getRowContextVarId(), name: `Table row of ${rowsetCV.name}`, type: "row", table: rowsetCV.table }
case "multiRow":
return { id: this.getRowContextVarId(), name: "Table row rowset", type: "rowset", table: rowsetCV.table }
return { id: this.getRowContextVarId(), name: `Table row rowset of ${rowsetCV.name}`, type: "rowset", table: rowsetCV.table }
}
throw new Error("Unknown mode")
}
Expand Down

0 comments on commit f1629a1

Please sign in to comment.