blob: a91665db1cfe07c735c91c0afbc3a06c54995973 [file] [log] [blame]
Matteo Scandolo500e4c42017-08-08 13:05:24 -07001
2<!--
3Copyright 2017-present Open Networking Foundation
4
5Licensed under the Apache License, Version 2.0 (the "License");
6you may not use this file except in compliance with the License.
7You may obtain a copy of the License at
8
9http://www.apache.org/licenses/LICENSE-2.0
10
11Unless required by applicable law or agreed to in writing, software
12distributed under the License is distributed on an "AS IS" BASIS,
13WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14See the License for the specific language governing permissions and
15limitations under the License.
16-->
17
Matteo Scandolo80056232017-07-10 16:24:41 -070018<label ng-if="vm.field.type !== 'object' && vm.field.type !== 'array'">
19 {{vm.field.label}}
20 <span class="required" ng-if="vm.field.validators.required">*</span>
21</label>
Matteo Scandoloee655a12016-12-19 15:38:43 -080022<input
23 xos-custom-validator custom-validator="vm.field.validators.custom || null"
24 ng-if="vm.field.type !== 'boolean' && vm.field.type !== 'object' && vm.field.type !== 'select' && vm.field.type !== 'array'"
25 type="{{vm.field.type}}"
26 name="{{vm.name}}"
27 class="form-control"
28 ng-model="vm.ngModel"
29 ng-minlength="vm.field.validators.minlength || 0"
30 ng-maxlength="vm.field.validators.maxlength || 2000"
31 ng-required="vm.field.validators.required || false" />
Matteo Scandoloe7e052d2017-07-31 19:54:31 -070032<select class="form-control" ng-if="vm.field.type === 'select'"
Matteo Scandoloee655a12016-12-19 15:38:43 -080033 name = "{{vm.name}}"
34 ng-options="item.id as item.label for item in vm.field.options"
35 ng-model="vm.ngModel"
36 ng-required="vm.field.validators.required || false">
37</select>
38<span class="boolean-field" ng-if="vm.field.type === 'boolean'">
39 <a
40 class="btn btn-success"
41 ng-show="vm.ngModel"
42 ng-click="vm.ngModel = false">
43 <i class="fa fa-check"></i>
44 </a>
45 <a
46 class="btn btn-danger"
47 ng-show="!vm.ngModel"
48 ng-click="vm.ngModel = true">
49 <i class="fa fa-remove"></i>
50 </a>
51 </span>
52<div
53 class="panel panel-default object-field"
54 ng-if="vm.field.type == 'object' && (!vm.isEmptyObject(vm.ngModel) || !vm.isEmptyObject(vm.field.properties))"
55>
56 <div class="panel-heading">{{vm.field.label}}</div>
57 <div class="panel-body">
58 <div ng-if="!vm.field.properties" ng-repeat="(k, v) in vm.ngModel">
59 <xos-field
60 name="k"
61 field="{label: vm.formatLabel(k), type: vm.getType(v)}"
62 ng-model="v">
63 </xos-field>
64 </div>
65 <div ng-if="vm.field.properties" ng-repeat="(k, v) in vm.field.properties">
66 <xos-field
67 name="k"
68 field="{
69 label: v.label || vm.formatLabel(k),
70 type: v.type,
71 validators: v.validators
72 }"
73 ng-model="vm.ngModel[k]">
74 </xos-field>
75 </div>
76 </div>
77</div>
78<div
79 class="panel panel-default array-field"
80 ng-if="vm.field.type == 'array'">
81 <div class="panel-heading">{{vm.field.label}}</div>
82 <div class="panel-body selected">
83 <ul class="draggable" dnd-list="vm.ngModel">
84 <li
85 class="array-element"
86 ng-repeat="item in vm.ngModel"
87 dnd-draggable="item"
88 dnd-moved="vm.ngModel.splice($index, 1)"
89 dnd-effect-allowed="move"
90 dnd-selected="models.selected = item"
91 >
92 <div class="well well-sm text-center">
93 {{item}}
94 </div>
95 </li>
96 <div class="clearfix"></div>
97 </ul>
98 </div>
99 <div class="panel-body unselected">
100 <ul class="draggable" dnd-list="vm.field.availableOptions">
101 <li
102 class="array-element"
103 ng-repeat="item in vm.field.availableOptions"
104 dnd-draggable="item"
105 dnd-moved="vm.field.availableOptions.splice($index, 1)"
106 dnd-effect-allowed="move"
107 dnd-selected="models.selected = item"
108 >
109 <div class="well well-sm text-center">
110 {{item}}
111 </div>
112 </li>
113 <div class="clearfix"></div>
114 </ul>
115 </div>
116</div>