@gisce/ooui 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -0
- package/dist/Binary.d.ts +14 -0
- package/dist/Binary.js +46 -0
- package/dist/Binary.js.map +1 -0
- package/dist/Boolean.d.ts +8 -0
- package/dist/Boolean.js +26 -0
- package/dist/Boolean.js.map +1 -0
- package/dist/Button.d.ts +29 -0
- package/dist/Button.js +108 -0
- package/dist/Button.js.map +1 -0
- package/dist/Char.d.ts +26 -0
- package/dist/Char.js +89 -0
- package/dist/Char.js.map +1 -0
- package/dist/Container.d.ts +44 -0
- package/dist/Container.js +148 -0
- package/dist/Container.js.map +1 -0
- package/dist/ContainerWidget.d.ts +42 -0
- package/dist/ContainerWidget.js +125 -0
- package/dist/ContainerWidget.js.map +1 -0
- package/dist/Date.d.ts +8 -0
- package/dist/Date.js +26 -0
- package/dist/Date.js.map +1 -0
- package/dist/DateTime.d.ts +8 -0
- package/dist/DateTime.js +26 -0
- package/dist/DateTime.js.map +1 -0
- package/dist/FiberGrid.d.ts +5 -0
- package/dist/FiberGrid.js +23 -0
- package/dist/FiberGrid.js.map +1 -0
- package/dist/Field.d.ts +59 -0
- package/dist/Field.js +162 -0
- package/dist/Field.js.map +1 -0
- package/dist/Float.d.ts +24 -0
- package/dist/Float.js +64 -0
- package/dist/Float.js.map +1 -0
- package/dist/FloatTime.d.ts +7 -0
- package/dist/FloatTime.js +26 -0
- package/dist/FloatTime.js.map +1 -0
- package/dist/Form.d.ts +53 -0
- package/dist/Form.js +199 -0
- package/dist/Form.js.map +1 -0
- package/dist/Group.d.ts +5 -0
- package/dist/Group.js +23 -0
- package/dist/Group.js.map +1 -0
- package/dist/Image.d.ts +7 -0
- package/dist/Image.js +26 -0
- package/dist/Image.js.map +1 -0
- package/dist/Integer.d.ts +8 -0
- package/dist/Integer.js +26 -0
- package/dist/Integer.js.map +1 -0
- package/dist/Label.d.ts +23 -0
- package/dist/Label.js +80 -0
- package/dist/Label.js.map +1 -0
- package/dist/Many2many.d.ts +26 -0
- package/dist/Many2many.js +80 -0
- package/dist/Many2many.js.map +1 -0
- package/dist/Many2one.d.ts +20 -0
- package/dist/Many2one.js +63 -0
- package/dist/Many2one.js.map +1 -0
- package/dist/NewLine.d.ts +5 -0
- package/dist/NewLine.js +26 -0
- package/dist/NewLine.js.map +1 -0
- package/dist/Notebook.d.ts +8 -0
- package/dist/Notebook.js +41 -0
- package/dist/Notebook.js.map +1 -0
- package/dist/One2many.d.ts +44 -0
- package/dist/One2many.js +130 -0
- package/dist/One2many.js.map +1 -0
- package/dist/Page.d.ts +5 -0
- package/dist/Page.js +23 -0
- package/dist/Page.js.map +1 -0
- package/dist/ProgressBar.d.ts +7 -0
- package/dist/ProgressBar.js +26 -0
- package/dist/ProgressBar.js.map +1 -0
- package/dist/Reference.d.ts +7 -0
- package/dist/Reference.js +26 -0
- package/dist/Reference.js.map +1 -0
- package/dist/SearchFilter.d.ts +28 -0
- package/dist/SearchFilter.js +81 -0
- package/dist/SearchFilter.js.map +1 -0
- package/dist/Selection.d.ts +20 -0
- package/dist/Selection.js +63 -0
- package/dist/Selection.js.map +1 -0
- package/dist/Separator.d.ts +12 -0
- package/dist/Separator.js +46 -0
- package/dist/Separator.js.map +1 -0
- package/dist/Text.d.ts +29 -0
- package/dist/Text.js +96 -0
- package/dist/Text.js.map +1 -0
- package/dist/Timeline.d.ts +17 -0
- package/dist/Timeline.js +56 -0
- package/dist/Timeline.js.map +1 -0
- package/dist/Tree.d.ts +31 -0
- package/dist/Tree.js +96 -0
- package/dist/Tree.js.map +1 -0
- package/dist/Widget.d.ts +47 -0
- package/dist/Widget.js +116 -0
- package/dist/Widget.js.map +1 -0
- package/dist/WidgetFactory.d.ts +9 -0
- package/dist/WidgetFactory.js +157 -0
- package/dist/WidgetFactory.js.map +1 -0
- package/dist/helpers/attributeParser.d.ts +6 -0
- package/dist/helpers/attributeParser.js +83 -0
- package/dist/helpers/attributeParser.js.map +1 -0
- package/dist/helpers/contextParser.d.ts +5 -0
- package/dist/helpers/contextParser.js +52 -0
- package/dist/helpers/contextParser.js.map +1 -0
- package/dist/helpers/domainParser.d.ts +5 -0
- package/dist/helpers/domainParser.js +26 -0
- package/dist/helpers/domainParser.js.map +1 -0
- package/dist/helpers/fieldParser.d.ts +5 -0
- package/dist/helpers/fieldParser.js +20 -0
- package/dist/helpers/fieldParser.js.map +1 -0
- package/dist/helpers/nodeParser.d.ts +7 -0
- package/dist/helpers/nodeParser.js +50 -0
- package/dist/helpers/nodeParser.js.map +1 -0
- package/dist/helpers/onChangeParser.d.ts +5 -0
- package/dist/helpers/onChangeParser.js +16 -0
- package/dist/helpers/onChangeParser.js.map +1 -0
- package/dist/helpers/stateParser.d.ts +14 -0
- package/dist/helpers/stateParser.js +46 -0
- package/dist/helpers/stateParser.js.map +1 -0
- package/dist/index.d.ts +33 -0
- package/dist/index.js +34 -0
- package/dist/index.js.map +1 -0
- package/package.json +49 -0
- package/src/Binary.ts +29 -0
- package/src/Boolean.ts +12 -0
- package/src/Button.ts +78 -0
- package/src/Char.ts +65 -0
- package/src/Container.ts +171 -0
- package/src/ContainerWidget.ts +105 -0
- package/src/Date.ts +12 -0
- package/src/DateTime.ts +12 -0
- package/src/FiberGrid.ts +9 -0
- package/src/Field.ts +147 -0
- package/src/Float.ts +45 -0
- package/src/FloatTime.ts +8 -0
- package/src/Form.ts +212 -0
- package/src/Group.ts +9 -0
- package/src/Image.ts +8 -0
- package/src/Integer.ts +13 -0
- package/src/Label.ts +46 -0
- package/src/Many2many.ts +59 -0
- package/src/Many2one.ts +44 -0
- package/src/NewLine.ts +9 -0
- package/src/Notebook.ts +24 -0
- package/src/One2many.ts +106 -0
- package/src/Page.ts +9 -0
- package/src/ProgressBar.ts +8 -0
- package/src/Reference.ts +10 -0
- package/src/SearchFilter.ts +81 -0
- package/src/Selection.ts +44 -0
- package/src/Separator.ts +30 -0
- package/src/Text.ts +76 -0
- package/src/Timeline.ts +44 -0
- package/src/Tree.ts +93 -0
- package/src/Widget.ts +121 -0
- package/src/WidgetFactory.ts +158 -0
- package/src/helpers/attributeParser.ts +108 -0
- package/src/helpers/contextParser.ts +66 -0
- package/src/helpers/domainParser.ts +39 -0
- package/src/helpers/fieldParser.ts +27 -0
- package/src/helpers/nodeParser.ts +57 -0
- package/src/helpers/onChangeParser.ts +18 -0
- package/src/helpers/stateParser.ts +62 -0
- package/src/index.ts +67 -0
- package/src/spec/Boolean.spec.ts +36 -0
- package/src/spec/Button.spec.ts +58 -0
- package/src/spec/Char.spec.ts +80 -0
- package/src/spec/Container.spec.ts +47 -0
- package/src/spec/ContainerWidget.spec.ts +35 -0
- package/src/spec/Date.spec.ts +36 -0
- package/src/spec/DateTime.spec.ts +36 -0
- package/src/spec/Float.spec.ts +29 -0
- package/src/spec/Form.spec.ts +976 -0
- package/src/spec/Group.spec.ts +32 -0
- package/src/spec/Label.spec.ts +46 -0
- package/src/spec/Many2many.spec.ts +36 -0
- package/src/spec/Many2one.spec.ts +36 -0
- package/src/spec/One2many.spec.ts +354 -0
- package/src/spec/SearchFilter.spec.ts +955 -0
- package/src/spec/Selection.spec.ts +52 -0
- package/src/spec/Separator.spec.ts +14 -0
- package/src/spec/Tree.spec.ts +214 -0
- package/src/spec/Widget.spec.ts +45 -0
- package/src/spec/WidgetFactory.spec.ts +40 -0
- package/src/spec/attributeParser.spec.ts +173 -0
- package/src/spec/contextParser.spec.ts +57 -0
- package/src/spec/domainParser.spec.ts +40 -0
- package/src/spec/fixtures/WidgetImpl.ts +10 -0
- package/src/spec/stateParser.spec.ts +161 -0
package/src/Char.ts
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import Field from "./Field";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* One-line input with a length limit.
|
|
5
|
+
*/
|
|
6
|
+
class Char extends Field {
|
|
7
|
+
/**
|
|
8
|
+
* Field place holder
|
|
9
|
+
*/
|
|
10
|
+
_placeholder: string = "";
|
|
11
|
+
get placeholder(): string {
|
|
12
|
+
return this._placeholder;
|
|
13
|
+
}
|
|
14
|
+
set placeholder(value: string) {
|
|
15
|
+
this._placeholder = value;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Field size
|
|
20
|
+
*/
|
|
21
|
+
_size: number = 150;
|
|
22
|
+
get size(): number {
|
|
23
|
+
return this._size;
|
|
24
|
+
}
|
|
25
|
+
set size(value: number) {
|
|
26
|
+
this._size = value;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
_isPassword: boolean = false;
|
|
30
|
+
get isPassword(): boolean {
|
|
31
|
+
return this._isPassword;
|
|
32
|
+
}
|
|
33
|
+
set isPassword(value: boolean) {
|
|
34
|
+
this._isPassword = value;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
_translatable: boolean = false;
|
|
38
|
+
get translatable(): boolean {
|
|
39
|
+
return this._translatable;
|
|
40
|
+
}
|
|
41
|
+
set translatable(value: boolean) {
|
|
42
|
+
this._translatable = value;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
constructor(props: any) {
|
|
46
|
+
super(props);
|
|
47
|
+
|
|
48
|
+
if (props) {
|
|
49
|
+
if (props.size) {
|
|
50
|
+
this._size = props.size;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (props.password) {
|
|
54
|
+
this.isPassword = props.password === "True" ? true : false;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (props.translate) {
|
|
58
|
+
this.translatable =
|
|
59
|
+
props.translate === "True" || props.translate === true ? true : false;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export default Char;
|
package/src/Container.ts
ADDED
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import Field from "./Field";
|
|
2
|
+
import NewLine from "./NewLine";
|
|
3
|
+
import Widget from "./Widget";
|
|
4
|
+
import Label from "./Label";
|
|
5
|
+
|
|
6
|
+
type AddWidgetOptions = {
|
|
7
|
+
addLabel: boolean;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
class Container {
|
|
11
|
+
/**
|
|
12
|
+
* Number of columns the container is divided
|
|
13
|
+
*/
|
|
14
|
+
_columns: number;
|
|
15
|
+
get columns(): number {
|
|
16
|
+
return this._columns;
|
|
17
|
+
}
|
|
18
|
+
set columns(value: number) {
|
|
19
|
+
this._columns = value;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Number of columns to use
|
|
24
|
+
*/
|
|
25
|
+
_colspan: number;
|
|
26
|
+
get colspan(): number {
|
|
27
|
+
return this._colspan;
|
|
28
|
+
}
|
|
29
|
+
set colspan(value: number) {
|
|
30
|
+
this._colspan = value;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Number of rows
|
|
35
|
+
*/
|
|
36
|
+
_rows: Widget[][];
|
|
37
|
+
get rows(): Widget[][] {
|
|
38
|
+
return this._rows;
|
|
39
|
+
}
|
|
40
|
+
set rows(value: Widget[][]) {
|
|
41
|
+
this._rows = value;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
_index: number;
|
|
45
|
+
get index(): number {
|
|
46
|
+
return this._index;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Determines if widget is read only (default is false)
|
|
51
|
+
*/
|
|
52
|
+
_readOnly: boolean;
|
|
53
|
+
get readOnly(): boolean {
|
|
54
|
+
return this._readOnly;
|
|
55
|
+
}
|
|
56
|
+
set readOnly(value: boolean) {
|
|
57
|
+
this._readOnly = value;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
constructor(
|
|
61
|
+
columns: number = 4,
|
|
62
|
+
colspan: number = 6,
|
|
63
|
+
readOnly: boolean = false
|
|
64
|
+
) {
|
|
65
|
+
this._columns = columns;
|
|
66
|
+
this._colspan = colspan;
|
|
67
|
+
this._rows = [[]];
|
|
68
|
+
this._index = 0;
|
|
69
|
+
this._readOnly = readOnly;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Returns the next free position
|
|
74
|
+
*/
|
|
75
|
+
freePosition(): number {
|
|
76
|
+
const span = this._rows[this._index]
|
|
77
|
+
.filter((el) => {
|
|
78
|
+
return !el.invisible;
|
|
79
|
+
})
|
|
80
|
+
.reduce((prev, current) => {
|
|
81
|
+
return prev + current.colspan;
|
|
82
|
+
}, 0);
|
|
83
|
+
return this._columns - span;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
addWidget(widget: Widget, options?: AddWidgetOptions) {
|
|
87
|
+
const widgetsToAdd: Widget[] = [];
|
|
88
|
+
const addLabel = options ? options.addLabel : true;
|
|
89
|
+
|
|
90
|
+
if (widget instanceof NewLine) {
|
|
91
|
+
this._rows.push([]);
|
|
92
|
+
this._index++;
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
if (widget.colspan > this._columns) {
|
|
97
|
+
// Widget colspan is greater than container columns, so we change widget
|
|
98
|
+
// colspan to fit container columns.
|
|
99
|
+
widget.colspan = this._columns;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// If the container is set to readonly, reflect it to its children
|
|
103
|
+
widget.readOnly = widget.readOnly || this.readOnly;
|
|
104
|
+
|
|
105
|
+
// For fields without nolabel we add a preceding label widget
|
|
106
|
+
if (addLabel && widget instanceof Field && !widget.nolabel) {
|
|
107
|
+
if (widget.colspan > 1) {
|
|
108
|
+
widget.colspan -= 1; // We substract one colspan for the corresponding label
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
const label = new Label({
|
|
112
|
+
name: widget.id + "_label",
|
|
113
|
+
string: widget.label,
|
|
114
|
+
invisible: widget.invisible,
|
|
115
|
+
help: widget.tooltip,
|
|
116
|
+
fieldForLabel: widget.id,
|
|
117
|
+
});
|
|
118
|
+
label.type = "label";
|
|
119
|
+
|
|
120
|
+
widgetsToAdd.push(label);
|
|
121
|
+
widgetsToAdd.push(widget);
|
|
122
|
+
} else {
|
|
123
|
+
widgetsToAdd.push(widget);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
const widgetsColspan = widgetsToAdd.reduce(
|
|
127
|
+
(accumulator: number, currentWidget: Widget) => {
|
|
128
|
+
return accumulator + currentWidget.colspan;
|
|
129
|
+
},
|
|
130
|
+
0
|
|
131
|
+
);
|
|
132
|
+
|
|
133
|
+
if (widgetsColspan > this.freePosition()) {
|
|
134
|
+
this._rows.push([]);
|
|
135
|
+
this._index++;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
this._rows[this._index] = this._rows[this._index].concat(widgetsToAdd);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Traverses children to find a matching container or widget with the exact same id.
|
|
143
|
+
* @param {string} id id (name) of the field or container to find
|
|
144
|
+
*/
|
|
145
|
+
findById(id: string): Widget | null {
|
|
146
|
+
let r: Widget | null = null;
|
|
147
|
+
if (this._rows && this._rows.length) {
|
|
148
|
+
this._rows.forEach((row) => {
|
|
149
|
+
if (r) {
|
|
150
|
+
// Item has been found.
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
if (row && row.length) {
|
|
155
|
+
row.forEach((item) => {
|
|
156
|
+
if (r) {
|
|
157
|
+
// Item has been found.
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
if (item) {
|
|
161
|
+
r = item.findById(id);
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
return r;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
export default Container;
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import Widget from "./Widget";
|
|
2
|
+
import Container from "./Container";
|
|
3
|
+
|
|
4
|
+
class ContainerWidget extends Widget {
|
|
5
|
+
/**
|
|
6
|
+
* Field identifier
|
|
7
|
+
*
|
|
8
|
+
* Corresponds to the field's name attribute from xml
|
|
9
|
+
*/
|
|
10
|
+
_id: string = "";
|
|
11
|
+
get id(): string {
|
|
12
|
+
return this._id;
|
|
13
|
+
}
|
|
14
|
+
set id(value: string) {
|
|
15
|
+
this._id = value;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
static _defaultColspan: number = 6;
|
|
19
|
+
static get defaultColspan(): number {
|
|
20
|
+
return ContainerWidget._defaultColspan;
|
|
21
|
+
}
|
|
22
|
+
static set defaultColspan(value: number) {
|
|
23
|
+
ContainerWidget._defaultColspan = value;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Container
|
|
28
|
+
*/
|
|
29
|
+
_container: Container;
|
|
30
|
+
get container(): Container {
|
|
31
|
+
return this._container;
|
|
32
|
+
}
|
|
33
|
+
set container(value: Container) {
|
|
34
|
+
this._container = value;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
get colspan(): number {
|
|
38
|
+
return this._container.colspan;
|
|
39
|
+
}
|
|
40
|
+
set colspan(value: number) {
|
|
41
|
+
this._container.colspan = +value;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Must expand widget
|
|
46
|
+
*/
|
|
47
|
+
_mustExpand: boolean = false;
|
|
48
|
+
get mustExpand(): boolean {
|
|
49
|
+
return this._mustExpand;
|
|
50
|
+
}
|
|
51
|
+
set mustExpand(value: boolean) {
|
|
52
|
+
this._mustExpand = value;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Container label
|
|
57
|
+
*/
|
|
58
|
+
_label: string = "";
|
|
59
|
+
get label(): string {
|
|
60
|
+
return this._label;
|
|
61
|
+
}
|
|
62
|
+
set label(value: string) {
|
|
63
|
+
this._label = value;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
constructor(props?: any) {
|
|
67
|
+
super(props);
|
|
68
|
+
|
|
69
|
+
this._container = new Container(
|
|
70
|
+
props && props.col,
|
|
71
|
+
ContainerWidget._defaultColspan,
|
|
72
|
+
this.readOnly
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
if (props) {
|
|
76
|
+
if (props.name) {
|
|
77
|
+
this._id = props.name;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if (props.colspan) {
|
|
81
|
+
this._container.colspan = +props.colspan;
|
|
82
|
+
} else {
|
|
83
|
+
this._mustExpand = true;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if (props.string) {
|
|
87
|
+
this._label = props.string;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Calls container's findById method to find the widgets matching with param id
|
|
94
|
+
* @param {string} id id to find
|
|
95
|
+
*/
|
|
96
|
+
findById(id: string): Widget | null {
|
|
97
|
+
if (id === this.id) {
|
|
98
|
+
return this;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
return this.container.findById(id);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export default ContainerWidget;
|
package/src/Date.ts
ADDED
package/src/DateTime.ts
ADDED
package/src/FiberGrid.ts
ADDED
package/src/Field.ts
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import Widget from "./Widget";
|
|
2
|
+
|
|
3
|
+
class Field extends Widget {
|
|
4
|
+
/**
|
|
5
|
+
* Field identifier
|
|
6
|
+
*
|
|
7
|
+
* Corresponds to the field's name attribute from xml
|
|
8
|
+
*/
|
|
9
|
+
_id: string = "";
|
|
10
|
+
get id(): string {
|
|
11
|
+
return this._id;
|
|
12
|
+
}
|
|
13
|
+
set id(value: string) {
|
|
14
|
+
this._id = value;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Label
|
|
19
|
+
*/
|
|
20
|
+
_label: string = "";
|
|
21
|
+
get label(): string {
|
|
22
|
+
return this._label;
|
|
23
|
+
}
|
|
24
|
+
set label(value: string) {
|
|
25
|
+
this._label = value;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* No label
|
|
30
|
+
*
|
|
31
|
+
* This field hasn't got to show the label
|
|
32
|
+
*
|
|
33
|
+
*/
|
|
34
|
+
_nolabel: boolean = false;
|
|
35
|
+
get nolabel(): boolean {
|
|
36
|
+
return this._nolabel;
|
|
37
|
+
}
|
|
38
|
+
set nolabel(value: boolean) {
|
|
39
|
+
this._nolabel = value;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
*
|
|
44
|
+
* Required field
|
|
45
|
+
*
|
|
46
|
+
*/
|
|
47
|
+
_required: boolean = false;
|
|
48
|
+
get required(): boolean {
|
|
49
|
+
return this._required;
|
|
50
|
+
}
|
|
51
|
+
set required(value: boolean) {
|
|
52
|
+
this._required = value;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Tooltip
|
|
57
|
+
*/
|
|
58
|
+
_tooltip?: string;
|
|
59
|
+
get tooltip(): string | undefined {
|
|
60
|
+
return this._tooltip;
|
|
61
|
+
}
|
|
62
|
+
set tooltip(value: string | undefined) {
|
|
63
|
+
this._tooltip = value;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Activated (default is true)
|
|
68
|
+
*/
|
|
69
|
+
_activated: boolean = true;
|
|
70
|
+
get activated(): boolean {
|
|
71
|
+
return this._activated;
|
|
72
|
+
}
|
|
73
|
+
set activated(value: boolean) {
|
|
74
|
+
this._activated = value;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Sum - sum parameter (label), this will mean that we have to sum this field in the tree
|
|
79
|
+
*/
|
|
80
|
+
_sum?: string;
|
|
81
|
+
get sum(): string | undefined {
|
|
82
|
+
return this._sum;
|
|
83
|
+
}
|
|
84
|
+
set sum(value: string | undefined) {
|
|
85
|
+
this._sum = value;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
constructor(props: any) {
|
|
89
|
+
super(props);
|
|
90
|
+
|
|
91
|
+
// Activated by default
|
|
92
|
+
this._activated = true;
|
|
93
|
+
|
|
94
|
+
if (props) {
|
|
95
|
+
if (props.name) {
|
|
96
|
+
this._id = props.name;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (props.activated) {
|
|
100
|
+
this._activated = props.activated;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
if (props.string) {
|
|
104
|
+
this._label = props.string;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (props.help) {
|
|
108
|
+
this._tooltip = props.help;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
if (
|
|
112
|
+
props.nolabel &&
|
|
113
|
+
(props.nolabel === "1" ||
|
|
114
|
+
(typeof props.nolabel === "boolean" && props.nolabel === true))
|
|
115
|
+
) {
|
|
116
|
+
this._nolabel = true;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
if (
|
|
120
|
+
props.required &&
|
|
121
|
+
(props.required === "1" ||
|
|
122
|
+
props.required === true ||
|
|
123
|
+
props.required === "True")
|
|
124
|
+
) {
|
|
125
|
+
this._required = true;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
if (props.sum) {
|
|
129
|
+
this._sum = props.sum;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Returns this instance in case this id matches param id.
|
|
136
|
+
* @param {string} id id (name) to find
|
|
137
|
+
*/
|
|
138
|
+
findById(id: string): Field | null {
|
|
139
|
+
let r: Field | null = null;
|
|
140
|
+
if (this._id === id) {
|
|
141
|
+
r = this;
|
|
142
|
+
}
|
|
143
|
+
return r;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export default Field;
|
package/src/Float.ts
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import Field from "./Field";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Float input
|
|
5
|
+
*/
|
|
6
|
+
class Float extends Field {
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Integer digits
|
|
10
|
+
*
|
|
11
|
+
* Number of integer digits that will be part of the float
|
|
12
|
+
*/
|
|
13
|
+
_integerDigits: number = 16;
|
|
14
|
+
get integerDigits(): number {
|
|
15
|
+
return this._integerDigits;
|
|
16
|
+
}
|
|
17
|
+
set integerDigits(value: number) {
|
|
18
|
+
this._integerDigits = value;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Decimal digits
|
|
23
|
+
*
|
|
24
|
+
* Number of decimal digits that will be part of the float
|
|
25
|
+
*/
|
|
26
|
+
_decimalDigits: number = 2;
|
|
27
|
+
get decimalDigits(): number {
|
|
28
|
+
return this._decimalDigits;
|
|
29
|
+
}
|
|
30
|
+
set decimalDigits(value: number) {
|
|
31
|
+
this._decimalDigits = value;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
constructor(props?: any) {
|
|
35
|
+
super(props);
|
|
36
|
+
|
|
37
|
+
if (props?.digits) {
|
|
38
|
+
const [integers, decimals] = props.digits;
|
|
39
|
+
this._integerDigits = integers;
|
|
40
|
+
this._decimalDigits = decimals;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export default Float;
|