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> |
| 21 | </label> |
Matteo Scandolo | ee655a1 | 2016-12-19 15:38:43 -0800 | [diff] [blame] | 22 | <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 Scandolo | e7e052d | 2017-07-31 19:54:31 -0700 | [diff] [blame] | 32 | <select class="form-control" ng-if="vm.field.type === 'select'" |
Matteo Scandolo | ee655a1 | 2016-12-19 15:38:43 -0800 | [diff] [blame] | 33 | 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> |