@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/Form.ts
ADDED
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import WidgetFactory from "./WidgetFactory";
|
|
2
|
+
import Container from "./Container";
|
|
3
|
+
import ContainerWidget from "./ContainerWidget";
|
|
4
|
+
import Widget from "./Widget";
|
|
5
|
+
import { parseNodes } from "./helpers/nodeParser";
|
|
6
|
+
import { evaluateAttributes } from "./helpers/attributeParser";
|
|
7
|
+
import { evaluateStates, evaluateButtonStates } from "./helpers/stateParser";
|
|
8
|
+
import { parseContext } from "./helpers/contextParser";
|
|
9
|
+
import { parseOnChange } from "./helpers/onChangeParser";
|
|
10
|
+
|
|
11
|
+
export type FormParseOptions = {
|
|
12
|
+
readOnly?: boolean;
|
|
13
|
+
values?: any;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
class Form {
|
|
17
|
+
/**
|
|
18
|
+
* Object containing fields specification of the form.
|
|
19
|
+
*/
|
|
20
|
+
_fields: any;
|
|
21
|
+
get fields() {
|
|
22
|
+
return this._fields;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
_container: Container;
|
|
26
|
+
get container(): Container {
|
|
27
|
+
return this._container;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
_string: string | null = null;
|
|
31
|
+
get string(): string | null {
|
|
32
|
+
return this._string;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Widget type
|
|
37
|
+
*/
|
|
38
|
+
_type: string = "form";
|
|
39
|
+
get type(): string {
|
|
40
|
+
return this._type;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Determines if form is read only (default is false)
|
|
45
|
+
*/
|
|
46
|
+
_readOnly: boolean = false;
|
|
47
|
+
get readOnly(): boolean {
|
|
48
|
+
return this._readOnly;
|
|
49
|
+
}
|
|
50
|
+
set readOnly(value: boolean) {
|
|
51
|
+
this._readOnly = value;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Context
|
|
56
|
+
*/
|
|
57
|
+
_context: any = {};
|
|
58
|
+
get context(): any {
|
|
59
|
+
return this._context;
|
|
60
|
+
}
|
|
61
|
+
set context(value: any) {
|
|
62
|
+
this._context = value;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Collection of onChange actions for fields
|
|
67
|
+
*/
|
|
68
|
+
_onChangeFields: any = {};
|
|
69
|
+
get onChangeFields(): any {
|
|
70
|
+
return this._onChangeFields;
|
|
71
|
+
}
|
|
72
|
+
set onChangeFields(value: any) {
|
|
73
|
+
this._onChangeFields = value;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/*
|
|
77
|
+
_widgets = {
|
|
78
|
+
*[Symbol.iterator]() {
|
|
79
|
+
if (this._container && this._container.length) {
|
|
80
|
+
this._container.forEach((item) => {
|
|
81
|
+
|
|
82
|
+
// yield item
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
get widgets() {
|
|
88
|
+
return this._widgets;
|
|
89
|
+
}
|
|
90
|
+
*/
|
|
91
|
+
|
|
92
|
+
constructor(fields: Object, columns: number = 4) {
|
|
93
|
+
this._fields = fields;
|
|
94
|
+
this._container = new Container(columns);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
parse(xml: string, options?: FormParseOptions) {
|
|
98
|
+
const { values = {}, readOnly = false } = options || {};
|
|
99
|
+
|
|
100
|
+
const parser = new DOMParser();
|
|
101
|
+
const view: Document = parser.parseFromString(xml, "text/xml");
|
|
102
|
+
this._string = view.documentElement.getAttribute("string");
|
|
103
|
+
this._readOnly = readOnly;
|
|
104
|
+
this._context = values["id"]
|
|
105
|
+
? { active_id: values["id"], active_ids: [values["id"]] }
|
|
106
|
+
: {};
|
|
107
|
+
|
|
108
|
+
this.parseNode({
|
|
109
|
+
node: view.documentElement,
|
|
110
|
+
container: this._container,
|
|
111
|
+
values,
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
parseNode({
|
|
116
|
+
node,
|
|
117
|
+
container,
|
|
118
|
+
values,
|
|
119
|
+
}: {
|
|
120
|
+
node: Element;
|
|
121
|
+
container: Container;
|
|
122
|
+
values: any;
|
|
123
|
+
}) {
|
|
124
|
+
const widgetFactory = new WidgetFactory();
|
|
125
|
+
|
|
126
|
+
const nodesParsed = parseNodes(node.childNodes, this._fields);
|
|
127
|
+
|
|
128
|
+
nodesParsed.forEach((nodeParsed) => {
|
|
129
|
+
const { tag, tagAttributes, child } = nodeParsed;
|
|
130
|
+
const evaluatedTagAttributes = evaluateAttributes({
|
|
131
|
+
tagAttributes,
|
|
132
|
+
values,
|
|
133
|
+
fields: this._fields,
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
let evaluatedStateAttributes;
|
|
137
|
+
|
|
138
|
+
if (tag === "button" && tagAttributes.states) {
|
|
139
|
+
evaluatedStateAttributes = evaluateButtonStates({
|
|
140
|
+
states: tagAttributes.states,
|
|
141
|
+
values,
|
|
142
|
+
});
|
|
143
|
+
} else {
|
|
144
|
+
evaluatedStateAttributes = evaluateStates({
|
|
145
|
+
fieldName: tagAttributes.name,
|
|
146
|
+
values,
|
|
147
|
+
fields: this._fields,
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
const widgetContext = parseContext({
|
|
152
|
+
context: tagAttributes["context"] || this._fields["context"],
|
|
153
|
+
values,
|
|
154
|
+
fields: this._fields,
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
if (tag !== "button") {
|
|
158
|
+
this._context = { ...this._context, ...widgetContext };
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
if (tagAttributes["on_change"]) {
|
|
162
|
+
this._onChangeFields[tagAttributes.name] = parseOnChange(
|
|
163
|
+
tagAttributes["on_change"]
|
|
164
|
+
);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
let domain: string | undefined = undefined;
|
|
168
|
+
|
|
169
|
+
if (
|
|
170
|
+
tagAttributes["domain"] &&
|
|
171
|
+
tagAttributes["domain"] !== "" &&
|
|
172
|
+
tagAttributes["domain"] !== "[]"
|
|
173
|
+
) {
|
|
174
|
+
domain = tagAttributes["domain"];
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
if (
|
|
178
|
+
this._fields[tagAttributes.name] &&
|
|
179
|
+
this._fields[tagAttributes.name].domain &&
|
|
180
|
+
this._fields[tagAttributes.name].domain !== "" &&
|
|
181
|
+
this._fields[tagAttributes.name].domain !== "[]"
|
|
182
|
+
) {
|
|
183
|
+
domain = this._fields[tagAttributes.name].domain;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
const widget = widgetFactory.createWidget(tag, {
|
|
187
|
+
...evaluatedTagAttributes,
|
|
188
|
+
...evaluatedStateAttributes,
|
|
189
|
+
context: widgetContext,
|
|
190
|
+
domain,
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
if (widget instanceof ContainerWidget) {
|
|
194
|
+
this.parseNode({ node: child, container: widget.container, values });
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
// If the form is set to readonly, reflect it to its children
|
|
198
|
+
widget.readOnly = widget.readOnly || this.readOnly;
|
|
199
|
+
container.addWidget(widget);
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Calls container's findById method to find the widgets matching with param id
|
|
205
|
+
* @param {string} id id to find
|
|
206
|
+
*/
|
|
207
|
+
findById(id: string): Widget | null {
|
|
208
|
+
return this.container.findById(id);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
export default Form;
|
package/src/Group.ts
ADDED
package/src/Image.ts
ADDED
package/src/Integer.ts
ADDED
package/src/Label.ts
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import Field from "./Field";
|
|
2
|
+
|
|
3
|
+
class Label extends Field {
|
|
4
|
+
/**
|
|
5
|
+
* Label text
|
|
6
|
+
*/
|
|
7
|
+
_text: string = "";
|
|
8
|
+
get text(): string {
|
|
9
|
+
return this._text;
|
|
10
|
+
}
|
|
11
|
+
set text(value: string) {
|
|
12
|
+
this._text = value;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Align text
|
|
17
|
+
*/
|
|
18
|
+
_align: string = "left";
|
|
19
|
+
get align(): string {
|
|
20
|
+
return this._align;
|
|
21
|
+
}
|
|
22
|
+
set align(value: string) {
|
|
23
|
+
this._align = value;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Id of the field that this label goes with. Null if it's an independent label
|
|
28
|
+
*/
|
|
29
|
+
_fieldForLabel: string | null = null;
|
|
30
|
+
get fieldForLabel(): string | null {
|
|
31
|
+
return this._fieldForLabel;
|
|
32
|
+
}
|
|
33
|
+
set fieldForLabel(value: string | null) {
|
|
34
|
+
this._fieldForLabel = value;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
constructor(props?: any) {
|
|
38
|
+
super({ ...props, nolabel: true });
|
|
39
|
+
|
|
40
|
+
if (props?.fieldForLabel) {
|
|
41
|
+
this._fieldForLabel = props.fieldForLabel;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export default Label;
|
package/src/Many2many.ts
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import Field from "./Field";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A Many2many relationship field
|
|
5
|
+
*/
|
|
6
|
+
class Many2many extends Field {
|
|
7
|
+
/**
|
|
8
|
+
* Field size
|
|
9
|
+
*/
|
|
10
|
+
_size: number = 150;
|
|
11
|
+
get size(): number {
|
|
12
|
+
return this._size;
|
|
13
|
+
}
|
|
14
|
+
set size(value: number) {
|
|
15
|
+
this._size = value;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Relation
|
|
20
|
+
*/
|
|
21
|
+
_relation: string = "";
|
|
22
|
+
get relation(): string {
|
|
23
|
+
return this._relation;
|
|
24
|
+
}
|
|
25
|
+
set relation(value: string) {
|
|
26
|
+
this._relation = value;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Must expand widget
|
|
31
|
+
*/
|
|
32
|
+
_mustExpand: boolean = false;
|
|
33
|
+
get mustExpand(): boolean {
|
|
34
|
+
return this._mustExpand;
|
|
35
|
+
}
|
|
36
|
+
set mustExpand(value: boolean) {
|
|
37
|
+
this._mustExpand = value;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
constructor(props: any) {
|
|
41
|
+
super(props);
|
|
42
|
+
|
|
43
|
+
if (props) {
|
|
44
|
+
if (props.size) {
|
|
45
|
+
this._size = props.size;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (props.relation) {
|
|
49
|
+
this._relation = props.relation;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (!props.colspan) {
|
|
53
|
+
this._mustExpand = true;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export default Many2many;
|
package/src/Many2one.ts
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import Field from "./Field";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A many2one relationship field
|
|
5
|
+
*/
|
|
6
|
+
class Many2one extends Field {
|
|
7
|
+
/**
|
|
8
|
+
* Field size
|
|
9
|
+
*/
|
|
10
|
+
_size: number = 150;
|
|
11
|
+
get size(): number {
|
|
12
|
+
return this._size;
|
|
13
|
+
}
|
|
14
|
+
set size(value: number) {
|
|
15
|
+
this._size = value;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Relation
|
|
20
|
+
*/
|
|
21
|
+
_relation: string = "";
|
|
22
|
+
get relation(): string {
|
|
23
|
+
return this._relation;
|
|
24
|
+
}
|
|
25
|
+
set relation(value: string) {
|
|
26
|
+
this._relation = value;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
constructor(props: any) {
|
|
30
|
+
super(props);
|
|
31
|
+
|
|
32
|
+
if (props) {
|
|
33
|
+
if (props.size) {
|
|
34
|
+
this._size = props.size;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (props.relation) {
|
|
38
|
+
this._relation = props.relation;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export default Many2one;
|
package/src/NewLine.ts
ADDED
package/src/Notebook.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import ContainerWidget from "./ContainerWidget";
|
|
2
|
+
|
|
3
|
+
class Notebook extends ContainerWidget {
|
|
4
|
+
static _defaultColspan: number = 3;
|
|
5
|
+
static get defaultColspan(): number {
|
|
6
|
+
return Notebook._defaultColspan;
|
|
7
|
+
}
|
|
8
|
+
static set defaultColspan(value: number) {
|
|
9
|
+
Notebook._defaultColspan = value;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
constructor(props: any) {
|
|
13
|
+
super(props);
|
|
14
|
+
this.colspan = Notebook._defaultColspan;
|
|
15
|
+
|
|
16
|
+
if (props) {
|
|
17
|
+
if (props.colspan) {
|
|
18
|
+
this.colspan = props.colspan;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export default Notebook;
|
package/src/One2many.ts
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import Field from "./Field";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A One2Many relationship field
|
|
5
|
+
*/
|
|
6
|
+
class One2many extends Field {
|
|
7
|
+
/**
|
|
8
|
+
* Field size
|
|
9
|
+
*/
|
|
10
|
+
_size: number = 150;
|
|
11
|
+
get size(): number {
|
|
12
|
+
return this._size;
|
|
13
|
+
}
|
|
14
|
+
set size(value: number) {
|
|
15
|
+
this._size = value;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Relation
|
|
20
|
+
*/
|
|
21
|
+
_relation: string = "";
|
|
22
|
+
get relation(): string {
|
|
23
|
+
return this._relation;
|
|
24
|
+
}
|
|
25
|
+
set relation(value: string) {
|
|
26
|
+
this._relation = value;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Inv_field
|
|
31
|
+
*/
|
|
32
|
+
_inv_field: string | undefined;
|
|
33
|
+
get inv_field(): string | undefined {
|
|
34
|
+
return this._inv_field;
|
|
35
|
+
}
|
|
36
|
+
set inv_field(value: string | undefined) {
|
|
37
|
+
this._inv_field = value;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Views
|
|
42
|
+
*/
|
|
43
|
+
_views: any = null;
|
|
44
|
+
get views(): any {
|
|
45
|
+
return this._views;
|
|
46
|
+
}
|
|
47
|
+
set views(value: any) {
|
|
48
|
+
this._views = value;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Mode
|
|
53
|
+
*/
|
|
54
|
+
_mode: Array<string> = [];
|
|
55
|
+
get mode(): Array<string> {
|
|
56
|
+
return this._mode;
|
|
57
|
+
}
|
|
58
|
+
set mode(value: Array<string>) {
|
|
59
|
+
this._mode = value;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Must expand widget
|
|
64
|
+
*/
|
|
65
|
+
_mustExpand: boolean = false;
|
|
66
|
+
get mustExpand(): boolean {
|
|
67
|
+
return this._mustExpand;
|
|
68
|
+
}
|
|
69
|
+
set mustExpand(value: boolean) {
|
|
70
|
+
this._mustExpand = value;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
constructor(props: any) {
|
|
74
|
+
super(props);
|
|
75
|
+
|
|
76
|
+
if (props) {
|
|
77
|
+
if (props.size) {
|
|
78
|
+
this._size = props.size;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (props.relation) {
|
|
82
|
+
this._relation = props.relation;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (props.mode) {
|
|
86
|
+
this._mode = props.mode.split(",");
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if (props.views) {
|
|
90
|
+
this._views = props.views;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if (props.colspan) {
|
|
94
|
+
this.colspan = props.colspan;
|
|
95
|
+
} else {
|
|
96
|
+
this._mustExpand = true;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (props.inv_field) {
|
|
100
|
+
this._inv_field = props.inv_field;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export default One2many;
|
package/src/Page.ts
ADDED
package/src/Reference.ts
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import WidgetFactory from "./WidgetFactory";
|
|
2
|
+
import Container from "./Container";
|
|
3
|
+
import Widget from "./Widget";
|
|
4
|
+
|
|
5
|
+
class SearchFilter {
|
|
6
|
+
/**
|
|
7
|
+
* Object containing the specific fields for primary and secondary search fields
|
|
8
|
+
*/
|
|
9
|
+
_searchFields: any;
|
|
10
|
+
get searchFields() {
|
|
11
|
+
return this._searchFields;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Object containing all the fields specification of the whole form
|
|
16
|
+
*/
|
|
17
|
+
_fields: any;
|
|
18
|
+
get fields() {
|
|
19
|
+
return this._fields;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
_simpleSearchContainer: Container;
|
|
23
|
+
get simpleSearchContainer(): Container {
|
|
24
|
+
return this._simpleSearchContainer;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
_advancedSearchContainer: Container;
|
|
28
|
+
get advancedSearchContainer(): Container {
|
|
29
|
+
return this._advancedSearchContainer;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
constructor(searchFields: Object, fields: Object, columns: number = 8) {
|
|
33
|
+
this._searchFields = searchFields;
|
|
34
|
+
this._fields = fields;
|
|
35
|
+
this._simpleSearchContainer = new Container(columns);
|
|
36
|
+
this._advancedSearchContainer = new Container(columns);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
parse() {
|
|
40
|
+
const widgetFactory = new WidgetFactory();
|
|
41
|
+
|
|
42
|
+
const simpleSearchWidgets = this.parseFields(
|
|
43
|
+
this.searchFields.primary,
|
|
44
|
+
widgetFactory
|
|
45
|
+
);
|
|
46
|
+
simpleSearchWidgets.forEach((widget) => {
|
|
47
|
+
this.simpleSearchContainer.addWidget(widget, { addLabel: false });
|
|
48
|
+
this.advancedSearchContainer.addWidget(widget, { addLabel: false });
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
const advancedSearchWidgets = this.parseFields(
|
|
52
|
+
this.searchFields.secondary,
|
|
53
|
+
widgetFactory
|
|
54
|
+
);
|
|
55
|
+
advancedSearchWidgets.forEach((widget) => {
|
|
56
|
+
this.advancedSearchContainer.addWidget(widget, { addLabel: false });
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
parseFields(searchFields: string[], widgetFactory: WidgetFactory) {
|
|
61
|
+
return searchFields.map((searchField) => {
|
|
62
|
+
const fieldAttributes = {
|
|
63
|
+
...this.fields[searchField],
|
|
64
|
+
name: searchField,
|
|
65
|
+
colspan: 2,
|
|
66
|
+
};
|
|
67
|
+
const { type } = fieldAttributes;
|
|
68
|
+
return widgetFactory.createWidget(type, fieldAttributes);
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Calls container's findById method to find the widgets matching with param id
|
|
74
|
+
* @param {string} id id to find
|
|
75
|
+
*/
|
|
76
|
+
findById(id: string): Widget | null {
|
|
77
|
+
return this.advancedSearchContainer.findById(id);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export default SearchFilter;
|
package/src/Selection.ts
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import Field from "./Field";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Selection field for key-value lists
|
|
5
|
+
*/
|
|
6
|
+
class Selection extends Field {
|
|
7
|
+
/**
|
|
8
|
+
* Field size
|
|
9
|
+
*/
|
|
10
|
+
_size: number = 150;
|
|
11
|
+
get size(): number {
|
|
12
|
+
return this._size;
|
|
13
|
+
}
|
|
14
|
+
set size(value: number) {
|
|
15
|
+
this._size = value;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Values and keys
|
|
20
|
+
*/
|
|
21
|
+
_selectionValues: Map<string, string> = new Map([]);
|
|
22
|
+
get selectionValues(): Map<string, string> {
|
|
23
|
+
return this._selectionValues;
|
|
24
|
+
}
|
|
25
|
+
set selectionValues(value: Map<string, string>) {
|
|
26
|
+
this._selectionValues = value;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
constructor(props: any) {
|
|
30
|
+
super(props);
|
|
31
|
+
|
|
32
|
+
if (props) {
|
|
33
|
+
if (props.size) {
|
|
34
|
+
this._size = props.size;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (props.selection) {
|
|
38
|
+
this._selectionValues = new Map(props.selection);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export default Selection;
|