blob: 5189ea54406ad27278e760bfc63d6856896b1a6d [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>
Matteo Scandolod67adee2018-03-08 16:27:05 -080021 <span class="read-only" ng-if="vm.field.read_only">read only</span>
Matteo Scandolo80056232017-07-10 16:24:41 -070022</label>
Matteo Scandolod67adee2018-03-08 16:27:05 -080023
24<div ng-if="vm.field.read_only">
25 <pre class="form-control" readonly>{{vm.ngModel || ""}}</pre>
Matteo Scandoloee655a12016-12-19 15:38:43 -080026</div>
Matteo Scandolod67adee2018-03-08 16:27:05 -080027
28<div ng-if="!vm.field.read_only">
29 <input
30 xos-custom-validator custom-validator="vm.field.validators.custom || null"
31 ng-if="vm.field.type !== 'boolean' && vm.field.type !== 'object' && vm.field.type !== 'select' && vm.field.type !== 'array'"
32 type="{{vm.field.type}}"
33 name="{{vm.name}}"
34 class="form-control"
35 ng-model="vm.ngModel"
36 ng-minlength="vm.field.validators.minlength || 0"
37 ng-maxlength="vm.field.validators.maxlength || 2000"
38 ng-required="vm.field.validators.required || false" />
39 <select class="form-control" ng-if="vm.field.type === 'select'"
40 name = "{{vm.name}}"
41 ng-options="item.id as item.label for item in vm.field.options"
42 ng-model="vm.ngModel"
43 ng-required="vm.field.validators.required || false">
44 </select>
45 <span class="boolean-field" ng-if="vm.field.type === 'boolean'">
46 <a
47 class="btn btn-success"
48 ng-show="vm.ngModel"
49 ng-click="vm.ngModel = false">
50 <i class="fa fa-check"></i>
51 </a>
52 <a
53 class="btn btn-danger"
54 ng-show="!vm.ngModel"
55 ng-click="vm.ngModel = true">
56 <i class="fa fa-remove"></i>
57 </a>
58 </span>
59 <div
60 class="panel panel-default object-field"
61 ng-if="vm.field.type == 'object' && (!vm.isEmptyObject(vm.ngModel) || !vm.isEmptyObject(vm.field.properties))"
62 >
63 <div class="panel-heading">{{vm.field.label}}</div>
64 <div class="panel-body">
65 <div ng-if="!vm.field.properties" ng-repeat="(k, v) in vm.ngModel">
66 <xos-field
67 name="k"
68 field="{label: vm.formatLabel(k), type: vm.getType(v)}"
69 ng-model="v">
70 </xos-field>
71 </div>
72 <div ng-if="vm.field.properties" ng-repeat="(k, v) in vm.field.properties">
73 <xos-field
74 name="k"
75 field="{
76 label: v.label || vm.formatLabel(k),
77 type: v.type,
78 validators: v.validators
79 }"
80 ng-model="vm.ngModel[k]">
81 </xos-field>
82 </div>
83 </div>
Matteo Scandoloee655a12016-12-19 15:38:43 -080084 </div>
Matteo Scandolod67adee2018-03-08 16:27:05 -080085 <div
86 class="panel panel-default array-field"
87 ng-if="vm.field.type == 'array'">
88 <div class="panel-heading">{{vm.field.label}}</div>
89 <div class="panel-body selected">
90 <ul class="draggable" dnd-list="vm.ngModel">
91 <li
92 class="array-element"
93 ng-repeat="item in vm.ngModel"
94 dnd-draggable="item"
95 dnd-moved="vm.ngModel.splice($index, 1)"
96 dnd-effect-allowed="move"
97 dnd-selected="models.selected = item"
98 >
99 <div class="well well-sm text-center">
100 {{item}}
101 </div>
102 </li>
103 <div class="clearfix"></div>
104 </ul>
105 </div>
106 <div class="panel-body unselected">
107 <ul class="draggable" dnd-list="vm.field.availableOptions">
108 <li
109 class="array-element"
110 ng-repeat="item in vm.field.availableOptions"
111 dnd-draggable="item"
112 dnd-moved="vm.field.availableOptions.splice($index, 1)"
113 dnd-effect-allowed="move"
114 dnd-selected="models.selected = item"
115 >
116 <div class="well well-sm text-center">
117 {{item}}
118 </div>
119 </li>
120 <div class="clearfix"></div>
121 </ul>
122 </div>
Matteo Scandoloee655a12016-12-19 15:38:43 -0800123 </div>
124</div>