|
| 1 | +/** |
| 2 | + * TODO: starting form in tabarray, and arrays. |
| 3 | + */ |
1 | 4 | angular.module('schemaForm').config(['schemaFormDecoratorsProvider', 'sfBuilderProvider', 'sfPathProvider',
|
2 | 5 | function(decoratorsProvider, sfBuilderProvider, sfPathProvider) {
|
3 | 6 | var base = 'decorators/bootstrap/';
|
@@ -32,13 +35,32 @@ function(decoratorsProvider, sfBuilderProvider, sfPathProvider) {
|
32 | 35 | items.appendChild(childFrag);
|
33 | 36 | }
|
34 | 37 | };
|
| 38 | + |
| 39 | + var tabs = function(args) { |
| 40 | + if (args.form.tabs && args.form.tabs.length > 0) { |
| 41 | + var tabContent = args.fieldFrag.querySelector('.tab-content'); |
| 42 | + |
| 43 | + args.form.tabs.forEach(function(tab, index) { |
| 44 | + var div = document.createElement('div'); |
| 45 | + div.className = 'tab-pane'; |
| 46 | + div.setAttribute('ng-disabled', 'form.readonly'); |
| 47 | + div.setAttribute('ng-show', 'selected.tab === ' + index); |
| 48 | + div.setAttribute('ng-class', '{active: selected.tab === ' + index + '}'); |
| 49 | + |
| 50 | + var childFrag = args.build(tab.items, args.path + '.tabs[' + index + '].items', args.state); |
| 51 | + div.appendChild(childFrag); |
| 52 | + tabContent.appendChild(div); |
| 53 | + }); |
| 54 | + } |
| 55 | + }; |
| 56 | + |
35 | 57 | var defaults = [sfField, ngModel, ngModelOptions];
|
36 | 58 | decoratorsProvider.defineDecorator('bootstrapDecorator', {
|
37 | 59 | textarea: {template: base + 'textarea.html', builder: defaults},
|
38 | 60 | fieldset: {template: base + 'fieldset.html', builder: [sfField, simpleTransclusion]},
|
39 | 61 | array: {template: base + 'array.html', builder: [sfField, ngModelOptions, ngModel, array]},
|
40 | 62 | tabarray: {template: base + 'tabarray.html', builder: [sfField, ngModelOptions, ngModel, array]},
|
41 |
| - tabs: {template: base + 'tabs.html', replace: false}, |
| 63 | + tabs: {template: base + 'tabs.html', builder: [sfField, ngModelOptions, ngModel, tabs]}, |
42 | 64 | section: {template: base + 'section.html', builder: [sfField, simpleTransclusion]},
|
43 | 65 | conditional: {template: base + 'section.html', builder: [sfField, simpleTransclusion]},
|
44 | 66 | actions: {template: base + 'actions.html', builder: defaults},
|
|
0 commit comments