diff --git a/lib/widgets/actions/addRow.js b/lib/widgets/actions/addRow.js index e2a7042c..f366bb82 100644 --- a/lib/widgets/actions/addRow.js +++ b/lib/widgets/actions/addRow.js @@ -114,8 +114,6 @@ var AddRowAction = /** @class */ (function (_super) { } var exprValidator = new mwater_expressions_1.ExprValidator(designCtx.schema, blocks_1.createExprVariables(designCtx.contextVars)); var exprUtils = new mwater_expressions_1.ExprUtils(designCtx.schema, blocks_1.createExprVariables(designCtx.contextVars)); - // Get type of column - var columnType = (column.type === "join") ? "id" : column.type; // Check context var var contextVarExpr = this.actionDef.columnValues[columnId]; var contextVar; @@ -135,7 +133,7 @@ var AddRowAction = /** @class */ (function (_super) { } // Validate expr var error; - error = exprValidator.validateExpr(contextVarExpr.expr, { table: contextVar ? contextVar.table : undefined, types: [columnType] }); + error = exprValidator.validateExpr(contextVarExpr.expr, { table: contextVar ? contextVar.table : undefined, types: [column.type] }); if (error) { return error; } diff --git a/lib/widgets/blocks/addRow.js b/lib/widgets/blocks/addRow.js index e68b00f6..8d7a94aa 100644 --- a/lib/widgets/blocks/addRow.js +++ b/lib/widgets/blocks/addRow.js @@ -132,8 +132,6 @@ var AddRowBlock = /** @class */ (function (_super) { } var exprValidator = new mwater_expressions_1.ExprValidator(options.schema, blocks_1.createExprVariables(options.contextVars)); var exprUtils = new mwater_expressions_1.ExprUtils(options.schema, blocks_1.createExprVariables(options.contextVars)); - // Get type of column - var columnType = (column.type === "join") ? "id" : column.type; // Check context var var contextVarExpr = this.blockDef.columnValues[columnId]; var contextVar; @@ -153,7 +151,7 @@ var AddRowBlock = /** @class */ (function (_super) { } // Validate expr var error; - error = exprValidator.validateExpr(contextVarExpr.expr, { table: contextVar ? contextVar.table : undefined, types: [columnType] }); + error = exprValidator.validateExpr(contextVarExpr.expr, { table: contextVar ? contextVar.table : undefined, types: [column.type] }); if (error) { return error; } diff --git a/lib/widgets/blocks/addWizard.js b/lib/widgets/blocks/addWizard.js index 876895ae..5b08a8c4 100644 --- a/lib/widgets/blocks/addWizard.js +++ b/lib/widgets/blocks/addWizard.js @@ -137,8 +137,7 @@ var AddWizardPane = function (props) { if (column.type === "enum" || column.type === "enumset" || column.type === "id" - || column.type === "id[]" - || (column.type === "join" && column.join.type === "n-1")) { + || column.type === "id[]") { createLabeledBlock({ id: uuid(), type: "dropdown", diff --git a/lib/widgets/blocks/controls/dropdown.js b/lib/widgets/blocks/controls/dropdown.js index 28b1d567..1a2df32d 100644 --- a/lib/widgets/blocks/controls/dropdown.js +++ b/lib/widgets/blocks/controls/dropdown.js @@ -77,10 +77,10 @@ var DropdownBlock = /** @class */ (function (_super) { } var contextVar = options.contextVars.find(function (cv) { return cv.id === _this.blockDef.rowContextVarId; }); var column = options.schema.getColumn(contextVar.table, this.blockDef.column); - if (column.type === "join") { + if (column.type === "id" || column.type == "id[]") { var idMode = this.blockDef.idMode || "simple"; var exprValidator = new mwater_expressions_1.ExprValidator(options.schema, blocks_1.createExprVariables(options.contextVars)); - var idTable = column.join.toTable; + var idTable = column.idTable; if (idMode == "simple") { if (!this.blockDef.idLabelExpr) { return "Label Expression required"; @@ -166,9 +166,6 @@ var DropdownBlock = /** @class */ (function (_super) { if (column.type === "id[]") { return this.renderIds(props, column); } - if (column.type === "join" && column.join.type === "n-1") { - return this.renderId(props, column); - } throw new Error("Unsupported type"); }; DropdownBlock.prototype.renderEnum = function (props, column) { @@ -211,7 +208,6 @@ var DropdownBlock = /** @class */ (function (_super) { return React.createElement(react_select_1.default, { value: value, onChange: handleChange, options: enumValues, placeholder: localization_1.localize(this.blockDef.placeholder, props.locale), getOptionLabel: getOptionLabel, getOptionValue: getOptionValue, isDisabled: props.disabled, isClearable: true, isMulti: true, closeMenuOnScroll: true, menuPortalTarget: document.body, classNamePrefix: "react-select-short", styles: { menuPortal: function (style) { return (__assign(__assign({}, style), { zIndex: 2000 })); } } }); }; DropdownBlock.prototype.renderId = function (props, column) { - var idTable = column.join ? column.join.toTable : column.idTable; var labelEmbeddedExprs; var searchExprs; var orderBy; @@ -226,7 +222,7 @@ var DropdownBlock = /** @class */ (function (_super) { searchExprs = [this.blockDef.idLabelExpr]; orderBy = [{ expr: this.blockDef.idLabelExpr, dir: "asc" }]; } - return React.createElement(IdDropdownComponent_1.IdDropdownComponent, { database: props.database, table: idTable, value: props.value, onChange: props.onChange, multi: false, labelEmbeddedExprs: labelEmbeddedExprs, searchExprs: searchExprs, orderBy: orderBy, filterExpr: this.blockDef.idFilterExpr || null, formatLabel: this.formatIdLabel.bind(null, props), contextVars: props.contextVars, contextVarValues: props.contextVarValues, styles: { menuPortal: function (style) { return (__assign(__assign({}, style), { zIndex: 2000 })); } } }); + return React.createElement(IdDropdownComponent_1.IdDropdownComponent, { database: props.database, table: column.idTable, value: props.value, onChange: props.onChange, multi: false, labelEmbeddedExprs: labelEmbeddedExprs, searchExprs: searchExprs, orderBy: orderBy, filterExpr: this.blockDef.idFilterExpr || null, formatLabel: this.formatIdLabel.bind(null, props), contextVars: props.contextVars, contextVarValues: props.contextVarValues, styles: { menuPortal: function (style) { return (__assign(__assign({}, style), { zIndex: 2000 })); } } }); }; DropdownBlock.prototype.renderIds = function (props, column) { var labelEmbeddedExprs; @@ -253,9 +249,9 @@ var DropdownBlock = /** @class */ (function (_super) { if (contextVar && contextVar.table && this.blockDef.column) { column = props.schema.getColumn(contextVar.table, this.blockDef.column); } - var isIdType = column && (column.type === "join" || column.type == "id" || column.type == "id[]"); + var isIdType = column && (column.type == "id" || column.type == "id[]"); var idMode = this.blockDef.idMode || "simple"; - var idTable = column && column.join ? column.join.toTable : (column ? column.idTable : null); + var idTable = column ? column.idTable : null; var handleConvertToToggle = function () { props.store.replaceBlock({ id: _this.blockDef.id, @@ -329,8 +325,7 @@ var DropdownBlock = /** @class */ (function (_super) { return column.type === "enum" || column.type === "enumset" || column.type === "id" - || column.type === "id[]" - || (column.type === "join" && column.join.type === "n-1"); + || column.type === "id[]"; }; return DropdownBlock; }(ControlBlock_1.ControlBlock)); diff --git a/lib/widgets/columnValues.js b/lib/widgets/columnValues.js index 95c7b770..c9f159aa 100644 --- a/lib/widgets/columnValues.js +++ b/lib/widgets/columnValues.js @@ -65,13 +65,11 @@ var ColumnValuesEditor = /** @class */ (function (_super) { } var contextVarExpr = this.props.value[columnId]; var contextVar = this.props.contextVars.find(function (cv) { return cv.id === contextVarExpr.contextVarId; }); - // Get type of column - var columnType = (column.type === "join") ? "id" : column.type; return react_1.default.createElement("tr", { key: columnId }, react_1.default.createElement("td", { key: "name" }, localization_1.localize(column.name, this.props.locale)), react_1.default.createElement("td", { key: "value" }, react_1.default.createElement(propertyEditors_1.LabeledProperty, { label: "Expression" }, - react_1.default.createElement(propertyEditors_1.ContextVarExprPropertyEditor, { contextVarId: contextVarExpr.contextVarId, expr: contextVarExpr.expr, onChange: this.handleContextVarExprChange.bind(null, columnId), contextVars: this.props.contextVars, schema: this.props.schema, dataSource: this.props.dataSource, idTable: column.idTable || (column.type === "join" ? column.join.toTable : undefined), enumValues: column.enumValues, types: [columnType] }))), + react_1.default.createElement(propertyEditors_1.ContextVarExprPropertyEditor, { contextVarId: contextVarExpr.contextVarId, expr: contextVarExpr.expr, onChange: this.handleContextVarExprChange.bind(null, columnId), contextVars: this.props.contextVars, schema: this.props.schema, dataSource: this.props.dataSource, idTable: column.idTable, enumValues: column.enumValues, types: [column.type] }))), react_1.default.createElement("td", { key: "remove" }, react_1.default.createElement("i", { className: "fa fa-remove", onClick: this.handleRemove.bind(null, columnId) }))); }; diff --git a/src/widgets/actions/addRow.tsx b/src/widgets/actions/addRow.tsx index e32072ff..4ae76121 100644 --- a/src/widgets/actions/addRow.tsx +++ b/src/widgets/actions/addRow.tsx @@ -56,9 +56,6 @@ export class AddRowAction extends Action { const exprValidator = new ExprValidator(designCtx.schema, createExprVariables(designCtx.contextVars)) const exprUtils = new ExprUtils(designCtx.schema, createExprVariables(designCtx.contextVars)) - // Get type of column - const columnType = (column.type === "join") ? "id" : column.type - // Check context var const contextVarExpr: ContextVarExpr = this.actionDef.columnValues[columnId] let contextVar: ContextVar | undefined @@ -80,7 +77,7 @@ export class AddRowAction extends Action { // Validate expr let error - error = exprValidator.validateExpr(contextVarExpr.expr, { table: contextVar ? contextVar.table : undefined, types: [columnType] }) + error = exprValidator.validateExpr(contextVarExpr.expr, { table: contextVar ? contextVar.table : undefined, types: [column.type] }) if (error) { return error } diff --git a/src/widgets/blocks/addRow.tsx b/src/widgets/blocks/addRow.tsx index 6aa58cfe..8edf396e 100644 --- a/src/widgets/blocks/addRow.tsx +++ b/src/widgets/blocks/addRow.tsx @@ -88,9 +88,6 @@ export class AddRowBlock extends Block { const exprValidator = new ExprValidator(options.schema, createExprVariables(options.contextVars)) const exprUtils = new ExprUtils(options.schema, createExprVariables(options.contextVars)) - // Get type of column - const columnType = (column.type === "join") ? "id" : column.type - // Check context var const contextVarExpr: ContextVarExpr = this.blockDef.columnValues[columnId] let contextVar: ContextVar | undefined @@ -112,7 +109,7 @@ export class AddRowBlock extends Block { // Validate expr let error - error = exprValidator.validateExpr(contextVarExpr.expr, { table: contextVar ? contextVar.table : undefined, types: [columnType] }) + error = exprValidator.validateExpr(contextVarExpr.expr, { table: contextVar ? contextVar.table : undefined, types: [column.type] }) if (error) { return error } diff --git a/src/widgets/blocks/addWizard.tsx b/src/widgets/blocks/addWizard.tsx index 6a4856db..4342355d 100644 --- a/src/widgets/blocks/addWizard.tsx +++ b/src/widgets/blocks/addWizard.tsx @@ -138,8 +138,7 @@ const AddWizardPane = (props: { if (column.type === "enum" || column.type === "enumset" || column.type === "id" - || column.type === "id[]" - || (column.type === "join" && column.join!.type === "n-1")) { + || column.type === "id[]") { createLabeledBlock({ id: uuid(), type: "dropdown", diff --git a/src/widgets/blocks/controls/dropdown.tsx b/src/widgets/blocks/controls/dropdown.tsx index 17883167..6a47dce9 100644 --- a/src/widgets/blocks/controls/dropdown.tsx +++ b/src/widgets/blocks/controls/dropdown.tsx @@ -59,10 +59,10 @@ export class DropdownBlock extends ControlBlock { const contextVar = options.contextVars.find(cv => cv.id === this.blockDef.rowContextVarId)! const column = options.schema.getColumn(contextVar.table!, this.blockDef.column!)! - if (column.type === "join") { + if (column.type === "id" || column.type == "id[]") { const idMode = this.blockDef.idMode || "simple" const exprValidator = new ExprValidator(options.schema, createExprVariables(options.contextVars)) - const idTable = column.join!.toTable + const idTable = column.idTable! if (idMode == "simple") { if (!this.blockDef.idLabelExpr) { @@ -166,9 +166,6 @@ export class DropdownBlock extends ControlBlock { if (column.type === "id[]") { return this.renderIds(props, column) } - if (column.type === "join" && column.join!.type === "n-1") { - return this.renderId(props, column) - } throw new Error("Unsupported type") } @@ -264,8 +261,6 @@ export class DropdownBlock extends ControlBlock { } renderId(props: RenderControlProps, column: Column) { - const idTable = column.join ? column.join.toTable : column.idTable - let labelEmbeddedExprs: Expr[] let searchExprs: Expr[] let orderBy: OrderBy[] @@ -284,7 +279,7 @@ export class DropdownBlock extends ControlBlock { return { column = props.schema.getColumn(contextVar.table, this.blockDef.column) } - const isIdType = column && (column.type === "join" || column.type == "id" || column.type == "id[]") + const isIdType = column && (column.type == "id" || column.type == "id[]") const idMode = this.blockDef.idMode || "simple" - const idTable = column && column.join ? column.join.toTable : (column ? column.idTable : null) + const idTable = column ? column.idTable : null const handleConvertToToggle = () => { props.store.replaceBlock({ @@ -506,7 +501,6 @@ export class DropdownBlock extends ControlBlock { return column.type === "enum" || column.type === "enumset" || column.type === "id" - || column.type === "id[]" - || (column.type === "join" && column.join!.type === "n-1") + || column.type === "id[]" } } \ No newline at end of file diff --git a/src/widgets/columnValues.tsx b/src/widgets/columnValues.tsx index f343aebb..c536930f 100644 --- a/src/widgets/columnValues.tsx +++ b/src/widgets/columnValues.tsx @@ -62,9 +62,6 @@ export class ColumnValuesEditor extends React.Component<{ const contextVar = this.props.contextVars.find(cv => cv.id === contextVarExpr.contextVarId) - // Get type of column - const columnType = (column.type === "join") ? "id" : column.type - return {localize(column.name, this.props.locale)} @@ -76,9 +73,9 @@ export class ColumnValuesEditor extends React.Component<{ contextVars={this.props.contextVars} schema={this.props.schema} dataSource={this.props.dataSource} - idTable={column.idTable || (column.type === "join" ? column.join!.toTable : undefined)} + idTable={column.idTable} enumValues={column.enumValues} - types={[columnType as LiteralType]} + types={[column.type as LiteralType]} />