@gisce/ooui 2.40.0-alpha.4 → 2.40.0-alpha.6
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/dist/Kanban.d.ts +13 -5
- package/dist/Kanban.d.ts.map +1 -1
- package/dist/ooui.es.js +28 -18
- package/dist/ooui.es.js.map +1 -1
- package/package.json +1 -1
- package/src/Kanban.ts +27 -13
- package/src/spec/Kanban.spec.ts +13 -14
package/package.json
CHANGED
package/src/Kanban.ts
CHANGED
|
@@ -44,6 +44,11 @@ class Kanban {
|
|
|
44
44
|
return this._string;
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
+
_status: string | null = null;
|
|
48
|
+
get status(): string | null {
|
|
49
|
+
return this._status;
|
|
50
|
+
}
|
|
51
|
+
|
|
47
52
|
/**
|
|
48
53
|
* Widget type
|
|
49
54
|
*/
|
|
@@ -55,11 +60,20 @@ class Kanban {
|
|
|
55
60
|
/**
|
|
56
61
|
* Field that defines the columns (e.g., "state")
|
|
57
62
|
*/
|
|
58
|
-
_column_field: string
|
|
59
|
-
get column_field(): string
|
|
63
|
+
_column_field: string = "state";
|
|
64
|
+
get column_field(): string {
|
|
60
65
|
return this._column_field;
|
|
61
66
|
}
|
|
62
67
|
|
|
68
|
+
/**
|
|
69
|
+
* Domain for filtering columns (for many2one fields)
|
|
70
|
+
* Example: "[('fold', '!=', True)]"
|
|
71
|
+
*/
|
|
72
|
+
_column_domain: string | null = null;
|
|
73
|
+
get column_domain(): string | null {
|
|
74
|
+
return this._column_domain;
|
|
75
|
+
}
|
|
76
|
+
|
|
63
77
|
/**
|
|
64
78
|
* Enable dragging cards between columns
|
|
65
79
|
*/
|
|
@@ -69,10 +83,10 @@ class Kanban {
|
|
|
69
83
|
}
|
|
70
84
|
|
|
71
85
|
/**
|
|
72
|
-
*
|
|
86
|
+
* Field name to use for sorting cards within columns
|
|
73
87
|
*/
|
|
74
|
-
_sort:
|
|
75
|
-
get sort():
|
|
88
|
+
_sort: string | undefined = undefined;
|
|
89
|
+
get sort(): string | undefined {
|
|
76
90
|
return this._sort;
|
|
77
91
|
}
|
|
78
92
|
|
|
@@ -128,19 +142,14 @@ class Kanban {
|
|
|
128
142
|
this._string = replaceEntities(this._string);
|
|
129
143
|
}
|
|
130
144
|
|
|
131
|
-
this._column_field = view.attributes.column_field ||
|
|
132
|
-
|
|
133
|
-
throw new Error("Kanban view must have a column_field attribute");
|
|
134
|
-
}
|
|
145
|
+
this._column_field = view.attributes.column_field || "state";
|
|
146
|
+
this._column_domain = view.attributes.column_domain || null;
|
|
135
147
|
|
|
136
148
|
this._drag =
|
|
137
149
|
view.attributes.drag !== undefined
|
|
138
150
|
? parseBoolAttribute(view.attributes.drag)
|
|
139
151
|
: true;
|
|
140
|
-
this._sort =
|
|
141
|
-
view.attributes.sort !== undefined
|
|
142
|
-
? parseBoolAttribute(view.attributes.sort)
|
|
143
|
-
: true;
|
|
152
|
+
this._sort = view.attributes.sort || undefined;
|
|
144
153
|
this._set_max_cards =
|
|
145
154
|
view.attributes.set_max_cards !== undefined
|
|
146
155
|
? parseBoolAttribute(view.attributes.set_max_cards)
|
|
@@ -151,6 +160,11 @@ class Kanban {
|
|
|
151
160
|
this._colors = replaceEntities(this._colors);
|
|
152
161
|
}
|
|
153
162
|
|
|
163
|
+
this._status = view.attributes.status || null;
|
|
164
|
+
if (this._status) {
|
|
165
|
+
this._status = replaceEntities(this._status);
|
|
166
|
+
}
|
|
167
|
+
|
|
154
168
|
const widgetFactory = new WidgetFactory();
|
|
155
169
|
|
|
156
170
|
// Parse children (fields and buttons)
|
package/src/spec/Kanban.spec.ts
CHANGED
|
@@ -4,7 +4,7 @@ import Field from "../Field";
|
|
|
4
4
|
import Button from "../Button";
|
|
5
5
|
|
|
6
6
|
const XML_VIEW_KANBAN = `<?xml version="1.0"?>
|
|
7
|
-
<kanban string="Tasks" column_field="state" drag="1" sort="
|
|
7
|
+
<kanban string="Tasks" column_field="state" drag="1" sort="sequence" set_max_cards="1" colors="blue:state=='draft';green:state=='done'">
|
|
8
8
|
<field name="name"/>
|
|
9
9
|
<field name="user_id" widget="avatar"/>
|
|
10
10
|
<field name="planned_hours" sum="Total hours" widget="float_time"/>
|
|
@@ -20,8 +20,8 @@ const XML_VIEW_KANBAN_MINIMAL = `<?xml version="1.0"?>
|
|
|
20
20
|
</kanban>
|
|
21
21
|
`;
|
|
22
22
|
|
|
23
|
-
const
|
|
24
|
-
<kanban column_field="state" drag="0"
|
|
23
|
+
const XML_VIEW_KANBAN_NO_DRAG = `<?xml version="1.0"?>
|
|
24
|
+
<kanban column_field="state" drag="0">
|
|
25
25
|
<field name="name"/>
|
|
26
26
|
<field name="priority"/>
|
|
27
27
|
</kanban>
|
|
@@ -97,7 +97,7 @@ describe("A Kanban", () => {
|
|
|
97
97
|
expect(tree.string).toBe("Tasks");
|
|
98
98
|
expect(tree.column_field).toBe("state");
|
|
99
99
|
expect(tree.drag).toBe(true);
|
|
100
|
-
expect(tree.sort).toBe(
|
|
100
|
+
expect(tree.sort).toBe("sequence");
|
|
101
101
|
expect(tree.set_max_cards).toBe(true);
|
|
102
102
|
expect(tree.colors).toBe("blue:state=='draft';green:state=='done'");
|
|
103
103
|
});
|
|
@@ -110,29 +110,28 @@ describe("A Kanban", () => {
|
|
|
110
110
|
expect(tree.string).toBe(null);
|
|
111
111
|
expect(tree.column_field).toBe("status");
|
|
112
112
|
expect(tree.drag).toBe(true); // Default value
|
|
113
|
-
expect(tree.sort).
|
|
113
|
+
expect(tree.sort).toBeUndefined(); // No sort field specified
|
|
114
114
|
expect(tree.set_max_cards).toBe(false); // Default value
|
|
115
115
|
});
|
|
116
116
|
|
|
117
|
-
it("should parse drag
|
|
117
|
+
it("should parse drag as false", () => {
|
|
118
118
|
const tree = new Kanban(FIELDS);
|
|
119
|
-
tree.parse(
|
|
119
|
+
tree.parse(XML_VIEW_KANBAN_NO_DRAG);
|
|
120
120
|
|
|
121
121
|
expect(tree.drag).toBe(false);
|
|
122
|
-
expect(tree.sort).
|
|
122
|
+
expect(tree.sort).toBeUndefined();
|
|
123
123
|
});
|
|
124
124
|
|
|
125
|
-
it("should
|
|
125
|
+
it("should fallback to 'state' when column_field is missing", () => {
|
|
126
126
|
const tree = new Kanban(FIELDS);
|
|
127
|
-
const
|
|
128
|
-
<kanban string="
|
|
127
|
+
const xmlWithoutColumnField = `<?xml version="1.0"?>
|
|
128
|
+
<kanban string="Tasks">
|
|
129
129
|
<field name="name"/>
|
|
130
130
|
</kanban>
|
|
131
131
|
`;
|
|
132
132
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
);
|
|
133
|
+
tree.parse(xmlWithoutColumnField);
|
|
134
|
+
expect(tree.column_field).toBe("state");
|
|
136
135
|
});
|
|
137
136
|
|
|
138
137
|
it("should parse fields correctly", () => {
|