Skip to content

Commit

Permalink
Add support for deprecated keyword
Browse files Browse the repository at this point in the history
Highlight deprecated(orange)
Add to legend
  • Loading branch information
jlblcc committed Sep 28, 2015
1 parent 3b6b622 commit b87860b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
18 changes: 14 additions & 4 deletions json-schema-viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,8 @@ if (typeof JSV === 'undefined') {
opacity: real ? 1 : 0.5,
required: s.required,
schema: s.id || schema.$ref || parentSchema(parent),
parentSchema: parent
parentSchema: parent,
deprecated: schema.deprecated || s.deprecated
};

node.require = parent && parent.required ? parent.required.indexOf(node.name) > -1 : false;
Expand Down Expand Up @@ -952,7 +953,9 @@ if (typeof JSV === 'undefined') {
if(!JSV.plain) {
JSV.setPermalink(d);

$('#info-title').text('Info: ' + d.name);
$('#info-title')
.text('Info: ' + d.name)
.toggleClass('deprecated', d.deprecated);
JSV.setInfo(d);
panel.panel( 'open' );
}
Expand Down Expand Up @@ -1096,6 +1099,9 @@ if (typeof JSV === 'undefined') {
.attr('class', function(d) {
return JSV.labels[d.name] ? 'node label' : 'node';
})
.classed('deprecated', function(d) {
return d.deprecated;
})
.attr('id', function(d, i) {
return 'n-' + d.id;
})
Expand Down Expand Up @@ -1303,12 +1309,16 @@ if (typeof JSV === 'undefined') {
itemCls: 'abstract',
y: 140,
opacity: 0.5
},{
text: 'Deprecated',
itemCls: 'deprecated',
y: 160
}];


var legendSvg = d3.select('#legend-items').append('svg')
//.attr('width', viewerWidth)
.attr('height', 160);
.attr('width', 170)
.attr('height', 180);

// Update the nodes…
var legendItem = legendSvg.selectAll('g.item-group')
Expand Down
8 changes: 8 additions & 0 deletions styles/sass/json-schema-viewer.scss
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,14 @@ p.ui-content.error-message {
stroke-width: 3px;
}

.deprecated {
color: orange;

text {
fill: orange;
}
}

.link {
fill: none;
stroke: #ccc;
Expand Down

0 comments on commit b87860b

Please sign in to comment.