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