diff --git a/docs/user-docs/annotation.md b/docs/user-docs/annotation.md index 8464f4e34..45af4e2de 100644 --- a/docs/user-docs/annotation.md +++ b/docs/user-docs/annotation.md @@ -91,7 +91,7 @@ element and its nested model elements. Supported JSON payload patterns: - `{`... `"comment":` _comment_ || `{` _context_: _ccomment_ `}` ...`}`: The _comment_ (tooltip) to be used in place of the model element's original comment. Set this to `false` if you don't want any tooltips. -- `{`... `"comment_display":` `{` _context_: `{` `"table_comment_display"`: _comment_display_ `,` `"column_comment_display"`: _comment_display_ `}` ... `}` +- `{`... `"comment_display":` `{` _context_: `{` `"table_comment_display"`: _comment_display_ `,` `"column_comment_display"`: _comment_display_ `,` `"comment_render_markdown"`: _comment_render_markdown_ `}` ... `}` - `{`... `"name":` _name_ ...`}`: The _name_ to use in place of the model element's original name. - `{`... `"markdown_name"`: _markdown_ `}`: The _markdown_ to use in place of the model element's original name. - `{`... `"name_style":` `{` `"underline_space"`: _uspace_ `,` `"title_case":` _tcase_ `,` `"markdown"`: _render_ `}` ...`}`: Element name conversion instructions. @@ -111,6 +111,11 @@ Supported JSON _comment_display_ patterns: - `tooltip`: Set to tooltip to show the comment as a hover over tooltip. - `inline`: Set to inline to show the comment as an inline tooltip. +Supported JSON _comment_render_markdown_ patterns: + +- `false`: Don't treat the defined `comment` on this model and its descendants as markdown. +- `true`: Treat the defined `comment` on this model and its descendants as markdown. + Supported JSON _uspace_ patterns: - `true`: Convert underline characters (`_`) into space characters in model element names. @@ -158,7 +163,7 @@ Supported JSON _context_ patterns: #### Tag: 2015 Display Settings Hierarchy - The `"comment"` setting applies *only* to the model element which is annotated. - - Currently the contextualized `comment` is only supported for tables. +- The `"_comment_render_markdown_": false` should be used if you don't want us to treat the comment as a markdown value. By default we're assuming given comments are markdown. - The `"table_comment_display"` and `"column_comment_display"` setting applies *only* to the model element which is annotated. - Currently the contextualized `table_comment_display` is supported for `compact` context for the title and the tables in detailed context when they are part of a foreign key relationship in `visible-columns` or `visible-foreign-keys`. - `column_comment_display` is accepted as a parameter, but currently doesn't do anything. @@ -426,6 +431,7 @@ Supported JSON payload patterns: - `{` ... `"from_name":` _fname_ ... `}`: The _fname_ string is a preferred name for the set of entities containing foreign key references described by this constraint. - `{` ... `"to_name":` _tname_ ... `}`: The _tname_ string is a preferred name for the set of entities containing keys described by this constraint. - `{` ... `"from_comment":` _comment_ ... `}`: The _comment_ string is a preferred comment for the set of entities containing keys described by this constraint. +- `{` ... `"comment_render_markdown":` _boolean_value_ ... `}`: The _boolean_value_ dictates whether the comments for this foreignkey should be treated as markdown or not. If not defined, its value will be inherited from the table (which could be inherited from the schema or the catalog. If it's not defined on any of the models, the default behavior is to treat comments as markdown). - `{` ... `"to_comment":` _comment_ ... `}`: The _comment_ string is a preferred comment for the set of entities containing keys described by this constraint. - `{` ... `"from_comment_display":` _comment_display_ ... `}`: The display mode for the tooltip. Set to `inline` to show it as text or `tooltip` to show as a hover tooltip. - Currently the `comment_display` is only supported for foreign key relationships in detailed context when they are part of `visible-columns` or `visible-foreign-keys`. @@ -1300,6 +1306,7 @@ The following attributes can be used to manipulate the presentation settings of - `markdown_name`: The markdown to use in place of the default heuristics for title of column. - `comment`: The tooltip to be used in place of the default heuristics for the column. Set this to `false` if you don't want any tooltip. +- `comment_render_markdown`: A boolean value that dictates whether the comment should be treated as markdown or not. If not defined, its value will be inherited from the underlying column or table (which could be inherited from the schema or the catalog. If it's not defined on any of the models, the default behavior is to treat comments as markdown). - `comment_display`: The display mode for the tooltip. Set to `inline` to show it as text or `tooltip` to show as a hover tooltip. - Currently `comment_display` is only supported for related tables in detailed context. - `hide_column_header`: Hide the column header (and still show the value). This is only supported in `detailed` context of `visible-columns` annotation. diff --git a/docs/user-docs/column-directive.md b/docs/user-docs/column-directive.md index 418668f9f..b8e0c45de 100644 --- a/docs/user-docs/column-directive.md +++ b/docs/user-docs/column-directive.md @@ -23,6 +23,7 @@ Column directive allows instruction of a data source and modification of its pre - [2. Presentation properties](#2-presentation-properties) - [markdown\_name](#markdown_name) - [comment](#comment) + - [comment\_render\_markdown](#comment-render-markdown) - [comment\_display](#comment_display) - [hide\_column\_header](#hide_column_header) - [self-link](#self-link) @@ -359,6 +360,14 @@ In Chaise, comment is displayed as tooltip associated with columns. To change th "comment": "New comment" +#### comment_render_markdown + +A boolean value that dictates whether the comment should be treated as markdown or not. If not defined, its value will be inherited from the underlying column or table which could be inherited from the schema or the catalog. If it's not defined on any of the models, the default behavior is to treat comments as markdown. + + "comment_render_markdown": false + +This boolean works independent of the `comment` property. Which means that you can define `commen_render_markdown` to be used in combination with the comment that is derived based on the heuristics. + #### comment_display By default Chaise will display `comment` as a tooltip. Set this value to `inline` to show it as text or `tooltip` to show as a hover tooltip. This property is only supported for related tables in detailed context of `visible-foreign-keys` annotation, and is not honored in other annotations. @@ -404,7 +413,7 @@ While generating a default presentation for all outbound foreign key paths, ERMr ##### selector_ux_mode -While generating a default presentation in `entry` mode for single outbound foreign key paths, Chaise will show a modal popup dialog for selecting rows. Using this attribute, you can modify this behavior. If this attribute is missing, we are going to use the inherited behavior from the [foreign key](annotation.md#tag-2016-foreign-key) annotation defined on the foreign key relationship. If that one is missing too, [table display](annotation.md#tag-2016-table-display) annotation will be applied. Supported values are `"facet-search-popup"` and `"simple-search-dropdown"`, with `"facet-search-popup"` being the default. +While generating a default presentation in `entry` mode for single outbound foreign key paths, Chaise will show a modal popup dialog for selecting rows. Using this attribute, you can modify this behavior. If this attribute is missing, we are going to use the inherited behavior from the [foreign key](annotation.md#tag-2016-foreign-key) annotation defined on the foreign key relationship. If that one is missing too, [table display](annotation.md#tag-2016-table-display) annotation will be applied. Supported values are `"facet-search-popup"` and `"simple-search-dropdown"`, with `"facet-search-popup"` being the default. ##### show_key_link diff --git a/js/column.js b/js/column.js index 8c8c268b4..87d1e94f5 100644 --- a/js/column.js +++ b/js/column.js @@ -294,7 +294,7 @@ ReferenceColumn.prototype = { var comment = null, commentDisplayMode, commentRenderMarkdown; if (this._simple) { var display = this._baseCols[0].getDisplay(this._context); - comment = display.comment ? display.comment.unformatted : null; + comment = display.comment; commentDisplayMode = display.commentDisplayMode; commentRenderMarkdown = display.commentRenderMarkdown; } @@ -302,7 +302,12 @@ ReferenceColumn.prototype = { if (!this.sourceObject) { this._comment = comment; } else { - this._comment = _processSourceObjectComment(this.sourceObject, comment, commentRenderMarkdown, commentDisplayMode); + this._comment = _processSourceObjectComment( + this.sourceObject, + comment ? comment.unformatted : null, + commentRenderMarkdown, + commentDisplayMode + ); } } @@ -1351,42 +1356,43 @@ PseudoColumn.prototype._determineInputDisabled = function () { Object.defineProperty(PseudoColumn.prototype, "comment", { get: function () { if (this._comment === undefined) { - var getDefaultCommentProps = function (self) { + var getComment = function (self) { if (self.hasAggregate) { + // if defined on the sourceObject use it. + var com = _processSourceObjectComment(self.sourceObject); + if (com) { + return com; + } + + // otherwise generate one var agIndex = module._pseudoColAggregateFns.indexOf(self.sourceObject.aggregate); var dname = self._baseCols[0].displayname.unformatted; if (self.isEntityMode) { dname = self._baseCols[0].table.displayname.unformatted; } - return { - comment: [module._pseudoColAggregateExplicitName[agIndex], dname].join(" "), - commentDisplayMode: module._commentDisplayModes.tooltip, - commentRenderMarkdown: false - }; + return _processModelComment([module._pseudoColAggregateExplicitName[agIndex], dname].join(" "), false); } - var temp; + // if it's not aggregate, we can get it from the table or column depending on entity mode: + var disp, commentDisplayMode; if (!self.isEntityMode) { - temp = self._baseCols[0].getDisplay(self._context); - return { - comment: temp.comment ? temp.comment.unformatted: null, - commentDisplayMode: temp.commentDisplayMode, - commentRenderMarkdown: temp.commentRenderMarkdown - }; + disp = self._baseCols[0].getDisplay(self._context); + commentDisplayMode = disp.commentDisplayMode; + } else { + disp = self.table.getDisplay(self._context); + commentDisplayMode = disp.tableCommentDisplayMode; } - // self.table should be leaf table - temp = self.table.getDisplay(self._context); - return { - comment: temp.comment ? temp.comment.unformatted: null, - commentDisplayMode: temp.tableCommentDisplayMode, - commentRenderMarkdown: temp.commentRenderMarkdown - }; - }; + return _processSourceObjectComment( + self.sourceObject, + disp.comment ? disp.comment.unformatted : null, + disp.commentRenderMarkdown, + commentDisplayMode + ); + } - var def = getDefaultCommentProps(this); - this._comment = _processSourceObjectComment(this.sourceObject, def.comment, def.commentRenderMarkdown, def.commentDisplayMode); + this._comment = getComment(this); } return this._comment; } diff --git a/js/reference.js b/js/reference.js index d8038608a..f088c9c81 100644 --- a/js/reference.js +++ b/js/reference.js @@ -4087,7 +4087,7 @@ // comment if (fkDisplay.fromComment) { - comment = fkDisplay.fromComment; + comment = fkDisplay.fromComment.unformatted; } else { comment = tableDisplay.comment ? tableDisplay.comment.unformatted : null; } diff --git a/js/utils/helpers.js b/js/utils/helpers.js index 42f66b857..7f1c8aa34 100644 --- a/js/utils/helpers.js +++ b/js/utils/helpers.js @@ -848,11 +848,10 @@ }; /** - * Given an input string for the comment, will return the actual strng that should be used. - * - if =false : returns empty string. - * - if =string: returns the string. - * - otherwise returns null - * TODO update comment + * Turn a comment annotaiton/string value into a proper comment object. + * @param {string|null|false} comment + * @param {boolean=true} isMarkdown whether the given comment should be rendered as markdown (default: true). + * @param {string} displayMode the display mode of the comment (inline, tooltip) * @private */ _processModelComment = function (comment, isMarkdown, displayMode) { diff --git a/test/specs/reference/conf/comment_display_inline_schema/schema.json b/test/specs/reference/conf/comment_display_inline_schema/schema.json index 5d8cb0492..d29b78d98 100644 --- a/test/specs/reference/conf/comment_display_inline_schema/schema.json +++ b/test/specs/reference/conf/comment_display_inline_schema/schema.json @@ -49,7 +49,12 @@ }, "tag:isrd.isi.edu,2016:visible-columns": { "detailed": [ - { "sourcekey": "simple_fk_1", "comment": "simple fk source syntax comment", "comment_display": "inline" }, + { + "sourcekey": "simple_fk_1", + "comment": "simple fk source syntax comment", + "comment_display": "inline", + "comment_render_markdown": true + }, { "sourcekey": "simple_fk_2" }, { "sourcekey": "simple_fk_3" }, { "sourcekey": "simple_fk_4" } @@ -146,7 +151,8 @@ "annotations": { "tag:isrd.isi.edu,2016:foreign-key": { "from_comment": "simple fk from_comment comment", - "from_comment_display": "inline" + "from_comment_display": "inline", + "comment_render_markdown": false } } } @@ -204,7 +210,8 @@ ], "annotations": { "tag:isrd.isi.edu,2016:foreign-key": { - "from_comment_display": "inline" + "from_comment_display": "inline", + "comment_render_markdown": false } } } @@ -287,7 +294,8 @@ }, "comment_display": { "detailed": { - "table_comment_display": "inline" + "table_comment_display": "inline", + "comment_render_markdown": true } } } @@ -379,18 +387,38 @@ "RID" ], "entity": true + }, + "multi_leaf_no_display": { + "source": [ + {"inbound": ["comment_display_inline_schema", "association_related_to_reference"]}, + {"outbound": ["comment_display_inline_schema", "association_to_inbound_related"]}, + {"outbound": ["comment_display_inline_schema", "multi_hop_fk_4"]}, + "RID" + ], + "entity": true } } }, "tag:isrd.isi.edu,2016:visible-columns": { "detailed": [ - { "sourcekey": "pb_source_comment", "comment": "pure and binary fk source syntax comment", "comment_display": "inline" }, + { + "sourcekey": "pb_source_comment", + "comment": "pure and binary fk source syntax comment", + "comment_display": "inline", + "comment_render_markdown": true + }, { "sourcekey": "pb_to_comment"}, { "sourcekey": "pb_to_comment_display" }, { "sourcekey": "pb_leaf_comment" }, - { "sourcekey": "multi_source_comment", "comment": "multi hop fk source syntax comment", "comment_display": "inline" }, + { + "sourcekey": "multi_source_comment", + "comment": "multi hop fk source syntax comment", + "comment_display": "inline", + "comment_render_markdown": true + }, { "sourcekey": "multi_comment_display"}, - { "sourcekey": "multi_leaf_comment" } + { "sourcekey": "multi_leaf_comment" }, + { "sourcekey": "multi_leaf_no_display" } ] } } @@ -494,7 +522,8 @@ "annotations": { "tag:isrd.isi.edu,2016:foreign-key": { "to_comment": "pure and binary fk to_comment", - "to_comment_display": "inline" + "to_comment_display": "inline", + "comment_render_markdown": false } } } @@ -652,14 +681,15 @@ }, "comment_display": { "detailed": { - "table_comment_display": "inline" + "table_comment_display": "inline", + "comment_render_markdown": true } } } } }, "inbound_related_reference_table_no_display": { - "comment": "foreign key to association table", + "comment": "foreign key to association table no display", "kind": "table", "table_name": "inbound_related_reference_table_no_display", "schema_name": "comment_display_inline_schema", @@ -723,6 +753,25 @@ } ], "annotations": {} + }, + { + "comment": "simple fk multi_hop_col_4 with comment_display", + "names": [["comment_display_inline_schema", "multi_hop_fk_4"]], + "foreign_key_columns": [ + { + "schema_name": "comment_display_inline_schema", + "table_name": "inbound_related_reference_table_no_display", + "column_name": "multi_hop_col_4" + } + ], + "referenced_columns": [ + { + "schema_name": "comment_display_inline_schema", + "table_name": "multi_hop_related_reference_table_no_leaf_display", + "column_name": "id" + } + ], + "annotations": {} } ], "column_definitions": [ @@ -753,6 +802,13 @@ "type": { "typename": "text" } + }, + { + "name": "multi_hop_col_4", + "nullok": false, + "type": { + "typename": "text" + } } ], "annotations": {} @@ -799,7 +855,8 @@ "tag:misd.isi.edu,2015:display": { "comment_display": { "detailed": { - "table_comment_display": "inline" + "table_comment_display": "inline", + "comment_render_markdown": true } } } @@ -830,11 +887,32 @@ }, "comment_display": { "detailed": { - "table_comment_display": "inline" + "table_comment_display": "inline", + "comment_render_markdown": false } } } } + }, + "multi_hop_related_reference_table_no_leaf_display": { + "comment": "foreign key to association table with no leaf display", + "kind": "table", + "table_name": "multi_hop_related_reference_table_no_leaf_display", + "schema_name": "comment_display_inline_schema", + "keys": [{ + "unique_columns": ["id"] + }], + "foreign_keys": [], + "column_definitions": [ + { + "name": "id", + "nullok": false, + "type": { + "typename": "text" + } + } + ], + "annotations": {} } } } diff --git a/test/specs/reference/conf/comment_display_related_schema/schema.json b/test/specs/reference/conf/comment_display_related_schema/schema.json index b094e402c..b341b2524 100644 --- a/test/specs/reference/conf/comment_display_related_schema/schema.json +++ b/test/specs/reference/conf/comment_display_related_schema/schema.json @@ -49,7 +49,12 @@ }, "tag:isrd.isi.edu,2016:visible-foreign-keys": { "detailed": [ - { "sourcekey": "simple_fk_1", "comment": "simple fk source syntax comment", "comment_display": "inline" }, + { + "sourcekey": "simple_fk_1", + "comment": "simple fk source syntax comment", + "comment_display": "inline", + "comment_render_markdown": false + }, { "sourcekey": "simple_fk_2" }, { "sourcekey": "simple_fk_3" }, { "sourcekey": "simple_fk_4" } @@ -146,7 +151,8 @@ "annotations": { "tag:isrd.isi.edu,2016:foreign-key": { "from_comment": "simple fk from_comment comment", - "from_comment_display": "inline" + "from_comment_display": "inline", + "comment_render_markdown": true } } } @@ -204,7 +210,8 @@ ], "annotations": { "tag:isrd.isi.edu,2016:foreign-key": { - "from_comment_display": "inline" + "from_comment_display": "inline", + "comment_render_markdown": true } } } @@ -287,7 +294,8 @@ }, "comment_display": { "detailed": { - "table_comment_display": "inline" + "table_comment_display": "inline", + "comment_render_markdown": false } } } @@ -379,18 +387,38 @@ "RID" ], "entity": true + }, + "multi_leaf_no_display": { + "source": [ + {"inbound": ["comment_display_inline_schema", "association_related_to_reference"]}, + {"outbound": ["comment_display_inline_schema", "association_to_inbound_related"]}, + {"outbound": ["comment_display_inline_schema", "multi_hop_fk_4"]}, + "RID" + ], + "entity": true } } }, "tag:isrd.isi.edu,2016:visible-foreign-keys": { "detailed": [ - { "sourcekey": "pb_source_comment", "comment": "pure and binary fk source syntax comment", "comment_display": "inline" }, + { + "sourcekey": "pb_source_comment", + "comment": "pure and binary fk source syntax comment", + "comment_display": "inline", + "comment_render_markdown": false + }, { "sourcekey": "pb_to_comment"}, { "sourcekey": "pb_to_comment_display" }, { "sourcekey": "pb_leaf_comment" }, - { "sourcekey": "multi_source_comment", "comment": "multi hop fk source syntax comment", "comment_display": "inline" }, + { + "sourcekey": "multi_source_comment", + "comment": "multi hop fk source syntax comment", + "comment_display": "inline", + "comment_render_markdown": false + }, { "sourcekey": "multi_comment_display"}, - { "sourcekey": "multi_leaf_comment" } + { "sourcekey": "multi_leaf_comment" }, + { "sourcekey": "multi_leaf_no_display" } ] } } @@ -494,7 +522,8 @@ "annotations": { "tag:isrd.isi.edu,2016:foreign-key": { "to_comment": "pure and binary fk to_comment", - "to_comment_display": "inline" + "to_comment_display": "inline", + "comment_render_markdown": true } } } @@ -652,14 +681,15 @@ }, "comment_display": { "detailed": { - "table_comment_display": "inline" + "table_comment_display": "inline", + "comment_render_markdown": false } } } } }, "inbound_related_reference_table_no_display": { - "comment": "foreign key to association table", + "comment": "foreign key to association table no display", "kind": "table", "table_name": "inbound_related_reference_table_no_display", "schema_name": "comment_display_related_schema", @@ -723,6 +753,25 @@ } ], "annotations": {} + }, + { + "comment": "simple fk multi_hop_col_4 with comment_display", + "names": [["comment_display_related_schema", "multi_hop_fk_4"]], + "foreign_key_columns": [ + { + "schema_name": "comment_display_related_schema", + "table_name": "inbound_related_reference_table_no_display", + "column_name": "multi_hop_col_4" + } + ], + "referenced_columns": [ + { + "schema_name": "comment_display_related_schema", + "table_name": "multi_hop_related_reference_table_no_leaf_display", + "column_name": "id" + } + ], + "annotations": {} } ], "column_definitions": [ @@ -753,6 +802,13 @@ "type": { "typename": "text" } + }, + { + "name": "multi_hop_col_4", + "nullok": false, + "type": { + "typename": "text" + } } ], "annotations": {} @@ -799,7 +855,8 @@ "tag:misd.isi.edu,2015:display": { "comment_display": { "detailed": { - "table_comment_display": "inline" + "table_comment_display": "inline", + "comment_render_markdown": false } } } @@ -830,11 +887,32 @@ }, "comment_display": { "detailed": { - "table_comment_display": "inline" + "table_comment_display": "inline", + "comment_render_markdown": true } } } } + }, + "multi_hop_related_reference_table_no_leaf_display": { + "comment": "foreign key to association table with no leaf display", + "kind": "table", + "table_name": "multi_hop_related_reference_table_no_leaf_display", + "schema_name": "comment_display_inline_schema", + "keys": [{ + "unique_columns": ["id"] + }], + "foreign_keys": [], + "column_definitions": [ + { + "name": "id", + "nullok": false, + "type": { + "typename": "text" + } + } + ], + "annotations": {} } } } diff --git a/test/specs/reference/tests/18.comment_display_inline.js b/test/specs/reference/tests/18.comment_display_inline.js index 6f824869c..716ccbdf1 100644 --- a/test/specs/reference/tests/18.comment_display_inline.js +++ b/test/specs/reference/tests/18.comment_display_inline.js @@ -1,7 +1,11 @@ +const utils = require("../../../utils/utilities.js"); + /** * For testing comment and comment_display using the visible columns annotation, fk annotation, and table annotation. * This spec is divided into 3 chunks for testing "simple inbound FK", "pure and binary FK", and "inbound multi hop foreign key" * + * there is a catalog annotstion that turns off markdown comments. + * * The structure of the tables used for "simple inbound FK": * 1. comment_display_simple_fk_table <- table_w_simple_key_source_override * 2. comment_display_simple_fk_table <- table_w_simple_key_fk_comment @@ -9,22 +13,23 @@ * 4. comment_display_simple_fk_table <- table_w_simple_key_leaf_annotation * * Visible-columns for "comment_display_simple_fk_table" match the order of the above tables/foreign keys relationships: - * 1. simple_fk_1 with comment in source syntax - * 2. simple_fk_2 with from_comment in FK annotation - * 3. simple_fk_3 with from_comment_display and no from_comment in FK annotation - * 4. simple_fk_4 with comment in display annotation on table + * 1. simple_fk_1 with comment in source syntax (turns on markdown comment) + * 2. simple_fk_2 with from_comment in FK annotation (turns off markdown comment) + * 3. simple_fk_3 with from_comment_display and no from_comment in FK annotation (turns off markdown comment) + * 4. simple_fk_4 with comment in display annotation on table (turns on markdown comment) * * * The structure of tables used for "pure and binary FKs": - * 1. comment_display_pb_table <- association_table -> inbound_related_reference_table_no_display - * 2. comment_display_pb_table <- tocomment_fk_association_to_inbound_related -> inbound_related_reference_table_no_display - * 3. comment_display_pb_table <- association_table_fk_to_comment_display -> inbound_related_reference_table_no_display - * 4. comment_display_pb_table <- association_table_leaf_comment -> inbound_related_reference_table + * 1. comment_display_pb_table <- association_table -> inbound_related_reference_table_no_display (turns on markdown comment) + * 2. comment_display_pb_table <- tocomment_fk_association_to_inbound_related -> inbound_related_reference_table_no_display (turns off markdown comment) + * 3. comment_display_pb_table <- association_table_fk_to_comment_display -> inbound_related_reference_table_no_display (turns off markdown comment) + * 4. comment_display_pb_table <- association_table_leaf_comment -> inbound_related_reference_table (turns on markdown comment) * * The structure of tables used for "inbound multi hop foreign key": - * 5. comment_display_pb_table <- association_table -> inbound_related_reference_table_no_display -> multi_hop_related_reference_table - * 6. comment_display_pb_table <- association_table -> inbound_related_reference_table_no_display -> multi_hop_related_reference_table_comment_display - * 7. comment_display_pb_table <- association_table -> inbound_related_reference_table_no_display -> multi_hop_related_reference_table_leaf_comment + * 5. comment_display_pb_table <- association_table -> inbound_related_reference_table_no_display -> multi_hop_related_reference_table (turns on markdown comment) + * 6. comment_display_pb_table <- association_table -> inbound_related_reference_table_no_display -> multi_hop_related_reference_table_comment_display (turns off markdown comment) + * 7. comment_display_pb_table <- association_table -> inbound_related_reference_table_no_display -> multi_hop_related_reference_table_leaf_comment (turns on markdown comment) + * 8. comment_display_pb_table <- association_table -> inbound_related_reference_table_no_display -> multi_hop_related_reference_table_no_leaf_display (turns off markdown comment) * * Visible-columns for "comment_display_pb_table" match the order of the above tables/foreign keys relationships: * 1. pb_source_comment with comment in source syntax @@ -39,15 +44,28 @@ **/ exports.execute = function (options) { - describe("comment related annotations,", function () { - - var catalog_id = process.env.DEFAULT_CATALOG, - schemaName = "comment_display_inline_schema", - limit = 1; + describe("comment annotations usage in visible columns,", () => { + + const catalog_id = process.env.DEFAULT_CATALOG, schemaName = "comment_display_inline_schema"; + + beforeAll((done) => { + // changing the default behaior + utils.setCatalogAnnotations(options, { + "tag:misd.isi.edu,2015:display": { + "comment_display": { + "*": { + "comment_render_markdown": false + } + } + } + }).then(() => { + done(); + }).catch((err) => done.fail(err)); + }); // simple "inbound" FK // main <- inbound leaf - describe("testing comment for simple foreign key", function() { + describe("for simple foreign key", function() { var tableSimpleFKName = "comment_display_simple_fk_table"; @@ -83,25 +101,16 @@ exports.execute = function (options) { }); }); - it("when from_comment and from_comment_display both are not defined", () => { + it("next from_comment and from_comment_display should be used.", () => { expect(simpleReference.columns[1].comment).toEqual({ - value: "

simple fk from_comment comment

\n", + value: "simple fk from_comment comment", unformatted: "simple fk from_comment comment", - isHTML: true, + isHTML: false, displayMode: 'inline' }); }); - it ('if from_comment is not defined but from_comment_display is used', () => { - expect(simpleReference.columns[2].comment).toEqual({ - value: "

simple fk with NO from comment

\n", - unformatted: "simple fk with NO from comment", - isHTML: true, - displayMode: 'inline' - }); - }) - - it("when from_comment and from_comment_display both are not defined", function () { + it("by default the leaf table comment and comment_display should be used.", function () { expect(simpleReference.columns[3].comment).toEqual({ value: '

simple fk leaf table display comment

\n', unformatted: 'simple fk leaf table display comment', @@ -109,11 +118,20 @@ exports.execute = function (options) { displayMode: 'inline' }); }); + + it ('if from_comment_display is defined but not the from_comment, leaf table comment and this proeprty should be mixed', () => { + expect(simpleReference.columns[2].comment).toEqual({ + value: "table with simple key to reference and a foreign key annotation with no from comment display", + unformatted: "table with simple key to reference and a foreign key annotation with no from comment display", + isHTML: false, + displayMode: 'inline' + }); + }); }); // pure and binary FK // main <- inbound association outbound -> leaf - describe("testing comment and comment_display for pure and binary relation", function() { + describe("for pure and binary relation", () => { var tablePBName = "comment_display_pb_table"; @@ -140,35 +158,39 @@ exports.execute = function (options) { }); - describe("for comment,", function () { - it("source syntax in visible foreign keys should be used first", function () { - expect(pBReference.columns[0].comment).toBe("pure and binary fk source syntax comment"); - }); - - it("then the to_comment in foreign-key annotation", function () { - expect(pBReference.columns[1].comment).toBe("pure and binary fk to_comment"); - }); - - it("next use display annotation on leaf table", function () { - expect(pBReference.columns[3].comment).toBe("pure and binary fk leaf table display comment"); + it("source syntax in visible-columns should be used first", () => { + expect(pBReference.columns[0].comment).toEqual({ + value: "

pure and binary fk source syntax comment

\n", + unformatted: "pure and binary fk source syntax comment", + isHTML: true, + displayMode: 'inline' }); }); - describe("for comment_display,", function () { - it("source syntax in visible foreign keys should be used first", function () { - expect(pBReference.columns[0].commentDisplay).toBe("inline"); - }); - - it("then the to_comment_display property in foreign-key annotation if to_comment was defined", function () { - expect(pBReference.columns[1].commentDisplay).toBe("inline"); + it("next to_comment and to_comment_display should be used.", () => { + expect(pBReference.columns[1].comment).toEqual({ + value: "pure and binary fk to_comment", + unformatted: "pure and binary fk to_comment", + isHTML: false, + displayMode: 'inline' }); + }); - it("ignore the to_comment_display property if to_comment is not defined", function () { - expect(pBReference.columns[2].commentDisplay).toBe("tooltip"); + it("next the leaf table comment and comment_display should be used.", function () { + expect(pBReference.columns[3].comment).toEqual({ + value: '

pure and binary fk leaf table display comment

\n', + unformatted: 'pure and binary fk leaf table display comment', + isHTML: true, + displayMode: 'inline' }); + }); - it("next use display annotation on leaf table", function () { - expect(pBReference.columns[3].commentDisplay).toBe("inline"); + it ('if to_comment_display is defined but not the to_comment, leaf table comment and this proeprty should be mixed', () => { + expect(pBReference.columns[2].comment).toEqual({ + value: "foreign key to association table no display", + unformatted: "foreign key to association table no display", + isHTML: false, + displayMode: 'inline' }); }); }); @@ -176,7 +198,7 @@ exports.execute = function (options) { // tests for pseudocolumn functionality when used for a related table // inbound multi hop foreign key // main <- inbound association outbound -> leaf outbound -> leaf - describe("testing comment and comment_display for multi hop foreign key", function() { + describe("for multi hop foreign key", function() { var tablePBName = "comment_display_pb_table"; @@ -203,33 +225,50 @@ exports.execute = function (options) { }); - describe("for comment,", function () { - it("source syntax in visible foreign keys should be used first", function () { - expect(multiHopReference.columns[4].comment).toBe("multi hop fk source syntax comment"); - }); - - it("next use display annotation on leaf table", function () { - expect(multiHopReference.columns[6].comment).toBe("multi hop fk leaf table display comment"); + it("source syntax in visible-columns should be used first", () => { + expect(multiHopReference.columns[4].comment).toEqual({ + isHTML: true, + unformatted: "multi hop fk source syntax comment", + value: "

multi hop fk source syntax comment

\n", + displayMode: 'inline' }); + }); - it("next use comment on leaf table,", function () { - expect(multiHopReference.columns[5].comment).toBe("foreign key to association table with comment_display and no comment"); + it("next use display annotation on leaf table", function () { + expect(multiHopReference.columns[6].comment).toEqual({ + isHTML: false, + unformatted: "multi hop fk leaf table display comment", + value: "multi hop fk leaf table display comment", + displayMode: 'inline' }); }); - describe("for comment_display,", function () { - it("source syntax in visible foreign keys should be used first", function () { - expect(multiHopReference.columns[4].commentDisplay).toBe("inline"); + it("next use comment on leaf table model while using comment_display and markdown of display annotation,", function () { + expect(multiHopReference.columns[5].comment).toEqual({ + isHTML: true, + unformatted: "foreign key to association table with comment_display and no comment", + value: "

foreign key to association table with comment_display and no comment

\n", + displayMode: 'inline' }); + }); - it("next use display annotation on leaf table", function () { - expect(multiHopReference.columns[5].commentDisplay).toBe("inline", "missmatch for index=5"); - expect(multiHopReference.columns[6].commentDisplay).toBe("inline", "missmatch for index=6"); + it("next use comment on leaf table model and display annotation of catalog,", function () { + expect(multiHopReference.columns[7].comment).toEqual({ + isHTML: false, + unformatted: "foreign key to association table with no leaf display", + value: "foreign key to association table with no leaf display", + displayMode: 'tooltip' }); - }); }); + afterAll((done) => { + // remove the catalog annotation + utils.setCatalogAnnotations(options, {}).then(() => { + done(); + }).catch((err) => done.fail(err)); + }); + }); }; diff --git a/test/specs/reference/tests/19.comment_display_related.js b/test/specs/reference/tests/19.comment_display_related.js index 6957fc178..17f788c9e 100644 --- a/test/specs/reference/tests/19.comment_display_related.js +++ b/test/specs/reference/tests/19.comment_display_related.js @@ -2,6 +2,11 @@ * For testing comment and comment_display using the visible foreign keys annotation, fk annotation, and table annotation. * This spec is divided into 3 chunks for testing "simple inbound FK", "pure and binary FK", and "inbound multi hop foreign key" * + * there are no catalog annotations in this spec + * the main difference with the other test spec/schema. in the other one catalog is turning of comment markdown, + * so the isHTML of that one is filpped from this one + * + * * The structure of the tables used for "simple inbound FK": * 1. comment_display_simple_fk_table <- table_w_simple_key_source_override * 2. comment_display_simple_fk_table <- table_w_simple_key_fk_comment @@ -9,22 +14,22 @@ * 4. comment_display_simple_fk_table <- table_w_simple_key_leaf_annotation * * Visible-foreign-keys for "comment_display_simple_fk_table" match the order of the above tables/foreign keys relationships: - * 1. simple_fk_1 with comment in source syntax - * 2. simple_fk_2 with from_comment in FK annotation - * 3. simple_fk_3 with from_comment_display and no from_comment in FK annotation - * 4. simple_fk_4 with comment in display annotation on table + * 1. simple_fk_1 with comment in source syntax (turns off markdown comment) + * 2. simple_fk_2 with from_comment in FK annotation (turns on markdown comment) + * 3. simple_fk_3 with from_comment_display and no from_comment in FK annotation (turns on markdown comment) + * 4. simple_fk_4 with comment in display annotation on table (turns off markdown comment) * * * The structure of tables used for "pure and binary FKs": - * 1. comment_display_pb_table <- association_table -> inbound_related_reference_table_no_display - * 2. comment_display_pb_table <- tocomment_fk_association_to_inbound_related -> inbound_related_reference_table_no_display - * 3. comment_display_pb_table <- association_table_fk_to_comment_display -> inbound_related_reference_table_no_display - * 4. comment_display_pb_table <- association_table_leaf_comment -> inbound_related_reference_table + * 1. comment_display_pb_table <- association_table -> inbound_related_reference_table_no_display (turns off markdown comment) + * 2. comment_display_pb_table <- tocomment_fk_association_to_inbound_related -> inbound_related_reference_table_no_display (turns on markdown comment) + * 3. comment_display_pb_table <- association_table_fk_to_comment_display -> inbound_related_reference_table_no_display (turns on markdown comment) + * 4. comment_display_pb_table <- association_table_leaf_comment -> inbound_related_reference_table (turns off markdown comment) * * The structure of tables used for "inbound multi hop foreign key": - * 5. comment_display_pb_table <- association_table -> inbound_related_reference_table_no_display -> multi_hop_related_reference_table - * 6. comment_display_pb_table <- association_table -> inbound_related_reference_table_no_display -> multi_hop_related_reference_table_comment_display - * 7. comment_display_pb_table <- association_table -> inbound_related_reference_table_no_display -> multi_hop_related_reference_table_leaf_comment + * 5. comment_display_pb_table <- association_table -> inbound_related_reference_table_no_display -> multi_hop_related_reference_table (turns off markdown comment) + * 6. comment_display_pb_table <- association_table -> inbound_related_reference_table_no_display -> multi_hop_related_reference_table_comment_display (turns on markdown comment) + * 7. comment_display_pb_table <- association_table -> inbound_related_reference_table_no_display -> multi_hop_related_reference_table_leaf_comment (turns off markdown comment) * * Visible-foreign-keys for "comment_display_pb_table" match the order of the above tables/foreign keys relationships: * 1. pb_source_comment with comment in source syntax @@ -39,13 +44,13 @@ */ exports.execute = function (options) { - xdescribe("testing foreign-key annotation,", function () { + describe("comment annotations usage in related references,", function () { var catalog_id = process.env.DEFAULT_CATALOG, schemaName = "comment_display_related_schema", limit = 1; - describe("testing comment and comment_display for simple foreign key", function() { + describe("for simple foreign key", function() { var tableSimpleFKName = "comment_display_simple_fk_table"; @@ -72,40 +77,45 @@ exports.execute = function (options) { }); - describe("for comment,", function () { - it("source syntax in visible foreign keys should be used first", function () { - expect(simpleReference.related[0].comment).toBe("simple fk source syntax comment"); - }); - - it("then the from_comment in foreign-key annotation", function () { - expect(simpleReference.related[1].comment).toBe("simple fk from_comment comment"); - }); - - it("next use display annotation on leaf table", function () { - expect(simpleReference.related[3].comment).toBe("simple fk leaf table display comment"); + it("source syntax in visible foreign keys should be used first", () => { + expect(simpleReference.related[0].comment).toEqual({ + value: "simple fk source syntax comment", + unformatted: "simple fk source syntax comment", + isHTML: false, + displayMode: 'inline' }); }); - describe("for comment_display,", function () { - it("source syntax in visible foreign keys should be used first", function () { - expect(simpleReference.related[0].commentDisplay).toBe("inline"); - }); - - it("then the from_comment_display property in foreign-key annotation if from_comment was defined", function () { - expect(simpleReference.related[1].commentDisplay).toBe("inline"); + it("next from_comment and from_comment_display should be used.", () => { + expect(simpleReference.related[1].comment).toEqual({ + value: "

simple fk from_comment comment

\n", + unformatted: "simple fk from_comment comment", + isHTML: true, + displayMode: 'inline' }); + }); - it("ignore the from_comment_display property if from_comment is not defined", function () { - expect(simpleReference.related[2].commentDisplay).toBe("tooltip"); + it("by default the leaf table comment and comment_display should be used.", function () { + expect(simpleReference.related[3].comment).toEqual({ + value: 'simple fk leaf table display comment', + unformatted: 'simple fk leaf table display comment', + isHTML: false, + displayMode: 'inline' }); + }); - it("next use display annotation on leaf table", function () { - expect(simpleReference.related[3].commentDisplay).toBe("inline"); + it ('if from_comment_display is defined but not the from_comment, leaf table comment and this proeprty should be mixed', () => { + expect(simpleReference.related[2].comment).toEqual({ + value: "

table with simple key to reference and a foreign key annotation with no from comment display

\n", + unformatted: "table with simple key to reference and a foreign key annotation with no from comment display", + isHTML: true, + displayMode: 'inline' }); }); + }); - describe("testing comment and comment_display for pure and binary relation", function() { + describe("for pure and binary relation", function() { var tablePBName = "comment_display_pb_table"; @@ -132,41 +142,46 @@ exports.execute = function (options) { }); - describe("for comment,", function () { - it("source syntax in visible foreign keys should be used first", function () { - expect(pBReference.related[0].comment).toBe("pure and binary fk source syntax comment"); - }); - - it("then the to_comment in foreign-key annotation", function () { - expect(pBReference.related[1].comment).toBe("pure and binary fk to_comment"); - }); - - it("next use display annotation on leaf table", function () { - expect(pBReference.related[3].comment).toBe("pure and binary fk leaf table display comment"); + it("source syntax in visible-columns should be used first", () => { + expect(pBReference.related[0].comment).toEqual({ + value: "pure and binary fk source syntax comment", + unformatted: "pure and binary fk source syntax comment", + isHTML: false, + displayMode: 'inline' }); }); - describe("for comment_display,", function () { - it("source syntax in visible foreign keys should be used first", function () { - expect(pBReference.related[0].commentDisplay).toBe("inline"); - }); - - it("then the to_comment_display property in foreign-key annotation if to_comment was defined", function () { - expect(pBReference.related[1].commentDisplay).toBe("inline"); + it("next to_comment and to_comment_display should be used.", () => { + expect(pBReference.related[1].comment).toEqual({ + value: "

pure and binary fk to_comment

\n", + unformatted: "pure and binary fk to_comment", + isHTML: true, + displayMode: 'inline' }); + }); - it("ignore the to_comment_display property if to_comment is not defined", function () { - expect(pBReference.related[2].commentDisplay).toBe("tooltip"); + it("next the leaf table comment and comment_display should be used.", function () { + expect(pBReference.related[3].comment).toEqual({ + value: 'pure and binary fk leaf table display comment', + unformatted: 'pure and binary fk leaf table display comment', + isHTML: false, + displayMode: 'inline' }); + }); - it("next use display annotation on leaf table", function () { - expect(pBReference.related[3].commentDisplay).toBe("inline"); + it ('if to_comment_display is defined but not the to_comment, leaf table comment and this proeprty should be mixed', () => { + expect(pBReference.related[2].comment).toEqual({ + value: "

foreign key to association table no display

\n", + unformatted: "foreign key to association table no display", + isHTML: true, + displayMode: 'inline' }); }); + }); // tests for pseudocolumn functionality when used for a related table - describe("testing comment and comment_display for multi hop foreign key", function() { + describe("for multi hop foreign key", function() { var tablePBName = "comment_display_pb_table"; @@ -193,28 +208,39 @@ exports.execute = function (options) { }); - describe("for comment,", function () { - it("source syntax in visible foreign keys should be used first", function () { - expect(multiHopReference.related[4].comment).toBe("multi hop fk source syntax comment"); - }); - - it("next use display annotation on leaf table", function () { - expect(multiHopReference.related[6].comment).toBe("multi hop fk leaf table display comment"); + it("source syntax in visible-columns should be used first", () => { + expect(multiHopReference.related[4].comment).toEqual({ + isHTML: false, + unformatted: "multi hop fk source syntax comment", + value: "multi hop fk source syntax comment", + displayMode: 'inline' }); + }); - it("next use comment on leaf table,", function () { - expect(multiHopReference.related[5].comment).toBe("foreign key to association table with comment_display and no comment"); + it("next use display annotation on leaf table", function () { + expect(multiHopReference.related[6].comment).toEqual({ + isHTML: true, + unformatted: "multi hop fk leaf table display comment", + value: "

multi hop fk leaf table display comment

\n", + displayMode: 'inline' }); }); - describe("for comment_display,", function () { - it("source syntax in visible foreign keys should be used first", function () { - expect(multiHopReference.related[4].commentDisplay).toBe("inline"); + it("next use comment on leaf table model while using comment_display and markdown of display annotation,", function () { + expect(multiHopReference.related[5].comment).toEqual({ + isHTML: false, + unformatted: "foreign key to association table with comment_display and no comment", + value: "foreign key to association table with comment_display and no comment", + displayMode: 'inline' }); + }); - it("next use display annotation on leaf table", function () { - expect(multiHopReference.related[5].commentDisplay).toBe("inline", "missmatch for index=5"); - expect(multiHopReference.related[6].commentDisplay).toBe("inline", "missmatch for index=6"); + it("next use comment on leaf table model and display annotation of catalog,", function () { + expect(multiHopReference.related[7].comment).toEqual({ + isHTML: true, + unformatted: "foreign key to association table with no leaf display", + value: "

foreign key to association table with no leaf display

\n", + displayMode: 'tooltip' }); }); });