Skip to content

Commit

Permalink
Merge pull request #14 from arno-di-loreto/feature/visual-indicator-r…
Browse files Browse the repository at this point in the history
…equired-property

Closes #10 : Node text in red when property is required
  • Loading branch information
arno-di-loreto authored Mar 4, 2018
2 parents b74952e + 06c1d45 commit 68e9d39
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
8 changes: 6 additions & 2 deletions data/3.0.1/Z_Object.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ Z Object:
description: |
Test description with a [link](http://apihandyman.io) and another [one](#openapi/).
fields:
- name: test
- name: required
type: string
required: true
description: |
Test properties with a [link](http://apihandyman.io) and another [one](#openapi/)
Test properties with a [link](http://apihandyman.io) and another [one](#openapi/)
- name: notRequired
type: string
description: Non required property
4 changes: 4 additions & 0 deletions web/static/css/tree.css
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,7 @@ div.tooltip {
margin-bottom: 20px;
padding-left: 0px;
}

.node .nodeRequired {
fill:red;
}
15 changes: 14 additions & 1 deletion web/static/js/drawTree.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
'use strict';
var template = OpenAPISpecificationVisualDocumentation.tooltip;

function getNodeTextClass(node) {
console.log('getNodeTextClass')
var result;
if(node.required) {
result = 'nodeRequired';
}
else {
result = 'nodeText';
}
console.log(node.name + ',' + node.required +':'+result);
return result;
}

function getStrokeColor(node) {
var color;
if (node.isTechnical) {
Expand Down Expand Up @@ -372,7 +385,7 @@ function drawTree(treeData){
return d.children || d.closedChildren ? -10 : 10;
})
.attr('dy', '.35em')
.attr('class', 'nodeText')
.attr('class', function(d){return getNodeTextClass(d);})
.attr('text-anchor', function(d) {
return d.children || d.closedChildren ? 'end' : 'start';
})
Expand Down

0 comments on commit 68e9d39

Please sign in to comment.