-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathapp.js
125 lines (124 loc) · 3.11 KB
/
app.js
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
/*global angular */
'use strict';
/**
* The main app module
* @name app
* @type {angular.Module}
*/
var app = angular.module('app', ['angular-underscore/filters', 'schemaForm-uiselect', 'pascalprecht.translate', 'ui.sortable'])
.controller('SelectController', function($scope, $rootScope){
$scope.schema = {
type: 'object',
title: 'Select',
properties: {
name: {
title: 'Name',
type: 'string'
},
select: {
title: 'Single Select',
type: 'string',
format: 'uiselect',
description: 'Only single item is allowd',
items: [
{ value: 1, label: 'label1'},
{ value: 2, label: 'label2'},
{ value: 3, label: 'label3'}
]
},
number_select: {
title: 'Number Select',
type: 'number',
format: 'uiselect',
description: 'Only single item is allowd',
items: [
{ value: 1, label: 'label1'},
{ value: 2, label: 'label2'},
{ value: 3, label: 'label3'}
]
},
select2: {
title: 'Single Select',
type: 'string',
format: 'uiselect',
description: 'Only single item is allowd',
items: [
{ value: 'one', label: 'label1'},
{ value: 'two', label: 'label2'},
{ value: 'three', label: 'label3'}
]
},
multiselect: {
title: 'Multi Select',
type: 'array',
format: 'uiselect',
description: 'Multi single items arre allowd',
minItems: 1,
maxItems: 4,
items: [
{ value: 'one', label: 'label1'},
{ value: 'two', label: 'label2'},
{ value: 'three', label: 'label3'},
{ value: 'four', label: 'label4'},
{ value: 'five', label: 'label5'}
]
},
another: {
title: 'Multi Select 2',
type: 'array',
format: 'uiselect',
description: 'Multi single items arre allowd',
minItems: 1,
items: [
{ value: 'one', label: 'labelx'},
{ value: 'two', label: 'labelc'},
{ value: 'three', label: 'label3'}
]
}
},
required: ['select', 'select2', 'another', 'multiselect']
};
$scope.refreshSelect = function(schema, search) {
console.log('called');
console.log(search);
schema.items = [
{ value: 'one', label: 'labelx'},
{ value: 'two', label: 'labelc'},
{ value: 'three', label: 'label3'}
];
}
$scope.form = [
'name',
{
key: 'select',
options: {
uiClass: 'short',
refreshDelay: 100,
refreshMethod: $scope.refreshSelect
}
},
'number_select',
{
key: 'select2'
},
{
key: 'another'
},
{
key: 'multiselect',
options: {
uiClass: 'short',
refreshDelay: 100,
refreshMethod: $scope.refreshSelect
}
}
];
$scope.model = {
number_select: 1,
multiselect: ['three', 'one']
};
$scope.submitted = function(form){
$scope.$broadcast('schemaFormValidate')
console.log($scope.model);
};
});