2
2
* Supported Section & Section Constants in Vue-Form-Builder
3
3
* @author Phat Tran
4
4
*/
5
- import { HELPER } from "@/libraries/helper" ;
6
- import { ROW_TYPES } from "@/configs/row" ;
7
-
8
- // Builder Views
9
- import NormalSectionView from "@/views/builder/section-views/NormalSectionView" ;
10
- // import TableSectionView from "@/views/builder/section-views/TableSectionView";
11
- import ToggleableSectionView from "@/views/builder/section-views/ToggleableSectionView" ;
12
- import TabSectionView from "@/views/builder/section-views/TabSectionView" ;
13
-
14
- // Builder Buttons [PRE]
15
- import TabSectionPreButtons from "@/views/builder/section-navigation-buttons/TabSectionPreButtons" ;
16
-
17
- // Builder Buttons [POST]
18
-
19
- // Renderer Views
20
- import RendererNormalSectionView from "@/views/renderer/section-views/NormalSectionView" ;
21
- import RendererToggleableSectionView from "@/views/renderer/section-views/ToggleableSectionView" ;
22
- import RendererTabSectionView from "@/views/renderer/section-views/TabSectionView" ;
23
- // import $ml from "../../../../src/language/ml.js"
24
- // import "../../../../src/language/ml.js"
25
-
26
-
27
-
28
-
29
- const SECTION_TYPES = {
30
- normal : {
31
- name : "NORMAL_BLOCK" ,
32
- description : "NORMAL_BLOCK_DESC" ,
33
- // name: "Normal Block",
34
- // description: "Normal block with a headline",
35
- value : 'normal' ,
36
-
37
- rowType : ROW_TYPES . normal ,
38
- builderView : NormalSectionView ,
39
- rendererView : RendererNormalSectionView ,
40
- } ,
41
-
42
- toggleable : {
43
- name : "TOGGLEABLE_BLOCK" ,
44
- description : "TOGGLEABLE_BLOCK_DESC" ,
45
- // name: "Toggle Block",
46
- // description: "Section block with toggle (display/hide) feature",
47
- value : 'toggleable' ,
48
-
49
- rowType : ROW_TYPES . normal ,
50
- builderView : ToggleableSectionView ,
51
- rendererView : RendererToggleableSectionView
52
- } ,
53
-
54
- // tab: {
55
- // name: "TAB_BLOCK",
56
- // description: "TAB_BLOCK_DESC",
57
- // // name: "Tab Block",
58
- // // description: "A block with multiple tabs feature",
59
- // value: "tab",
60
-
61
- // rowType: ROW_TYPES.tabRow,
62
- // builderView: TabSectionView,
63
- // rendererView: RendererTabSectionView,
64
- // preCustomButtonView: TabSectionPreButtons,
65
- // }
66
-
67
- // table: {
68
- // name: "Table Block",
69
- // description: "Section block built from a table with 2 column",
70
- // value: 'table',
71
- //
72
- // rowType: ROW_TYPES.tableRow,
73
- // builderView: TableSectionView
74
- // },
75
-
76
-
77
- } ;
78
-
79
- /**
80
- * DEFAULT DATA in order to create/reread from the configuration
81
- */
82
- const SECTION_DEFAULT_DATA = {
83
- uniqueId : '' ,
84
-
85
- headline : '' ,
86
- headlineAdditionalClass : '' ,
87
-
88
- subHeadline : '' ,
89
- subHeadlineAdditionalClass : '' ,
90
-
91
- isShowHeadline : true ,
92
-
93
- sortOrder : 0 ,
94
- type : '' ,
95
- rows : [ ] , // array of rowId
96
- controls : [ ] , // array of controlIds
97
- permission : { }
98
- } ;
99
-
100
- /**
101
- * Create new Section
102
- * @param type
103
- * @param sortOrder
104
- */
105
- function createNewSection ( type , sortOrder = 0 ) {
106
- if ( ! SECTION_TYPES [ type ] ) {
107
- throw new TypeError ( `Section Type: ${ type } doesn't exists in Vue-Form-Builder` ) ;
108
- }
109
-
110
- // create new section data base on the default data
111
- let newSectionData = HELPER . cloneDeep ( SECTION_DEFAULT_DATA )
112
- newSectionData . type = type
113
- newSectionData . uniqueId = "section-" + HELPER . getUUIDv4 ( )
114
- newSectionData . headline = "Yeni Kısım"
115
- newSectionData . subHeadline = "Bu yeni bölümün alt başlığıdır"
116
- newSectionData . sortOrder = sortOrder
117
-
118
- return newSectionData ;
119
- }
120
-
121
- export {
122
- SECTION_TYPES ,
123
- SECTION_DEFAULT_DATA ,
124
- createNewSection
125
- }
5
+ import { HELPER } from "@/libraries/helper" ;
6
+ import { ROW_TYPES } from "@/configs/row" ;
7
+
8
+ // Builder Views
9
+ import NormalSectionView from "@/views/builder/section-views/NormalSectionView" ;
10
+ import TableSectionView from "@/views/builder/section-views/TableSectionView" ;
11
+ import ToggleableSectionView from "@/views/builder/section-views/ToggleableSectionView" ;
12
+ import FileSectionView from "@/views/builder/section-views/FileSectionView" ;
13
+ import TabSectionView from "@/views/builder/section-views/TabSectionView" ;
14
+
15
+ // Builder Buttons [PRE]
16
+ import TabSectionPreButtons from "@/views/builder/section-navigation-buttons/TabSectionPreButtons" ;
17
+
18
+ // Builder Buttons [POST]
19
+
20
+ // Renderer Views
21
+ import RendererNormalSectionView from "@/views/renderer/section-views/NormalSectionView" ;
22
+ import RendererToggleableSectionView from "@/views/renderer/section-views/ToggleableSectionView" ;
23
+ import RendererTabSectionView from "@/views/renderer/section-views/TabSectionView" ;
24
+ import RendererTableSectionView from "@/views/renderer/section-views/TableSectionView" ;
25
+ import RendererFileSectionView from "@/views/renderer/section-views/FileSectionView" ;
26
+
27
+
28
+
29
+
30
+ const SECTION_TYPES = {
31
+ normal : {
32
+ name : "Normal Block" ,
33
+ description : "Normal block with a headline" ,
34
+ value : 'normal' ,
35
+
36
+ rowType : ROW_TYPES . normal ,
37
+ builderView : NormalSectionView ,
38
+ rendererView : RendererNormalSectionView ,
39
+ } ,
40
+
41
+ toggleable : {
42
+ name : "Toggleable Block" ,
43
+ description : "Section block with toggle (display/hide) feature" ,
44
+ value : 'toggleable' ,
45
+
46
+ rowType : ROW_TYPES . normal ,
47
+ builderView : ToggleableSectionView ,
48
+ rendererView : RendererToggleableSectionView
49
+ } ,
50
+
51
+ // tab: {
52
+ // name: "Tab Block",
53
+ // description: "A block with multiple tabs feature",
54
+ // value: "tab",
55
+
56
+ // rowType: ROW_TYPES.tabRow,
57
+ // builderView: TabSectionView,
58
+ // rendererView: RendererTabSectionView,
59
+ // preCustomButtonView: TabSectionPreButtons,
60
+ // }
61
+
62
+ table : {
63
+ name : "Table Block" ,
64
+ description : "Section block built from a table" ,
65
+ value : 'table' ,
66
+
67
+ rowType : ROW_TYPES . tableRow ,
68
+ builderView : TableSectionView ,
69
+ rendererView : RendererTableSectionView
70
+ } ,
71
+
72
+ file : {
73
+ name : "File Block" ,
74
+ description : "Section block with add file feature" ,
75
+ value : 'file' ,
76
+
77
+ rowType : ROW_TYPES . fileRow ,
78
+ builderView : FileSectionView ,
79
+ rendererView : RendererFileSectionView
80
+ } ,
81
+
82
+
83
+ } ;
84
+
85
+ /**
86
+ * DEFAULT DATA in order to create/reread from the configuration
87
+ */
88
+ const SECTION_DEFAULT_DATA = {
89
+ uniqueId : '' ,
90
+
91
+ headline : '' ,
92
+ headlineAdditionalClass : '' ,
93
+
94
+ subHeadline : '' ,
95
+ subHeadlineAdditionalClass : '' ,
96
+
97
+ isShowHeadline : true ,
98
+
99
+ sortOrder : 0 ,
100
+ type : '' ,
101
+ rows : [ ] , // array of rowId
102
+ controls : [ ] , // array of controlIds
103
+ permission : { } ,
104
+ } ;
105
+
106
+ /**
107
+ * Create new Section
108
+ * @param type
109
+ * @param sortOrder
110
+ */
111
+ function createNewSection ( type , sortOrder = 0 ) {
112
+ if ( ! SECTION_TYPES [ type ] ) {
113
+ throw new TypeError ( `Section Type: ${ type } doesn't exists in Vue-Form-Builder` ) ;
114
+ }
115
+
116
+ // create new section data base on the default data
117
+ let newSectionData = HELPER . cloneDeep ( SECTION_DEFAULT_DATA )
118
+ newSectionData . type = type
119
+ newSectionData . uniqueId = "section-" + HELPER . getUUIDv4 ( )
120
+ newSectionData . headline = "New Section"
121
+ newSectionData . subHeadline = "This is the sub-headline of the new section"
122
+ newSectionData . sortOrder = sortOrder
123
+ if ( type == 'table' ) {
124
+ newSectionData . tableObject = {
125
+ data : [ ] ,
126
+ tableColumns : [ ]
127
+ }
128
+ }
129
+
130
+ return newSectionData ;
131
+ }
132
+
133
+ export {
134
+ SECTION_TYPES ,
135
+ SECTION_DEFAULT_DATA ,
136
+ createNewSection
137
+ }
0 commit comments