Skip to content

Commit f7ef241

Browse files
committed
Update schemaform provider
Better handle default types
1 parent c7a87b4 commit f7ef241

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

src/services/schema-form.provider.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,6 @@ export default function() {
5757
this.defaults[type] = [];
5858
}
5959
this.defaults[type].unshift(rule);
60-
console.log('TEST prependRule');
61-
console.log(type, rule, '==============');
62-
console.log(this.defaults['string']);
6360
};
6461

6562
/**
@@ -105,7 +102,10 @@ export default function() {
105102
/**
106103
* Create form defaults from schema
107104
*/
108-
service.defaults = schemaDefaults.defaultForm;
105+
service.defaults = function(schema, types, ignore, options) {
106+
let defaultTypes = types || typeDefault;
107+
return schemaDefaults.defaultForm(schema, defaultTypes, ignore, options);
108+
};
109109

110110
//Utility functions
111111
/**

src/services/schema-form.provider.spec.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -316,12 +316,16 @@ describe('schemaForm', function() {
316316
});
317317

318318
describe('#appendRule() and #prependRule()', function() {
319+
beforeEach(module('schemaForm'));
320+
beforeEach(
321+
module(function($sceProvider) {
322+
$sceProvider.enabled(false);
323+
})
324+
);
325+
319326
it('should extend with new defaults',function(){
320327
module(function(schemaFormProvider){
321328
schemaFormProvider.prependRule('string', function(name, schema, options) {
322-
console.log('RUN prependRule');
323-
console.log('Name:'+name);
324-
console.log(JSON.stringify(options));
325329
if (schema.format === 'foobar') {
326330
var f = schemaFormProvider.createStandardForm(name, schema, options);
327331
f.type = 'foobar';
@@ -361,8 +365,6 @@ console.log(JSON.stringify(options));
361365

362366
//no form is implicitly ['*']
363367
var defaults = schemaForm.defaults(schema).form;
364-
console.log('TEST schemaForm.defaults(schema)');
365-
console.log(JSON.stringify(defaults[0]));
366368
defaults[0].type.should.be.equal('foobar');
367369
defaults[0].title.should.be.equal('Name');
368370
defaults[1].type.should.be.equal('select');

0 commit comments

Comments
 (0)