-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathexample.js
More file actions
139 lines (127 loc) · 4.41 KB
/
example.js
File metadata and controls
139 lines (127 loc) · 4.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
/**
* Created by Nicklas B on 2016-01-13.
*/
/*global angular */
"use strict";
/**
* The main app module
* @name exampleApp
* @type {angular.Module}
*/
var exampleApp = angular.module("exampleApp", ["schemaForm"]);
exampleApp.controller("exampleController", ["$scope", function ($scope) {
// This function returns the schema and form for the field.
$scope.getDefinitions = function(_ref) {
return {
schema:
{
type: "object",
title: "Complex UI test",
properties: {
test1: {
"properties": {
"delete": {
"type": "boolean"
},
"insert": {
"type": "boolean"
},
"mappings": {
"items": {
"properties": {
"dest_reference": {
"type": "string"
},
"is_key": {
"type": "boolean"
},
"src_datatype": {
"type": "string"
},
"src_reference": {
"type": "string"
},
"substitution": {
"properties": {},
"type": "object"
}
},
"type": "object"
},
"type": "array"
},
"post_execute_sql": {
"type": "string"
},
"update": {
"type": "boolean"
}
},
"type": "object"
},
test2: {
type: "string",
description: "...second field"
}
},
required: ["test1"]
},
form : ["*"]
}
};
// This is the schema definition for the whole thing.
$scope.schema = {
type: "object",
title: "Complex UI ",
properties: {
complexUIField: {
type: "object",
format: "",
description: "So this is a complex UI field."
},
anyfield: {
type: "string",
format: "",
description: "This is just a run-of-the-mill string field."
}
},
required: ["complexUIField"]
};
// Define all UI aspects of the form (default for HTML class is modal-dialog, a little bit too tight in many cases)
$scope.form = [
{
"key": "complexUIField",
"title": "Example of complex structure editor",
"type": "complex-ui",
"options": {
"definitionsCallback": "getDefinitions",
"modal": true,
"buttonCaption": "..",
"includeURI": "example_include.html"
},
"onChange": $scope.onChange
},
{
"key": "anyfield",
"title": "A string",
"options": {
"definitionsCallback": "getDefinitions"
},
"onChange": $scope.onChange
},
{
type: "submit",
style: "btn-ok",
title: "OK outer"
}
];
$scope.onChange = function (modelValue, key) {
console.log("Value: " + modelValue + " Key:" + key)
};
// This is called by asf on submit, specified in example.html, ng-submit.
$scope.submitted = function (form) {
$scope.$broadcast("schemaFormValidate");
console.log($scope.model);
};
$scope.model = {"complexUIField" : {}}
}]);