Matteo Scandolo | 8005623 | 2017-07-10 16:24:41 -0700 | [diff] [blame] | 1 | <label ng-if="vm.field.type !== 'object' && vm.field.type !== 'array'"> |
| 2 | {{vm.field.label}} |
| 3 | <span class="required" ng-if="vm.field.validators.required">*</span> |
| 4 | </label> |
Matteo Scandolo | ee655a1 | 2016-12-19 15:38:43 -0800 | [diff] [blame] | 5 | <input |
| 6 | xos-custom-validator custom-validator="vm.field.validators.custom || null" |
| 7 | ng-if="vm.field.type !== 'boolean' && vm.field.type !== 'object' && vm.field.type !== 'select' && vm.field.type !== 'array'" |
| 8 | type="{{vm.field.type}}" |
| 9 | name="{{vm.name}}" |
| 10 | class="form-control" |
| 11 | ng-model="vm.ngModel" |
| 12 | ng-minlength="vm.field.validators.minlength || 0" |
| 13 | ng-maxlength="vm.field.validators.maxlength || 2000" |
| 14 | ng-required="vm.field.validators.required || false" /> |
Matteo Scandolo | e7e052d | 2017-07-31 19:54:31 -0700 | [diff] [blame] | 15 | <select class="form-control" ng-if="vm.field.type === 'select'" |
Matteo Scandolo | ee655a1 | 2016-12-19 15:38:43 -0800 | [diff] [blame] | 16 | name = "{{vm.name}}" |
| 17 | ng-options="item.id as item.label for item in vm.field.options" |
| 18 | ng-model="vm.ngModel" |
| 19 | ng-required="vm.field.validators.required || false"> |
| 20 | </select> |
| 21 | <span class="boolean-field" ng-if="vm.field.type === 'boolean'"> |
| 22 | <a |
| 23 | class="btn btn-success" |
| 24 | ng-show="vm.ngModel" |
| 25 | ng-click="vm.ngModel = false"> |
| 26 | <i class="fa fa-check"></i> |
| 27 | </a> |
| 28 | <a |
| 29 | class="btn btn-danger" |
| 30 | ng-show="!vm.ngModel" |
| 31 | ng-click="vm.ngModel = true"> |
| 32 | <i class="fa fa-remove"></i> |
| 33 | </a> |
| 34 | </span> |
| 35 | <div |
| 36 | class="panel panel-default object-field" |
| 37 | ng-if="vm.field.type == 'object' && (!vm.isEmptyObject(vm.ngModel) || !vm.isEmptyObject(vm.field.properties))" |
| 38 | > |
| 39 | <div class="panel-heading">{{vm.field.label}}</div> |
| 40 | <div class="panel-body"> |
| 41 | <div ng-if="!vm.field.properties" ng-repeat="(k, v) in vm.ngModel"> |
| 42 | <xos-field |
| 43 | name="k" |
| 44 | field="{label: vm.formatLabel(k), type: vm.getType(v)}" |
| 45 | ng-model="v"> |
| 46 | </xos-field> |
| 47 | </div> |
| 48 | <div ng-if="vm.field.properties" ng-repeat="(k, v) in vm.field.properties"> |
| 49 | <xos-field |
| 50 | name="k" |
| 51 | field="{ |
| 52 | label: v.label || vm.formatLabel(k), |
| 53 | type: v.type, |
| 54 | validators: v.validators |
| 55 | }" |
| 56 | ng-model="vm.ngModel[k]"> |
| 57 | </xos-field> |
| 58 | </div> |
| 59 | </div> |
| 60 | </div> |
| 61 | <div |
| 62 | class="panel panel-default array-field" |
| 63 | ng-if="vm.field.type == 'array'"> |
| 64 | <div class="panel-heading">{{vm.field.label}}</div> |
| 65 | <div class="panel-body selected"> |
| 66 | <ul class="draggable" dnd-list="vm.ngModel"> |
| 67 | <li |
| 68 | class="array-element" |
| 69 | ng-repeat="item in vm.ngModel" |
| 70 | dnd-draggable="item" |
| 71 | dnd-moved="vm.ngModel.splice($index, 1)" |
| 72 | dnd-effect-allowed="move" |
| 73 | dnd-selected="models.selected = item" |
| 74 | > |
| 75 | <div class="well well-sm text-center"> |
| 76 | {{item}} |
| 77 | </div> |
| 78 | </li> |
| 79 | <div class="clearfix"></div> |
| 80 | </ul> |
| 81 | </div> |
| 82 | <div class="panel-body unselected"> |
| 83 | <ul class="draggable" dnd-list="vm.field.availableOptions"> |
| 84 | <li |
| 85 | class="array-element" |
| 86 | ng-repeat="item in vm.field.availableOptions" |
| 87 | dnd-draggable="item" |
| 88 | dnd-moved="vm.field.availableOptions.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> |