Skip to content

Commit f73bee2

Browse files
authored
Merge pull request eugenp#581 from ivanp81/master
Add JSONForms example
2 parents 5975a65 + cc9370e commit f73bee2

5 files changed

Lines changed: 102 additions & 0 deletions

File tree

‎json/src/main/webapp/index.html‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<!DOCTYPE html>
2+
<html ng-app="jsonforms-intro">
3+
<head>
4+
<title>Introduction to JSONForms</title>
5+
<script src="node_modules/jsonforms/dist/jsonforms.js" type="text/javascript"></script>
6+
<script src="js/app.js" type="text/javascript"></script>
7+
<script src="js/schema.js" type="text/javascript"></script>
8+
<script src="js/ui-schema.js" type="text/javascript"></script>
9+
</head>
10+
<body>
11+
<div class="container" ng-controller="MyController">
12+
<div class="row" id="demo">
13+
<div class="col-sm-12">
14+
<div class="panel-primary panel-default">
15+
<div class="panel-heading">
16+
<h3 class="panel-title"><strong>Introduction to JSONForms</strong></h3>
17+
</div>
18+
<div class="panel-body jsf">
19+
Bound data: {{data}}
20+
<jsonforms schema="schema" ui-schema="uiSchema" data="data"/>
21+
</div>
22+
</div>
23+
</div>
24+
</div>
25+
</div>
26+
</body>
27+
</html>

‎json/src/main/webapp/js/app.js‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
'use strict';
2+
3+
var app = angular.module('jsonforms-intro', ['jsonforms']);
4+
app.controller('MyController', ['$scope', 'Schema', 'UISchema', function($scope, Schema, UISchema) {
5+
6+
$scope.schema = Schema;
7+
8+
$scope.uiSchema = UISchema;
9+
10+
$scope.data = {
11+
"id": 1,
12+
"name": "Lampshade",
13+
"price": 1.85
14+
};
15+
}]);

‎json/src/main/webapp/js/schema.js‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
'use strict';
2+
3+
var app = angular.module('jsonforms-intro');
4+
app.value('Schema',
5+
{
6+
"$schema": "http://json-schema.org/draft-04/schema#",
7+
"title": "Product",
8+
"description": "A product from the catalog",
9+
"type": "object",
10+
"properties": {
11+
"id": {
12+
"description": "The unique identifier for a product",
13+
"type": "integer"
14+
},
15+
"name": {
16+
"description": "Name of the product",
17+
"type": "string"
18+
},
19+
"price": {
20+
"type": "number",
21+
"minimum": 0,
22+
"exclusiveMinimum": true
23+
}
24+
},
25+
"required": ["id", "name", "price"]
26+
}
27+
);
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
'use strict';
2+
3+
var app = angular.module('jsonforms-intro');
4+
app.value('UISchema',
5+
{
6+
"type": "HorizontalLayout",
7+
"elements": [
8+
{
9+
"type": "Control",
10+
"scope": { "$ref": "#/properties/id" }
11+
},
12+
{
13+
"type": "Control",
14+
"scope": { "$ref": "#/properties/name" }
15+
},
16+
{
17+
"type": "Control",
18+
"scope": { "$ref": "#/properties/price" }
19+
},
20+
]
21+
}
22+
);

‎json/src/main/webapp/package.json‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"name": "jsonforms-intro",
3+
"description": "Introduction to JSONForms",
4+
"version": "0.0.1",
5+
"license": "MIT",
6+
"dependencies": {
7+
"typings": "0.6.5",
8+
"jsonforms": "0.0.19",
9+
"bootstrap": "3.3.6"
10+
}
11+
}

0 commit comments

Comments
 (0)