Skip to content

Commit 0a88586

Browse files
committed
Support for sortOptions
The ui-sortable directive is now passed sortOptions. sortOptions.items defaults to ignore the last list item.
1 parent 11aee56 commit 0a88586

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/bootstrap-decorator.js

+12-1
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,24 @@ function(decoratorsProvider, sfBuilderProvider, sfPathProvider) {
2727
});
2828
}
2929
};
30+
31+
// Set tabArray sortOptions.items default.
32+
var tabArray = function(args) {
33+
if(args.form.hasOwnProperty('sortOptions')) {
34+
if(!args.form.sortOptions.hasOwnProperty('items')) {
35+
args.form.sortOptions['items'] = 'li:not(:last-child)';
36+
}
37+
} else {
38+
args.form['sortOptions'] = {items: 'li:not(:last-child)'};
39+
}
40+
}
3041

3142
var defaults = [sfField, ngModel, ngModelOptions, condition];
3243
decoratorsProvider.defineDecorator('bootstrapDecorator', {
3344
textarea: {template: base + 'textarea.html', builder: defaults},
3445
fieldset: {template: base + 'fieldset.html', builder: [sfField, simpleTransclusion, condition]},
3546
array: {template: base + 'array.html', builder: [sfField, ngModelOptions, ngModel, array, condition]},
36-
tabarray: {template: base + 'tabarray.html', builder: [sfField, ngModelOptions, ngModel, array, condition]},
47+
tabarray: {template: base + 'tabarray.html', builder: [sfField, ngModelOptions, ngModel, array, condition, tabArray]},
3748
tabs: {template: base + 'tabs.html', builder: [sfField, ngModelOptions, tabs, condition]},
3849
section: {template: base + 'section.html', builder: [sfField, simpleTransclusion, condition]},
3950
conditional: {template: base + 'section.html', builder: [sfField, simpleTransclusion, condition]},

src/tabarray.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
ng-class="{'col-xs-3': !form.tabType || form.tabType === 'left'}">
99
<ol class="nav nav-tabs"
1010
ng-class="{ 'tabs-left': !form.tabType || form.tabType === 'left'}"
11-
sf-field-model ui-sortable="{items: 'li:not(:last-child)'}">
11+
sf-field-model ui-sortable="form.sortOptions">
1212
<li sf-field-model="ng-repeat"
1313
ng-repeat="item in $$value$$ track by $index"
1414
ng-click="$event.preventDefault() || (selected.tab = $index)"

0 commit comments

Comments
 (0)