This repository was archived by the owner on Apr 10, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +72
-7
lines changed Expand file tree Collapse file tree 3 files changed +72
-7
lines changed Original file line number Diff line number Diff line change @@ -7,11 +7,61 @@ const Form = require('../../Utils/form');
7
7
* @returns {N/server/widget }
8
8
*/
9
9
10
- const FieldType = { DATE : 'date' } ;
11
- const FieldLayoutType = { NORMAL : 'normal' } ;
12
- const FieldBreakType = { STARTCOL : 'startcol' } ;
13
- const FieldDisplayType = { HIDDEN : 'hidden' } ;
14
- const SublistType = { LIST : 'list' } ;
10
+ const FieldType = {
11
+ CHECKBOX : 'checkbox' ,
12
+ CURRENCY : 'currency' ,
13
+ DATE : 'date' ,
14
+ DATETIME : 'datetime' ,
15
+ DATETIMETZ : 'datetimetz' ,
16
+ EMAIL : 'email' ,
17
+ FILE : 'file' ,
18
+ FLOAT : 'float' ,
19
+ HELP : 'help' ,
20
+ INLINEHTML : 'inlinehtml' ,
21
+ INTEGER : 'interger' ,
22
+ IMAGE : 'image' ,
23
+ LABEL : 'label' ,
24
+ LONGTEXT : 'longtext' ,
25
+ MULTISELECT : 'multiselect' ,
26
+ PASSWORD : 'password' ,
27
+ PERCENT : 'percent' ,
28
+ PHONE : 'phone' ,
29
+ SELECT : 'select' ,
30
+ RADIO : 'radio' ,
31
+ RICHTEXT : 'richtext' ,
32
+ TEXT : 'text' ,
33
+ TEXTAREA : 'textarea' ,
34
+ TIMEOFDAY : 'timeofday' ,
35
+ URL : 'url' ,
36
+ } ;
37
+ const FieldLayoutType = {
38
+ STARTROW : 'startrow' ,
39
+ MIDROW : 'midrow' ,
40
+ ENDROW : 'endrow' ,
41
+ OUTSIDE : 'outside' ,
42
+ OUTSIDEBELOW : 'outsidebelow' ,
43
+ OUTSIDEABOVE : 'outsideabove' ,
44
+ NORMAL : 'normal' ,
45
+ } ;
46
+ const FieldBreakType = {
47
+ NONE : 'none' ,
48
+ STARTCOL : 'startcol' ,
49
+ STARTROW : 'startrow' ,
50
+ } ;
51
+ const FieldDisplayType = {
52
+ DISABLED : 'disabled' ,
53
+ ENTRY : 'entry' ,
54
+ HIDDEN : 'hidden' ,
55
+ INLINE : 'inline' ,
56
+ NORMAL : 'normal' ,
57
+ READONLY : 'readonly' ,
58
+ } ;
59
+ const SublistType = {
60
+ INLINEEDITOR : 'inlineeditor' ,
61
+ EDITOR : 'editor' ,
62
+ LIST : 'list' ,
63
+ STATICLIST : 'staticlist' ,
64
+ } ;
15
65
16
66
module . exports = {
17
67
FieldType,
Original file line number Diff line number Diff line change @@ -9,4 +9,13 @@ describe('Testing form', () => {
9
9
it ( 'Should return a function ' , ( ) => {
10
10
expect ( fileUnderTest ) . toEqual ( expect . any ( Function ) ) ;
11
11
} ) ;
12
+
13
+ it ( 'Should return a object ' , ( ) => {
14
+ expect ( fileUnderTest ( ) ) . toEqual ( expect . any ( Object ) ) ;
15
+ } ) ;
16
+
17
+ it ( 'Should has own property addButton ' , ( ) => {
18
+ const result = fileUnderTest ( ) . addSublist ( { id : 'id' , type : 'type' , label : 'label' } ) ;
19
+ expect ( Object . prototype . hasOwnProperty . call ( result , 'addButton' ) ) . toBeTruthy ( ) ;
20
+ } ) ;
12
21
} ) ;
Original file line number Diff line number Diff line change @@ -22,14 +22,19 @@ function NsForm(name) {
22
22
getName : ( ) => this . name ,
23
23
addButton : obj => this . buttons . push ( obj ) ,
24
24
addSublist : ( obj ) => {
25
- this . sublist . push ( obj ) ;
26
- return {
25
+ const list = {
26
+ ... obj ,
27
27
addField : ( options ) => {
28
28
this . fields . push ( options ) ;
29
29
return field ;
30
30
} ,
31
+ addButton : ( options ) => {
32
+ this . buttons . push ( options ) ;
33
+ } ,
31
34
setSublistValue : ( ) => '' ,
32
35
} ;
36
+ this . sublist . push ( list ) ;
37
+ return list ;
33
38
} ,
34
39
addSubmitButton : obj => this . submitButtons . push ( obj ) ,
35
40
addField : ( obj ) => {
@@ -38,6 +43,7 @@ function NsForm(name) {
38
43
} ,
39
44
getFields : ( ) => this . fields ,
40
45
getButtons : ( ) => this . buttons ,
46
+ getSublist : ( { id } ) => this . sublist . find ( list => list . id === id ) ,
41
47
getSubmitButtons : ( ) => this . submitButtons ,
42
48
} ;
43
49
}
You can’t perform that action at this time.
0 commit comments