Skip to content

Commit 5e3aae5

Browse files
author
daniel.gomez
committed
Deleted createFactory, now we are returning a singleton instance
1 parent a7d3ac6 commit 5e3aae5

File tree

4 files changed

+32
-32
lines changed

4 files changed

+32
-32
lines changed

src/factory/BootstrapFactory.js

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -38,34 +38,6 @@ class BootstrapFactory extends ComponentFactory {
3838
this.setDefaultGroupComponent('Group');
3939
};
4040

41-
static createComponentFactory(type) {
42-
switch (type) {
43-
case 'edit':
44-
return new BootstrapFactory({
45-
'string': 'TextBox',
46-
'array': 'ArrayContainer',
47-
'datetime': 'DateTimePicker',
48-
'time': 'DateTimePicker',
49-
'date': 'DateTimePicker',
50-
'int' : 'TextBox',
51-
'float': 'TextBox',
52-
'bool': 'Checkbox',
53-
'group': 'FieldGroup'
54-
});
55-
case 'details':
56-
return new BootstrapFactory({
57-
'string': 'Static',
58-
'array': 'ArrayContainer',
59-
'datetime': 'Static',
60-
'time': 'Static',
61-
'date': 'Static',
62-
'int': 'Static',
63-
'float': 'Static',
64-
'bool': 'Static',
65-
'group': 'FieldGroup'
66-
});
67-
}
68-
}
6941
}
7042

7143
export default BootstrapFactory;
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
export default {
2+
edit: {
3+
string: 'TextBox',
4+
array: 'ArrayContainer',
5+
datetime: 'DateTimePicker',
6+
time: 'DateTimePicker',
7+
date: 'DateTimePicker',
8+
int : 'TextBox',
9+
float: 'TextBox',
10+
bool: 'Checkbox',
11+
group: 'FieldGroup'
12+
},
13+
details: {
14+
string: 'Static',
15+
array: 'ArrayContainer',
16+
datetime: 'Static',
17+
time: 'Static',
18+
date: 'Static',
19+
int: 'Static',
20+
float: 'Static',
21+
bool: 'Static',
22+
group: 'FieldGroup'
23+
}
24+
}

src/index.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
1-
export BootstrapFactory from './factory/BootstrapFactory';
1+
import BootstrapFactory from './factory/BootstrapFactory';
2+
import TypeConfig from './factory/constants/TypeConstants'
3+
4+
export const EditComponentFactory = new BootstrapFactory(TypeConfig.edit)
5+
export const DetailsComponentFactory = new BootstrapFactory(TypeConfig.details);

test/createFactory.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { BootstrapFactory } from '../src/index';
1+
import { EditComponentFactory, DetailsComponentFactory } from '../src/index';
22
import { expect } from 'chai';
33

44

@@ -17,7 +17,7 @@ describe("Factory creation", function() {
1717
'group': 'FieldGroup'
1818
};
1919

20-
let factory = BootstrapFactory.createComponentFactory("edit");
20+
let factory = EditComponentFactory;
2121

2222
expect(factory.defaultFieldComponents).to.be.deep.equal(correctConfig);
2323
done()
@@ -36,7 +36,7 @@ describe("Factory creation", function() {
3636
'group': 'FieldGroup'
3737
};
3838

39-
let factory = BootstrapFactory.createComponentFactory("details");
39+
let factory = DetailsComponentFactory;
4040

4141
expect(factory.defaultFieldComponents).to.be.deep.equal(correctConfig);
4242
done()

0 commit comments

Comments
 (0)