Skip to content

Commit 16ed432

Browse files
committed
fix issues in the tests and code + add documentation
1 parent 2c7c911 commit 16ed432

File tree

9 files changed

+444
-202
lines changed

9 files changed

+444
-202
lines changed

docs/user-docs/annotation.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ element and its nested model elements.
9191
Supported JSON payload patterns:
9292

9393
- `{`... `"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.
94-
- `{`... `"comment_display":` `{` _context_: `{` `"table_comment_display"`: _comment_display_ `,` `"column_comment_display"`: _comment_display_ `}` ... `}`
94+
- `{`... `"comment_display":` `{` _context_: `{` `"table_comment_display"`: _comment_display_ `,` `"column_comment_display"`: _comment_display_ `,` `"comment_render_markdown"`: _comment_render_markdown_ `}` ... `}`
9595
- `{`... `"name":` _name_ ...`}`: The _name_ to use in place of the model element's original name.
9696
- `{`... `"markdown_name"`: _markdown_ `}`: The _markdown_ to use in place of the model element's original name.
9797
- `{`... `"name_style":` `{` `"underline_space"`: _uspace_ `,` `"title_case":` _tcase_ `,` `"markdown"`: _render_ `}` ...`}`: Element name conversion instructions.
@@ -111,6 +111,11 @@ Supported JSON _comment_display_ patterns:
111111
- `tooltip`: Set to tooltip to show the comment as a hover over tooltip.
112112
- `inline`: Set to inline to show the comment as an inline tooltip.
113113

114+
Supported JSON _comment_render_markdown_ patterns:
115+
116+
- `false`: Don't treat the defined `comment` on this model and its descendants as markdown.
117+
- `true`: Treat the defined `comment` on this model and its descendants as markdown.
118+
114119
Supported JSON _uspace_ patterns:
115120

116121
- `true`: Convert underline characters (`_`) into space characters in model element names.
@@ -158,7 +163,7 @@ Supported JSON _context_ patterns:
158163
#### Tag: 2015 Display Settings Hierarchy
159164

160165
- The `"comment"` setting applies *only* to the model element which is annotated.
161-
- Currently the contextualized `comment` is only supported for tables.
166+
- 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.
162167
- The `"table_comment_display"` and `"column_comment_display"` setting applies *only* to the model element which is annotated.
163168
- 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`.
164169
- `column_comment_display` is accepted as a parameter, but currently doesn't do anything.
@@ -426,6 +431,7 @@ Supported JSON payload patterns:
426431
- `{` ... `"from_name":` _fname_ ... `}`: The _fname_ string is a preferred name for the set of entities containing foreign key references described by this constraint.
427432
- `{` ... `"to_name":` _tname_ ... `}`: The _tname_ string is a preferred name for the set of entities containing keys described by this constraint.
428433
- `{` ... `"from_comment":` _comment_ ... `}`: The _comment_ string is a preferred comment for the set of entities containing keys described by this constraint.
434+
- `{` ... `"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).
429435
- `{` ... `"to_comment":` _comment_ ... `}`: The _comment_ string is a preferred comment for the set of entities containing keys described by this constraint.
430436
- `{` ... `"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.
431437
- 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
13001306

13011307
- `markdown_name`: The markdown to use in place of the default heuristics for title of column.
13021308
- `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.
1309+
- `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).
13031310
- `comment_display`: The display mode for the tooltip. Set to `inline` to show it as text or `tooltip` to show as a hover tooltip.
13041311
- Currently `comment_display` is only supported for related tables in detailed context.
13051312
- `hide_column_header`: Hide the column header (and still show the value). This is only supported in `detailed` context of `visible-columns` annotation.

docs/user-docs/column-directive.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ Column directive allows instruction of a data source and modification of its pre
2323
- [2. Presentation properties](#2-presentation-properties)
2424
- [markdown\_name](#markdown_name)
2525
- [comment](#comment)
26+
- [comment\_render\_markdown](#comment-render-markdown)
2627
- [comment\_display](#comment_display)
2728
- [hide\_column\_header](#hide_column_header)
2829
- [self-link](#self-link)
@@ -359,6 +360,14 @@ In Chaise, comment is displayed as tooltip associated with columns. To change th
359360

360361
"comment": "New comment"
361362

363+
#### comment_render_markdown
364+
365+
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.
366+
367+
"comment_render_markdown": false
368+
369+
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.
370+
362371
#### comment_display
363372

364373
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
404413

405414
##### selector_ux_mode
406415

407-
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.
416+
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.
408417

409418
##### show_key_link
410419

js/column.js

Lines changed: 31 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -294,15 +294,20 @@ ReferenceColumn.prototype = {
294294
var comment = null, commentDisplayMode, commentRenderMarkdown;
295295
if (this._simple) {
296296
var display = this._baseCols[0].getDisplay(this._context);
297-
comment = display.comment ? display.comment.unformatted : null;
297+
comment = display.comment;
298298
commentDisplayMode = display.commentDisplayMode;
299299
commentRenderMarkdown = display.commentRenderMarkdown;
300300
}
301301

302302
if (!this.sourceObject) {
303303
this._comment = comment;
304304
} else {
305-
this._comment = _processSourceObjectComment(this.sourceObject, comment, commentRenderMarkdown, commentDisplayMode);
305+
this._comment = _processSourceObjectComment(
306+
this.sourceObject,
307+
comment ? comment.unformatted : null,
308+
commentRenderMarkdown,
309+
commentDisplayMode
310+
);
306311
}
307312

308313
}
@@ -1351,42 +1356,43 @@ PseudoColumn.prototype._determineInputDisabled = function () {
13511356
Object.defineProperty(PseudoColumn.prototype, "comment", {
13521357
get: function () {
13531358
if (this._comment === undefined) {
1354-
var getDefaultCommentProps = function (self) {
1359+
var getComment = function (self) {
13551360
if (self.hasAggregate) {
1361+
// if defined on the sourceObject use it.
1362+
var com = _processSourceObjectComment(self.sourceObject);
1363+
if (com) {
1364+
return com;
1365+
}
1366+
1367+
// otherwise generate one
13561368
var agIndex = module._pseudoColAggregateFns.indexOf(self.sourceObject.aggregate);
13571369
var dname = self._baseCols[0].displayname.unformatted;
13581370
if (self.isEntityMode) {
13591371
dname = self._baseCols[0].table.displayname.unformatted;
13601372
}
13611373

1362-
return {
1363-
comment: [module._pseudoColAggregateExplicitName[agIndex], dname].join(" "),
1364-
commentDisplayMode: module._commentDisplayModes.tooltip,
1365-
commentRenderMarkdown: false
1366-
};
1374+
return _processModelComment([module._pseudoColAggregateExplicitName[agIndex], dname].join(" "), false);
13671375
}
13681376

1369-
var temp;
1377+
// if it's not aggregate, we can get it from the table or column depending on entity mode:
1378+
var disp, commentDisplayMode;
13701379
if (!self.isEntityMode) {
1371-
temp = self._baseCols[0].getDisplay(self._context);
1372-
return {
1373-
comment: temp.comment ? temp.comment.unformatted: null,
1374-
commentDisplayMode: temp.commentDisplayMode,
1375-
commentRenderMarkdown: temp.commentRenderMarkdown
1376-
};
1380+
disp = self._baseCols[0].getDisplay(self._context);
1381+
commentDisplayMode = disp.commentDisplayMode;
1382+
} else {
1383+
disp = self.table.getDisplay(self._context);
1384+
commentDisplayMode = disp.tableCommentDisplayMode;
13771385
}
13781386

1379-
// self.table should be leaf table
1380-
temp = self.table.getDisplay(self._context);
1381-
return {
1382-
comment: temp.comment ? temp.comment.unformatted: null,
1383-
commentDisplayMode: temp.tableCommentDisplayMode,
1384-
commentRenderMarkdown: temp.commentRenderMarkdown
1385-
};
1386-
};
1387+
return _processSourceObjectComment(
1388+
self.sourceObject,
1389+
disp.comment ? disp.comment.unformatted : null,
1390+
disp.commentRenderMarkdown,
1391+
commentDisplayMode
1392+
);
1393+
}
13871394

1388-
var def = getDefaultCommentProps(this);
1389-
this._comment = _processSourceObjectComment(this.sourceObject, def.comment, def.commentRenderMarkdown, def.commentDisplayMode);
1395+
this._comment = getComment(this);
13901396
}
13911397
return this._comment;
13921398
}

js/reference.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4087,7 +4087,7 @@
40874087

40884088
// comment
40894089
if (fkDisplay.fromComment) {
4090-
comment = fkDisplay.fromComment;
4090+
comment = fkDisplay.fromComment.unformatted;
40914091
} else {
40924092
comment = tableDisplay.comment ? tableDisplay.comment.unformatted : null;
40934093
}

js/utils/helpers.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -848,11 +848,10 @@
848848
};
849849

850850
/**
851-
* Given an input string for the comment, will return the actual strng that should be used.
852-
* - if =false : returns empty string.
853-
* - if =string: returns the string.
854-
* - otherwise returns null
855-
* TODO update comment
851+
* Turn a comment annotaiton/string value into a proper comment object.
852+
* @param {string|null|false} comment
853+
* @param {boolean=true} isMarkdown whether the given comment should be rendered as markdown (default: true).
854+
* @param {string} displayMode the display mode of the comment (inline, tooltip)
856855
* @private
857856
*/
858857
_processModelComment = function (comment, isMarkdown, displayMode) {

0 commit comments

Comments
 (0)