Matteo Scandolo | 500e4c4 | 2017-08-08 13:05:24 -0700 | [diff] [blame] | 1 | |
| 2 | <!-- |
| 3 | Copyright 2017-present Open Networking Foundation |
| 4 | |
| 5 | Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | you may not use this file except in compliance with the License. |
| 7 | You may obtain a copy of the License at |
| 8 | |
| 9 | http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | |
| 11 | Unless required by applicable law or agreed to in writing, software |
| 12 | distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | See the License for the specific language governing permissions and |
| 15 | limitations under the License. |
| 16 | --> |
| 17 | |
Matteo Scandolo | 8005623 | 2017-07-10 16:24:41 -0700 | [diff] [blame] | 18 | <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 Scandolo | d67adee | 2018-03-08 16:27:05 -0800 | [diff] [blame] | 21 | <span class="read-only" ng-if="vm.field.read_only">read only</span> |
Matteo Scandolo | 8005623 | 2017-07-10 16:24:41 -0700 | [diff] [blame] | 22 | </label> |
Matteo Scandolo | d67adee | 2018-03-08 16:27:05 -0800 | [diff] [blame] | 23 | |
| 24 | <div ng-if="vm.field.read_only"> |
| 25 | <pre class="form-control" readonly>{{vm.ngModel || ""}}</pre> |
Matteo Scandolo | ee655a1 | 2016-12-19 15:38:43 -0800 | [diff] [blame] | 26 | </div> |
Matteo Scandolo | d67adee | 2018-03-08 16:27:05 -0800 | [diff] [blame] | 27 | |
| 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 Scandolo | ee655a1 | 2016-12-19 15:38:43 -0800 | [diff] [blame] | 84 | </div> |
Matteo Scandolo | d67adee | 2018-03-08 16:27:05 -0800 | [diff] [blame] | 85 | <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 Scandolo | ee655a1 | 2016-12-19 15:38:43 -0800 | [diff] [blame] | 123 | </div> |
| 124 | </div> |