Skip to content

Commit a2633ef

Browse files
committed
Sections
Simple div groupings
1 parent 8621d5c commit a2633ef

File tree

3 files changed

+41
-0
lines changed

3 files changed

+41
-0
lines changed

src/directives/decorators/bootstrap/bootstrap-decorator.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ function($parse, $compile, $http, $templateCache){
1313
if (form.type === 'fieldset') {
1414
return 'directives/decorators/bootstrap/fieldset.html';
1515
}
16+
if (form.type === 'section') {
17+
return 'directives/decorators/bootstrap/section.html';
18+
}
1619
if (form.type === 'select') {
1720
return 'directives/decorators/bootstrap/select.html';
1821
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<div>
2+
<bootstrap-decorator ng-repeat="item in form.items" form="item"></bootstrap-decorator>
3+
</div>

test/schema-form-test.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,41 @@ describe('Schema form',function(){
507507
tmpl.children().eq(1).find('input[type=checkbox]').length.should.be.eq(2);
508508
});
509509
});
510+
511+
it('should handle a simple div when type "section" is specified',function(){
512+
513+
inject(function($compile,$rootScope){
514+
var scope = $rootScope.$new();
515+
scope.person = {};
516+
517+
scope.schema = exampleSchema;
518+
519+
scope.form = [{
520+
type: "section",
521+
items: [
522+
{
523+
key: 'name',
524+
notitle: true
525+
},
526+
{
527+
key: 'gender',
528+
notitle: true
529+
}
530+
]
531+
}];
532+
533+
var tmpl = angular.element('<form sf-schema="schema" sf-form="form" sf-model="person"></form>');
534+
535+
$compile(tmpl)(scope);
536+
$rootScope.$apply();
537+
538+
tmpl.children().length.should.be.equal(1);
539+
tmpl.children().eq(0).is('div').should.be.true;
540+
tmpl.children().eq(0).children().length.should.be.eq(2);
541+
});
542+
});
543+
544+
510545
});
511546

512547

0 commit comments

Comments
 (0)